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.

drh 2021-01-28 18:37 trunk
Commit 635a8b2bf0ebd77f5ab9bfda2a16016526d81240324adcdefd1af867b5b82fb4
2 files changed +2 -1 +11 -10
+2 -1
--- src/hbmenu.js
+++ src/hbmenu.js
@@ -240,11 +240,12 @@
240240
showPanel();
241241
}
242242
}
243243
// else, can't parse response as HTML or XML
244244
}
245
- xhr.open("GET", hbButton.href + "?popup");
245
+ var url = hbButton.href + (hbButton.href.includes("?")?"&popup":"?popup")
246
+ xhr.open("GET", url);
246247
xhr.responseType = "document";
247248
xhr.send();
248249
}
249250
else {
250251
showPanel(); // just show what we built above
251252
--- 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 @@
2121
#include "sitemap.h"
2222
#include <assert.h>
2323
2424
/*
2525
** WEBPAGE: sitemap
26
-** WEBPAGE: sitemap-ex
2726
**
2827
** List some of the web pages offered by the Fossil web engine. This
2928
** page is intended as a supplement to the menu bar on the main screen.
3029
** That is, this page is designed to hold links that are omitted from
3130
** the main menu due to lack of space.
@@ -40,12 +39,14 @@
4039
**
4140
** * A "capexpr" expression that determines whether or not to include
4241
** the entry based on user capabilities. "*" means always include
4342
** the entry and "{}" means never.
4443
**
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.
4748
**
4849
** If the "popup" query parameter is present and this is a POST request
4950
** from the same origin, then the normal HTML header and footer information
5051
** is omitted and the HTML text returned is just a raw "<ul>...</ul>".
5152
*/
@@ -52,11 +53,11 @@
5253
void sitemap_page(void){
5354
int srchFlags;
5455
int inSublist = 0;
5556
int i;
5657
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"));
5859
const char *zExtra;
5960
6061
#if 0 /* Removed 2021-01-26 */
6162
const struct {
6263
const char *zTitle;
@@ -68,12 +69,12 @@
6869
{ "Contact", "sitemap-contact" },
6970
};
7071
#endif
7172
7273
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
7576
** then disable anti-robot defenses */
7677
isPopup = 1;
7778
g.perm.Hyperlink = 1;
7879
g.javascriptHyperlink = 0;
7980
}
@@ -82,11 +83,11 @@
8283
style_header("Site Map");
8384
style_adunit_config(ADUNIT_RIGHT_OK);
8485
}
8586
8687
@ <ul id="sitemap" class="columns" style="column-width:20em">
87
- if( bAllEntries ){
88
+ if( (e&1)==0 ){
8889
@ <li>%z(href("%R/home"))Home Page</a>
8990
}
9091
9192
#if 0 /* Removed 2021-01-26 */
9293
for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){
@@ -103,17 +104,17 @@
103104
}
104105
}
105106
#endif
106107
107108
zExtra = db_get("sitemap-extra",0);
108
- if( zExtra ){
109
+ if( zExtra && (e&2)==0 ){
109110
int rc;
110111
char **azExtra = 0;
111112
int *anExtra;
112113
int nExtra = 0;
113114
if( isPopup ) Th_FossilInit(0);
114
- if( !bAllEntries ) inSublist = 1;
115
+ if( (e&1)!=0 ) inSublist = 1;
115116
rc = Th_SplitList(g.interp, zExtra, (int)strlen(zExtra),
116117
&azExtra, &anExtra, &nExtra);
117118
if( rc==TH_OK && nExtra ){
118119
for(i=0; i+2<nExtra; i+=3){
119120
int nResult = 0;
@@ -136,11 +137,11 @@
136137
}
137138
}
138139
}
139140
Th_Free(g.interp, azExtra);
140141
}
141
- if( !bAllEntries ) goto end_of_sitemap;
142
+ if( (e&1)!=0 ) goto end_of_sitemap;
142143
if( srchFlags & SRCH_DOC ){
143144
if( !inSublist ){
144145
@ <ul>
145146
inSublist = 1;
146147
}
147148
--- 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

Keyboard Shortcuts

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