Fossil SCM
Change of plan: Instead of a separate /sitemap-ex page, add the e= query parameter to /sitemap. Standard content is omitted with e=1. Extra content is omitted with e=2.
Commit
635a8b2bf0ebd77f5ab9bfda2a16016526d81240324adcdefd1af867b5b82fb4
Parent
0b982b6f144abd3…
2 files changed
+2
-1
+11
-10
+2
-1
| --- src/hbmenu.js | ||
| +++ src/hbmenu.js | ||
| @@ -240,11 +240,12 @@ | ||
| 240 | 240 | showPanel(); |
| 241 | 241 | } |
| 242 | 242 | } |
| 243 | 243 | // else, can't parse response as HTML or XML |
| 244 | 244 | } |
| 245 | - xhr.open("GET", hbButton.href + "?popup"); | |
| 245 | + var url = hbButton.href + (hbButton.href.includes("?")?"&popup":"?popup") | |
| 246 | + xhr.open("GET", url); | |
| 246 | 247 | xhr.responseType = "document"; |
| 247 | 248 | xhr.send(); |
| 248 | 249 | } |
| 249 | 250 | else { |
| 250 | 251 | showPanel(); // just show what we built above |
| 251 | 252 |
| --- src/hbmenu.js | |
| +++ src/hbmenu.js | |
| @@ -240,11 +240,12 @@ | |
| 240 | showPanel(); |
| 241 | } |
| 242 | } |
| 243 | // else, can't parse response as HTML or XML |
| 244 | } |
| 245 | xhr.open("GET", hbButton.href + "?popup"); |
| 246 | xhr.responseType = "document"; |
| 247 | xhr.send(); |
| 248 | } |
| 249 | else { |
| 250 | showPanel(); // just show what we built above |
| 251 |
| --- src/hbmenu.js | |
| +++ src/hbmenu.js | |
| @@ -240,11 +240,12 @@ | |
| 240 | showPanel(); |
| 241 | } |
| 242 | } |
| 243 | // else, can't parse response as HTML or XML |
| 244 | } |
| 245 | var url = hbButton.href + (hbButton.href.includes("?")?"&popup":"?popup") |
| 246 | xhr.open("GET", url); |
| 247 | xhr.responseType = "document"; |
| 248 | xhr.send(); |
| 249 | } |
| 250 | else { |
| 251 | showPanel(); // just show what we built above |
| 252 |
+11
-10
| --- src/sitemap.c | ||
| +++ src/sitemap.c | ||
| @@ -21,11 +21,10 @@ | ||
| 21 | 21 | #include "sitemap.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | |
| 24 | 24 | /* |
| 25 | 25 | ** WEBPAGE: sitemap |
| 26 | -** WEBPAGE: sitemap-ex | |
| 27 | 26 | ** |
| 28 | 27 | ** List some of the web pages offered by the Fossil web engine. This |
| 29 | 28 | ** page is intended as a supplement to the menu bar on the main screen. |
| 30 | 29 | ** That is, this page is designed to hold links that are omitted from |
| 31 | 30 | ** the main menu due to lack of space. |
| @@ -40,12 +39,14 @@ | ||
| 40 | 39 | ** |
| 41 | 40 | ** * A "capexpr" expression that determines whether or not to include |
| 42 | 41 | ** the entry based on user capabilities. "*" means always include |
| 43 | 42 | ** the entry and "{}" means never. |
| 44 | 43 | ** |
| 45 | -** The /sitemap-ex page works /sitemap except that it includes only the | |
| 46 | -** sitemap-extra content and omits the standard content. | |
| 44 | +** If the "e=1" query parameter is present, then the standard content | |
| 45 | +** is omitted and only the sitemap-extra content is shown. If "e=2" is | |
| 46 | +** present, then only the standard content is shown and sitemap-extra | |
| 47 | +** content is omitted. | |
| 47 | 48 | ** |
| 48 | 49 | ** If the "popup" query parameter is present and this is a POST request |
| 49 | 50 | ** from the same origin, then the normal HTML header and footer information |
| 50 | 51 | ** is omitted and the HTML text returned is just a raw "<ul>...</ul>". |
| 51 | 52 | */ |
| @@ -52,11 +53,11 @@ | ||
| 52 | 53 | void sitemap_page(void){ |
| 53 | 54 | int srchFlags; |
| 54 | 55 | int inSublist = 0; |
| 55 | 56 | int i; |
| 56 | 57 | int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */ |
| 57 | - int bAllEntries = fossil_strcmp(g.zPath,"sitemap")==0; | |
| 58 | + int e = atoi(PD("e","0")); | |
| 58 | 59 | const char *zExtra; |
| 59 | 60 | |
| 60 | 61 | #if 0 /* Removed 2021-01-26 */ |
| 61 | 62 | const struct { |
| 62 | 63 | const char *zTitle; |
| @@ -68,12 +69,12 @@ | ||
| 68 | 69 | { "Contact", "sitemap-contact" }, |
| 69 | 70 | }; |
| 70 | 71 | #endif |
| 71 | 72 | |
| 72 | 73 | login_check_credentials(); |
| 73 | - if( P("popup")!=0 && (g.perm.Setup || cgi_csrf_safe(0)) ){ | |
| 74 | - /* If this is a POST from the same origin with the popup=1 parameter, | |
| 74 | + if( P("popup")!=0 ){ | |
| 75 | + /* The "popup" query parameter | |
| 75 | 76 | ** then disable anti-robot defenses */ |
| 76 | 77 | isPopup = 1; |
| 77 | 78 | g.perm.Hyperlink = 1; |
| 78 | 79 | g.javascriptHyperlink = 0; |
| 79 | 80 | } |
| @@ -82,11 +83,11 @@ | ||
| 82 | 83 | style_header("Site Map"); |
| 83 | 84 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 84 | 85 | } |
| 85 | 86 | |
| 86 | 87 | @ <ul id="sitemap" class="columns" style="column-width:20em"> |
| 87 | - if( bAllEntries ){ | |
| 88 | + if( (e&1)==0 ){ | |
| 88 | 89 | @ <li>%z(href("%R/home"))Home Page</a> |
| 89 | 90 | } |
| 90 | 91 | |
| 91 | 92 | #if 0 /* Removed 2021-01-26 */ |
| 92 | 93 | for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){ |
| @@ -103,17 +104,17 @@ | ||
| 103 | 104 | } |
| 104 | 105 | } |
| 105 | 106 | #endif |
| 106 | 107 | |
| 107 | 108 | zExtra = db_get("sitemap-extra",0); |
| 108 | - if( zExtra ){ | |
| 109 | + if( zExtra && (e&2)==0 ){ | |
| 109 | 110 | int rc; |
| 110 | 111 | char **azExtra = 0; |
| 111 | 112 | int *anExtra; |
| 112 | 113 | int nExtra = 0; |
| 113 | 114 | if( isPopup ) Th_FossilInit(0); |
| 114 | - if( !bAllEntries ) inSublist = 1; | |
| 115 | + if( (e&1)!=0 ) inSublist = 1; | |
| 115 | 116 | rc = Th_SplitList(g.interp, zExtra, (int)strlen(zExtra), |
| 116 | 117 | &azExtra, &anExtra, &nExtra); |
| 117 | 118 | if( rc==TH_OK && nExtra ){ |
| 118 | 119 | for(i=0; i+2<nExtra; i+=3){ |
| 119 | 120 | int nResult = 0; |
| @@ -136,11 +137,11 @@ | ||
| 136 | 137 | } |
| 137 | 138 | } |
| 138 | 139 | } |
| 139 | 140 | Th_Free(g.interp, azExtra); |
| 140 | 141 | } |
| 141 | - if( !bAllEntries ) goto end_of_sitemap; | |
| 142 | + if( (e&1)!=0 ) goto end_of_sitemap; | |
| 142 | 143 | if( srchFlags & SRCH_DOC ){ |
| 143 | 144 | if( !inSublist ){ |
| 144 | 145 | @ <ul> |
| 145 | 146 | inSublist = 1; |
| 146 | 147 | } |
| 147 | 148 |
| --- src/sitemap.c | |
| +++ src/sitemap.c | |
| @@ -21,11 +21,10 @@ | |
| 21 | #include "sitemap.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | /* |
| 25 | ** WEBPAGE: sitemap |
| 26 | ** WEBPAGE: sitemap-ex |
| 27 | ** |
| 28 | ** List some of the web pages offered by the Fossil web engine. This |
| 29 | ** page is intended as a supplement to the menu bar on the main screen. |
| 30 | ** That is, this page is designed to hold links that are omitted from |
| 31 | ** the main menu due to lack of space. |
| @@ -40,12 +39,14 @@ | |
| 40 | ** |
| 41 | ** * A "capexpr" expression that determines whether or not to include |
| 42 | ** the entry based on user capabilities. "*" means always include |
| 43 | ** the entry and "{}" means never. |
| 44 | ** |
| 45 | ** The /sitemap-ex page works /sitemap except that it includes only the |
| 46 | ** sitemap-extra content and omits the standard content. |
| 47 | ** |
| 48 | ** If the "popup" query parameter is present and this is a POST request |
| 49 | ** from the same origin, then the normal HTML header and footer information |
| 50 | ** is omitted and the HTML text returned is just a raw "<ul>...</ul>". |
| 51 | */ |
| @@ -52,11 +53,11 @@ | |
| 52 | void sitemap_page(void){ |
| 53 | int srchFlags; |
| 54 | int inSublist = 0; |
| 55 | int i; |
| 56 | int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */ |
| 57 | int bAllEntries = fossil_strcmp(g.zPath,"sitemap")==0; |
| 58 | const char *zExtra; |
| 59 | |
| 60 | #if 0 /* Removed 2021-01-26 */ |
| 61 | const struct { |
| 62 | const char *zTitle; |
| @@ -68,12 +69,12 @@ | |
| 68 | { "Contact", "sitemap-contact" }, |
| 69 | }; |
| 70 | #endif |
| 71 | |
| 72 | login_check_credentials(); |
| 73 | if( P("popup")!=0 && (g.perm.Setup || cgi_csrf_safe(0)) ){ |
| 74 | /* If this is a POST from the same origin with the popup=1 parameter, |
| 75 | ** then disable anti-robot defenses */ |
| 76 | isPopup = 1; |
| 77 | g.perm.Hyperlink = 1; |
| 78 | g.javascriptHyperlink = 0; |
| 79 | } |
| @@ -82,11 +83,11 @@ | |
| 82 | style_header("Site Map"); |
| 83 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 84 | } |
| 85 | |
| 86 | @ <ul id="sitemap" class="columns" style="column-width:20em"> |
| 87 | if( bAllEntries ){ |
| 88 | @ <li>%z(href("%R/home"))Home Page</a> |
| 89 | } |
| 90 | |
| 91 | #if 0 /* Removed 2021-01-26 */ |
| 92 | for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){ |
| @@ -103,17 +104,17 @@ | |
| 103 | } |
| 104 | } |
| 105 | #endif |
| 106 | |
| 107 | zExtra = db_get("sitemap-extra",0); |
| 108 | if( zExtra ){ |
| 109 | int rc; |
| 110 | char **azExtra = 0; |
| 111 | int *anExtra; |
| 112 | int nExtra = 0; |
| 113 | if( isPopup ) Th_FossilInit(0); |
| 114 | if( !bAllEntries ) inSublist = 1; |
| 115 | rc = Th_SplitList(g.interp, zExtra, (int)strlen(zExtra), |
| 116 | &azExtra, &anExtra, &nExtra); |
| 117 | if( rc==TH_OK && nExtra ){ |
| 118 | for(i=0; i+2<nExtra; i+=3){ |
| 119 | int nResult = 0; |
| @@ -136,11 +137,11 @@ | |
| 136 | } |
| 137 | } |
| 138 | } |
| 139 | Th_Free(g.interp, azExtra); |
| 140 | } |
| 141 | if( !bAllEntries ) goto end_of_sitemap; |
| 142 | if( srchFlags & SRCH_DOC ){ |
| 143 | if( !inSublist ){ |
| 144 | @ <ul> |
| 145 | inSublist = 1; |
| 146 | } |
| 147 |
| --- src/sitemap.c | |
| +++ src/sitemap.c | |
| @@ -21,11 +21,10 @@ | |
| 21 | #include "sitemap.h" |
| 22 | #include <assert.h> |
| 23 | |
| 24 | /* |
| 25 | ** WEBPAGE: sitemap |
| 26 | ** |
| 27 | ** List some of the web pages offered by the Fossil web engine. This |
| 28 | ** page is intended as a supplement to the menu bar on the main screen. |
| 29 | ** That is, this page is designed to hold links that are omitted from |
| 30 | ** the main menu due to lack of space. |
| @@ -40,12 +39,14 @@ | |
| 39 | ** |
| 40 | ** * A "capexpr" expression that determines whether or not to include |
| 41 | ** the entry based on user capabilities. "*" means always include |
| 42 | ** the entry and "{}" means never. |
| 43 | ** |
| 44 | ** If the "e=1" query parameter is present, then the standard content |
| 45 | ** is omitted and only the sitemap-extra content is shown. If "e=2" is |
| 46 | ** present, then only the standard content is shown and sitemap-extra |
| 47 | ** content is omitted. |
| 48 | ** |
| 49 | ** If the "popup" query parameter is present and this is a POST request |
| 50 | ** from the same origin, then the normal HTML header and footer information |
| 51 | ** is omitted and the HTML text returned is just a raw "<ul>...</ul>". |
| 52 | */ |
| @@ -52,11 +53,11 @@ | |
| 53 | void sitemap_page(void){ |
| 54 | int srchFlags; |
| 55 | int inSublist = 0; |
| 56 | int i; |
| 57 | int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */ |
| 58 | int e = atoi(PD("e","0")); |
| 59 | const char *zExtra; |
| 60 | |
| 61 | #if 0 /* Removed 2021-01-26 */ |
| 62 | const struct { |
| 63 | const char *zTitle; |
| @@ -68,12 +69,12 @@ | |
| 69 | { "Contact", "sitemap-contact" }, |
| 70 | }; |
| 71 | #endif |
| 72 | |
| 73 | login_check_credentials(); |
| 74 | if( P("popup")!=0 ){ |
| 75 | /* The "popup" query parameter |
| 76 | ** then disable anti-robot defenses */ |
| 77 | isPopup = 1; |
| 78 | g.perm.Hyperlink = 1; |
| 79 | g.javascriptHyperlink = 0; |
| 80 | } |
| @@ -82,11 +83,11 @@ | |
| 83 | style_header("Site Map"); |
| 84 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 85 | } |
| 86 | |
| 87 | @ <ul id="sitemap" class="columns" style="column-width:20em"> |
| 88 | if( (e&1)==0 ){ |
| 89 | @ <li>%z(href("%R/home"))Home Page</a> |
| 90 | } |
| 91 | |
| 92 | #if 0 /* Removed 2021-01-26 */ |
| 93 | for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){ |
| @@ -103,17 +104,17 @@ | |
| 104 | } |
| 105 | } |
| 106 | #endif |
| 107 | |
| 108 | zExtra = db_get("sitemap-extra",0); |
| 109 | if( zExtra && (e&2)==0 ){ |
| 110 | int rc; |
| 111 | char **azExtra = 0; |
| 112 | int *anExtra; |
| 113 | int nExtra = 0; |
| 114 | if( isPopup ) Th_FossilInit(0); |
| 115 | if( (e&1)!=0 ) inSublist = 1; |
| 116 | rc = Th_SplitList(g.interp, zExtra, (int)strlen(zExtra), |
| 117 | &azExtra, &anExtra, &nExtra); |
| 118 | if( rc==TH_OK && nExtra ){ |
| 119 | for(i=0; i+2<nExtra; i+=3){ |
| 120 | int nResult = 0; |
| @@ -136,11 +137,11 @@ | |
| 137 | } |
| 138 | } |
| 139 | } |
| 140 | Th_Free(g.interp, azExtra); |
| 141 | } |
| 142 | if( (e&1)!=0 ) goto end_of_sitemap; |
| 143 | if( srchFlags & SRCH_DOC ){ |
| 144 | if( !inSublist ){ |
| 145 | @ <ul> |
| 146 | inSublist = 1; |
| 147 | } |
| 148 |