Fossil SCM
Add the /sitemap-ex webpage - potentially useful for customized hamburger menus.
Commit
5f36ec7d10c56b2d66c3070fda9beb35880a27b28915a843a390449739595902
Parent
60a28a8d898224e…
1 file changed
+28
-2
+28
-2
| --- src/sitemap.c | ||
| +++ src/sitemap.c | ||
| @@ -21,21 +21,42 @@ | ||
| 21 | 21 | #include "sitemap.h" |
| 22 | 22 | #include <assert.h> |
| 23 | 23 | |
| 24 | 24 | /* |
| 25 | 25 | ** WEBPAGE: sitemap |
| 26 | +** WEBPAGE: sitemap-ex | |
| 26 | 27 | ** |
| 27 | 28 | ** List some of the web pages offered by the Fossil web engine. This |
| 28 | 29 | ** page is intended as a supplement to the menu bar on the main screen. |
| 29 | 30 | ** That is, this page is designed to hold links that are omitted from |
| 30 | 31 | ** the main menu due to lack of space. |
| 32 | +** | |
| 33 | +** Additional entries defined by the "sitemap-extra" setting are included | |
| 34 | +** in the sitemap. "sitemap-extra" should be a TCL script with three | |
| 35 | +** values per entry: | |
| 36 | +** | |
| 37 | +** * The displayed text | |
| 38 | +** | |
| 39 | +** * The URL | |
| 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>". | |
| 31 | 51 | */ |
| 32 | 52 | void sitemap_page(void){ |
| 33 | 53 | int srchFlags; |
| 34 | 54 | int inSublist = 0; |
| 35 | 55 | int i; |
| 36 | 56 | int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */ |
| 57 | + int bAllEntries = fossil_strcmp(g.zPath,"sitemap")==0; | |
| 37 | 58 | const char *zExtra; |
| 38 | 59 | |
| 39 | 60 | #if 0 /* Removed 2021-01-26 */ |
| 40 | 61 | const struct { |
| 41 | 62 | const char *zTitle; |
| @@ -47,11 +68,11 @@ | ||
| 47 | 68 | { "Contact", "sitemap-contact" }, |
| 48 | 69 | }; |
| 49 | 70 | #endif |
| 50 | 71 | |
| 51 | 72 | login_check_credentials(); |
| 52 | - if( P("popup")!=0 && cgi_csrf_safe(0) ){ | |
| 73 | + if( P("popup")!=0 && (g.perm.Setup || cgi_csrf_safe(0)) ){ | |
| 53 | 74 | /* If this is a POST from the same origin with the popup=1 parameter, |
| 54 | 75 | ** then disable anti-robot defenses */ |
| 55 | 76 | isPopup = 1; |
| 56 | 77 | g.perm.Hyperlink = 1; |
| 57 | 78 | g.javascriptHyperlink = 0; |
| @@ -61,11 +82,13 @@ | ||
| 61 | 82 | style_header("Site Map"); |
| 62 | 83 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 63 | 84 | } |
| 64 | 85 | |
| 65 | 86 | @ <ul id="sitemap" class="columns" style="column-width:20em"> |
| 66 | - @ <li>%z(href("%R/home"))Home Page</a> | |
| 87 | + if( bAllEntries ){ | |
| 88 | + @ <li>%z(href("%R/home"))Home Page</a> | |
| 89 | + } | |
| 67 | 90 | |
| 68 | 91 | #if 0 /* Removed 2021-01-26 */ |
| 69 | 92 | for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){ |
| 70 | 93 | char *z = db_get(aExtra[i].zProperty,0); |
| 71 | 94 | if( z==0 || z[0]==0 ) continue; |
| @@ -112,10 +135,11 @@ | ||
| 112 | 135 | } |
| 113 | 136 | } |
| 114 | 137 | } |
| 115 | 138 | Th_Free(g.interp, azExtra); |
| 116 | 139 | } |
| 140 | + if( !bAllEntries ) goto end_of_sitemap; | |
| 117 | 141 | if( srchFlags & SRCH_DOC ){ |
| 118 | 142 | if( !inSublist ){ |
| 119 | 143 | @ <ul> |
| 120 | 144 | inSublist = 1; |
| 121 | 145 | } |
| @@ -265,10 +289,12 @@ | ||
| 265 | 289 | @ <li>%z(href("%R/skins"))Skins</a></li> |
| 266 | 290 | @ <li>%z(href("%R/sitemap-test"))Test Pages</a></li> |
| 267 | 291 | if( isPopup ){ |
| 268 | 292 | @ <li>%z(href("%R/sitemap"))Site Map</a></li> |
| 269 | 293 | } |
| 294 | + | |
| 295 | +end_of_sitemap: | |
| 270 | 296 | @ </ul> |
| 271 | 297 | if( !isPopup ){ |
| 272 | 298 | style_finish_page(); |
| 273 | 299 | } |
| 274 | 300 | } |
| 275 | 301 |
| --- src/sitemap.c | |
| +++ src/sitemap.c | |
| @@ -21,21 +21,42 @@ | |
| 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. |
| 31 | */ |
| 32 | void sitemap_page(void){ |
| 33 | int srchFlags; |
| 34 | int inSublist = 0; |
| 35 | int i; |
| 36 | int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */ |
| 37 | const char *zExtra; |
| 38 | |
| 39 | #if 0 /* Removed 2021-01-26 */ |
| 40 | const struct { |
| 41 | const char *zTitle; |
| @@ -47,11 +68,11 @@ | |
| 47 | { "Contact", "sitemap-contact" }, |
| 48 | }; |
| 49 | #endif |
| 50 | |
| 51 | login_check_credentials(); |
| 52 | if( P("popup")!=0 && cgi_csrf_safe(0) ){ |
| 53 | /* If this is a POST from the same origin with the popup=1 parameter, |
| 54 | ** then disable anti-robot defenses */ |
| 55 | isPopup = 1; |
| 56 | g.perm.Hyperlink = 1; |
| 57 | g.javascriptHyperlink = 0; |
| @@ -61,11 +82,13 @@ | |
| 61 | style_header("Site Map"); |
| 62 | style_adunit_config(ADUNIT_RIGHT_OK); |
| 63 | } |
| 64 | |
| 65 | @ <ul id="sitemap" class="columns" style="column-width:20em"> |
| 66 | @ <li>%z(href("%R/home"))Home Page</a> |
| 67 | |
| 68 | #if 0 /* Removed 2021-01-26 */ |
| 69 | for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){ |
| 70 | char *z = db_get(aExtra[i].zProperty,0); |
| 71 | if( z==0 || z[0]==0 ) continue; |
| @@ -112,10 +135,11 @@ | |
| 112 | } |
| 113 | } |
| 114 | } |
| 115 | Th_Free(g.interp, azExtra); |
| 116 | } |
| 117 | if( srchFlags & SRCH_DOC ){ |
| 118 | if( !inSublist ){ |
| 119 | @ <ul> |
| 120 | inSublist = 1; |
| 121 | } |
| @@ -265,10 +289,12 @@ | |
| 265 | @ <li>%z(href("%R/skins"))Skins</a></li> |
| 266 | @ <li>%z(href("%R/sitemap-test"))Test Pages</a></li> |
| 267 | if( isPopup ){ |
| 268 | @ <li>%z(href("%R/sitemap"))Site Map</a></li> |
| 269 | } |
| 270 | @ </ul> |
| 271 | if( !isPopup ){ |
| 272 | style_finish_page(); |
| 273 | } |
| 274 | } |
| 275 |
| --- src/sitemap.c | |
| +++ src/sitemap.c | |
| @@ -21,21 +21,42 @@ | |
| 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. |
| 32 | ** |
| 33 | ** Additional entries defined by the "sitemap-extra" setting are included |
| 34 | ** in the sitemap. "sitemap-extra" should be a TCL script with three |
| 35 | ** values per entry: |
| 36 | ** |
| 37 | ** * The displayed text |
| 38 | ** |
| 39 | ** * The URL |
| 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 | 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; |
| @@ -47,11 +68,11 @@ | |
| 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; |
| @@ -61,11 +82,13 @@ | |
| 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++){ |
| 93 | char *z = db_get(aExtra[i].zProperty,0); |
| 94 | if( z==0 || z[0]==0 ) continue; |
| @@ -112,10 +135,11 @@ | |
| 135 | } |
| 136 | } |
| 137 | } |
| 138 | Th_Free(g.interp, azExtra); |
| 139 | } |
| 140 | if( !bAllEntries ) goto end_of_sitemap; |
| 141 | if( srchFlags & SRCH_DOC ){ |
| 142 | if( !inSublist ){ |
| 143 | @ <ul> |
| 144 | inSublist = 1; |
| 145 | } |
| @@ -265,10 +289,12 @@ | |
| 289 | @ <li>%z(href("%R/skins"))Skins</a></li> |
| 290 | @ <li>%z(href("%R/sitemap-test"))Test Pages</a></li> |
| 291 | if( isPopup ){ |
| 292 | @ <li>%z(href("%R/sitemap"))Site Map</a></li> |
| 293 | } |
| 294 | |
| 295 | end_of_sitemap: |
| 296 | @ </ul> |
| 297 | if( !isPopup ){ |
| 298 | style_finish_page(); |
| 299 | } |
| 300 | } |
| 301 |