Fossil SCM
Add the 'defHeader' command to TH1.
Commit
c1cb6886cd15c3b194520a20dd9049f5c618c7fefd029d9308941343b001b468
Parent
1fc2df905e74e1e…
4 files changed
+8
-1
+20
+16
-5
+8
+8
-1
| --- src/style.c | ||
| +++ src/style.c | ||
| @@ -552,11 +552,11 @@ | ||
| 552 | 552 | /* |
| 553 | 553 | ** Default HTML page header text through <body>. If the repository-specific |
| 554 | 554 | ** header template lacks a <body> tag, then all of the following is |
| 555 | 555 | ** prepended. |
| 556 | 556 | */ |
| 557 | -static char zDfltHeader[] = | |
| 557 | +static const char zDfltHeader[] = | |
| 558 | 558 | @ <html> |
| 559 | 559 | @ <head> |
| 560 | 560 | @ <base href="$baseurl/$current_page" /> |
| 561 | 561 | @ <meta http-equiv="Content-Security-Policy" content="$default_csp" /> |
| 562 | 562 | @ <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| @@ -565,10 +565,17 @@ | ||
| 565 | 565 | @ href="$home/timeline.rss" /> |
| 566 | 566 | @ <link rel="stylesheet" href="$stylesheet_url" type="text/css" /> |
| 567 | 567 | @ </head> |
| 568 | 568 | @ <body> |
| 569 | 569 | ; |
| 570 | + | |
| 571 | +/* | |
| 572 | +** Returns the default page header. | |
| 573 | +*/ | |
| 574 | +const char *get_default_header(){ | |
| 575 | + return zDfltHeader; | |
| 576 | +} | |
| 570 | 577 | |
| 571 | 578 | /* |
| 572 | 579 | ** Initialize all the default TH1 variables |
| 573 | 580 | */ |
| 574 | 581 | static void style_init_th1_vars(const char *zTitle){ |
| 575 | 582 |
| --- 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 |
+20
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -1345,10 +1345,29 @@ | ||
| 1345 | 1345 | } |
| 1346 | 1346 | rc = Th_Render(argv[1]); |
| 1347 | 1347 | Th_SetResult(interp, 0, 0); |
| 1348 | 1348 | return rc; |
| 1349 | 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 | +} | |
| 1350 | 1369 | |
| 1351 | 1370 | /* |
| 1352 | 1371 | ** TH1 command: styleHeader TITLE |
| 1353 | 1372 | ** |
| 1354 | 1373 | ** Render the configured style header for the selected skin. |
| @@ -2112,10 +2131,11 @@ | ||
| 2112 | 2131 | {"checkout", checkoutCmd, 0}, |
| 2113 | 2132 | {"combobox", comboboxCmd, 0}, |
| 2114 | 2133 | {"copybtn", copybtnCmd, 0}, |
| 2115 | 2134 | {"date", dateCmd, 0}, |
| 2116 | 2135 | {"decorate", wikiCmd, (void*)&aFlags[2]}, |
| 2136 | + {"defHeader", defHeaderCmd, 0}, | |
| 2117 | 2137 | {"dir", dirCmd, 0}, |
| 2118 | 2138 | {"enable_output", enableOutputCmd, 0}, |
| 2119 | 2139 | {"encode64", encode64Cmd, 0}, |
| 2120 | 2140 | {"getParameter", getParameterCmd, 0}, |
| 2121 | 2141 | {"glob_match", globMatchCmd, 0}, |
| 2122 | 2142 |
| --- 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 @@ | ||
| 771 | 771 | ------------------- END TRACE LOG -------------------}} |
| 772 | 772 | } |
| 773 | 773 | |
| 774 | 774 | ############################################################################### |
| 775 | 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 | + | |
| 776 | 787 | fossil test-th-eval "styleHeader {Page Title Here}" |
| 777 | 788 | test th1-header-1 {$RESULT eq {TH_ERROR: repository unavailable}} |
| 778 | 789 | |
| 779 | 790 | ############################################################################### |
| 780 | 791 | |
| @@ -1036,15 +1047,15 @@ | ||
| 1036 | 1047 | # |
| 1037 | 1048 | fossil test-th-eval "info commands" |
| 1038 | 1049 | set sorted_result [lsort $RESULT] |
| 1039 | 1050 | protOut "Sorted: $sorted_result" |
| 1040 | 1051 | 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 \ | |
| 1046 | 1057 | repository return searchable set setParameter setting stime string \ |
| 1047 | 1058 | styleFooter styleHeader styleScript tclReady trace unset unversioned \ |
| 1048 | 1059 | uplevel upvar utime verifyCsrf verifyLogin wiki} |
| 1049 | 1060 | set tcl_commands {tclEval tclExpr tclInvoke tclIsSafe tclMakeSafe} |
| 1050 | 1061 | if {$th1Tcl} { |
| 1051 | 1062 |
| --- 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 @@ | ||
| 173 | 173 | * checkout |
| 174 | 174 | * combobox |
| 175 | 175 | * copybtn |
| 176 | 176 | * date |
| 177 | 177 | * decorate |
| 178 | + * defHeader | |
| 178 | 179 | * dir |
| 179 | 180 | * enable\_output |
| 180 | 181 | * encode64 |
| 181 | 182 | * getParameter |
| 182 | 183 | * glob\_match |
| @@ -316,10 +317,17 @@ | ||
| 316 | 317 | |
| 317 | 318 | * decorate STRING |
| 318 | 319 | |
| 319 | 320 | Renders STRING as wiki content; however, only links are handled. No |
| 320 | 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. | |
| 321 | 329 | |
| 322 | 330 | <a name="dir"></a>TH1 dir Command |
| 323 | 331 | --------------------------------- |
| 324 | 332 | |
| 325 | 333 | * dir CHECKIN ?GLOB? ?DETAILS? |
| 326 | 334 |
| --- 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 |