html/_graphics/markup-preview.png
html/_graphics/newpage.png
html/_graphics/ok.png
+html/_graphics/pinkhatch.png
html/_graphics/tick.png
html/_graphics/xml.png
html/_js/editor.js
scripts/cocanwiki_date.ml
scripts/cocanwiki_diff.ml
scripts/cocanwiki_emailnotify.ml
+scripts/cocanwiki_ext_calendar.ml
scripts/cocanwiki_files.ml
scripts/cocanwiki_images.ml
scripts/cocanwiki_images.mli
templates/admin/edit_host_css_form.html
templates/admin/edit_hostnames_form.html
templates/admin/host.html
+templates/calendar_day.html
+templates/calendar_month.html
+templates/calendar_year.html
+templates/calendar_year_1m.html
templates/change_password_form.html
templates/contact.txt
templates/contact_show.html
/* Stylesheet for COCANWIKI.
- * $Id: standard.css,v 1.8 2004/10/07 16:54:24 rich Exp $
+ * $Id: standard.css,v 1.9 2004/10/07 18:56:48 rich Exp $
*/
body {
display: inline;
margin-right: 2em;
}
+
+table.cal_year {
+ border-collapse: collapse;
+ border: 1px solid #eee;
+ width: 90%;
+ margin-left: 5%;
+ margin-right: 5%;
+}
+
+table.cal_year th.cal_year_header {
+ background-color: #eef;
+}
+
+table.cal_year th.cal_year_header a.cal_year_left {
+ margin-right: 2em;
+}
+
+table.cal_year th.cal_year_header a.cal_year_right {
+ margin-left: 2em;
+}
+
+table.cal_year td.cal_year_month {
+ vertical-align: top;
+}
+
+table.cal_year_1m th.cal_year_1m_header {
+ background-color: #eef;
+}
+
+table.cal_year_1m th.cal_year_1m_header_weekend {
+ background-color: #fef;
+}
+
+/*
+table.cal_year_1m tr.cal_year_1m_row td {
+ height: 1.4em;
+}
+*/
+
+table.cal_year_1m tr.cal_year_1m_row a {
+ text-decoration: none;
+}
+
+table.cal_year_1m tr.cal_year_1m_row td.cal_year_1m_weekend {
+ background-color: #fef;
+}
+
+table.cal_year_1m tr.cal_year_1m_row td.cal_year_1m_events {
+ border: 2px solid #000;
+}
+
+/*
+table.cal_year_1m tr.cal_year_1m_row td.cal_year_1m_empty {
+ background: url(/_graphics/pinkhatch.png) repeat;
+}
+*/
+
+table.cal_year td.cal_year_events ul {
+ list-style: none;
+ padding: 0px;
+ margin: 0px;
+}
+
+table.cal_year td.cal_year_events ul {
+ display: inline;
+ margin-right: 2em;
+}
(* COCANWIKI - a wiki written in Objective CAML.
* Written by Richard W.M. Jones <rich@merjis.com>.
* Copyright (C) 2004 Merjis Ltd.
- * $Id: cocanwiki_ext_calendar.ml,v 1.1 2004/10/07 16:54:24 rich Exp $
+ * $Id: cocanwiki_ext_calendar.ml,v 1.2 2004/10/07 18:56:53 rich Exp $
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
let day_template = _get_template "calendar_day.html"
let month_template = _get_template "calendar_month.html"
let year_template = _get_template "calendar_year.html"
+let year_1m_template = _get_template "calendar_year_1m.html"
let rec range a b =
if a <= b then
| _ -> assert false) in
List.filter_map
(fun (from_url, title, to_url) ->
- try let date = valid_date to_url in Some (date, title, from_url)
+ try let date = valid_date to_url in Some (date, (title, from_url))
with Not_found -> None) results in
let pages = List.sort pages in
"<p>" ^ url ^ " is not an actual date.</p>"
| Some (yyyy, 0, 0) -> (* Year view. *)
let template = year_template in
- failwith "not impl";
-
-
-
-
+ template#set "yyyy" (string_of_int yyyy);
+ template#set "prev_yyyy" (string_of_int (yyyy - 1));
+ template#set "next_yyyy" (string_of_int (yyyy + 1));
+
+ (* Return true if there are any events on a particular day. *)
+ let has_events date = List.exists (fun (d, _) -> date = d) pages in
+
+ (* Generate each month template separately ...
+ * Wow, finally found a place I can use a for loop.
+ *)
+ for mm = 1 to 12 do
+ let str =
+ let template = year_1m_template in
+ template#set "yyyy" (string_of_int yyyy);
+ template#set "mm" (sprintf "%02d" mm);
+ template#set "month_name" (long_month mm);
+ let dow = GregorianDate.day_of_week (yyyy, mm, 1) in
+ let dow = if dow = 7 then 0 else dow in
+ let max_dd = GregorianDate.days_in_month yyyy mm in
+ let dd = ref (1-dow) in
+ let rows = ref [] in
+ for r = 0 to 5 do (* up to 5 rows ... *)
+ let cols = ref [] in
+ for c = 0 to 6 do (* 7 columns, Sunday - Saturday *)
+ let is_day = !dd >= 1 && !dd <= max_dd in
+ let clasz =
+ if is_day then (
+ let date = yyyy, mm, !dd in
+ let is_weekend = GregorianDate.day_of_week date >= 6 in
+ let events = has_events date in
+ (if is_weekend then "cal_year_1m_weekend " else "") ^
+ (if events then "cal_year_1m_events" else "")
+ ) else
+ "cal_year_1m_empty" in
+ let col =
+ [ "is_day", Template.VarConditional is_day;
+ "dd", Template.VarString (sprintf "%02d" !dd);
+ "class", Template.VarString clasz ] in
+ cols := col :: !cols;
+ incr dd
+ done;
+ rows := [ "cols", Template.VarTable (List.rev !cols) ] :: !rows;
+ cols := []
+ done;
+
+ template#table "rows" (List.rev !rows);
+
+ template#to_string in
+ template#set ("month" ^ string_of_int mm) str
+ done;
+
+ (* Annual events. *)
+ let events =
+ List.filter (function ((_, 0, 0), _) -> true | _ -> false) pages in
+ let table =
+ List.map (fun (_, (title, page)) ->
+ [ "title", Template.VarString title;
+ "page", Template.VarString page ]) events in
+ template#table "events" table;
template#to_string
(* Get all monthly events and all daily events. *)
let monthly_events, daily_events =
- List.partition (function ((_, _, 0), _, _) -> true | _ -> false)
+ List.partition (function ((_, _, 0), _) -> true | _ -> false)
pages in
(* Table of monthly events. *)
let table =
- List.map (fun (_, title, page) ->
+ List.map (fun (_, (title, page)) ->
[ "title", Template.VarString title;
"page", Template.VarString page ]) monthly_events in
template#table "monthly_events" table;
let table =
List.map (fun dd ->
let events =
- List.filter (fun ((_, _, d), _, _) -> d = dd)
+ List.filter (fun ((_, _, d), _) -> d = dd)
daily_events in
let table =
- List.map (fun (_, title, page) ->
+ List.map (fun (_, (title, page)) ->
[ "title", Template.VarString title;
"page", Template.VarString page ])
events in
+<table class="cal_year">
+<tr>
+<th colspan="3" class="cal_year_header">
+ <a href="/::prev_yyyy::" class="cal_year_left" title="Previous year"><<</a>
+ ::yyyy::
+ <a href="/::next_yyyy::" class="cal_year_right" title="Next year">>></a>
+</th>
+</tr>
+<tr>
+ <td class="cal_year_month">::month1::</td>
+ <td class="cal_year_month">::month2::</td>
+ <td class="cal_year_month">::month3::</td>
+</tr>
+<tr>
+ <td class="cal_year_month">::month4::</td>
+ <td class="cal_year_month">::month5::</td>
+ <td class="cal_year_month">::month6::</td>
+</tr>
+<tr>
+ <td class="cal_year_month">::month7::</td>
+ <td class="cal_year_month">::month8::</td>
+ <td class="cal_year_month">::month9::</td>
+</tr>
+<tr>
+ <td class="cal_year_month">::month10::</td>
+ <td class="cal_year_month">::month11::</td>
+ <td class="cal_year_month">::month12::</td>
+</tr>
+<tr class="cal_year_events">
+<td colspan="3" class="cal_year_events">
+Pages which link to this year:
+<ul>
+::table(events)::<li><a href="/::page::">::title_html::</a></li>::end::
+</ul>
+</td>
+</tr>
+</table>
\ No newline at end of file