Fossil SCM

Rework the /sitemap customization settings. There is now just a single setting "sitemap-extra" that is a TCL list of triples, where each triple defines a new entry in the /sitemap. Legacy entries are ignored. Administrators that have a custom /sitemap configuration will need to update the "Custom Sitemap Entries" setting on the /Admin/Configuration page after updating to this version of Fossil or later.

drh 2021-01-26 19:37 trunk
Commit aa5beb8c297faf1fbd215337908d3d263ce7e8ba1a8d6c412c12498643b0ee9f
--- skins/default/css.txt
+++ skins/default/css.txt
@@ -272,11 +272,11 @@
272272
padding: 10px 10px;
273273
}
274274
.mainmenu {
275275
padding: 10px;
276276
}
277
- .desktoponly {
277
+ .not-mobile {
278278
display: none;
279279
}
280280
}
281281
@media screen and (min-width: 600px) {
282282
/* Spacing for desktop */
@@ -296,9 +296,9 @@
296296
padding: 10px;
297297
}
298298
}
299299
@media screen and (max-width: 1200px) {
300300
/* Special declarations for narrow desktop or wide mobile */
301
- .wideonly {
301
+ .wide-screen {
302302
display: none;
303303
}
304304
}
305305
--- skins/default/css.txt
+++ skins/default/css.txt
@@ -272,11 +272,11 @@
272 padding: 10px 10px;
273 }
274 .mainmenu {
275 padding: 10px;
276 }
277 .desktoponly {
278 display: none;
279 }
280 }
281 @media screen and (min-width: 600px) {
282 /* Spacing for desktop */
@@ -296,9 +296,9 @@
296 padding: 10px;
297 }
298 }
299 @media screen and (max-width: 1200px) {
300 /* Special declarations for narrow desktop or wide mobile */
301 .wideonly {
302 display: none;
303 }
304 }
305
--- skins/default/css.txt
+++ skins/default/css.txt
@@ -272,11 +272,11 @@
272 padding: 10px 10px;
273 }
274 .mainmenu {
275 padding: 10px;
276 }
277 .not-mobile {
278 display: none;
279 }
280 }
281 @media screen and (min-width: 600px) {
282 /* Spacing for desktop */
@@ -296,9 +296,9 @@
296 padding: 10px;
297 }
298 }
299 @media screen and (max-width: 1200px) {
300 /* Special declarations for narrow desktop or wide mobile */
301 .wide-screen {
302 display: none;
303 }
304 }
305
+1 -4
--- src/configure.c
+++ src/configure.c
@@ -112,14 +112,11 @@
112112
{ "timeline-utc", CONFIGSET_SKIN },
113113
{ "adunit", CONFIGSET_SKIN },
114114
{ "adunit-omit-if-admin", CONFIGSET_SKIN },
115115
{ "adunit-omit-if-user", CONFIGSET_SKIN },
116116
{ "default-csp", CONFIGSET_SKIN },
117
- { "sitemap-docidx", CONFIGSET_SKIN },
118
- { "sitemap-download", CONFIGSET_SKIN },
119
- { "sitemap-license", CONFIGSET_SKIN },
120
- { "sitemap-contact", CONFIGSET_SKIN },
117
+ { "sitemap-extra", CONFIGSET_SKIN },
121118
{ "safe-html", CONFIGSET_SKIN },
122119
123120
#ifdef FOSSIL_ENABLE_TH1_DOCS
124121
{ "th1-docs", CONFIGSET_TH1 },
125122
#endif
126123
--- src/configure.c
+++ src/configure.c
@@ -112,14 +112,11 @@
112 { "timeline-utc", CONFIGSET_SKIN },
113 { "adunit", CONFIGSET_SKIN },
114 { "adunit-omit-if-admin", CONFIGSET_SKIN },
115 { "adunit-omit-if-user", CONFIGSET_SKIN },
116 { "default-csp", CONFIGSET_SKIN },
117 { "sitemap-docidx", CONFIGSET_SKIN },
118 { "sitemap-download", CONFIGSET_SKIN },
119 { "sitemap-license", CONFIGSET_SKIN },
120 { "sitemap-contact", CONFIGSET_SKIN },
121 { "safe-html", CONFIGSET_SKIN },
122
123 #ifdef FOSSIL_ENABLE_TH1_DOCS
124 { "th1-docs", CONFIGSET_TH1 },
125 #endif
126
--- src/configure.c
+++ src/configure.c
@@ -112,14 +112,11 @@
112 { "timeline-utc", CONFIGSET_SKIN },
113 { "adunit", CONFIGSET_SKIN },
114 { "adunit-omit-if-admin", CONFIGSET_SKIN },
115 { "adunit-omit-if-user", CONFIGSET_SKIN },
116 { "default-csp", CONFIGSET_SKIN },
117 { "sitemap-extra", CONFIGSET_SKIN },
 
 
 
