Fossil SCM

Reverted [37409e7dbe] in favor of [5244a548], which is cleaner, smaller, and works.

stephan 2020-08-24 04:33 trunk
Commit a7d8c58d48c0810219dcba440c3dbcdd95b7d91584bb135d7eac22eb0c74cde4
1 file changed +11 -34
+11 -34
--- src/wiki.c
+++ src/wiki.c
@@ -729,24 +729,12 @@
729729
** Loads the given wiki page, sets the response type to
730730
** application/json, and emits it as a JSON object. If zPageName is a
731731
** sandbox page then a "fake" object is emitted, as the wikiajax API
732732
** does not permit saving the sandbox.
733733
**
734
-** If includeLeadingComma is true then a comma will be emitted
735
-** preceeding the object. This parameter is a bit of a hack to allow
736
-** wiki page list generation to recover from an unusual (so far unique
737
-** to one repo) error mode.
738
-**
739
-** Returns true on success, false on error. Its behaviour on error
740
-** depends on the 4th argument: if it's true, this function simply
741
-** returns false, else it queues up a JSON response and returns false.
742
-** The intention of this flag is to avoid a weird corner case seen, so
743
-** far, only on the main fossil repo (not clones of it) in which
744
-** loading fails for a page named "Security Desk Technician". The
745
-** hypothesis is that that page was once shunned on the core repo, but
746
-** a reference to it still exists in the tables from which we pull the
747
-** wiki list.
734
+** Returns true on success, false on error, and on error it
735
+** queues up a JSON-format error response.
748736
**
749737
** Output JSON format:
750738
**
751739
** { name: "page name",
752740
** type: "normal" | "tag" | "checkin" | "branch" | "sandbox",
@@ -759,23 +747,18 @@
759747
** }
760748
**
761749
** If includeContent is false then the content member is elided.
762750
*/
763751
static int wiki_ajax_emit_page_object(const char *zPageName,
764
- int includeContent,
765
- int includeLeadingComma,
766
- int ignoreLoadError){
752
+ int includeContent){
767753
Manifest * pWiki = 0;
768754
char * zUuid;
769755
770756
if( is_sandbox(zPageName) ){
771757
char * zMimetype =
772758
db_get("sandbox-mimetype","text/x-fossil-wiki");
773759
char * zBody = db_get("sandbox","");
774
- if(includeLeadingComma){
775
- CX(",");
776
- }
777760
CX("{\"name\": %!j, \"type\": \"sandbox\", "
778761
"\"mimetype\": %!j, \"version\": null, \"parent\": null",
779762
zPageName, zMimetype);
780763
if(includeContent){
781764
CX(", \"content\": %!j",
@@ -784,19 +767,14 @@
784767
CX("}");
785768
fossil_free(zMimetype);
786769
fossil_free(zBody);
787770
return 1;
788771
}else if( !wiki_fetch_by_name(zPageName, 0, 0, &pWiki) ){
789
- if(ignoreLoadError!=0){
790
- ajax_route_error(404, "Wiki page could not be loaded: %s",
791
- zPageName);
792
- }
772
+ ajax_route_error(404, "Wiki page could not be loaded: %s",
773
+ zPageName);
793774
return 0;
794775
}else{
795
- if(includeLeadingComma){
796
- CX(",");
797
- }
798776
zUuid = rid_to_uuid(pWiki->rid);
799777
CX("{\"name\": %!j, \"type\": %!j, "
800778
"\"version\": %!j, "
801779
"\"mimetype\": %!j, ",
802780
pWiki->zWikiTitle,
@@ -879,11 +857,11 @@
879857
}
880858
blob_init(&content, zContent ? zContent : "", -1);
881859
cgi_set_content_type("application/json");
882860
db_begin_transaction();
883861
wiki_cmd_commit(zPageName, parentRid, &content, zMimetype, 0);
884
- rollback = wiki_ajax_emit_page_object(zPageName, 1, 0, 0) ? 0 : 1;
862
+ rollback = wiki_ajax_emit_page_object(zPageName, 1) ? 0 : 1;
885863
db_end_transaction(rollback);
886864
}
887865
888866
/*
889867
** Ajax route handler for /wikiajax/fetch.
@@ -902,11 +880,11 @@
902880
if( zPageName==0 || zPageName[0]==0 ){
903881
ajax_route_error(400,"Missing page name.");
904882
return;
905883
}
906884
cgi_set_content_type("application/json");
907
- wiki_ajax_emit_page_object(zPageName, 1, 0, 0);
885
+ wiki_ajax_emit_page_object(zPageName, 1);
908886
}
909887
910888
/*
911889
** Ajax route handler for /wikiajax/diff.
912890
**
@@ -1011,18 +989,17 @@
1011989
" UNION SELECT 'Sandbox' AS name"
1012990
" ORDER BY name COLLATE NOCASE");
1013991
CX("[");
1014992
while( SQLITE_ROW==db_step(&q) ){
1015993
char const * zName = db_column_text(&q,0);
994
+ if(n++){
995
+ CX(",");
996
+ }
1016997
if(verbose==0){
1017
- if(n++){
1018
- CX(",");
1019
- }
1020998
CX("%!j", zName);
1021999
}else{
1022
- wiki_ajax_emit_page_object(zName, includeContent,
1023
- n++>0, 1);
1000
+ wiki_ajax_emit_page_object(zName, includeContent);
10241001
}
10251002
}
10261003
CX("]");
10271004
db_finalize(&q);
10281005
db_end_transaction(0);
10291006
--- src/wiki.c
+++ src/wiki.c
@@ -729,24 +729,12 @@
729 ** Loads the given wiki page, sets the response type to
730 ** application/json, and emits it as a JSON object. If zPageName is a
731 ** sandbox page then a "fake" object is emitted, as the wikiajax API
732 ** does not permit saving the sandbox.
733 **
734 ** If includeLeadingComma is true then a comma will be emitted
735 ** preceeding the object. This parameter is a bit of a hack to allow
736 ** wiki page list generation to recover from an unusual (so far unique
737 ** to one repo) error mode.
738 **
739 ** Returns true on success, false on error. Its behaviour on error
740 ** depends on the 4th argument: if it's true, this function simply
741 ** returns false, else it queues up a JSON response and returns false.
742 ** The intention of this flag is to avoid a weird corner case seen, so
743 ** far, only on the main fossil repo (not clones of it) in which
744 ** loading fails for a page named "Security Desk Technician". The
745 ** hypothesis is that that page was once shunned on the core repo, but
746 ** a reference to it still exists in the tables from which we pull the
747 ** wiki list.
748 **
749 ** Output JSON format:
750 **
751 ** { name: "page name",
752 ** type: "normal" | "tag" | "checkin" | "branch" | "sandbox",
@@ -759,23 +747,18 @@
759 ** }
760 **
761 ** If includeContent is false then the content member is elided.
762 */
763 static int wiki_ajax_emit_page_object(const char *zPageName,
764 int includeContent,
765 int includeLeadingComma,
766 int ignoreLoadError){
767 Manifest * pWiki = 0;
768 char * zUuid;
769
770 if( is_sandbox(zPageName) ){
771 char * zMimetype =
772 db_get("sandbox-mimetype","text/x-fossil-wiki");
773 char * zBody = db_get("sandbox","");
774 if(includeLeadingComma){
775 CX(",");
776 }
777 CX("{\"name\": %!j, \"type\": \"sandbox\", "
778 "\"mimetype\": %!j, \"version\": null, \"parent\": null",
779 zPageName, zMimetype);
780 if(includeContent){
781 CX(", \"content\": %!j",
@@ -784,19 +767,14 @@
784 CX("}");
785 fossil_free(zMimetype);
786 fossil_free(zBody);
787 return 1;
788 }else if( !wiki_fetch_by_name(zPageName, 0, 0, &pWiki) ){
789 if(ignoreLoadError!=0){
790 ajax_route_error(404, "Wiki page could not be loaded: %s",
791 zPageName);
792 }
793 return 0;
794 }else{
795 if(includeLeadingComma){
796 CX(",");
797 }
798 zUuid = rid_to_uuid(pWiki->rid);
799 CX("{\"name\": %!j, \"type\": %!j, "
800 "\"version\": %!j, "
801 "\"mimetype\": %!j, ",
802 pWiki->zWikiTitle,
@@ -879,11 +857,11 @@
879 }
880 blob_init(&content, zContent ? zContent : "", -1);
881 cgi_set_content_type("application/json");
882 db_begin_transaction();
883 wiki_cmd_commit(zPageName, parentRid, &content, zMimetype, 0);
884 rollback = wiki_ajax_emit_page_object(zPageName, 1, 0, 0) ? 0 : 1;
885 db_end_transaction(rollback);
886 }
887
888 /*
889 ** Ajax route handler for /wikiajax/fetch.
@@ -902,11 +880,11 @@
902 if( zPageName==0 || zPageName[0]==0 ){
903 ajax_route_error(400,"Missing page name.");
904 return;
905 }
906 cgi_set_content_type("application/json");
907 wiki_ajax_emit_page_object(zPageName, 1, 0, 0);
908 }
909
910 /*
911 ** Ajax route handler for /wikiajax/diff.
912 **
@@ -1011,18 +989,17 @@
1011 " UNION SELECT 'Sandbox' AS name"
1012 " ORDER BY name COLLATE NOCASE");
1013 CX("[");
1014 while( SQLITE_ROW==db_step(&q) ){
1015 char const * zName = db_column_text(&q,0);
 
 
 
1016 if(verbose==0){
1017 if(n++){
1018 CX(",");
1019 }
1020 CX("%!j", zName);
1021 }else{
1022 wiki_ajax_emit_page_object(zName, includeContent,
1023 n++>0, 1);
1024 }
1025 }
1026 CX("]");
1027 db_finalize(&q);
1028 db_end_transaction(0);
1029
--- src/wiki.c
+++ src/wiki.c
@@ -729,24 +729,12 @@
729 ** Loads the given wiki page, sets the response type to
730 ** application/json, and emits it as a JSON object. If zPageName is a
731 ** sandbox page then a "fake" object is emitted, as the wikiajax API
732 ** does not permit saving the sandbox.
733 **
734 ** Returns true on success, false on error, and on error it
735 ** queues up a JSON-format error response.
 
 
 
 
 
 
 
 
 
 
 
 
736 **
737 ** Output JSON format:
738 **
739 ** { name: "page name",
740 ** type: "normal" | "tag" | "checkin" | "branch" | "sandbox",
@@ -759,23 +747,18 @@
747 ** }
748 **
749 ** If includeContent is false then the content member is elided.
750 */
751 static int wiki_ajax_emit_page_object(const char *zPageName,
752 int includeContent){
 
 
753 Manifest * pWiki = 0;
754 char * zUuid;
755
756 if( is_sandbox(zPageName) ){
757 char * zMimetype =
758 db_get("sandbox-mimetype","text/x-fossil-wiki");
759 char * zBody = db_get("sandbox","");
 
 
 
760 CX("{\"name\": %!j, \"type\": \"sandbox\", "
761 "\"mimetype\": %!j, \"version\": null, \"parent\": null",
762 zPageName, zMimetype);
763 if(includeContent){
764 CX(", \"content\": %!j",
@@ -784,19 +767,14 @@
767 CX("}");
768 fossil_free(zMimetype);
769 fossil_free(zBody);
770 return 1;
771 }else if( !wiki_fetch_by_name(zPageName, 0, 0, &pWiki) ){
772 ajax_route_error(404, "Wiki page could not be loaded: %s",
773 zPageName);
 
 
774 return 0;
775 }else{
 
 
 
776 zUuid = rid_to_uuid(pWiki->rid);
777 CX("{\"name\": %!j, \"type\": %!j, "
778 "\"version\": %!j, "
779 "\"mimetype\": %!j, ",
780 pWiki->zWikiTitle,
@@ -879,11 +857,11 @@
857 }
858 blob_init(&content, zContent ? zContent : "", -1);
859 cgi_set_content_type("application/json");
860 db_begin_transaction();
861 wiki_cmd_commit(zPageName, parentRid, &content, zMimetype, 0);
862 rollback = wiki_ajax_emit_page_object(zPageName, 1) ? 0 : 1;
863 db_end_transaction(rollback);
864 }
865
866 /*
867 ** Ajax route handler for /wikiajax/fetch.
@@ -902,11 +880,11 @@
880 if( zPageName==0 || zPageName[0]==0 ){
881 ajax_route_error(400,"Missing page name.");
882 return;
883 }
884 cgi_set_content_type("application/json");
885 wiki_ajax_emit_page_object(zPageName, 1);
886 }
887
888 /*
889 ** Ajax route handler for /wikiajax/diff.
890 **
@@ -1011,18 +989,17 @@
989 " UNION SELECT 'Sandbox' AS name"
990 " ORDER BY name COLLATE NOCASE");
991 CX("[");
992 while( SQLITE_ROW==db_step(&q) ){
993 char const * zName = db_column_text(&q,0);
994 if(n++){
995 CX(",");
996 }
997 if(verbose==0){
 
 
 
998 CX("%!j", zName);
999 }else{
1000 wiki_ajax_emit_page_object(zName, includeContent);
 
1001 }
1002 }
1003 CX("]");
1004 db_finalize(&q);
1005 db_end_transaction(0);
1006

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button