Fossil SCM

Add TH1 command "<code>submenu</code>". For the time being it has just one subcommand "<code>link</code>" that adds a hyperlink to the submenu of a page.

george 2022-11-24 22:13 trunk
Commit 71b221657bfa7bdf05f00e863e991423db483ad0e111ef971c15cabf2658dba9
+2 -1
--- src/style.c
+++ src/style.c
@@ -995,11 +995,12 @@
995995
for(i=0; i<nSubmenu; i++){
996996
struct Submenu *p = &aSubmenu[i];
997997
style_derive_classname(p->zLabel, zClass, sizeof zClass);
998998
/* switching away from the %h formatting below might be dangerous
999999
** because some places use %s to compose zLabel and zLink;
1000
- ** e.g. /rptview page. "sml" stands for submenu link.
1000
+ ** e.g. /rptview page and the submenuCmd() function.
1001
+ ** "sml" stands for submenu link.
10011002
*/
10021003
if( p->zLink==0 ){
10031004
@ <span class="label sml-%s(zClass)">%h(p->zLabel)</span>
10041005
}else{
10051006
@ <a class="label sml-%s(zClass)" href="%h(p->zLink)">%h(p->zLabel)</a>
10061007
--- src/style.c
+++ src/style.c
@@ -995,11 +995,12 @@
995 for(i=0; i<nSubmenu; i++){
996 struct Submenu *p = &aSubmenu[i];
997 style_derive_classname(p->zLabel, zClass, sizeof zClass);
998 /* switching away from the %h formatting below might be dangerous
999 ** because some places use %s to compose zLabel and zLink;
1000 ** e.g. /rptview page. "sml" stands for submenu link.
 
1001 */
1002 if( p->zLink==0 ){
1003 @ <span class="label sml-%s(zClass)">%h(p->zLabel)</span>
1004 }else{
1005 @ <a class="label sml-%s(zClass)" href="%h(p->zLink)">%h(p->zLabel)</a>
1006
--- src/style.c
+++ src/style.c
@@ -995,11 +995,12 @@
995 for(i=0; i<nSubmenu; i++){
996 struct Submenu *p = &aSubmenu[i];
997 style_derive_classname(p->zLabel, zClass, sizeof zClass);
998 /* switching away from the %h formatting below might be dangerous
999 ** because some places use %s to compose zLabel and zLink;
1000 ** e.g. /rptview page and the submenuCmd() function.
1001 ** "sml" stands for submenu link.
1002 */
1003 if( p->zLink==0 ){
1004 @ <span class="label sml-%s(zClass)">%h(p->zLabel)</span>
1005 }else{
1006 @ <a class="label sml-%s(zClass)" href="%h(p->zLink)">%h(p->zLabel)</a>
1007
--- src/th_main.c
+++ src/th_main.c
@@ -1587,10 +1587,42 @@
15871587
}else{
15881588
Th_SetResult(interp, "repository unavailable", -1);
15891589
return TH_ERROR;
15901590
}
15911591
}
1592
+
1593
+/*
1594
+** TH1 command: submenu link LABEL URL
1595
+**
1596
+** Add a hyperlink to the submenu.
1597
+*/
1598
+static int submenuCmd(
1599
+ Th_Interp *interp,
1600
+ void *p,
1601
+ int argc,
1602
+ const char **argv,
1603
+ int *argl
1604
+){
1605
+ if( argc!=4 || memcmp(argv[1],"link",5)!=0 ){
1606
+ return Th_WrongNumArgs(interp, "submenu link LABEL URL");
1607
+ }
1608
+ if( argl[2]==0 ){
1609
+ Th_SetResult(interp, "link's LABEL is empty", -1);
1610
+ return TH_ERROR;
1611
+ }
1612
+ if( argl[3]==0 ){
1613
+ Th_SetResult(interp, "link's URL is empty", -1);
1614
+ return TH_ERROR;
1615
+ }
1616
+ /*
1617
+ ** Label and URL are unescaped because it is expected that
1618
+ ** style_finish_page() provides propper escaping via %h format.
1619
+ */
1620
+ style_submenu_element( fossil_strdup(argv[2]), "%s", argv[3] );
1621
+ Th_SetResult(interp, 0, 0);
1622
+ return TH_OK;
1623
+}
15921624
15931625
/*
15941626
** TH1 command: builtin_request_js NAME
15951627
**
15961628
** Request that the built-in javascript file called NAME be added to the
@@ -2330,10 +2362,11 @@
23302362
{"setParameter", setParameterCmd, 0},
23312363
{"setting", settingCmd, 0},
23322364
{"styleFooter", styleFooterCmd, 0},
23332365
{"styleHeader", styleHeaderCmd, 0},
23342366
{"styleScript", styleScriptCmd, 0},
2367
+ {"submenu", submenuCmd, 0},
23352368
{"tclReady", tclReadyCmd, 0},
23362369
{"trace", traceCmd, 0},
23372370
{"stime", stimeCmd, 0},
23382371
{"unversioned", unversionedCmd, 0},
23392372
{"utime", utimeCmd, 0},
23402373
--- src/th_main.c
+++ src/th_main.c
@@ -1587,10 +1587,42 @@
1587 }else{
1588 Th_SetResult(interp, "repository unavailable", -1);
1589 return TH_ERROR;
1590 }
1591 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1592
1593 /*
1594 ** TH1 command: builtin_request_js NAME
1595 **
1596 ** Request that the built-in javascript file called NAME be added to the
@@ -2330,10 +2362,11 @@
2330 {"setParameter", setParameterCmd, 0},
2331 {"setting", settingCmd, 0},
2332 {"styleFooter", styleFooterCmd, 0},
2333 {"styleHeader", styleHeaderCmd, 0},
2334 {"styleScript", styleScriptCmd, 0},
 
2335 {"tclReady", tclReadyCmd, 0},
2336 {"trace", traceCmd, 0},
2337 {"stime", stimeCmd, 0},
2338 {"unversioned", unversionedCmd, 0},
2339 {"utime", utimeCmd, 0},
2340
--- src/th_main.c
+++ src/th_main.c
@@ -1587,10 +1587,42 @@
1587 }else{
1588 Th_SetResult(interp, "repository unavailable", -1);
1589 return TH_ERROR;
1590 }
1591 }
1592
1593 /*
1594 ** TH1 command: submenu link LABEL URL
1595 **
1596 ** Add a hyperlink to the submenu.
1597 */
1598 static int submenuCmd(
1599 Th_Interp *interp,
1600 void *p,
1601 int argc,
1602 const char **argv,
1603 int *argl
1604 ){
1605 if( argc!=4 || memcmp(argv[1],"link",5)!=0 ){
1606 return Th_WrongNumArgs(interp, "submenu link LABEL URL");
1607 }
1608 if( argl[2]==0 ){
1609 Th_SetResult(interp, "link's LABEL is empty", -1);
1610 return TH_ERROR;
1611 }
1612 if( argl[3]==0 ){
1613 Th_SetResult(interp, "link's URL is empty", -1);
1614 return TH_ERROR;
1615 }
1616 /*
1617 ** Label and URL are unescaped because it is expected that
1618 ** style_finish_page() provides propper escaping via %h format.
1619 */
1620 style_submenu_element( fossil_strdup(argv[2]), "%s", argv[3] );
1621 Th_SetResult(interp, 0, 0);
1622 return TH_OK;
1623 }
1624
1625 /*
1626 ** TH1 command: builtin_request_js NAME
1627 **
1628 ** Request that the built-in javascript file called NAME be added to the
@@ -2330,10 +2362,11 @@
2362 {"setParameter", setParameterCmd, 0},
2363 {"setting", settingCmd, 0},
2364 {"styleFooter", styleFooterCmd, 0},
2365 {"styleHeader", styleHeaderCmd, 0},
2366 {"styleScript", styleScriptCmd, 0},
2367 {"submenu", submenuCmd, 0},
2368 {"tclReady", tclReadyCmd, 0},
2369 {"trace", traceCmd, 0},
2370 {"stime", stimeCmd, 0},
2371 {"unversioned", unversionedCmd, 0},
2372 {"utime", utimeCmd, 0},
2373
+8
--- www/th1.md
+++ www/th1.md
@@ -213,10 +213,11 @@
213213
* [setting](#setting)
214214
* [stime](#stime)
215215
* [styleHeader](#styleHeader)
216216
* [styleFooter](#styleFooter)
217217
* [styleScript](#styleScript)
218
+ * [submenu](#submenu)
218219
* [tclEval](#tclEval)
219220
* [tclExpr](#tclExpr)
220221
* [tclInvoke](#tclInvoke)
221222
* [tclIsSafe](#tclIsSafe)
222223
* [tclMakeSafe](#tclMakeSafe)
@@ -734,10 +735,17 @@
734735
735736
* styleScript
736737
737738
Render the configured JavaScript for the selected skin.
738739
740
+<a id="submenu"></a>TH1 submenu Command
741
+-----------------------------------------
742
+
743
+ * submenu link LABEL URL
744
+
745
+Add hyperlink to the submenu of the current page.
746
+
739747
<a id="tclEval"></a>TH1 tclEval Command
740748
-----------------------------------------
741749
742750
**This command requires the Tcl integration feature.**
743751
744752
--- www/th1.md
+++ www/th1.md
@@ -213,10 +213,11 @@
213 * [setting](#setting)
214 * [stime](#stime)
215 * [styleHeader](#styleHeader)
216 * [styleFooter](#styleFooter)
217 * [styleScript](#styleScript)
 
218 * [tclEval](#tclEval)
219 * [tclExpr](#tclExpr)
220 * [tclInvoke](#tclInvoke)
221 * [tclIsSafe](#tclIsSafe)
222 * [tclMakeSafe](#tclMakeSafe)
@@ -734,10 +735,17 @@
734
735 * styleScript
736
737 Render the configured JavaScript for the selected skin.
738
 
 
 
 
 
 
 
739 <a id="tclEval"></a>TH1 tclEval Command
740 -----------------------------------------
741
742 **This command requires the Tcl integration feature.**
743
744
--- www/th1.md
+++ www/th1.md
@@ -213,10 +213,11 @@
213 * [setting](#setting)
214 * [stime](#stime)
215 * [styleHeader](#styleHeader)
216 * [styleFooter](#styleFooter)
217 * [styleScript](#styleScript)
218 * [submenu](#submenu)
219 * [tclEval](#tclEval)
220 * [tclExpr](#tclExpr)
221 * [tclInvoke](#tclInvoke)
222 * [tclIsSafe](#tclIsSafe)
223 * [tclMakeSafe](#tclMakeSafe)
@@ -734,10 +735,17 @@
735
736 * styleScript
737
738 Render the configured JavaScript for the selected skin.
739
740 <a id="submenu"></a>TH1 submenu Command
741 -----------------------------------------
742
743 * submenu link LABEL URL
744
745 Add hyperlink to the submenu of the current page.
746
747 <a id="tclEval"></a>TH1 tclEval Command
748 -----------------------------------------
749
750 **This command requires the Tcl integration feature.**
751
752

Keyboard Shortcuts

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