Index: src/report.c ================================================================== --- src/report.c +++ src/report.c @@ -27,11 +27,11 @@ /* Forward references to static routines */ static void report_format_hints(void); /* -** WEBPAGE: /reportlist +** WEBPAGE: reportlist */ void view_list(void){ const char *zScript; Blob ril; /* Report Item List */ Stmt q; @@ -267,11 +267,11 @@ report_unrestrict_sql(); return zErr; } /* -** WEBPAGE: /rptsql +** WEBPAGE: rptsql */ void view_see_sql(void){ int rn; const char *zTitle; const char *zSQL; @@ -313,12 +313,12 @@ report_format_hints(); style_footer(); } /* -** WEBPAGE: /rptnew -** WEBPAGE: /rptedit +** WEBPAGE: rptnew +** WEBPAGE: rptedit */ void view_edit(void){ int rn; const char *zTitle; const char *z; @@ -891,11 +891,11 @@ return rc; } /* -** WEBPAGE: /rptview +** WEBPAGE: rptview ** ** Generate a report. The rn query parameter is the report number ** corresponding to REPORTFMT.RN. If the tablist query parameter exists, ** then the output consists of lines of tab-separated fields instead of ** an HTML table. @@ -1141,6 +1141,5 @@ report_unrestrict_sql(); if( zFilter ){ free(zSql); } } - Index: src/setup.c ================================================================== --- src/setup.c +++ src/setup.c @@ -48,11 +48,11 @@ } @ </td><td width="5"></td><td valign="top">%h(zDesc)</td></tr> } /* -** WEBPAGE: /setup +** WEBPAGE: setup */ void setup_page(void){ login_check_credentials(); if( !g.perm.Setup ){ login_needed(); @@ -241,11 +241,11 @@ while( zPw[0]=='*' ){ zPw++; } return zPw[0]!=0; } /* -** WEBPAGE: /setup_uedit +** WEBPAGE: setup_uedit */ void user_edit(void){ const char *zId, *zLogin, *zInfo, *zCap, *zPw; char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap; char *oak, *oad, *oac, *oaf, *oam, *oah, *oag, *oae; Index: src/style.c ================================================================== --- src/style.c +++ src/style.c @@ -85,11 +85,11 @@ login_check_credentials(); va_start(ap, zTitleFormat); zTitle = vmprintf(zTitleFormat, ap); va_end(ap); - + cgi_destination(CGI_HEADER); cgi_printf("%s","<!DOCTYPE html>"); if( g.thTrace ) Th_Trace("BEGIN_HEADER<br />\n", -1); @@ -98,10 +98,11 @@ Th_Store("title", zTitle); Th_Store("baseurl", g.zBaseURL); Th_Store("home", g.zTop); Th_Store("index_page", db_get("index-page","/home")); Th_Store("current_page", g.zPath); + Th_Store("stylesheet", db_get("style-stylesheet", "style.css")); Th_Store("release_version", RELEASE_VERSION); Th_Store("manifest_version", MANIFEST_VERSION); Th_Store("manifest_date", MANIFEST_DATE); Th_Store("compiler_name", COMPILER_NAME); if( g.zLogin ){ @@ -193,11 +194,11 @@ @ <html> @ <head> @ <title>$<project_name>: $<title></title> @ <link rel="alternate" type="application/rss+xml" title="RSS Feed" @ href="$home/timeline.rss" /> -@ <link rel="stylesheet" href="$home/style.css?default" type="text/css" +@ <link rel="stylesheet" href="$home/$stylesheet" type="text/css" @ media="screen" /> @ </head> @ <body> @ <div class="header"> @ <div class="logo"> @@ -698,11 +699,12 @@ @ ** 2. change the default hash adding behaviour to ON @ ** or change the class defition of element identified by id="clrcust" @ ** to a standard jscolor definition with java script in the footer. */ }, { "div.endContent", - "format for end of content area, to be used to clear page flow(sidebox on branch,..", + "format for end of content area, to be used to clear " + "page flow(sidebox on branch,..", @ clear: both; }, { "p.generalError", "format for general errors", @ color: red; @@ -775,31 +777,53 @@ } } /* ** WEBPAGE: style.css +** WEBPAGE: style +** +** The first form (style.css) is the default. The second form (style) is +** intended to be used with a query path (ex: style/76a6de45.css) where the +** extra suffix (the "76a6de45.css") is a randomly-generated name that +** changes every time the style sheet changes. Changing the name causes +** the style-sheet to be reloaded by the web browser. */ void page_style_css(void){ - const char *zCSS = 0; + const char *zCSS; int i; + Blob css; + Stmt q; + /* The mime-type for CSS */ cgi_set_content_type("text/css"); - zCSS = db_get("css",(char*)zDefaultCSS); - /* append user defined css */ - cgi_append_content(zCSS, -1); - /* add special missing definitions */ + + /* Content is cacheable */ + g.isConst = 1; + + /* Initialize TH1 variables that can appear in the stylesheet + ** template. + */ + db_prepare(&q, "SELECT substr(name,7), value FROM config" + " WHERE name GLOB 'style-*'); + while( db_step(&q)==SQLITE_ROW ){ + Th_Store(db_column_text(&q,0), db_column_text(&q,1)); + } + db_finalize(&q); + + /* Construct the CSS text */ + blob_init(&css, db_get("css", (char*)zDefaultCSS), -1); for (i=1;cssDefaultList[i].elementClass;i++) if (!strstr(zCSS,cssDefaultList[i].elementClass)) { - cgi_append_content("/* ", -1); - cgi_append_content(cssDefaultList[i].comment, -1); - cgi_append_content(" */\n", -1); - cgi_append_content(cssDefaultList[i].elementClass, -1); - cgi_append_content(" {\n", -1); - cgi_append_content(cssDefaultList[i].value, -1); - cgi_append_content("}\n\n", -1); + blob_appendf(&css, "/* %s */\n%s {\n%s}\n\n", + cssDefaultList[i].comment, + cssDefaultList[i].elementClass, + cssDefaultList[i].value); } - g.isConst = 1; + } + + /* Render the CSS */ + Th_Render(blob_str(&css)); } /* ** WEBPAGE: test_env */ Index: src/tag.c ================================================================== --- src/tag.c +++ src/tag.c @@ -523,11 +523,11 @@ tag_cmd_usage: usage("add|cancel|find|list ..."); } /* -** WEBPAGE: /taglist +** WEBPAGE: taglist */ void taglist_page(void){ Stmt q; login_check_credentials(); @@ -561,11 +561,11 @@ db_finalize(&q); style_footer(); } /* -** WEBPAGE: /tagtimeline +** WEBPAGE: tagtimeline */ void tagtimeline_page(void){ Stmt q; login_check_credentials();