olelo 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. data/.travis.yml +4 -0
  2. data/Rakefile +6 -12
  3. data/bin/olelo +13 -8
  4. data/config.ru +21 -15
  5. data/config/aspects.rb +45 -32
  6. data/config/config.yml.default +1 -0
  7. data/config/initializers/00-mime_types.rb +22 -17
  8. data/config/initializers/01-slim.rb +2 -2
  9. data/lib/olelo.rb +1 -8
  10. data/lib/olelo/application.rb +33 -34
  11. data/lib/olelo/attributes.rb +4 -4
  12. data/lib/olelo/extensions.rb +0 -7
  13. data/lib/olelo/helper.rb +13 -25
  14. data/lib/olelo/html_safe.rb +0 -4
  15. data/lib/olelo/locale.yml +6 -3
  16. data/lib/olelo/menu.rb +1 -1
  17. data/lib/olelo/page.rb +21 -18
  18. data/lib/olelo/version.rb +1 -1
  19. data/olelo.gemspec +5 -3
  20. data/plugins/aspects/changelog.rb +5 -5
  21. data/plugins/aspects/documentbrowser.rb +5 -5
  22. data/plugins/{gallery → aspects/gallery}/gallery.css +0 -0
  23. data/plugins/{gallery → aspects/gallery}/gallery.scss +0 -0
  24. data/plugins/{gallery → aspects/gallery}/main.rb +3 -3
  25. data/plugins/aspects/highlight.rb +1 -1
  26. data/plugins/aspects/image.rb +1 -1
  27. data/plugins/aspects/imageinfo.rb +3 -3
  28. data/plugins/aspects/main.rb +21 -21
  29. data/plugins/aspects/pageinfo.rb +2 -2
  30. data/plugins/aspects/source.rb +1 -1
  31. data/plugins/aspects/subpages.rb +7 -7
  32. data/plugins/aspects/text.rb +1 -1
  33. data/plugins/authentication/portal.rb +2 -2
  34. data/plugins/authentication/yamlfile.rb +1 -1
  35. data/plugins/blog/main.rb +10 -10
  36. data/plugins/editor/preview.rb +3 -3
  37. data/plugins/filters/creole.rb +1 -1
  38. data/plugins/filters/editsection.rb +2 -2
  39. data/plugins/filters/html2xml.rb +6 -0
  40. data/plugins/filters/main.rb +1 -1
  41. data/plugins/filters/remind/main.rb +15 -0
  42. data/plugins/filters/remind/rem2html +562 -0
  43. data/plugins/filters/s5/main.rb +1 -1
  44. data/plugins/login/persistent.rb +1 -1
  45. data/plugins/misc/system.rb +4 -0
  46. data/plugins/misc/variables.rb +1 -1
  47. data/plugins/misc/webdav.rb +10 -10
  48. data/plugins/repositories/git_grep.rb +2 -2
  49. data/plugins/repositories/gitrb_repository.rb +10 -10
  50. data/plugins/repositories/rugged_repository.rb +7 -7
  51. data/plugins/tags/code.rb +1 -1
  52. data/plugins/tags/footnotes.rb +4 -3
  53. data/plugins/tags/gist.rb +2 -2
  54. data/plugins/tags/html.rb +11 -11
  55. data/plugins/tags/include.rb +6 -6
  56. data/plugins/tags/main.rb +10 -10
  57. data/plugins/tags/math.rb +2 -2
  58. data/plugins/tags/redirect.rb +3 -3
  59. data/plugins/tags/scripting.rb +12 -12
  60. data/plugins/tags/sort.rb +1 -1
  61. data/plugins/tags/tabs.rb +1 -1
  62. data/plugins/treeview/main.rb +3 -3
  63. data/plugins/treeview/script.js +5 -5
  64. data/plugins/treeview/script/00-jquery.treeview.js +6 -6
  65. data/plugins/treeview/script/init.js +1 -1
  66. data/plugins/utils/assets.rb +4 -4
  67. data/plugins/utils/cache.rb +10 -6
  68. data/plugins/utils/store.rb +4 -4
  69. data/static/script.js +124 -126
  70. data/static/script/{02-jquery.js → 01-jquery.js} +0 -0
  71. data/static/script/02-olelo.storage.js +54 -0
  72. data/static/script/10-olelo.historytable.js +2 -2
  73. data/static/script/13-olelo.tabwidget.js +2 -2
  74. data/test/helper.rb +5 -4
  75. data/test/page_test.rb +1 -1
  76. data/test/request_test.rb +42 -38
  77. data/test/string_extensions_test.rb +0 -6
  78. data/test/templates_test.rb +1 -1
  79. data/test/util_test.rb +1 -1
  80. data/views/changes.slim +2 -2
  81. data/views/compare.slim +4 -4
  82. data/views/delete.slim +2 -2
  83. data/views/deleted.slim +1 -1
  84. data/views/edit.slim +31 -26
  85. data/views/history.slim +5 -5
  86. data/views/layout.slim +1 -1
  87. data/views/login.slim +30 -32
  88. data/views/move.slim +3 -3
  89. data/views/profile.slim +2 -2
  90. data/views/show.slim +1 -1
  91. metadata +43 -104
  92. data/static/script/01-jstorage.js +0 -217
