| | @@ -85,11 +85,11 @@ |
| 85 | 85 | login_check_credentials(); |
| 86 | 86 | |
| 87 | 87 | va_start(ap, zTitleFormat); |
| 88 | 88 | zTitle = vmprintf(zTitleFormat, ap); |
| 89 | 89 | va_end(ap); |
| 90 | | - |
| 90 | + |
| 91 | 91 | cgi_destination(CGI_HEADER); |
| 92 | 92 | cgi_printf("%s","<!DOCTYPE html>"); |
| 93 | 93 | |
| 94 | 94 | if( g.thTrace ) Th_Trace("BEGIN_HEADER<br />\n", -1); |
| 95 | 95 | |
| | @@ -98,10 +98,11 @@ |
| 98 | 98 | Th_Store("title", zTitle); |
| 99 | 99 | Th_Store("baseurl", g.zBaseURL); |
| 100 | 100 | Th_Store("home", g.zTop); |
| 101 | 101 | Th_Store("index_page", db_get("index-page","/home")); |
| 102 | 102 | Th_Store("current_page", g.zPath); |
| 103 | + Th_Store("stylesheet", db_get("style-stylesheet", "style.css")); |
| 103 | 104 | Th_Store("release_version", RELEASE_VERSION); |
| 104 | 105 | Th_Store("manifest_version", MANIFEST_VERSION); |
| 105 | 106 | Th_Store("manifest_date", MANIFEST_DATE); |
| 106 | 107 | Th_Store("compiler_name", COMPILER_NAME); |
| 107 | 108 | if( g.zLogin ){ |
| | @@ -193,11 +194,11 @@ |
| 193 | 194 | @ <html> |
| 194 | 195 | @ <head> |
| 195 | 196 | @ <title>$<project_name>: $<title></title> |
| 196 | 197 | @ <link rel="alternate" type="application/rss+xml" title="RSS Feed" |
| 197 | 198 | @ href="$home/timeline.rss" /> |
| 198 | | -@ <link rel="stylesheet" href="$home/style.css?default" type="text/css" |
| 199 | +@ <link rel="stylesheet" href="$home/$stylesheet" type="text/css" |
| 199 | 200 | @ media="screen" /> |
| 200 | 201 | @ </head> |
| 201 | 202 | @ <body> |
| 202 | 203 | @ <div class="header"> |
| 203 | 204 | @ <div class="logo"> |
| | @@ -698,11 +699,12 @@ |
| 698 | 699 | @ ** 2. change the default hash adding behaviour to ON |
| 699 | 700 | @ ** or change the class defition of element identified by id="clrcust" |
| 700 | 701 | @ ** to a standard jscolor definition with java script in the footer. */ |
| 701 | 702 | }, |
| 702 | 703 | { "div.endContent", |
| 703 | | - "format for end of content area, to be used to clear page flow(sidebox on branch,..", |
| 704 | + "format for end of content area, to be used to clear " |
| 705 | + "page flow(sidebox on branch,..", |
| 704 | 706 | @ clear: both; |
| 705 | 707 | }, |
| 706 | 708 | { "p.generalError", |
| 707 | 709 | "format for general errors", |
| 708 | 710 | @ color: red; |
| | @@ -775,31 +777,53 @@ |
| 775 | 777 | } |
| 776 | 778 | } |
| 777 | 779 | |
| 778 | 780 | /* |
| 779 | 781 | ** WEBPAGE: style.css |
| 782 | +** WEBPAGE: style |
| 783 | +** |
| 784 | +** The first form (style.css) is the default. The second form (style) is |
| 785 | +** intended to be used with a query path (ex: style/76a6de45.css) where the |
| 786 | +** extra suffix (the "76a6de45.css") is a randomly-generated name that |
| 787 | +** changes every time the style sheet changes. Changing the name causes |
| 788 | +** the style-sheet to be reloaded by the web browser. |
| 780 | 789 | */ |
| 781 | 790 | void page_style_css(void){ |
| 782 | | - const char *zCSS = 0; |
| 791 | + const char *zCSS; |
| 783 | 792 | int i; |
| 793 | + Blob css; |
| 794 | + Stmt q; |
| 784 | 795 | |
| 796 | + /* The mime-type for CSS */ |
| 785 | 797 | cgi_set_content_type("text/css"); |
| 786 | | - zCSS = db_get("css",(char*)zDefaultCSS); |
| 787 | | - /* append user defined css */ |
| 788 | | - cgi_append_content(zCSS, -1); |
| 789 | | - /* add special missing definitions */ |
| 798 | + |
| 799 | + /* Content is cacheable */ |
| 800 | + g.isConst = 1; |
| 801 | + |
| 802 | + /* Initialize TH1 variables that can appear in the stylesheet |
| 803 | + ** template. |
| 804 | + */ |
| 805 | + db_prepare(&q, "SELECT substr(name,7), value FROM config" |
| 806 | + " WHERE name GLOB 'style-*'); |
| 807 | + while( db_step(&q)==SQLITE_ROW ){ |
| 808 | + Th_Store(db_column_text(&q,0), db_column_text(&q,1)); |
| 809 | + } |
| 810 | + db_finalize(&q); |
| 811 | + |
| 812 | + /* Construct the CSS text */ |
| 813 | + blob_init(&css, db_get("css", (char*)zDefaultCSS), -1); |
| 790 | 814 | for (i=1;cssDefaultList[i].elementClass;i++) |
| 791 | 815 | if (!strstr(zCSS,cssDefaultList[i].elementClass)) { |
| 792 | | - cgi_append_content("/* ", -1); |
| 793 | | - cgi_append_content(cssDefaultList[i].comment, -1); |
| 794 | | - cgi_append_content(" */\n", -1); |
| 795 | | - cgi_append_content(cssDefaultList[i].elementClass, -1); |
| 796 | | - cgi_append_content(" {\n", -1); |
| 797 | | - cgi_append_content(cssDefaultList[i].value, -1); |
| 798 | | - cgi_append_content("}\n\n", -1); |
| 799 | | - } |
| 800 | | - g.isConst = 1; |
| 816 | + blob_appendf(&css, "/* %s */\n%s {\n%s}\n\n", |
| 817 | + cssDefaultList[i].comment, |
| 818 | + cssDefaultList[i].elementClass, |
| 819 | + cssDefaultList[i].value); |
| 820 | + } |
| 821 | + } |
| 822 | + |
| 823 | + /* Render the CSS */ |
| 824 | + Th_Render(blob_str(&css)); |
| 801 | 825 | } |
| 802 | 826 | |
| 803 | 827 | /* |
| 804 | 828 | ** WEBPAGE: test_env |
| 805 | 829 | */ |
| 806 | 830 | |