From: rich Date: Thu, 7 Oct 2004 18:56:47 +0000 (+0000) Subject: Year view. X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=222362cfc31cfff96b41d8840feec190baf36075;p=cocanwiki.git Year view. --- diff --git a/MANIFEST b/MANIFEST index cb13c83..14fabbf 100644 --- a/MANIFEST +++ b/MANIFEST @@ -29,6 +29,7 @@ html/_graphics/mailto.png 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 @@ -59,6 +60,7 @@ scripts/cocanwiki_create_host.mli 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 @@ -162,6 +164,10 @@ templates/admin/edit_emails_form.html 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 diff --git a/html/_css/standard.css b/html/_css/standard.css index 70c16d7..a85365b 100644 --- a/html/_css/standard.css +++ b/html/_css/standard.css @@ -1,5 +1,5 @@ /* 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 { @@ -346,3 +346,70 @@ table.cal_month tr.cal_month_row li { 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; +} diff --git a/html/_graphics/pinkhatch.png b/html/_graphics/pinkhatch.png new file mode 100644 index 0000000..8f95f7c Binary files /dev/null and b/html/_graphics/pinkhatch.png differ diff --git a/scripts/cocanwiki_ext_calendar.ml b/scripts/cocanwiki_ext_calendar.ml index 2e35698..e4e2506 100644 --- a/scripts/cocanwiki_ext_calendar.ml +++ b/scripts/cocanwiki_ext_calendar.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * 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 @@ -36,6 +36,7 @@ open Cocanwiki_date 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 @@ -99,7 +100,7 @@ let extension (dbh : Dbi.connection) hostid url = | _ -> 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 @@ -113,13 +114,67 @@ let extension (dbh : Dbi.connection) hostid url = "

" ^ url ^ " is not an actual date.

" | 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 @@ -143,12 +198,12 @@ let extension (dbh : Dbi.connection) hostid url = (* 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; @@ -160,10 +215,10 @@ let extension (dbh : Dbi.connection) hostid url = 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 diff --git a/templates/calendar_year.html b/templates/calendar_year.html index e69de29..cd8fee1 100644 --- a/templates/calendar_year.html +++ b/templates/calendar_year.html @@ -0,0 +1,37 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ << + ::yyyy:: + >> +
::month1::::month2::::month3::
::month4::::month5::::month6::
::month7::::month8::::month9::
::month10::::month11::::month12::
+Pages which link to this year: + +
\ No newline at end of file diff --git a/templates/calendar_year_1m.html b/templates/calendar_year_1m.html new file mode 100644 index 0000000..ec3f784 --- /dev/null +++ b/templates/calendar_year_1m.html @@ -0,0 +1,17 @@ + + + + + + + +::table(rows):: + +::table(cols):: + +::end:: + +::end:: +
::month_name_html:: ::yyyy::
SuMoTuWeThFrSa
+ ::if(is_day)::::dd::::end:: +
\ No newline at end of file