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