Diffstat (limited to 'htdocs/examples/calendar.chtml') (more/less context) (ignore whitespace changes)
-rw-r--r-- | htdocs/examples/calendar.chtml | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/htdocs/examples/calendar.chtml b/htdocs/examples/calendar.chtml index eea20cb..85aa7ba 100644 --- a/htdocs/examples/calendar.chtml +++ b/htdocs/examples/calendar.chtml | |||
@@ -1,101 +1,102 @@ | |||
1 | <%impl> | 1 | <%impl> |
2 | /* vim:set ft=sitecing: */ | 2 | /* vim:set ft=sitecing: */ |
3 | #include <time.h> | 3 | #include <time.h> |
4 | #include <konforka/exception.h> | 4 | #include <konforka/exception.h> |
5 | </%impl> | 5 | </%impl> |
6 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | 6 | <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
7 | % __SCIF->flush(); | ||
7 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> | 8 | <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> |
8 | <head> | 9 | <head> |
9 | <title>really simple page</title> | 10 | <title>really simple page</title> |
10 | <style type="text/css"> | 11 | <style type="text/css"> |
11 | table.calendar { | 12 | table.calendar { |
12 | font-family: monospace; | 13 | font-family: monospace; |
13 | } | 14 | } |
14 | table.calendar th.heading { | 15 | table.calendar th.heading { |
15 | border: double blue 3px; | 16 | border: double blue 3px; |
16 | } | 17 | } |
17 | table.calendar td { | 18 | table.calendar td { |
18 | text-align: right; | 19 | text-align: right; |
19 | margin: 0.5ex; padding: 2px; | 20 | margin: 0.5ex; padding: 2px; |
20 | border: solid 1px black; | 21 | border: solid 1px black; |
21 | } | 22 | } |
22 | table.calendar .wd-0, table.calendar .wd-6 { | 23 | table.calendar .wd-0, table.calendar .wd-6 { |
23 | color: red; | 24 | color: red; |
24 | } | 25 | } |
25 | table.calendar td.unexistant { | 26 | table.calendar td.unexistant { |
26 | border: none; | 27 | border: none; |
27 | } | 28 | } |
28 | table.calendar td.today { | 29 | table.calendar td.today { |
29 | background: #ffffc0; | 30 | background: #ffffc0; |
30 | color: blue; | 31 | color: blue; |
31 | font-weight: bold; | 32 | font-weight: bold; |
32 | } | 33 | } |
33 | </style> | 34 | </style> |
34 | </head> | 35 | </head> |
35 | <body> | 36 | <body> |
36 | % /* Just call the calendar member function */ | 37 | % /* Just call the calendar member function */ |
37 | % calendar(); | 38 | % calendar(); |
38 | </body> | 39 | </body> |
39 | </html> | 40 | </html> |
40 | <%method void calendar() %> | 41 | <%method void calendar() %> |
41 | <%code> | 42 | <%code> |
42 | time_t tt = time(0); | 43 | time_t tt = time(0); |
43 | struct tm t; | 44 | struct tm t; |
44 | if(!localtime_r(&tt,&t)) | 45 | if(!localtime_r(&tt,&t)) |
45 | throw konforka::exception(CODEPOINT,"couldn't fetch current date"); | 46 | throw konforka::exception(CODEPOINT,"couldn't fetch current date"); |
46 | char h[16]; | 47 | char h[16]; |
47 | if(strftime(h,sizeof(h),"%B, %Y",&t)>=sizeof(h)) | 48 | if(strftime(h,sizeof(h),"%B, %Y",&t)>=sizeof(h)) |
48 | throw konforka::exception(CODEPOINT,"couldn't produce heading for the calendar"); | 49 | throw konforka::exception(CODEPOINT,"couldn't produce heading for the calendar"); |
49 | int today = t.tm_mday; | 50 | int today = t.tm_mday; |
50 | t.tm_mday = 1; | 51 | t.tm_mday = 1; |
51 | tt=mktime(&t); | 52 | tt=mktime(&t); |
52 | if(!localtime_r(&tt,&t)) | 53 | if(!localtime_r(&tt,&t)) |
53 | throw konforka::exception(CODEPOINT,"couldn't fetch current date"); | 54 | throw konforka::exception(CODEPOINT,"couldn't fetch current date"); |
54 | int dim = 31; | 55 | int dim = 31; |
55 | if(t.tm_mon==3 || t.tm_mon==5 || t.tm_mon==8 || t.tm_mon==10) { | 56 | if(t.tm_mon==3 || t.tm_mon==5 || t.tm_mon==8 || t.tm_mon==10) { |
56 | dim = 30; | 57 | dim = 30; |
57 | }else if(t.tm_mon==1) { | 58 | }else if(t.tm_mon==1) { |
58 | dim = (t.tm_year%4)?28:29; | 59 | dim = (t.tm_year%4)?28:29; |
59 | } | 60 | } |
60 | </%code> | 61 | </%code> |
61 | <table class="calendar"> | 62 | <table class="calendar"> |
62 | <tr> | 63 | <tr> |
63 | <th class="heading" colspan="7"><% h %></th> | 64 | <th class="heading" colspan="7"><% h %></th> |
64 | </tr> | 65 | </tr> |
65 | <tr> | 66 | <tr> |
66 | <th class="wd-0">Sun</th> | 67 | <th class="wd-0">Sun</th> |
67 | <th class="wd-1">Mon</th> | 68 | <th class="wd-1">Mon</th> |
68 | <th class="wd-2">Tue</th> | 69 | <th class="wd-2">Tue</th> |
69 | <th class="wd-3">Wed</th> | 70 | <th class="wd-3">Wed</th> |
70 | <th class="wd-4">Thu</th> | 71 | <th class="wd-4">Thu</th> |
71 | <th class="wd-5">Fri</th> | 72 | <th class="wd-5">Fri</th> |
72 | <th class="wd-6">Sat</th> | 73 | <th class="wd-6">Sat</th> |
73 | </tr> | 74 | </tr> |
74 | <%code> | 75 | <%code> |
75 | int dow=0; int dom=1-t.tm_wday; | 76 | int dow=0; int dom=1-t.tm_wday; |
76 | for(;;dom++,dow=(dow+1)%7) { | 77 | for(;;dom++,dow=(dow+1)%7) { |
77 | if(!dow) { | 78 | if(!dow) { |
78 | <%output> | 79 | <%output> |
79 | <tr> | 80 | <tr> |
80 | </%output> | 81 | </%output> |
81 | } | 82 | } |
82 | bool be = (dom>=1 && dom<=dim); | 83 | bool be = (dom>=1 && dom<=dim); |
83 | std::string ec = be?" existant":" unexistant"; | 84 | std::string ec = be?" existant":" unexistant"; |
84 | if(dom==today) | 85 | if(dom==today) |
85 | ec+=" today"; | 86 | ec+=" today"; |
86 | <%output><td class="wd-<% dow %><% ec %>"></%output> | 87 | <%output><td class="wd-<% dow %><% ec %>"></%output> |
87 | if(be) { | 88 | if(be) { |
88 | <%output><% dom %></%output> | 89 | <%output><% dom %></%output> |
89 | } | 90 | } |
90 | <%output></td></%output> | 91 | <%output></td></%output> |
91 | if(dow==6) { | 92 | if(dow==6) { |
92 | <%output> | 93 | <%output> |
93 | </tr> | 94 | </tr> |
94 | </%output> | 95 | </%output> |
95 | if(dom>=dim) | 96 | if(dom>=dim) |
96 | break; | 97 | break; |
97 | } | 98 | } |
98 | } | 99 | } |
99 | </%code> | 100 | </%code> |
100 | </table> | 101 | </table> |
101 | </%method> | 102 | </%method> |