@@ -0,0 +1,15 @@
1
+ description 'Filter which converts remind calendars to html'
2
+
3
+ Filter.create :remind do |context, content|
4
+ unless context.params[:date]
5
+ throw :redirect, build_path(context.page.path,
6
+ context.request.params.merge(date: Time.now.strftime('%Y-%m')))
7
+ end
8
+ months = (context.params[:months] || 2).to_i
9
+ date = context.params[:date].split('-', 2)
10
+ date = Time.new(date.first.to_i, date.last.to_i).strftime('%Y/%m/01')
11
+ Shell.new.
12
+ remind('-m', '-p', "-c#{months}", '-', date).
13
+ perl(File.join(File.dirname(__FILE__), 'rem2html'), '--tableonly').
14
+ run(content)
15
+ end
@@ -0,0 +1,562 @@
1
+ #!/usr/bin/perl
2
+
3
+ # rem2html
4
+ #
5
+ # A script to convert from the output of "remind -p" to Hyper-Text Markup
6
+ # Language (HTML), the text format used in WWW documents. By default, it
7
+ # outputs a stand-alone file which can be fed directly into a web browser.
8
+ # The output uses nested <TABLE> blocks, so it will only work in a browser
9
+ # which supports tables (Netscape, MSIE, etc, NOT Lynx).
10
+ #
11
+ # This script works well on my computer (Linux 2.0.27) under Perl 5.003 and
12
+ # 5.004. It should work fine on other unices but I have no idea whether
13
+ # it will run under VMS, OS/2, Windows, etc.
14
+ #
15
+ # [Note from David: The REMIND license prohibits you from using REMIND
16
+ # under Windows.]
17
+ #
18
+ # Rem2html puts "normal" CAL or MSG-type reminders in a <P></P> pair,
19
+ # and escapes any special HTML characters.
20
+ #
21
+ # If you want to put actual HTML code in the calendar (hyper-links, for
22
+ # example), use the "SPECIAL HTML" type. For example:
23
+ #
24
+ # REM Wed SPECIAL HTML <P> Meeting at \
25
+ # <A HREF="http://www.linuxhq.com">Linux HQ</A> </P>
26
+ #
27
+ # This file is Copyright (C) 1997-8 by Don Schwarz <darkowl@mcs.net>
28
+ # and David F. Skoll
29
+ #
30
+ # v1.2-beta, Hal Burgiss <hal@foobox.net> 03/03/05
31
+ #
32
+ # Changelog:
33
+ #
34
+ # - Fixed some mark-up mishaps for calendars with multiple months.
35
+ # - Added provision for a default CSS stylesheet (remind.css), and various
36
+ # related mark-up additions.
37
+ # - Added a 'nomini' option for eliminating the 'small calendar' thumbnails.
38
+ # - Added a 'title' option for HTML page title.
39
+ # - Added a 'print' option for nicer print look.
40
+ # - Added a 'months' option to control the size of the calendar.
41
+ # - Added a 'dtd' option to allow control of the document DTD.
42
+ # - Added some minor mark-up changes/improvements, eg xhtml compliant.
43
+ # - Added capability to grok remind data from within rem2html, looking for
44
+ # cgi type output, with -x option.
45
+ #
46
+ # A work in progress at this point.
47
+ #
48
+ #
49
+ ########################################################################
50
+
51
+ use Getopt::Long;
52
+
53
+ @months = (January,February,March,April,May,June,July,August,September,October,November,December);
54
+ $def_width = '14%';
55
+
56
+ $DefaultImageDir = "%IMAGEBASE%";
57
+ $DefaultImageDir = "/images";
58
+ if ($DefaultImageDir =~ m@/$@) {
59
+ chop $DefaultImageDir;
60
+ }
61
+
62
+ $rem2html_version = "1.2-beta";
63
+
64
+ &parse_options();
65
+
66
+ # Backgound color -- unfortunately, most Web browsers (as of 14 October 1999)
67
+ # do not correctly handle transparency in PNG images, so I had to make the
68
+ # moon image background white.
69
+ $Options{'bgcolor'} ||= "bgcolor=\"#FFFFFF\"";
70
+
71
+ # if (-t STDIN) {
72
+ # print STDERR "(Rem2HTML: Input should not come from a terminal.)\n";
73
+ # $Options{'help'} = 1;
74
+ # }
75
+
76
+ if ($Options{'help'}) {
77
+ &show_usage();
78
+ } elsif ($Options{'version'}) {
79
+ print "Rem2HTML Version $rem2html_version.\n";
80
+ } else {
81
+ $successes = 0;
82
+ $today = &today();
83
+ $num = ($Options{'months'}) ? $Options{'months'} : 3;
84
+ # get the data from remind here.
85
+ $Options{'x'} && open STDIN, "$Options{'x'} |" || die "<b>Unable to open todo file</b><br>";
86
+ if (-t STDIN) {
87
+ print STDERR "(Rem2HTML: Input should not come from a terminal.)\n";
88
+ &show_usage();
89
+ } else {
90
+ while(1) {
91
+ last if (!parse_input());
92
+ $successes++;
93
+ &output_header();
94
+ &output_data();
95
+ &output_footer();
96
+ }
97
+ print STDERR "Rem2HTML: Couldn't find any calendar data.\n" if (!$successes);
98
+ unless ($Options{'tableonly'}) {
99
+ print <<EndOfHTML;
100
+ </body>
101
+ </html>
102
+ EndOfHTML
103
+ }
104
+ }
105
+ exit(0);
106
+
107
+ sub show_usage {
108
+ print STDERR <<EndOfUsage;
109
+ Rem2HTML: Produce a HTML calendar from the output of Remind.
110
+
111
+ Usage: rem2html [options]
112
+
113
+ Options:
114
+
115
+ --help, -h Print this information
116
+ --version Version information
117
+ --dtd,-d file Use this file as the DTD specification.
118
+ -p file Prepend the specified HTML file to the beginning of the
119
+ HTML output
120
+ -a file Append the specified HTML file to the end of the output
121
+ -f[shted] font Set font for small cal, hdr, title, cal entries,day numbers
122
+ -s[hted] size Set size for header, title, calendar entries and/or day
123
+ numbers
124
+ --backurl url Make the title on the previous month's small calendar entry
125
+ a hyperlink to <url>
126
+ --forwurl url Same as --backurl, but with the next month's small calendar
127
+ --tableonly Output the results as a <TABLE> block only, no <HTML>, etc.
128
+ --title name Set HTML <title>
129
+ --nomini Omit the small calendar thumbnails for previous/next months.
130
+ --months, -m num Number of months for calendar to display.
131
+ --print Minor changes to facilitate a more printable page.
132
+ --border,-b size Set the border thickness of the table
133
+ --cellspace,-t size Set the line thickness of the table
134
+ --bgcolor,-g color Set the background color for the day entries
135
+ -x cmd Run the specified remind command from within rem2html.
136
+
137
+ EndOfUsage
138
+
139
+ }
140
+
141
+ sub escape_html {
142
+ my($in) = @_;
143
+ $in =~ s/\&/\&amp;/g;
144
+ $in =~ s/\</\&lt;/g;
145
+ $in =~ s/\>/\&gt;/g;
146
+ return $in;
147
+ }
148
+
149
+ sub parse_options {
150
+ %Options = ();
151
+
152
+ GetOptions (\%Options, "help|h",
153
+ "version",
154
+ "border|b=i",
155
+ "cellspace|t=i",
156
+ "dtd|d=s",
157
+ "backurl|bu:s", "forwurl|fu:s",
158
+ "tableonly|to",
159
+ "title|ti:s",
160
+ "nomini|nm",
161
+ "months|m:i",
162
+ "prologue|p=s",
163
+ "print",
164
+ "append|a=s",
165
+ "bgcolor|g=s",
166
+ "x:s",
167
+ "fs=s", "fh=s", "ft=s", "fe=s", "fd=s",
168
+ "sh=i", "st=i", "se=i", "sd=i",
169
+ );
170
+
171
+ $Options{'border'} = "border=" . ($Options{'border'} || 1);
172
+ $Options{'cellspace'} &&= "cellspacing=$Options{'cellspace'}";
173
+ $Options{'bgcolor'} &&= "bgcolor=$Options{'bgcolor'}";
174
+ $Options{'title'} = ($Options{'title'}) ? $Options{'title'} : "Calendar";
175
+ }
176
+
177
+ sub parse_input {
178
+ local $where = 0;
179
+ local $msg;
180
+ local $type;
181
+ local $day;
182
+ my $title;
183
+ @days = ();
184
+ @shades = ();
185
+ @moons = ();
186
+ while (<>) {
187
+ chomp($_);
188
+ if (/rem2(html|ps) begin/) {
189
+ } elsif (!$where) {
190
+ next;
191
+ } elsif ($where == 1) {
192
+ # local ($month, $year); # need this later.
193
+ ($month, $year, $month_length, $firstday, $mfirst) = split(" ");
194
+ $caption = "$month, $year";
195
+ for $i ( 1 .. $month_length) { push(@days, ""); }
196
+ } elsif ($where == 2) {
197
+ @DayNames = split(" ");
198
+ } elsif ($where == 3) {
199
+ @prevsc = split(" ");
200
+ } elsif ($where == 4) {
201
+ @nextsc = split(" ");
202
+ } else {
203
+ return 1 if /rem2(html|ps) end/;
204
+ next unless m/^(\d*).(\d*).(\d*)\s+(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s*(.*)$/;
205
+ $type = $4;
206
+ $msg = $8;
207
+ $day = $3;
208
+ if ($type eq "HTML") {
209
+ $days[$day] .= "$msg ";
210
+ } elsif ($type eq "MOON") {
211
+ my($phase, $text);
212
+ if ($msg =~ /^\s*(\d+)\s+\S+\s+\S+\s+(.*)$/) {
213
+ $phase = $1;
214
+ $text = $2;
215
+ } elsif ($msg =~ /^\s*(\d+)/) {
216
+ $phase = $1;
217
+ $text = "";
218
+ } else {
219
+ next;
220
+ }
221
+ next if ($phase > 3);
222
+ if ($phase == 0) {
223
+ $text = "<image src=\"$DefaultImageDir/newmoon.png\" alt=\"New Moon\"" .
224
+ "width=16 height=16> <font size=\"-2\">" . escape_html($text);
225
+ } elsif ($phase == 1) {
226
+ $text = "<image src=\"$DefaultImageDir/firstquarter.png\" alt=\"First Quarter\"" .
227
+ "width=16 height=16> <font size=\"-2\">" . escape_html($text);
228
+ } elsif ($phase == 2) {
229
+ $text = "<span class=\"moon\" >Full </span><image src=\"$DefaultImageDir/fullmoon.png\" alt=\"Full Moon\"" .
230
+ "width=16 height=16> <font size=\"-2\">\&nbsp;" . escape_html($text);
231
+ } else {
232
+ $text = "<image src=\"$DefaultImageDir/lastquarter.png\" alt=\"Last Quarter\"" .
233
+ "width=16 height=16> <font size=\"-2\">" . escape_html($text);
234
+ }
235
+ $moons[$day] = $text . "</font> ";
236
+ } elsif ($type eq "SHADE") {
237
+ my($red, $green, $blue);
238
+ if ($msg =~ /^\s*(\d+)\s+(\d+)\s+(\d+)\s*$/) {
239
+ $red = $1;
240
+ $green = $2;
241
+ $blue = $3;
242
+ } elsif ($msg =~ /^\s*(\d+)\s*$/) {
243
+ $red = $1;
244
+ $green = $1;
245
+ $blue = $1;
246
+ } else {
247
+ next;
248
+ }
249
+ next if ($red > 255 || $green > 255 || $blue > 255);
250
+ # shading done here
251
+ $shades[$day] = sprintf(" class=\"shaded\" bgcolor=\"#%02X%02X%02X\"",
252
+ $red, $green, $blue);
253
+ } elsif ($type eq "*") {
254
+ # this is the MSG from remind
255
+ $title = $msg if ( $msg =~ /DETAIL:/ );
256
+ $title =~ s/.*DETAIL: //;
257
+ $msg =~ s/DETAIL: .*//;
258
+ $title = "title=\"$title\"" if (length($title) > 0);
259
+ $msg = &escape_html($msg);
260
+ # $days[$day] .= "<p class=\"msg\"><a href='#' $title>$msg</a></p>";
261
+ # $days[$day] .= "<p class=\"msg\"><span $title>$msg</span></p>";
262
+ $days[$day] .= "<span class=\"msg\" $title>$msg</span><br/>";
263
+ }
264
+ }
265
+ $where++;
266
+ }
267
+ if ($where) {
268
+ return 1;
269
+ }
270
+ return 0;
271
+ }
272
+
273
+ sub output_header {
274
+ local ($title, $dayheader);
275
+ my $width="100%";
276
+ my $class = ($Options{'print'}) ? 'class="printable"' : "";
277
+ if ($successes eq 1) {
278
+ if (!$Options{'tableonly'}) {
279
+ if ($Options{'dtd'}) {
280
+ open(DTD, "< $Options{'dtd'}");
281
+ print while ( <DTD> );
282
+ close(DTD);
283
+ }
284
+ print <<EndOfHTML;
285
+ <html>
286
+ <head><title>$Options{'title'}</title>
287
+ <meta http-equiv="refresh" content="1200">
288
+ <link rel="stylesheet" id="mainStyle" href="remind.css" type="text/css" />
289
+ <script language="javascript">
290
+ <!--
291
+ function hotbox_on(name) {
292
+ if (name == "nada") {
293
+ return false;
294
+ }
295
+ oldcolor=document.getElementById(name).style.borderColor;
296
+ document.getElementById(name).style.borderColor="pink" ;
297
+ document.getElementById(name).style.borderWidth="3px" ;
298
+ return true;
299
+ }
300
+ function hotbox_off(name) {
301
+ if (name == "nada") {
302
+ return false;
303
+ }
304
+ oldcolor="black";
305
+ document.getElementById(name).style.borderWidth="1px" ;
306
+ document.getElementById(name).style.borderColor=oldcolor ;
307
+ return true;
308
+ }
309
+ // END -->
310
+ </script>
311
+ </head><body $class $Options{'bgcolor'} >
312
+
313
+ EndOfHTML
314
+ }
315
+
316
+ print <<EndOfHTML;
317
+ <!--
318
+ This output was produced by Rem2HTML $rem2html_version (written by
319
+ Don Schwarz <darkowl\@mcs.net>, updated and modified by Hal Burgiss
320
+ <hal\@foobox.net>), and Remind (written by David F. Skoll).
321
+ -->
322
+
323
+ EndOfHTML
324
+ }
325
+
326
+ if ($Options{'prologue'}) {
327
+ open(PROLOGUE, "< $Options{'prologue'}");
328
+ print while ( <PROLOGUE> );
329
+ close(PROLOGUE);
330
+ }
331
+
332
+ $caption = &format_font($caption, $Options{'ft'}, $Options{'st'} || "+1");
333
+
334
+ print <<EndOfHTML;
335
+ <div class="calendar" id="$month$year">
336
+ <table class="caltable" $Options{'border'} $Options{'cellspace'} $Options{'bgcolor'} width=100%>
337
+ <caption><strong>$caption</strong></caption>
338
+ <tr>
339
+ EndOfHTML
340
+
341
+ $mfirst || &print_day_header($DayNames[0]);
342
+
343
+ for($i=1; $i<7; $i++) {
344
+ &print_day_header($DayNames[$i]);
345
+ }
346
+
347
+ $mfirst && &print_day_header($DayNames[0]);
348
+ print "</tr>\n";
349
+ }
350
+
351
+ sub output_footer {
352
+ print "</table></div><p></p>\n\n";
353
+
354
+ if ($Options{'append'}) {
355
+ open(EPILOGUE, "< $Options{'append'}");
356
+ print while ( <EPILOGUE> );
357
+ close(EPILOGUE);
358
+ }
359
+
360
+ }
361
+ }
362
+
363
+ sub output_data {
364
+ local ($endday, $prevday, $nextday, $week, $weekday);
365
+ local ($element, $day, $msg, $fday, $id, $cell);
366
+ $firstday -= $mfirst;
367
+ if ($firstday < 0) { $firstday += 7; }
368
+ $endday = $firstday + $month_length;
369
+ $endweek = $endday + (6 - ($endday % 7));
370
+ $endday %= 7;
371
+
372
+ if ( $firstday > 1 ) {
373
+ $prevday = 0;
374
+ $nextday = 1;
375
+ } elsif ($endday ? ($endday < 5) : !$firstday) {
376
+ $prevday = $endweek - 1;
377
+ $nextday = $endweek;
378
+ } else {
379
+ $prevday = 0;
380
+ $nextday = $endweek;
381
+ }
382
+
383
+ for $week ( 0..5 ) {
384
+ print " <tr>\n";
385
+ for $weekday ( 0..6 ) {
386
+ $element = ($week * 7) + ($weekday * 1);
387
+ $day = $element - $firstday + 1;
388
+ $cell = ($Options{'print'}) ? "print" :"cell";
389
+ $msg = $days[$day];
390
+ $id = $Options{'print'} ? "nada" : &fdate($day,$month,$year) ;
391
+ $id = "today" if ("$today" eq "$id");
392
+ $id = "nada" if ( "$id" ne "today" && (length($msg) eq 0) );
393
+ $msg = $msg ? &format_font($msg, $Options{'fe'}, $Options{'se'})
394
+ : " <br> <br> <br> <br>";
395
+ $fday = &format_font($day, $Options{'fd'}, $Options{'sd'} || -1);
396
+ if ($day > 0 && $day <= $month_length) {
397
+ # day numeral is here.
398
+ print <<EndOfHTML;
399
+ <td class="$cell" id="$id" onmousedown='hotbox_on("$id");' onmouseup='hotbox_off("$id");' height="120" valign=top width=$def_width $shades[$day]>
400
+ <div class="innercell">
401
+ <div class="numeral">$moons[$day]$fday</div>
402
+ </div><p></p>
403
+ <div class="bottomcell">
404
+ $msg
405
+ </div></td>
406
+ EndOfHTML
407
+
408
+ } elsif ($element == $prevday) {
409
+ &small_calendar(@prevsc, 1, $Options{'backurl'});
410
+ } elsif ($element == $nextday) {
411
+ &small_calendar(@nextsc, 2, $Options{'forwurl'});
412
+ } else {
413
+ print " <td width=$def_width><BR></TD>";
414
+ }
415
+ }
416
+ print " </tr>\n";
417
+ last if $day >= $month_length && $element >= $nextday;
418
+ }
419
+ }
420
+
421
+ sub small_calendar {
422
+ local ($scname, $scn, $which, $url) = @_;
423
+ local ($scstart, $l, $week, $weekday, $tday);
424
+ $scname = "<a href=\"$url\">$scname</a>", if $url;
425
+ $scname = &format_font($scname, $Options{'fs'}, -2);
426
+
427
+ if ($which == 1) {
428
+ $scstart = $firstday - ($scn % 7);
429
+ if ($scstart < 0) { $scstart += 7; }
430
+ } else {
431
+ $scstart = $firstday + ($month_length % 7);
432
+ if ($scstart > 6) { $scstart -= 7; }
433
+ }
434
+
435
+
436
+ if ($Options{'nomini'}) {
437
+ # Skip the 'small cal' stuff HB
438
+ print "<td width=$def_width valign=TOP>
439
+ <table width=100%>
440
+ <tr><td></td></tr>
441
+ </table>
442
+ </td>";
443
+ return 1;
444
+ }
445
+
446
+ print <<EndOfHTML;
447
+ <td width=$def_width valign=top>
448
+ <table width=100%>
449
+ <caption><strong>$scname</strong></caption>
450
+ <tr>
451
+ EndOfHTML
452
+
453
+ $mfirst || &print_day_header(substr($DayNames[0], 0, 1), 1);
454
+
455
+ for ($i=1; $i<7; $i++) {
456
+ &print_day_header(substr($DayNames[$i], 0, 1), 1);
457
+ }
458
+
459
+ $mfirst && &print_day_header(substr($DayNames[0], 0, 1), 1);
460
+
461
+ print "</tr>\n";
462
+
463
+ for $week ( 0..5 ) {
464
+ print " <tr>\n";
465
+ for $weekday ( 0..6 ) {
466
+ $tday = ($week * 7) + ($weekday * 1) - $scstart + 1;
467
+ $tday = "", if $tday <= 0 || $tday > $scn;
468
+ print " <td width=$def_width><font size=-2>$tday</font></td>\n";
469
+ }
470
+ print " </tr>\n";
471
+ last if $tday >= $scn;
472
+ }
473
+
474
+ print <<EndOfHTML;
475
+ </table>
476
+ </td>
477
+ EndOfHTML
478
+
479
+ }
480
+
481
+ sub format_font {
482
+ local ($text, $font, $size) = @_;
483
+
484
+ if (!$text) {
485
+ return "";
486
+ } elsif ($font && $size) {
487
+ return "<font face=$font size=$size>$text</font>";
488
+ } elsif ($font) {
489
+ return "<font face=$font>$text</font>";
490
+ } elsif ($size) {
491
+ return "<font size=$size>$text</font>";
492
+ } else {
493
+ return $text;
494
+ }
495
+ }
496
+
497
+ sub print_day_header {
498
+ local ($dheader, $small) = @_;
499
+
500
+ if ($small) {
501
+ $dheader = &format_font($dheader, $Options{'fs'}, -2);
502
+ } else {
503
+ $dheader = &format_font($dheader, $Options{'fh'}, $Options{'sh'});
504
+ }
505
+
506
+ print " <th width=$def_width>$dheader</th>\n";
507
+ }
508
+
509
+ sub fdate($day,$month,$year) {
510
+ my $fday=$day;
511
+ my $fmon;
512
+
513
+ if ($day < 10 ) {
514
+ $fday = "0$fday";
515
+ }
516
+
517
+ if ($month eq "January") {
518
+ $fmon="01";
519
+ } elsif ( $month eq "February" ) {
520
+ $fmon="02";
521
+ } elsif ( $month eq "March" ) {
522
+ $fmon="03";
523
+ } elsif ( $month eq "April" ) {
524
+ $fmon="04";
525
+ } elsif ( $month eq "May" ) {
526
+ $fmon="05";
527
+ } elsif ( $month eq "June" ) {
528
+ $fmon="06";
529
+ } elsif ( $month eq "July" ) {
530
+ $fmon="07";
531
+ } elsif ( $month eq "August" ) {
532
+ $fmon="08";
533
+ } elsif ( $month eq "September" ) {
534
+ $fmon="09";
535
+ } elsif ( $month eq "October" ) {
536
+ $fmon="10";
537
+ } elsif ( $month eq "November" ) {
538
+ $fmon="11";
539
+ } elsif ( $month eq "December" ) {
540
+ $fmon="12";
541
+ }
542
+
543
+ return ("$fday$fmon$year");
544
+
545
+ }
546
+
547
+ sub today() {
548
+ my($s,$t,$a,$mday,$mon,$year) = localtime(time);
549
+ $year+=1900;
550
+ $mon++;
551
+
552
+ if ( $mday < 10 ) {
553
+ $mday = "0$mday";
554
+ }
555
+
556
+ if ( $mon < 10 ) {
557
+ $mon = "0$mon";
558
+ }
559
+
560
+ return "$mday$mon$year";
561
+
562
+ }