Fossil SCM
Add the styleScript TH1 command to enabling including the script element of the skin in-line in the header or footer.
Commit
dc88a533e239863b1f8cb00556c3e045d2c733be085a795ad7c2b26f03c2986a
Parent
e5dbc6122d7b1c3…
1 file changed
+30
-1
+30
-1
| --- src/th_main.c | ||
| +++ src/th_main.c | ||
| @@ -1300,10 +1300,38 @@ | ||
| 1300 | 1300 | }else{ |
| 1301 | 1301 | Th_SetResult(interp, "repository unavailable", -1); |
| 1302 | 1302 | return TH_ERROR; |
| 1303 | 1303 | } |
| 1304 | 1304 | } |
| 1305 | + | |
| 1306 | +/* | |
| 1307 | +** TH1 command: styleScript | |
| 1308 | +** | |
| 1309 | +** Render the configured javascript for the selected skin | |
| 1310 | +*/ | |
| 1311 | +static int styleScriptCmd( | |
| 1312 | + Th_Interp *interp, | |
| 1313 | + void *p, | |
| 1314 | + int argc, | |
| 1315 | + const char **argv, | |
| 1316 | + int *argl | |
| 1317 | +){ | |
| 1318 | + if( argc!=1 ){ | |
| 1319 | + return Th_WrongNumArgs(interp, "styleScript"); | |
| 1320 | + } | |
| 1321 | + if( Th_IsRepositoryOpen() ){ | |
| 1322 | + const char *zScript = skin_get("js"); | |
| 1323 | + if( zScript==0 ) zScript = ""; | |
| 1324 | + Th_Render(zScript); | |
| 1325 | + Th_SetResult(interp, 0, 0); | |
| 1326 | + return TH_OK; | |
| 1327 | + }else{ | |
| 1328 | + Th_SetResult(interp, "repository unavailable", -1); | |
| 1329 | + return TH_ERROR; | |
| 1330 | + } | |
| 1331 | +} | |
| 1332 | + | |
| 1305 | 1333 | |
| 1306 | 1334 | /* |
| 1307 | 1335 | ** TH1 command: artifact ID ?FILENAME? |
| 1308 | 1336 | ** |
| 1309 | 1337 | ** Attempts to locate the specified artifact and return its contents. An |
| @@ -1984,12 +2012,13 @@ | ||
| 1984 | 2012 | {"render", renderCmd, 0}, |
| 1985 | 2013 | {"repository", repositoryCmd, 0}, |
| 1986 | 2014 | {"searchable", searchableCmd, 0}, |
| 1987 | 2015 | {"setParameter", setParameterCmd, 0}, |
| 1988 | 2016 | {"setting", settingCmd, 0}, |
| 1989 | - {"styleHeader", styleHeaderCmd, 0}, | |
| 1990 | 2017 | {"styleFooter", styleFooterCmd, 0}, |
| 2018 | + {"styleHeader", styleHeaderCmd, 0}, | |
| 2019 | + {"styleScript", styleScriptCmd, 0}, | |
| 1991 | 2020 | {"tclReady", tclReadyCmd, 0}, |
| 1992 | 2021 | {"trace", traceCmd, 0}, |
| 1993 | 2022 | {"stime", stimeCmd, 0}, |
| 1994 | 2023 | {"unversioned", unversionedCmd, 0}, |
| 1995 | 2024 | {"utime", utimeCmd, 0}, |
| 1996 | 2025 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -1300,10 +1300,38 @@ | |
| 1300 | }else{ |
| 1301 | Th_SetResult(interp, "repository unavailable", -1); |
| 1302 | return TH_ERROR; |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | /* |
| 1307 | ** TH1 command: artifact ID ?FILENAME? |
| 1308 | ** |
| 1309 | ** Attempts to locate the specified artifact and return its contents. An |
| @@ -1984,12 +2012,13 @@ | |
| 1984 | {"render", renderCmd, 0}, |
| 1985 | {"repository", repositoryCmd, 0}, |
| 1986 | {"searchable", searchableCmd, 0}, |
| 1987 | {"setParameter", setParameterCmd, 0}, |
| 1988 | {"setting", settingCmd, 0}, |
| 1989 | {"styleHeader", styleHeaderCmd, 0}, |
| 1990 | {"styleFooter", styleFooterCmd, 0}, |
| 1991 | {"tclReady", tclReadyCmd, 0}, |
| 1992 | {"trace", traceCmd, 0}, |
| 1993 | {"stime", stimeCmd, 0}, |
| 1994 | {"unversioned", unversionedCmd, 0}, |
| 1995 | {"utime", utimeCmd, 0}, |
| 1996 |
| --- src/th_main.c | |
| +++ src/th_main.c | |
| @@ -1300,10 +1300,38 @@ | |
| 1300 | }else{ |
| 1301 | Th_SetResult(interp, "repository unavailable", -1); |
| 1302 | return TH_ERROR; |
| 1303 | } |
| 1304 | } |
| 1305 | |
| 1306 | /* |
| 1307 | ** TH1 command: styleScript |
| 1308 | ** |
| 1309 | ** Render the configured javascript for the selected skin |
| 1310 | */ |
| 1311 | static int styleScriptCmd( |
| 1312 | Th_Interp *interp, |
| 1313 | void *p, |
| 1314 | int argc, |
| 1315 | const char **argv, |
| 1316 | int *argl |
| 1317 | ){ |
| 1318 | if( argc!=1 ){ |
| 1319 | return Th_WrongNumArgs(interp, "styleScript"); |
| 1320 | } |
| 1321 | if( Th_IsRepositoryOpen() ){ |
| 1322 | const char *zScript = skin_get("js"); |
| 1323 | if( zScript==0 ) zScript = ""; |
| 1324 | Th_Render(zScript); |
| 1325 | Th_SetResult(interp, 0, 0); |
| 1326 | return TH_OK; |
| 1327 | }else{ |
| 1328 | Th_SetResult(interp, "repository unavailable", -1); |
| 1329 | return TH_ERROR; |
| 1330 | } |
| 1331 | } |
| 1332 | |
| 1333 | |
| 1334 | /* |
| 1335 | ** TH1 command: artifact ID ?FILENAME? |
| 1336 | ** |
| 1337 | ** Attempts to locate the specified artifact and return its contents. An |
| @@ -1984,12 +2012,13 @@ | |
| 2012 | {"render", renderCmd, 0}, |
| 2013 | {"repository", repositoryCmd, 0}, |
| 2014 | {"searchable", searchableCmd, 0}, |
| 2015 | {"setParameter", setParameterCmd, 0}, |
| 2016 | {"setting", settingCmd, 0}, |
| 2017 | {"styleFooter", styleFooterCmd, 0}, |
| 2018 | {"styleHeader", styleHeaderCmd, 0}, |
| 2019 | {"styleScript", styleScriptCmd, 0}, |
| 2020 | {"tclReady", tclReadyCmd, 0}, |
| 2021 | {"trace", traceCmd, 0}, |
| 2022 | {"stime", stimeCmd, 0}, |
| 2023 | {"unversioned", unversionedCmd, 0}, |
| 2024 | {"utime", utimeCmd, 0}, |
| 2025 |