Fossil SCM
Improved TH1 script for header generation in the etienne1 skin.
Commit
924315bdfc2e3380873d8fec118fb07bcb263afe
Parent
de6f310d9cdbb2e…
2 files changed
+29
-60
+33
-7
+29
-60
| --- skins/etienne1/header.txt | ||
| +++ skins/etienne1/header.txt | ||
| @@ -19,70 +19,39 @@ | ||
| 19 | 19 | } |
| 20 | 20 | </th1></div> |
| 21 | 21 | </div> |
| 22 | 22 | |
| 23 | 23 | <div class="mainmenu"> |
| 24 | - <th1> | |
| 25 | -proc isin {val lst} { | |
| 26 | - set tot [llength $lst] | |
| 27 | - for {set i 0} {$i < $tot} {set i [expr {$i + 1}]} { | |
| 28 | - set cur [lindex $lst $i] | |
| 29 | - if {$val eq $cur} { | |
| 30 | - return 0 | |
| 31 | - } | |
| 32 | - } | |
| 33 | - return 1 | |
| 34 | -} | |
| 35 | - | |
| 36 | -proc menulink {pagename url name} { | |
| 37 | - upvar current_page current | |
| 38 | - upvar home home | |
| 39 | - | |
| 40 | - set compsetup [string compare [string range $current 0 4] setup] | |
| 41 | - set comphome [string compare [string range $current 0 3] home] | |
| 42 | - set comptag [string compare $current tagtimeline] | |
| 43 | - set compbr [string compare $current brtimeline] | |
| 44 | - set compdir [isin $current "artifact ci finfo hexdump"] | |
| 45 | - set comptl [string compare $current info] | |
| 46 | - set comptkt [isin $current "modreq rptedit tktnew rptsql rptview"] | |
| 47 | - | |
| 48 | - html "<a href='$home$url'" | |
| 49 | - | |
| 50 | - if {$pagename eq $current | |
| 51 | - || ($pagename eq "home" && $comphome == 0) | |
| 52 | - || ($pagename eq "setup" && $compsetup == 0) | |
| 53 | - || ($pagename eq "taglist" && $comptag == 0) | |
| 54 | - || ($pagename eq "dir" && $compdir == 0) | |
| 55 | - || ($pagename eq "timeline" && $comptl == 0) | |
| 56 | - || ($pagename eq "ticket" && $comptkt == 0) | |
| 57 | - || ($pagename eq "brlist" && $compbr == 0) | |
| 58 | - } { | |
| 59 | - html " class='active' " | |
| 60 | - } | |
| 61 | - | |
| 62 | - html ">$name</a>" | |
| 63 | -} | |
| 64 | - | |
| 65 | -menulink "home" $index_page Home | |
| 66 | - | |
| 67 | -if {[anycap jor]} { | |
| 68 | - menulink "timeline" "/timeline" Timeline | |
| 69 | -} | |
| 70 | -if {[anoncap oh]} { | |
| 71 | - menulink "dir" "/dir?ci=tip" Files | |
| 72 | -} | |
| 73 | -if {[anoncap o]} { | |
| 74 | - menulink "brlist" "/brlist" Branches | |
| 75 | - menulink "taglist" "/taglist" Tags | |
| 76 | -} | |
| 77 | -if {[anoncap r]} { | |
| 78 | - menulink "ticket" "/ticket" Tickets | |
| 79 | -} | |
| 80 | -if {[anoncap j]} { | |
| 81 | - menulink "wiki" "/wiki" Wiki | |
| 24 | +<th1> | |
| 25 | +proc menulink {re url name} { | |
| 26 | + upvar current_page current | |
| 27 | + upvar home home | |
| 28 | + if {($re eq "" && $url eq "/$current") | |
| 29 | + || ($re ne "" && [regexp $re /$current])} { | |
| 30 | + html "<a href='$home$url' class='active'>$name</a>\n" | |
| 31 | + } else { | |
| 32 | + html "<a href='$home$url'>$name</a>\n" | |
| 33 | + } | |
| 34 | +} | |
| 35 | +menulink "" $index_page Home | |
| 36 | +if {[anycap jor]} { | |
| 37 | + menulink "" "/timeline" Timeline | |
| 38 | +} | |
| 39 | +if {[hascap oh]} { | |
| 40 | + menulink "^/dir.*" "/dir?ci=tip" Files | |
| 41 | +} | |
| 42 | +if {[hascap o]} { | |
| 43 | + menulink "" "/brlist" Branches | |
| 44 | + menulink "" "/taglist" Tags | |
| 45 | +} | |
| 46 | +if {[hascap r]} { | |
| 47 | + menulink "" "/ticket" Tickets | |
| 48 | +} | |
| 49 | +if {[hascap j]} { | |
| 50 | + menulink "" "/wiki" Wiki | |
| 82 | 51 | } |
| 83 | 52 | if {[hascap s]} { |
| 84 | - menulink "setup" "/setup" Admin | |
| 53 | + menulink "" "/setup" Admin | |
| 85 | 54 | } elseif {[hascap a]} { |
| 86 | - menulink "setup_ulist" "/setup_ulist" Users | |
| 55 | + menulink "" "/setup_ulist" Users | |
| 87 | 56 | } |
| 88 | 57 | </th1></div> |
| 89 | 58 |
| --- skins/etienne1/header.txt | |
| +++ skins/etienne1/header.txt | |
| @@ -19,70 +19,39 @@ | |
| 19 | } |
| 20 | </th1></div> |
| 21 | </div> |
| 22 | |
| 23 | <div class="mainmenu"> |
| 24 | <th1> |
| 25 | proc isin {val lst} { |
| 26 | set tot [llength $lst] |
| 27 | for {set i 0} {$i < $tot} {set i [expr {$i + 1}]} { |
| 28 | set cur [lindex $lst $i] |
| 29 | if {$val eq $cur} { |
| 30 | return 0 |
| 31 | } |
| 32 | } |
| 33 | return 1 |
| 34 | } |
| 35 | |
| 36 | proc menulink {pagename url name} { |
| 37 | upvar current_page current |
| 38 | upvar home home |
| 39 | |
| 40 | set compsetup [string compare [string range $current 0 4] setup] |
| 41 | set comphome [string compare [string range $current 0 3] home] |
| 42 | set comptag [string compare $current tagtimeline] |
| 43 | set compbr [string compare $current brtimeline] |
| 44 | set compdir [isin $current "artifact ci finfo hexdump"] |
| 45 | set comptl [string compare $current info] |
| 46 | set comptkt [isin $current "modreq rptedit tktnew rptsql rptview"] |
| 47 | |
| 48 | html "<a href='$home$url'" |
| 49 | |
| 50 | if {$pagename eq $current |
| 51 | || ($pagename eq "home" && $comphome == 0) |
| 52 | || ($pagename eq "setup" && $compsetup == 0) |
| 53 | || ($pagename eq "taglist" && $comptag == 0) |
| 54 | || ($pagename eq "dir" && $compdir == 0) |
| 55 | || ($pagename eq "timeline" && $comptl == 0) |
| 56 | || ($pagename eq "ticket" && $comptkt == 0) |
| 57 | || ($pagename eq "brlist" && $compbr == 0) |
| 58 | } { |
| 59 | html " class='active' " |
| 60 | } |
| 61 | |
| 62 | html ">$name</a>" |
| 63 | } |
| 64 | |
| 65 | menulink "home" $index_page Home |
| 66 | |
| 67 | if {[anycap jor]} { |
| 68 | menulink "timeline" "/timeline" Timeline |
| 69 | } |
| 70 | if {[anoncap oh]} { |
| 71 | menulink "dir" "/dir?ci=tip" Files |
| 72 | } |
| 73 | if {[anoncap o]} { |
| 74 | menulink "brlist" "/brlist" Branches |
| 75 | menulink "taglist" "/taglist" Tags |
| 76 | } |
| 77 | if {[anoncap r]} { |
| 78 | menulink "ticket" "/ticket" Tickets |
| 79 | } |
| 80 | if {[anoncap j]} { |
| 81 | menulink "wiki" "/wiki" Wiki |
| 82 | } |
| 83 | if {[hascap s]} { |
| 84 | menulink "setup" "/setup" Admin |
| 85 | } elseif {[hascap a]} { |
| 86 | menulink "setup_ulist" "/setup_ulist" Users |
| 87 | } |
| 88 | </th1></div> |
| 89 |
| --- skins/etienne1/header.txt | |
| +++ skins/etienne1/header.txt | |
| @@ -19,70 +19,39 @@ | |
| 19 | } |
| 20 | </th1></div> |
| 21 | </div> |
| 22 | |
| 23 | <div class="mainmenu"> |
| 24 | <th1> |
| 25 | proc menulink {re url name} { |
| 26 | upvar current_page current |
| 27 | upvar home home |
| 28 | if {($re eq "" && $url eq "/$current") |
| 29 | || ($re ne "" && [regexp $re /$current])} { |
| 30 | html "<a href='$home$url' class='active'>$name</a>\n" |
| 31 | } else { |
| 32 | html "<a href='$home$url'>$name</a>\n" |
| 33 | } |
| 34 | } |
| 35 | menulink "" $index_page Home |
| 36 | if {[anycap jor]} { |
| 37 | menulink "" "/timeline" Timeline |
| 38 | } |
| 39 | if {[hascap oh]} { |
| 40 | menulink "^/dir.*" "/dir?ci=tip" Files |
| 41 | } |
| 42 | if {[hascap o]} { |
| 43 | menulink "" "/brlist" Branches |
| 44 | menulink "" "/taglist" Tags |
| 45 | } |
| 46 | if {[hascap r]} { |
| 47 | menulink "" "/ticket" Tickets |
| 48 | } |
| 49 | if {[hascap j]} { |
| 50 | menulink "" "/wiki" Wiki |
| 51 | } |
| 52 | if {[hascap s]} { |
| 53 | menulink "" "/setup" Admin |
| 54 | } elseif {[hascap a]} { |
| 55 | menulink "" "/setup_ulist" Users |
| 56 | } |
| 57 | </th1></div> |
| 58 |
+33
-7
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -1958,21 +1958,35 @@ | ||
| 1958 | 1958 | return rc; |
| 1959 | 1959 | } |
| 1960 | 1960 | |
| 1961 | 1961 | /* |
| 1962 | 1962 | ** COMMAND: test-th-render |
| 1963 | +** | |
| 1964 | +** Usage: %fossil test-th-render FILE | |
| 1965 | +** | |
| 1966 | +** Read the content of the file named "FILE" as if it were a header or | |
| 1967 | +** footer or ticket rendering script, evaluate it, and show the results | |
| 1968 | +** on standard output. | |
| 1969 | +** | |
| 1970 | +** Options: | |
| 1971 | +** | |
| 1972 | +** --cgi Include a CGI response header in the output | |
| 1973 | +** --http Include an HTTP response header in the output | |
| 1974 | +** --open-config Open the configuration database | |
| 1963 | 1975 | */ |
| 1964 | 1976 | void test_th_render(void){ |
| 1965 | - int forceCgi, fullHttpReply; | |
| 1977 | + int forceCgi = 0, fullHttpReply = 0; | |
| 1966 | 1978 | Blob in; |
| 1967 | 1979 | Th_InitTraceLog(); |
| 1968 | - forceCgi = find_option("th-force-cgi", 0, 0)!=0; | |
| 1969 | - fullHttpReply = find_option("th-full-http", 0, 0)!=0; | |
| 1980 | + forceCgi = find_option("cgi", 0, 0)!=0; | |
| 1981 | + fullHttpReply = find_option("http", 0, 0)!=0; | |
| 1982 | + if( fullHttpReply ) forceCgi = 1; | |
| 1970 | 1983 | if( forceCgi ) Th_ForceCgi(fullHttpReply); |
| 1971 | - if( find_option("th-open-config", 0, 0)!=0 ){ | |
| 1984 | + if( find_option("open-config", 0, 0)!=0 ){ | |
| 1972 | 1985 | Th_OpenConfig(1); |
| 1973 | 1986 | } |
| 1987 | + verify_all_options(); | |
| 1974 | 1988 | if( g.argc<3 ){ |
| 1975 | 1989 | usage("FILE"); |
| 1976 | 1990 | } |
| 1977 | 1991 | blob_zero(&in); |
| 1978 | 1992 | blob_read_from_file(&in, g.argv[2]); |
| @@ -1981,20 +1995,32 @@ | ||
| 1981 | 1995 | if( forceCgi ) cgi_reply(); |
| 1982 | 1996 | } |
| 1983 | 1997 | |
| 1984 | 1998 | /* |
| 1985 | 1999 | ** COMMAND: test-th-eval |
| 2000 | +** | |
| 2001 | +** Usage: %fossil test-th-eval SCRIPT | |
| 2002 | +** | |
| 2003 | +** Evaluate SCRIPT as if it were a header or footer or ticket rendering | |
| 2004 | +** script, evaluate it, and show the results on standard output. | |
| 2005 | +** | |
| 2006 | +** Options: | |
| 2007 | +** | |
| 2008 | +** --cgi Include a CGI response header in the output | |
| 2009 | +** --http Include an HTTP response header in the output | |
| 2010 | +** --open-config Open the configuration database | |
| 1986 | 2011 | */ |
| 1987 | 2012 | void test_th_eval(void){ |
| 1988 | 2013 | int rc; |
| 1989 | 2014 | const char *zRc; |
| 1990 | 2015 | int forceCgi, fullHttpReply; |
| 1991 | 2016 | Th_InitTraceLog(); |
| 1992 | - forceCgi = find_option("th-force-cgi", 0, 0)!=0; | |
| 1993 | - fullHttpReply = find_option("th-full-http", 0, 0)!=0; | |
| 2017 | + forceCgi = find_option("cgi", 0, 0)!=0; | |
| 2018 | + fullHttpReply = find_option("http", 0, 0)!=0; | |
| 2019 | + if( fullHttpReply ) forceCgi = 1; | |
| 1994 | 2020 | if( forceCgi ) Th_ForceCgi(fullHttpReply); |
| 1995 | - if( find_option("th-open-config", 0, 0)!=0 ){ | |
| 2021 | + if( find_option("open-config", 0, 0)!=0 ){ | |
| 1996 | 2022 | Th_OpenConfig(1); |
| 1997 | 2023 | } |
| 1998 | 2024 | if( g.argc!=3 ){ |
| 1999 | 2025 | usage("script"); |
| 2000 | 2026 | } |
| 2001 | 2027 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -1958,21 +1958,35 @@ | |
| 1958 | return rc; |
| 1959 | } |
| 1960 | |
| 1961 | /* |
| 1962 | ** COMMAND: test-th-render |
| 1963 | */ |
| 1964 | void test_th_render(void){ |
| 1965 | int forceCgi, fullHttpReply; |
| 1966 | Blob in; |
| 1967 | Th_InitTraceLog(); |
| 1968 | forceCgi = find_option("th-force-cgi", 0, 0)!=0; |
| 1969 | fullHttpReply = find_option("th-full-http", 0, 0)!=0; |
| 1970 | if( forceCgi ) Th_ForceCgi(fullHttpReply); |
| 1971 | if( find_option("th-open-config", 0, 0)!=0 ){ |
| 1972 | Th_OpenConfig(1); |
| 1973 | } |
| 1974 | if( g.argc<3 ){ |
| 1975 | usage("FILE"); |
| 1976 | } |
| 1977 | blob_zero(&in); |
| 1978 | blob_read_from_file(&in, g.argv[2]); |
| @@ -1981,20 +1995,32 @@ | |
| 1981 | if( forceCgi ) cgi_reply(); |
| 1982 | } |
| 1983 | |
| 1984 | /* |
| 1985 | ** COMMAND: test-th-eval |
| 1986 | */ |
| 1987 | void test_th_eval(void){ |
| 1988 | int rc; |
| 1989 | const char *zRc; |
| 1990 | int forceCgi, fullHttpReply; |
| 1991 | Th_InitTraceLog(); |
| 1992 | forceCgi = find_option("th-force-cgi", 0, 0)!=0; |
| 1993 | fullHttpReply = find_option("th-full-http", 0, 0)!=0; |
| 1994 | if( forceCgi ) Th_ForceCgi(fullHttpReply); |
| 1995 | if( find_option("th-open-config", 0, 0)!=0 ){ |
| 1996 | Th_OpenConfig(1); |
| 1997 | } |
| 1998 | if( g.argc!=3 ){ |
| 1999 | usage("script"); |
| 2000 | } |
| 2001 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -1958,21 +1958,35 @@ | |
| 1958 | return rc; |
| 1959 | } |
| 1960 | |
| 1961 | /* |
| 1962 | ** COMMAND: test-th-render |
| 1963 | ** |
| 1964 | ** Usage: %fossil test-th-render FILE |
| 1965 | ** |
| 1966 | ** Read the content of the file named "FILE" as if it were a header or |
| 1967 | ** footer or ticket rendering script, evaluate it, and show the results |
| 1968 | ** on standard output. |
| 1969 | ** |
| 1970 | ** Options: |
| 1971 | ** |
| 1972 | ** --cgi Include a CGI response header in the output |
| 1973 | ** --http Include an HTTP response header in the output |
| 1974 | ** --open-config Open the configuration database |
| 1975 | */ |
| 1976 | void test_th_render(void){ |
| 1977 | int forceCgi = 0, fullHttpReply = 0; |
| 1978 | Blob in; |
| 1979 | Th_InitTraceLog(); |
| 1980 | forceCgi = find_option("cgi", 0, 0)!=0; |
| 1981 | fullHttpReply = find_option("http", 0, 0)!=0; |
| 1982 | if( fullHttpReply ) forceCgi = 1; |
| 1983 | if( forceCgi ) Th_ForceCgi(fullHttpReply); |
| 1984 | if( find_option("open-config", 0, 0)!=0 ){ |
| 1985 | Th_OpenConfig(1); |
| 1986 | } |
| 1987 | verify_all_options(); |
| 1988 | if( g.argc<3 ){ |
| 1989 | usage("FILE"); |
| 1990 | } |
| 1991 | blob_zero(&in); |
| 1992 | blob_read_from_file(&in, g.argv[2]); |
| @@ -1981,20 +1995,32 @@ | |
| 1995 | if( forceCgi ) cgi_reply(); |
| 1996 | } |
| 1997 | |
| 1998 | /* |
| 1999 | ** COMMAND: test-th-eval |
| 2000 | ** |
| 2001 | ** Usage: %fossil test-th-eval SCRIPT |
| 2002 | ** |
| 2003 | ** Evaluate SCRIPT as if it were a header or footer or ticket rendering |
| 2004 | ** script, evaluate it, and show the results on standard output. |
| 2005 | ** |
| 2006 | ** Options: |
| 2007 | ** |
| 2008 | ** --cgi Include a CGI response header in the output |
| 2009 | ** --http Include an HTTP response header in the output |
| 2010 | ** --open-config Open the configuration database |
| 2011 | */ |
| 2012 | void test_th_eval(void){ |
| 2013 | int rc; |
| 2014 | const char *zRc; |
| 2015 | int forceCgi, fullHttpReply; |
| 2016 | Th_InitTraceLog(); |
| 2017 | forceCgi = find_option("cgi", 0, 0)!=0; |
| 2018 | fullHttpReply = find_option("http", 0, 0)!=0; |
| 2019 | if( fullHttpReply ) forceCgi = 1; |
| 2020 | if( forceCgi ) Th_ForceCgi(fullHttpReply); |
| 2021 | if( find_option("open-config", 0, 0)!=0 ){ |
| 2022 | Th_OpenConfig(1); |
| 2023 | } |
| 2024 | if( g.argc!=3 ){ |
| 2025 | usage("script"); |
| 2026 | } |
| 2027 |