Fossil SCM

Add the /sitemap-ex webpage - potentially useful for customized hamburger menus.

drh 2021-01-28 17:48 trunk
Commit 5f36ec7d10c56b2d66c3070fda9beb35880a27b28915a843a390449739595902
1 file changed +28 -2
+28 -2
--- src/sitemap.c
+++ src/sitemap.c
@@ -21,21 +21,42 @@
2121
#include "sitemap.h"
2222
#include <assert.h>
2323
2424
/*
2525
** WEBPAGE: sitemap
26
+** WEBPAGE: sitemap-ex
2627
**
2728
** List some of the web pages offered by the Fossil web engine. This
2829
** page is intended as a supplement to the menu bar on the main screen.
2930
** That is, this page is designed to hold links that are omitted from
3031
** 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>".
3151
*/
3252
void sitemap_page(void){
3353
int srchFlags;
3454
int inSublist = 0;
3555
int i;
3656
int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */
57
+ int bAllEntries = fossil_strcmp(g.zPath,"sitemap")==0;
3758
const char *zExtra;
3859
3960
#if 0 /* Removed 2021-01-26 */
4061
const struct {
4162
const char *zTitle;
@@ -47,11 +68,11 @@
4768
{ "Contact", "sitemap-contact" },
4869
};
4970
#endif
5071
5172
login_check_credentials();
52
- if( P("popup")!=0 && cgi_csrf_safe(0) ){
73
+ if( P("popup")!=0 && (g.perm.Setup || cgi_csrf_safe(0)) ){
5374
/* If this is a POST from the same origin with the popup=1 parameter,
5475
** then disable anti-robot defenses */
5576
isPopup = 1;
5677
g.perm.Hyperlink = 1;
5778
g.javascriptHyperlink = 0;
@@ -61,11 +82,13 @@
6182
style_header("Site Map");
6283
style_adunit_config(ADUNIT_RIGHT_OK);
6384
}
6485
6586
@ <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
+ }
6790
6891
#if 0 /* Removed 2021-01-26 */
6992
for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){
7093
char *z = db_get(aExtra[i].zProperty,0);
7194
if( z==0 || z[0]==0 ) continue;
@@ -112,10 +135,11 @@
112135
}
113136
}
114137
}
115138
Th_Free(g.interp, azExtra);
116139
}
140
+ if( !bAllEntries ) goto end_of_sitemap;
117141
if( srchFlags & SRCH_DOC ){
118142
if( !inSublist ){
119143
@ <ul>
120144
inSublist = 1;
121145
}
@@ -265,10 +289,12 @@
265289
@ <li>%z(href("%R/skins"))Skins</a></li>
266290
@ <li>%z(href("%R/sitemap-test"))Test Pages</a></li>
267291
if( isPopup ){
268292
@ <li>%z(href("%R/sitemap"))Site Map</a></li>
269293
}
294
+
295
+end_of_sitemap:
270296
@ </ul>
271297
if( !isPopup ){
272298
style_finish_page();
273299
}
274300
}
275301
--- 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

Keyboard Shortcuts

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