Fossil SCM

Process the style sheet using TH1 prior to returning it. This branch is experimental.

drh 2012-01-04 18:29 UTC th1-css
Commit d1b68cc0f3c29a63572dc92a0c5ad2e8798cfc78
+5 -6
--- src/report.c
+++ src/report.c
@@ -27,11 +27,11 @@
2727
2828
/* Forward references to static routines */
2929
static void report_format_hints(void);
3030
3131
/*
32
-** WEBPAGE: /reportlist
32
+** WEBPAGE: reportlist
3333
*/
3434
void view_list(void){
3535
const char *zScript;
3636
Blob ril; /* Report Item List */
3737
Stmt q;
@@ -267,11 +267,11 @@
267267
report_unrestrict_sql();
268268
return zErr;
269269
}
270270
271271
/*
272
-** WEBPAGE: /rptsql
272
+** WEBPAGE: rptsql
273273
*/
274274
void view_see_sql(void){
275275
int rn;
276276
const char *zTitle;
277277
const char *zSQL;
@@ -313,12 +313,12 @@
313313
report_format_hints();
314314
style_footer();
315315
}
316316
317317
/*
318
-** WEBPAGE: /rptnew
319
-** WEBPAGE: /rptedit
318
+** WEBPAGE: rptnew
319
+** WEBPAGE: rptedit
320320
*/
321321
void view_edit(void){
322322
int rn;
323323
const char *zTitle;
324324
const char *z;
@@ -891,11 +891,11 @@
891891
return rc;
892892
}
893893
894894
895895
/*
896
-** WEBPAGE: /rptview
896
+** WEBPAGE: rptview
897897
**
898898
** Generate a report. The rn query parameter is the report number
899899
** corresponding to REPORTFMT.RN. If the tablist query parameter exists,
900900
** then the output consists of lines of tab-separated fields instead of
901901
** an HTML table.
@@ -1141,6 +1141,5 @@
11411141
report_unrestrict_sql();
11421142
if( zFilter ){
11431143
free(zSql);
11441144
}
11451145
}
1146
-
11471146
--- src/report.c
+++ src/report.c
@@ -27,11 +27,11 @@
27
28 /* Forward references to static routines */
29 static void report_format_hints(void);
30
31 /*
32 ** WEBPAGE: /reportlist
33 */
34 void view_list(void){
35 const char *zScript;
36 Blob ril; /* Report Item List */
37 Stmt q;
@@ -267,11 +267,11 @@
267 report_unrestrict_sql();
268 return zErr;
269 }
270
271 /*
272 ** WEBPAGE: /rptsql
273 */
274 void view_see_sql(void){
275 int rn;
276 const char *zTitle;
277 const char *zSQL;
@@ -313,12 +313,12 @@
313 report_format_hints();
314 style_footer();
315 }
316
317 /*
318 ** WEBPAGE: /rptnew
319 ** WEBPAGE: /rptedit
320 */
321 void view_edit(void){
322 int rn;
323 const char *zTitle;
324 const char *z;
@@ -891,11 +891,11 @@
891 return rc;
892 }
893
894
895 /*
896 ** WEBPAGE: /rptview
897 **
898 ** Generate a report. The rn query parameter is the report number
899 ** corresponding to REPORTFMT.RN. If the tablist query parameter exists,
900 ** then the output consists of lines of tab-separated fields instead of
901 ** an HTML table.
@@ -1141,6 +1141,5 @@
1141 report_unrestrict_sql();
1142 if( zFilter ){
1143 free(zSql);
1144 }
1145 }
1146
1147
--- src/report.c
+++ src/report.c
@@ -27,11 +27,11 @@
27
28 /* Forward references to static routines */
29 static void report_format_hints(void);
30
31 /*
32 ** WEBPAGE: reportlist
33 */
34 void view_list(void){
35 const char *zScript;
36 Blob ril; /* Report Item List */
37 Stmt q;
@@ -267,11 +267,11 @@
267 report_unrestrict_sql();
268 return zErr;
269 }
270
271 /*
272 ** WEBPAGE: rptsql
273 */
274 void view_see_sql(void){
275 int rn;
276 const char *zTitle;
277 const char *zSQL;
@@ -313,12 +313,12 @@
313 report_format_hints();
314 style_footer();
315 }
316
317 /*
318 ** WEBPAGE: rptnew
319 ** WEBPAGE: rptedit
320 */
321 void view_edit(void){
322 int rn;
323 const char *zTitle;
324 const char *z;
@@ -891,11 +891,11 @@
891 return rc;
892 }
893
894
895 /*
896 ** WEBPAGE: rptview
897 **
898 ** Generate a report. The rn query parameter is the report number
899 ** corresponding to REPORTFMT.RN. If the tablist query parameter exists,
900 ** then the output consists of lines of tab-separated fields instead of
901 ** an HTML table.
@@ -1141,6 +1141,5 @@
1141 report_unrestrict_sql();
1142 if( zFilter ){
1143 free(zSql);
1144 }
1145 }
 
1146
+2 -2
--- src/setup.c
+++ src/setup.c
@@ -48,11 +48,11 @@
4848
}
4949
@ </td><td width="5"></td><td valign="top">%h(zDesc)</td></tr>
5050
}
5151
5252
/*
53
-** WEBPAGE: /setup
53
+** WEBPAGE: setup
5454
*/
5555
void setup_page(void){
5656
login_check_credentials();
5757
if( !g.perm.Setup ){
5858
login_needed();
@@ -241,11 +241,11 @@
241241
while( zPw[0]=='*' ){ zPw++; }
242242
return zPw[0]!=0;
243243
}
244244
245245
/*
246
-** WEBPAGE: /setup_uedit
246
+** WEBPAGE: setup_uedit
247247
*/
248248
void user_edit(void){
249249
const char *zId, *zLogin, *zInfo, *zCap, *zPw;
250250
char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap;
251251
char *oak, *oad, *oac, *oaf, *oam, *oah, *oag, *oae;
252252
--- src/setup.c
+++ src/setup.c
@@ -48,11 +48,11 @@
48 }
49 @ </td><td width="5"></td><td valign="top">%h(zDesc)</td></tr>
50 }
51
52 /*
53 ** WEBPAGE: /setup
54 */
55 void setup_page(void){
56 login_check_credentials();
57 if( !g.perm.Setup ){
58 login_needed();
@@ -241,11 +241,11 @@
241 while( zPw[0]=='*' ){ zPw++; }
242 return zPw[0]!=0;
243 }
244
245 /*
246 ** WEBPAGE: /setup_uedit
247 */
248 void user_edit(void){
249 const char *zId, *zLogin, *zInfo, *zCap, *zPw;
250 char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap;
251 char *oak, *oad, *oac, *oaf, *oam, *oah, *oag, *oae;
252
--- src/setup.c
+++ src/setup.c
@@ -48,11 +48,11 @@
48 }
49 @ </td><td width="5"></td><td valign="top">%h(zDesc)</td></tr>
50 }
51
52 /*
53 ** WEBPAGE: setup
54 */
55 void setup_page(void){
56 login_check_credentials();
57 if( !g.perm.Setup ){
58 login_needed();
@@ -241,11 +241,11 @@
241 while( zPw[0]=='*' ){ zPw++; }
242 return zPw[0]!=0;
243 }
244
245 /*
246 ** WEBPAGE: setup_uedit
247 */
248 void user_edit(void){
249 const char *zId, *zLogin, *zInfo, *zCap, *zPw;
250 char *oaa, *oas, *oar, *oaw, *oan, *oai, *oaj, *oao, *oap;
251 char *oak, *oad, *oac, *oaf, *oam, *oah, *oag, *oae;
252
+41 -17
--- src/style.c
+++ src/style.c
@@ -85,11 +85,11 @@
8585
login_check_credentials();
8686
8787
va_start(ap, zTitleFormat);
8888
zTitle = vmprintf(zTitleFormat, ap);
8989
va_end(ap);
90
-
90
+
9191
cgi_destination(CGI_HEADER);
9292
cgi_printf("%s","<!DOCTYPE html>");
9393
9494
if( g.thTrace ) Th_Trace("BEGIN_HEADER<br />\n", -1);
9595
@@ -98,10 +98,11 @@
9898
Th_Store("title", zTitle);
9999
Th_Store("baseurl", g.zBaseURL);
100100
Th_Store("home", g.zTop);
101101
Th_Store("index_page", db_get("index-page","/home"));
102102
Th_Store("current_page", g.zPath);
103
+ Th_Store("stylesheet", db_get("style-stylesheet", "style.css"));
103104
Th_Store("release_version", RELEASE_VERSION);
104105
Th_Store("manifest_version", MANIFEST_VERSION);
105106
Th_Store("manifest_date", MANIFEST_DATE);
106107
Th_Store("compiler_name", COMPILER_NAME);
107108
if( g.zLogin ){
@@ -193,11 +194,11 @@
193194
@ <html>
194195
@ <head>
195196
@ <title>$<project_name>: $<title></title>
196197
@ <link rel="alternate" type="application/rss+xml" title="RSS Feed"
197198
@ 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"
199200
@ media="screen" />
200201
@ </head>
201202
@ <body>
202203
@ <div class="header">
203204
@ <div class="logo">
@@ -698,11 +699,12 @@
698699
@ ** 2. change the default hash adding behaviour to ON
699700
@ ** or change the class defition of element identified by id="clrcust"
700701
@ ** to a standard jscolor definition with java script in the footer. */
701702
},
702703
{ "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,..",
704706
@ clear: both;
705707
},
706708
{ "p.generalError",
707709
"format for general errors",
708710
@ color: red;
@@ -775,31 +777,53 @@
775777
}
776778
}
777779
778780
/*
779781
** 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.
780789
*/
781790
void page_style_css(void){
782
- const char *zCSS = 0;
791
+ const char *zCSS;
783792
int i;
793
+ Blob css;
794
+ Stmt q;
784795
796
+ /* The mime-type for CSS */
785797
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);
790814
for (i=1;cssDefaultList[i].elementClass;i++)
791815
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));
801825
}
802826
803827
/*
804828
** WEBPAGE: test_env
805829
*/
806830
--- src/style.c
+++ src/style.c
@@ -85,11 +85,11 @@
85 login_check_credentials();
86
87 va_start(ap, zTitleFormat);
88 zTitle = vmprintf(zTitleFormat, ap);
89 va_end(ap);
90
91 cgi_destination(CGI_HEADER);
92 cgi_printf("%s","<!DOCTYPE html>");
93
94 if( g.thTrace ) Th_Trace("BEGIN_HEADER<br />\n", -1);
95
@@ -98,10 +98,11 @@
98 Th_Store("title", zTitle);
99 Th_Store("baseurl", g.zBaseURL);
100 Th_Store("home", g.zTop);
101 Th_Store("index_page", db_get("index-page","/home"));
102 Th_Store("current_page", g.zPath);
 