118 { "safe-html", CONFIGSET_SKIN },
119
120 #ifdef FOSSIL_ENABLE_TH1_DOCS
121 { "th1-docs", CONFIGSET_TH1 },
122 #endif
123
+22 -18
--- src/setup.c
+++ src/setup.c
@@ -1017,29 +1017,33 @@
10171017
@ begin with "/" and it must specify a valid page. For example,
10181018
@ "<b>/home</b>" will work but "<b>home</b>" will not, since it omits the
10191019
@ leading "/".</p>
10201020
@ <p>(Property: "index-page")
10211021
@ <hr>
1022
- @ <p>Extra links to appear on the <a href="%R/sitemap">/sitemap</a> page.
1023
- @ Often these are filled in with links like
1024
- @ "/doc/trunk/doc/<i>filename</i>.md" so that they refer to
1025
- @ embedded documentation, or like "/wiki/<i>pagename</i>" to refer
1026
- @ to wiki pages.
1027
- @ Leave blank to omit.
1022
+ @ <p>Extra links to appear on the <a href="%R/sitemap">/sitemap</a> page,
1023
+ @ as sub-items of the "Home Page" entry, appearing before the
1024
+ @ "Documentation Search" entry (if any). In skins that use the /sitemap
1025
+ @ page to construct a hamburger menu dropdown, new entries added here
1026
+ @ will appear on the hamburger menu.
1027
+ @
1028
+ @ <p>This setting should be a TCL list divided into triples. Each
1029
+ @ triple defines a new entry:
1030
+ @ <ol>
1031
+ @ <li> The first term is the display name of the /sitemap entry
1032
+ @ <li> The second term is a hyperlink to take when a user clicks on the
1033
+ @ entry. Hyperlinks that start with "/" are relative to the
1034
+ @ repository root.
1035
+ @ <li> The third term is an argument to the TH1 "capexpr" command.
1036
+ @ If capexpr evalutes to true, then the entry is shown. If not,
1037
+ @ the entry is omitted. "*" is always true.
1038
+ @ </ol>
1039
+ @
1040
+ @ <p>The default value is blank, meaning no added entries.
1041
+ @ (Property: sitemap-extra)
10281042
@ <p>
1029
- entry_attribute("Documentation Index", 40, "sitemap-docidx", "smdocidx",
1030
- "", 0);
1031
- @ (Property: sitemap-docidx)<br>
1032
- entry_attribute("Download", 40, "sitemap-download", "smdownload",
1033
- "", 0);
1034
- @ (Property: sitemap-download)<br>
1035
- entry_attribute("License", 40, "sitemap-license", "smlicense",
1036
- "", 0);
1037
- @ (Property: sitemap-license)<br>
1038
- entry_attribute("Contact", 40, "sitemap-contact", "smcontact",
1039
- "", 0);
1040
- @ (Property: sitemap-contact)
1043
+ textarea_attribute("Custom Sitemap Entries", 8, 80,
1044
+ "sitemap-extra", "smextra", "", 0);
10411045
@ <hr />
10421046
@ <p><input type="submit" name="submit" value="Apply Changes" /></p>
10431047
@ </div></form>
10441048
db_end_transaction(0);
10451049
style_finish_page();
10461050
--- src/setup.c
+++ src/setup.c
@@ -1017,29 +1017,33 @@
1017 @ begin with "/" and it must specify a valid page. For example,
1018 @ "<b>/home</b>" will work but "<b>home</b>" will not, since it omits the
1019 @ leading "/".</p>
1020 @ <p>(Property: "index-page")
1021 @ <hr>
1022 @ <p>Extra links to appear on the <a href="%R/sitemap">/sitemap</a> page.
1023 @ Often these are filled in with links like
1024 @ "/doc/trunk/doc/<i>filename</i>.md" so that they refer to
1025 @ embedded documentation, or like "/wiki/<i>pagename</i>" to refer
1026 @ to wiki pages.
1027 @ Leave blank to omit.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1028 @ <p>
1029 entry_attribute("Documentation Index", 40, "sitemap-docidx", "smdocidx",
1030 "", 0);
1031 @ (Property: sitemap-docidx)<br>
1032 entry_attribute("Download", 40, "sitemap-download", "smdownload",
1033 "", 0);
1034 @ (Property: sitemap-download)<br>
1035 entry_attribute("License", 40, "sitemap-license", "smlicense",
1036 "", 0);
1037 @ (Property: sitemap-license)<br>
1038 entry_attribute("Contact", 40, "sitemap-contact", "smcontact",
1039 "", 0);
1040 @ (Property: sitemap-contact)
1041 @ <hr />
1042 @ <p><input type="submit" name="submit" value="Apply Changes" /></p>
1043 @ </div></form>
1044 db_end_transaction(0);
1045 style_finish_page();
1046
--- src/setup.c
+++ src/setup.c
@@ -1017,29 +1017,33 @@
1017 @ begin with "/" and it must specify a valid page. For example,
1018 @ "<b>/home</b>" will work but "<b>home</b>" will not, since it omits the
1019 @ leading "/".</p>
1020 @ <p>(Property: "index-page")
1021 @ <hr>
1022 @ <p>Extra links to appear on the <a href="%R/sitemap">/sitemap</a> page,
1023 @ as sub-items of the "Home Page" entry, appearing before the
1024 @ "Documentation Search" entry (if any). In skins that use the /sitemap
1025 @ page to construct a hamburger menu dropdown, new entries added here
1026 @ will appear on the hamburger menu.
1027 @
1028 @ <p>This setting should be a TCL list divided into triples. Each
1029 @ triple defines a new entry:
1030 @ <ol>
1031 @ <li> The first term is the display name of the /sitemap entry
1032 @ <li> The second term is a hyperlink to take when a user clicks on the
1033 @ entry. Hyperlinks that start with "/" are relative to the
1034 @ repository root.
1035 @ <li> The third term is an argument to the TH1 "capexpr" command.
1036 @ If capexpr evalutes to true, then the entry is shown. If not,
1037 @ the entry is omitted. "*" is always true.
1038 @ </ol>
1039 @
1040 @ <p>The default value is blank, meaning no added entries.
1041 @ (Property: sitemap-extra)
1042 @ <p>
1043 textarea_attribute("Custom Sitemap Entries", 8, 80,
1044 "sitemap-extra", "smextra", "", 0);
 
 
 
 
 
 
 
 
 
 
1045 @ <hr />
1046 @ <p><input type="submit" name="submit" value="Apply Changes" /></p>
1047 @ </div></form>
1048 db_end_transaction(0);
1049 style_finish_page();
1050
--- src/sitemap.c
+++ src/sitemap.c
@@ -32,19 +32,23 @@
3232
void sitemap_page(void){
3333
int srchFlags;
3434
int inSublist = 0;
3535
int i;
3636
int isPopup = 0; /* This is an XMLHttpRequest() for /sitemap */
37
+ const char *zExtra;
38
+
39
+#if 0 /* Removed 2021-01-26 */
3740
const struct {
3841
const char *zTitle;
3942
const char *zProperty;
4043
} aExtra[] = {
4144
{ "Documentation", "sitemap-docidx" },
4245
{ "Download", "sitemap-download" },
4346
{ "License", "sitemap-license" },
4447
{ "Contact", "sitemap-contact" },
4548
};
49
+#endif
4650
4751
login_check_credentials();
4852
if( P("popup")!=0 && cgi_csrf_safe(0) ){
4953
/* If this is a POST from the same origin with the popup=1 parameter,
5054
** then disable anti-robot defenses */
@@ -55,12 +59,15 @@
5559
srchFlags = search_restrict(SRCH_ALL);
5660
if( !isPopup ){
5761
style_header("Site Map");
5862
style_adunit_config(ADUNIT_RIGHT_OK);
5963
}
64
+
6065
@ <ul id="sitemap" class="columns" style="column-width:20em">
6166
@ <li>%z(href("%R/home"))Home Page</a>
67
+
68
+#if 0 /* Removed 2021-01-26 */
6269
for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){
6370
char *z = db_get(aExtra[i].zProperty,0);
6471
if( z==0 || z[0]==0 ) continue;
6572
if( !inSublist ){
6673
@ <ul>
@@ -70,10 +77,45 @@
7077
@ <li>%z(href("%R%s",z))%s(aExtra[i].zTitle)</a></li>
7178
}else{
7279
@ <li>%z(href("%s",z))%s(aExtra[i].zTitle)</a></li>
7380
}
7481
}
82
+#endif
83
+
84
+ zExtra = db_get("sitemap-extra",0);
85
+ if( zExtra ){
86
+ int rc;
87
+ char **azExtra = 0;
88
+ int *anExtra;
89
+ int nExtra = 0;
90
+ if( isPopup ) Th_FossilInit(0);
91
+ rc = Th_SplitList(g.interp, zExtra, (int)strlen(zExtra),
92
+ &azExtra, &anExtra, &nExtra);
93
+ if( rc==TH_OK && nExtra ){
94
+ for(i=0; i+2<nExtra; i+=3){
95
+ int nResult = 0;
96
+ const char *zResult;
97
+ int iCond = 0;
98
+ rc = capexprCmd(g.interp, 0, 2,
99
+ (const char**)&azExtra[i+1], (int*)&anExtra[i+1]);
100
+ if( rc!=TH_OK ) continue;
101
+ zResult = Th_GetResult(g.interp, &nResult);
102
+ Th_ToInt(g.interp, zResult, nResult, &iCond);
103
+ if( iCond==0 ) continue;
104
+ if( !inSublist ){
105
+ @ <ul>
106
+ inSublist = 1;
107
+ }
108
+ if( azExtra[i+1][0]=='/' ){
109
+ @ <li>%z(href("%R%s",azExtra[i+1]))%h(azExtra[i])</a></li>
110
+ }else{
111
+ @ <li>%z(href("%s",azExtra[i+1]))%s(azExtra[i])</a></li>
112
+ }
113
+ }
114
+ }
115
+ Th_Free(g.interp, azExtra);
116
+ }
75117
if( srchFlags & SRCH_DOC ){
76118
if( !inSublist ){
77119
@ <ul>
78120
inSublist = 1;
79121
}
80122
--- src/sitemap.c
+++ src/sitemap.c
@@ -32,19 +32,23 @@
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 struct {
38 const char *zTitle;
39 const char *zProperty;
40 } aExtra[] = {
41 { "Documentation", "sitemap-docidx" },
42 { "Download", "sitemap-download" },
43 { "License", "sitemap-license" },
44 { "Contact", "sitemap-contact" },
45 };
 
46
47 login_check_credentials();
48 if( P("popup")!=0 && cgi_csrf_safe(0) ){
49 /* If this is a POST from the same origin with the popup=1 parameter,
50 ** then disable anti-robot defenses */
@@ -55,12 +59,15 @@
55 srchFlags = search_restrict(SRCH_ALL);
56 if( !isPopup ){
57 style_header("Site Map");
58 style_adunit_config(ADUNIT_RIGHT_OK);
59 }
 
60 @ <ul id="sitemap" class="columns" style="column-width:20em">
61 @ <li>%z(href("%R/home"))Home Page</a>
 
 
62 for(i=0; i<sizeof(aExtra)/sizeof(aExtra[0]); i++){
63 char *z = db_get(aExtra[i].zProperty,0);
64 if( z==0 || z[0]==0 ) continue;
65 if( !inSublist ){
66 @ <ul>
@@ -70,10 +77,45 @@
70 @ <li>%z(href("%R%s",z))%s(aExtra[i].zTitle)</a></li>
71 }else{
72 @ <li>%z(href("%s",z))%s(aExtra[i].zTitle)</a></li>
73 }
74 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
75 if( srchFlags & SRCH_DOC ){
76 if( !inSublist ){
77 @ <ul>
78 inSublist = 1;
79 }
80
--- src/sitemap.c
+++ src/sitemap.c
@@ -32,19 +32,23 @@
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;
42 const char *zProperty;
43 } aExtra[] = {
44 { "Documentation", "sitemap-docidx" },
45 { "Download", "sitemap-download" },
46 { "License", "sitemap-license" },
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,12 +59,15 @@
59 srchFlags = search_restrict(SRCH_ALL);
60 if( !isPopup ){
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;
72 if( !inSublist ){
73 @ <ul>
@@ -70,10 +77,45 @@
77 @ <li>%z(href("%R%s",z))%s(aExtra[i].zTitle)</a></li>
78 }else{
79 @ <li>%z(href("%s",z))%s(aExtra[i].zTitle)</a></li>
80 }
81 }
82 #endif
83
84 zExtra = db_get("sitemap-extra",0);
85 if( zExtra ){
86 int rc;
87 char **azExtra = 0;
88 int *anExtra;
89 int nExtra = 0;
90 if( isPopup ) Th_FossilInit(0);
91 rc = Th_SplitList(g.interp, zExtra, (int)strlen(zExtra),
92 &azExtra, &anExtra, &nExtra);
93 if( rc==TH_OK && nExtra ){
94 for(i=0; i+2<nExtra; i+=3){
95 int nResult = 0;
96 const char *zResult;
97 int iCond = 0;
98 rc = capexprCmd(g.interp, 0, 2,
99 (const char**)&azExtra[i+1], (int*)&anExtra[i+1]);
100 if( rc!=TH_OK ) continue;
101 zResult = Th_GetResult(g.interp, &nResult);
102 Th_ToInt(g.interp, zResult, nResult, &iCond);
103 if( iCond==0 ) continue;
104 if( !inSublist ){
105 @ <ul>
106 inSublist = 1;
107 }
108 if( azExtra[i+1][0]=='/' ){
109 @ <li>%z(href("%R%s",azExtra[i+1]))%h(azExtra[i])</a></li>
110 }else{
111 @ <li>%z(href("%s",azExtra[i+1]))%s(azExtra[i])</a></li>
112 }
113 }
114 }
115 Th_Free(g.interp, azExtra);
116 }
117 if( srchFlags & SRCH_DOC ){
118 if( !inSublist ){
119 @ <ul>
120 inSublist = 1;
121 }
122
+1 -1
--- src/th_main.c
+++ src/th_main.c
@@ -812,11 +812,11 @@
812812
** capexpr {j o r} True if any one of j, o, or r are available
813813
** capexpr {oh} True if both o and h are available
814814
** capexpr {@2 @3 4 5 6} 2 or 3 available for anonymous or one of
815815
** 4, 5 or 6 is available for the user
816816
*/
817
-static int capexprCmd(
817
+int capexprCmd(
818818
Th_Interp *interp,
819819
void *p,
820820
int argc,
821821
const char **argv,
822822
int *argl
823823
--- src/th_main.c
+++ src/th_main.c
@@ -812,11 +812,11 @@
812 ** capexpr {j o r} True if any one of j, o, or r are available
813 ** capexpr {oh} True if both o and h are available
814 ** capexpr {@2 @3 4 5 6} 2 or 3 available for anonymous or one of
815 ** 4, 5 or 6 is available for the user
816 */
817 static int capexprCmd(
818 Th_Interp *interp,
819 void *p,
820 int argc,
821 const char **argv,
822 int *argl
823
--- src/th_main.c
+++ src/th_main.c
@@ -812,11 +812,11 @@
812 ** capexpr {j o r} True if any one of j, o, or r are available
813 ** capexpr {oh} True if both o and h are available
814 ** capexpr {@2 @3 4 5 6} 2 or 3 available for anonymous or one of
815 ** 4, 5 or 6 is available for the user
816 */
817 int capexprCmd(
818 Th_Interp *interp,
819 void *p,
820 int argc,
821 const char **argv,
822 int *argl
823

Keyboard Shortcuts

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