Fossil SCM

Add the 'defHeader' command to TH1.

mistachkin 2020-09-10 00:54 trunk
Commit c1cb6886cd15c3b194520a20dd9049f5c618c7fefd029d9308941343b001b468
+8 -1
--- src/style.c
+++ src/style.c
@@ -552,11 +552,11 @@
552552
/*
553553
** Default HTML page header text through <body>. If the repository-specific
554554
** header template lacks a <body> tag, then all of the following is
555555
** prepended.
556556
*/
557
-static char zDfltHeader[] =
557
+static const char zDfltHeader[] =
558558
@ <html>
559559
@ <head>
560560
@ <base href="$baseurl/$current_page" />
561561
@ <meta http-equiv="Content-Security-Policy" content="$default_csp" />
562562
@ <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -565,10 +565,17 @@
565565
@ href="$home/timeline.rss" />
566566
@ <link rel="stylesheet" href="$stylesheet_url" type="text/css" />
567567
@ </head>
568568
@ <body>
569569
;
570
+
571
+/*
572
+** Returns the default page header.
573
+*/
574
+const char *get_default_header(){
575
+ return zDfltHeader;
576
+}
570577
571578
/*
572579
** Initialize all the default TH1 variables
573580
*/
574581
static void style_init_th1_vars(const char *zTitle){
575582
--- src/style.c
+++ src/style.c
@@ -552,11 +552,11 @@
552 /*
553 ** Default HTML page header text through <body>. If the repository-specific
554 ** header template lacks a <body> tag, then all of the following is
555 ** prepended.
556 */
557 static char zDfltHeader[] =
558 @ <html>
559 @ <head>
560 @ <base href="$baseurl/$current_page" />
561 @ <meta http-equiv="Content-Security-Policy" content="$default_csp" />
562 @ <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -565,10 +565,17 @@
565 @ href="$home/timeline.rss" />
566 @ <link rel="stylesheet" href="$stylesheet_url" type="text/css" />
567 @ </head>
568 @ <body>
569 ;
 
 
 
 
 
 
 
570
571 /*
572 ** Initialize all the default TH1 variables
573 */
574 static void style_init_th1_vars(const char *zTitle){
575
--- src/style.c
+++ src/style.c
@@ -552,11 +552,11 @@
552 /*
553 ** Default HTML page header text through <body>. If the repository-specific
554 ** header template lacks a <body> tag, then all of the following is
555 ** prepended.
556 */
557 static const char zDfltHeader[] =
558 @ <html>
559 @ <head>
560 @ <base href="$baseurl/$current_page" />
561 @ <meta http-equiv="Content-Security-Policy" content="$default_csp" />
562 @ <meta name="viewport" content="width=device-width, initial-scale=1.0">
@@ -565,10 +565,17 @@
565 @ href="$home/timeline.rss" />
566 @ <link rel="stylesheet" href="$stylesheet_url" type="text/css" />
567 @ </head>
568 @ <body>
569 ;
570
571 /*
572 ** Returns the default page header.
573 */
574 const char *get_default_header(){
575 return zDfltHeader;
576 }
577
578 /*
579 ** Initialize all the default TH1 variables
580 */
581 static void style_init_th1_vars(const char *zTitle){
582
--- src/th_main.c
+++ src/th_main.c
@@ -1345,10 +1345,29 @@
13451345
}
13461346
rc = Th_Render(argv[1]);
13471347
Th_SetResult(interp, 0, 0);
13481348
return rc;
13491349
}
1350
+
1351
+/*
1352
+** TH1 command: defHeader TITLE
1353
+**
1354
+** Returns the default page header.
1355
+*/
1356
+static int defHeaderCmd(
1357
+ Th_Interp *interp,
1358
+ void *p,
1359
+ int argc,
1360
+ const char **argv,
1361
+ int *argl
1362
+){
1363
+ if( argc!=1 ){
1364
+ return Th_WrongNumArgs(interp, "defHeader");
1365
+ }
1366
+ Th_SetResult(interp, get_default_header(), -1);
1367
+ return TH_OK;
1368
+}
13501369
13511370
/*
13521371
** TH1 command: styleHeader TITLE
13531372
**
13541373
** Render the configured style header for the selected skin.
@@ -2112,10 +2131,11 @@
21122131
{"checkout", checkoutCmd, 0},
21132132
{"combobox", comboboxCmd, 0},
21142133
{"copybtn", copybtnCmd, 0},
21152134
{"date", dateCmd, 0},
21162135
{"decorate", wikiCmd, (void*)&aFlags[2]},
2136
+ {"defHeader", defHeaderCmd, 0},
21172137
{"dir", dirCmd, 0},
21182138
{"enable_output", enableOutputCmd, 0},
21192139
{"encode64", encode64Cmd, 0},
21202140
{"getParameter", getParameterCmd, 0},
21212141
{"glob_match", globMatchCmd, 0},
21222142
--- src/th_main.c
+++ src/th_main.c
@@ -1345,10 +1345,29 @@
1345 }
1346 rc = Th_Render(argv[1]);
1347 Th_SetResult(interp, 0, 0);
1348 return rc;
1349 }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1350
1351 /*
1352 ** TH1 command: styleHeader TITLE
1353 **
1354 ** Render the configured style header for the selected skin.
@@ -2112,10 +2131,11 @@
2112 {"checkout", checkoutCmd, 0},
2113 {"combobox", comboboxCmd, 0},
2114 {"copybtn", copybtnCmd, 0},
2115 {"date", dateCmd, 0},
2116 {"decorate", wikiCmd, (void*)&aFlags[2]},
 
2117 {"dir", dirCmd, 0},
2118 {"enable_output", enableOutputCmd, 0},
2119 {"encode64", encode64Cmd, 0},
2120 {"getParameter", getParameterCmd, 0},
2121 {"glob_match", globMatchCmd, 0},
2122
--- src/th_main.c
+++ src/th_main.c
@@ -1345,10 +1345,29 @@
1345 }
1346 rc = Th_Render(argv[1]);
1347 Th_SetResult(interp, 0, 0);
1348 return rc;
1349 }
1350
1351 /*
1352 ** TH1 command: defHeader TITLE
1353 **
1354 ** Returns the default page header.
1355 */
1356 static int defHeaderCmd(
1357 Th_Interp *interp,
1358 void *p,
1359 int argc,
1360 const char **argv,
1361 int *argl
1362 ){
1363 if( argc!=1 ){
1364 return Th_WrongNumArgs(interp, "defHeader");
1365 }
1366 Th_SetResult(interp, get_default_header(), -1);
1367 return TH_OK;
1368 }
1369
1370 /*
1371 ** TH1 command: styleHeader TITLE
1372 **
1373 ** Render the configured style header for the selected skin.
@@ -2112,10 +2131,11 @@
2131 {"checkout", checkoutCmd, 0},
2132 {"combobox", comboboxCmd, 0},
2133 {"copybtn", copybtnCmd, 0},
2134 {"date", dateCmd, 0},
2135 {"decorate", wikiCmd, (void*)&aFlags[2]},
2136 {"defHeader", defHeaderCmd, 0},
2137 {"dir", dirCmd, 0},
2138 {"enable_output", enableOutputCmd, 0},
2139 {"encode64", encode64Cmd, 0},
2140 {"getParameter", getParameterCmd, 0},
2141 {"glob_match", globMatchCmd, 0},
2142
+16 -5
--- test/th1.test
+++ test/th1.test
@@ -771,10 +771,21 @@
771771
------------------- END TRACE LOG -------------------}}
772772
}
773773
774774
###############################################################################
775775
776
+fossil test-th-eval "defHeader {Page Title Here}"
777
+test th1-defHeader-1 {$RESULT eq \
778
+ {TH_ERROR: wrong # args: should be "defHeader"}}
779
+
780
+###############################################################################
781
+
782
+fossil test-th-eval "defHeader"
783
+test th1-defHeader-2 {[string match *<body> [normalize_result]]}
784
+
785
+###############################################################################
786
+
776787
fossil test-th-eval "styleHeader {Page Title Here}"
777788
test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}}
778789
779790
###############################################################################
780791
@@ -1036,15 +1047,15 @@
10361047
#
10371048
fossil test-th-eval "info commands"
10381049
set sorted_result [lsort $RESULT]
10391050
protOut "Sorted: $sorted_result"
10401051
set base_commands {anoncap anycap array artifact break breakpoint catch\
1041
- cgiHeaderLine checkout combobox continue copybtn date decorate dir \
1042
- enable_output encode64 error expr for getParameter glob_match \
1043
- globalState hascap hasfeature html htmlize http httpize if info \
1044
- insertCsrf lindex linecount list llength lsearch markdown nonce proc \
1045
- puts query randhex redirect regexp reinitialize rename render \
1052
+ cgiHeaderLine checkout combobox continue copybtn date decorate \
1053
+ defHeader dir enable_output encode64 error expr for getParameter \
1054
+ glob_match globalState hascap hasfeature html htmlize http httpize if \
1055
+ info insertCsrf lindex linecount list llength lsearch markdown nonce \
1056
+ proc puts query randhex redirect regexp reinitialize rename render \
10461057
repository return searchable set setParameter setting stime string \
10471058
styleFooter styleHeader styleScript tclReady trace unset unversioned \
10481059
uplevel upvar utime verifyCsrf verifyLogin wiki}
10491060
set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
10501061
if {$th1Tcl} {
10511062
--- test/th1.test
+++ test/th1.test
@@ -771,10 +771,21 @@
771 ------------------- END TRACE LOG -------------------}}
772 }
773
774 ###############################################################################
775
 
 
 
 
 
 
 
 
 
 
 
776 fossil test-th-eval "styleHeader {Page Title Here}"
777 test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}}
778
779 ###############################################################################
780
@@ -1036,15 +1047,15 @@
1036 #
1037 fossil test-th-eval "info commands"
1038 set sorted_result [lsort $RESULT]
1039 protOut "Sorted: $sorted_result"
1040 set base_commands {anoncap anycap array artifact break breakpoint catch\
1041 cgiHeaderLine checkout combobox continue copybtn date decorate dir \
1042 enable_output encode64 error expr for getParameter glob_match \
1043 globalState hascap hasfeature html htmlize http httpize if info \
1044 insertCsrf lindex linecount list llength lsearch markdown nonce proc \
1045 puts query randhex redirect regexp reinitialize rename render \
1046 repository return searchable set setParameter setting stime string \
1047 styleFooter styleHeader styleScript tclReady trace unset unversioned \
1048 uplevel upvar utime verifyCsrf verifyLogin wiki}
1049 set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
1050 if {$th1Tcl} {
1051
--- test/th1.test
+++ test/th1.test
@@ -771,10 +771,21 @@
771 ------------------- END TRACE LOG -------------------}}
772 }
773
774 ###############################################################################
775
776 fossil test-th-eval "defHeader {Page Title Here}"
777 test th1-defHeader-1 {$RESULT eq \
778 {TH_ERROR: wrong # args: should be "defHeader"}}
779
780 ###############################################################################
781
782 fossil test-th-eval "defHeader"
783 test th1-defHeader-2 {[string match *<body> [normalize_result]]}
784
785 ###############################################################################
786
787 fossil test-th-eval "styleHeader {Page Title Here}"
788 test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}}
789
790 ###############################################################################
791
@@ -1036,15 +1047,15 @@
1047 #
1048 fossil test-th-eval "info commands"
1049 set sorted_result [lsort $RESULT]
1050 protOut "Sorted: $sorted_result"
1051 set base_commands {anoncap anycap array artifact break breakpoint catch\
1052 cgiHeaderLine checkout combobox continue copybtn date decorate \
1053 defHeader dir enable_output encode64 error expr for getParameter \
1054 glob_match globalState hascap hasfeature html htmlize http httpize if \
1055 info insertCsrf lindex linecount list llength lsearch markdown nonce \
1056 proc puts query randhex redirect regexp reinitialize rename render \
1057 repository return searchable set setParameter setting stime string \
1058 styleFooter styleHeader styleScript tclReady trace unset unversioned \
1059 uplevel upvar utime verifyCsrf verifyLogin wiki}
1060 set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe}
1061 if {$th1Tcl} {
1062
+8
--- www/th1.md
+++ www/th1.md
@@ -173,10 +173,11 @@
173173
* checkout
174174
* combobox
175175
* copybtn
176176
* date
177177
* decorate
178
+ * defHeader
178179
* dir
179180
* enable\_output
180181
* encode64
181182
* getParameter
182183
* glob\_match
@@ -316,10 +317,17 @@
316317
317318
* decorate STRING
318319
319320
Renders STRING as wiki content; however, only links are handled. No
320321
other markup is processed.
322
+
323
+<a name="defHeader"></a>TH1 defHeader Command
324
+---------------------------------------------
325
+
326
+ * defHeader
327
+
328
+Returns the default page header.
321329
322330
<a name="dir"></a>TH1 dir Command
323331
---------------------------------
324332
325333
* dir CHECKIN ?GLOB? ?DETAILS?
326334
--- www/th1.md
+++ www/th1.md
@@ -173,10 +173,11 @@
173 * checkout
174 * combobox
175 * copybtn
176 * date
177 * decorate
 
178 * dir
179 * enable\_output
180 * encode64
181 * getParameter
182 * glob\_match
@@ -316,10 +317,17 @@
316
317 * decorate STRING
318
319 Renders STRING as wiki content; however, only links are handled. No
320 other markup is processed.
 
 
 
 
 
 
 
321
322 <a name="dir"></a>TH1 dir Command
323 ---------------------------------
324
325 * dir CHECKIN ?GLOB? ?DETAILS?
326
--- www/th1.md
+++ www/th1.md
@@ -173,10 +173,11 @@
173 * checkout
174 * combobox
175 * copybtn
176 * date
177 * decorate
178 * defHeader
179 * dir
180 * enable\_output
181 * encode64
182 * getParameter
183 * glob\_match
@@ -316,10 +317,17 @@
317
318 * decorate STRING
319
320 Renders STRING as wiki content; however, only links are handled. No
321 other markup is processed.
322
323 <a name="defHeader"></a>TH1 defHeader Command
324 ---------------------------------------------
325
326 * defHeader
327
328 Returns the default page header.
329
330 <a name="dir"></a>TH1 dir Command
331 ---------------------------------
332
333 * dir CHECKIN ?GLOB? ?DETAILS?
334

Keyboard Shortcuts

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