103 Th_Store("release_version", RELEASE_VERSION);
104 Th_Store("manifest_version", MANIFEST_VERSION);
105 Th_Store("manifest_date", MANIFEST_DATE);
106 Th_Store("compiler_name", COMPILER_NAME);
107 if( g.zLogin ){
@@ -193,11 +194,11 @@
193 @ <html>
194 @ <head>
195 @ <title>$<project_name>: $<title></title>
196 @ <link rel="alternate" type="application/rss+xml" title="RSS Feed"
197 @ href="$home/timeline.rss" />
198 @ <link rel="stylesheet" href="$home/style.css?default" type="text/css"
199 @ media="screen" />
200 @ </head>
201 @ <body>
202 @ <div class="header">
203 @ <div class="logo">
@@ -698,11 +699,12 @@
698 @ ** 2. change the default hash adding behaviour to ON
699 @ ** or change the class defition of element identified by id="clrcust"
700 @ ** to a standard jscolor definition with java script in the footer. */
701 },
702 { "div.endContent",
703 "format for end of content area, to be used to clear page flow(sidebox on branch,..",
 
704 @ clear: both;
705 },
706 { "p.generalError",
707 "format for general errors",
708 @ color: red;
@@ -775,31 +777,53 @@
775 }
776 }
777
778 /*
779 ** WEBPAGE: style.css
 
 
 
 
 
 
 
780 */
781 void page_style_css(void){
782 const char *zCSS = 0;
783 int i;
 
 
784
 
785 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 */
 
 
 
 
 
 
 
 
 
 
 
 
790 for (i=1;cssDefaultList[i].elementClass;i++)
791 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;
801 }
802
803 /*
804 ** WEBPAGE: test_env
805 */
806
--- src/style.c
+++ src/style.c
@@ -85,11 +85,11 @@
85 login_check_credentials();
86
87 va_start(ap, zTitleFormat);
88 zTitle = vmprintf(zTitleFormat, ap);
89 va_end(ap);
90
91 cgi_destination(CGI_HEADER);
92 cgi_printf("%s","<!DOCTYPE html>");
93
94 if( g.thTrace ) Th_Trace("BEGIN_HEADER<br />\n", -1);
95
@@ -98,10 +98,11 @@
98 Th_Store("title", zTitle);
99 Th_Store("baseurl", g.zBaseURL);
100 Th_Store("home", g.zTop);
101 Th_Store("index_page", db_get("index-page","/home"));
102 Th_Store("current_page", g.zPath);
103 Th_Store("stylesheet", db_get("style-stylesheet", "style.css"));
104 Th_Store("release_version", RELEASE_VERSION);
105 Th_Store("manifest_version", MANIFEST_VERSION);
106 Th_Store("manifest_date", MANIFEST_DATE);
107 Th_Store("compiler_name", COMPILER_NAME);
108 if( g.zLogin ){
@@ -193,11 +194,11 @@
194 @ <html>
195 @ <head>
196 @ <title>$<project_name>: $<title></title>
197 @ <link rel="alternate" type="application/rss+xml" title="RSS Feed"
198 @ href="$home/timeline.rss" />
199 @ <link rel="stylesheet" href="$home/$stylesheet" type="text/css"
200 @ media="screen" />
201 @ </head>
202 @ <body>
203 @ <div class="header">
204 @ <div class="logo">
@@ -698,11 +699,12 @@
699 @ ** 2. change the default hash adding behaviour to ON
700 @ ** or change the class defition of element identified by id="clrcust"
701 @ ** to a standard jscolor definition with java script in the footer. */
702 },
703 { "div.endContent",
704 "format for end of content area, to be used to clear "
705 "page flow(sidebox on branch,..",
706 @ clear: both;
707 },
708 { "p.generalError",
709 "format for general errors",
710 @ color: red;
@@ -775,31 +777,53 @@
777 }
778 }
779
780 /*
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.
789 */
790 void page_style_css(void){
791 const char *zCSS;
792 int i;
793 Blob css;
794 Stmt q;
795
796 /* The mime-type for CSS */
797 cgi_set_content_type("text/css");
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);
814 for (i=1;cssDefaultList[i].elementClass;i++)
815 if (!strstr(zCSS,cssDefaultList[i].elementClass)) {
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));
825 }
826
827 /*
828 ** WEBPAGE: test_env
829 */
830
+2 -2
--- src/tag.c
+++ src/tag.c
@@ -523,11 +523,11 @@
523523
tag_cmd_usage:
524524
usage("add|cancel|find|list ...");
525525
}
526526
527527
/*
528
-** WEBPAGE: /taglist
528
+** WEBPAGE: taglist
529529
*/
530530
void taglist_page(void){
531531
Stmt q;
532532
533533
login_check_credentials();
@@ -561,11 +561,11 @@
561561
db_finalize(&q);
562562
style_footer();
563563
}
564564
565565
/*
566
-** WEBPAGE: /tagtimeline
566
+** WEBPAGE: tagtimeline
567567
*/
568568
void tagtimeline_page(void){
569569
Stmt q;
570570
571571
login_check_credentials();
572572
--- src/tag.c
+++ src/tag.c
@@ -523,11 +523,11 @@
523 tag_cmd_usage:
524 usage("add|cancel|find|list ...");
525 }
526
527 /*
528 ** WEBPAGE: /taglist
529 */
530 void taglist_page(void){
531 Stmt q;
532
533 login_check_credentials();
@@ -561,11 +561,11 @@
561 db_finalize(&q);
562 style_footer();
563 }
564
565 /*
566 ** WEBPAGE: /tagtimeline
567 */
568 void tagtimeline_page(void){
569 Stmt q;
570
571 login_check_credentials();
572
--- src/tag.c
+++ src/tag.c
@@ -523,11 +523,11 @@
523 tag_cmd_usage:
524 usage("add|cancel|find|list ...");
525 }
526
527 /*
528 ** WEBPAGE: taglist
529 */
530 void taglist_page(void){
531 Stmt q;
532
533 login_check_credentials();
@@ -561,11 +561,11 @@
561 db_finalize(&q);
562 style_footer();
563 }
564
565 /*
566 ** WEBPAGE: tagtimeline
567 */
568 void tagtimeline_page(void){
569 Stmt q;
570
571 login_check_credentials();
572

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button