From 34f804bb80902490c619e85759ab110fc440a838 Mon Sep 17 00:00:00 2001 From: rich Date: Mon, 1 Nov 2004 17:46:21 +0000 Subject: [PATCH] "Versions of this page" and "Recent changes" RSS feeds. Not been able to check that these actually work yet however. --- MANIFEST | 8 ++- conf/cocanwiki.conf | 6 ++- scripts/.depend | 12 ++++- scripts/history.ml | 3 +- scripts/history_rss.ml | 103 ++++++++++++++++++++++++++++++++++++ scripts/{rss.ml => page_rss.ml} | 2 +- scripts/recent_rss.ml | 103 ++++++++++++++++++++++++++++++++++++ templates/history.html | 4 ++ templates/history_rss.xml | 29 ++++++++++ templates/{rss.xml => page_rss.xml} | 0 templates/recent.html | 1 + templates/recent_rss.xml | 29 ++++++++++ 12 files changed, 292 insertions(+), 8 deletions(-) create mode 100644 scripts/history_rss.ml rename scripts/{rss.ml => page_rss.ml} (98%) create mode 100644 scripts/recent_rss.ml create mode 100644 templates/history_rss.xml rename templates/{rss.xml => page_rss.xml} (100%) create mode 100644 templates/recent_rss.xml diff --git a/MANIFEST b/MANIFEST index 4fa2701..999c0ac 100644 --- a/MANIFEST +++ b/MANIFEST @@ -118,6 +118,7 @@ scripts/files.ml scripts/forgot_password.ml scripts/forgot_password_form.ml scripts/history.ml +scripts/history_rss.ml scripts/host_menu.ml scripts/hoststyle.ml scripts/image.ml @@ -171,14 +172,15 @@ scripts/page_email_confirm.ml scripts/page_email_form.ml scripts/page_email_send.ml scripts/page_email_unsubscribe.ml +scripts/page_rss.ml scripts/pagestyle.ml scripts/preview.ml scripts/rebuild_links.ml scripts/recent.ml +scripts/recent_rss.ml scripts/recently_visited.ml scripts/restore.ml scripts/restore_form.ml -scripts/rss.ml scripts/search.ml scripts/send_feedback.ml scripts/send_feedback_form.ml @@ -242,6 +244,7 @@ templates/files.html templates/footer.html templates/forgot_password_form.html templates/history.html +templates/history_rss.xml templates/host_menu.html templates/images.html templates/invite_user.txt @@ -265,13 +268,14 @@ templates/page.html templates/page_404.html templates/page_email_form.html templates/page_email_send.txt +templates/page_rss.xml templates/rebuild_links.html templates/rebuild_links_done.html templates/rebuild_links_start.html templates/recent.html +templates/recent_rss.xml templates/recently_visited.html templates/restore_form.html -templates/rss.xml templates/send_feedback.txt templates/send_feedback_form.html templates/set_password_form.html diff --git a/conf/cocanwiki.conf b/conf/cocanwiki.conf index 69ac832..a0aab97 100644 --- a/conf/cocanwiki.conf +++ b/conf/cocanwiki.conf @@ -1,5 +1,5 @@ # Apache configuration for COCANWIKI. -# $Id: cocanwiki.conf,v 1.17 2004/10/27 21:14:05 rich Exp $ +# $Id: cocanwiki.conf,v 1.18 2004/11/01 17:46:21 rich Exp $ # Uncomment the following lines if necessary. You will probably need # to adjust the paths to reflect where cocanwiki is really installed. @@ -68,6 +68,7 @@ RewriteRule ^/_ml_unsub$ /_bin/mailing_list_unsubscribe.cmo [PT,L,QSA] RewriteRule ^/_pe_confirm$ /_bin/page_email_confirm.cmo [PT,L,QSA] RewriteRule ^/_pe_unsub$ /_bin/page_email_unsubscribe.cmo [PT,L,QSA] RewriteRule ^/_recent$ /_bin/recent.cmo [PT,L,QSA] +RewriteRule ^/_recent.rss$ /_bin/recent_rss.cmo [PT,L,QSA] RewriteRule ^/_sitemap$ /_bin/sitemap.cmo [PT,L,QSA] RewriteRule ^/_userprefs$ /_bin/user_prefs_form.cmo [PT,L,QSA] RewriteRule ^/_users$ /_bin/users.cmo [PT,L,QSA] @@ -85,7 +86,8 @@ RewriteRule ^/([^_].*)/edit$ /_bin/edit.cmo?page=$1 [PT,L,QSA] RewriteRule ^/([^_].*)/editcss$ /_bin/edit_page_css_form.cmo?page=$1 [PT,L,QSA] RewriteRule ^/([^_].*)/edittitle$ /_bin/edit_page_title_form.cmo?page=$1 [PT,L,QSA] RewriteRule ^/([^_].*)/history$ /_bin/history.cmo?page=$1 [PT,L,QSA] -RewriteRule ^/([^_].*)/index.rss$ /_bin/rss.cmo?page=$1 [PT,L,QSA] +RewriteRule ^/([^_].*)/history.rss$ /_bin/history_rss.cmo?page=$1 [PT,L,QSA] +RewriteRule ^/([^_].*)/index.rss$ /_bin/page_rss.cmo?page=$1 [PT,L,QSA] RewriteRule ^/([^_].*)/links$ /_bin/links.cmo?page=$1 [PT,L,QSA] RewriteRule ^/([^_].*)/source$ /_bin/source.cmo?page=$1 [PT,L,QSA] RewriteRule ^/([^_].*)/stats$ /_bin/stats.cmo?page=$1 [PT,L,QSA] diff --git a/scripts/.depend b/scripts/.depend index 2f0ab5b..c12925f 100644 --- a/scripts/.depend +++ b/scripts/.depend @@ -176,6 +176,10 @@ history.cmo: lib/cocanwiki.cmo lib/cocanwiki_date.cmo \ lib/cocanwiki_template.cmi history.cmx: lib/cocanwiki.cmx lib/cocanwiki_date.cmx \ lib/cocanwiki_template.cmx +history_rss.cmo: lib/cocanwiki.cmo lib/cocanwiki_date.cmo \ + lib/cocanwiki_template.cmi +history_rss.cmx: lib/cocanwiki.cmx lib/cocanwiki_date.cmx \ + lib/cocanwiki_template.cmx host_menu.cmo: lib/cocanwiki.cmo lib/cocanwiki_template.cmi host_menu.cmx: lib/cocanwiki.cmx lib/cocanwiki_template.cmx hoststyle.cmo: lib/cocanwiki.cmo lib/cocanwiki_template.cmi @@ -256,6 +260,8 @@ page_email_send.cmx: lib/cocanwiki.cmx lib/cocanwiki_ok.cmx \ lib/cocanwiki_strings.cmx lib/cocanwiki_template.cmx page_email_unsubscribe.cmo: lib/cocanwiki.cmo lib/cocanwiki_ok.cmo page_email_unsubscribe.cmx: lib/cocanwiki.cmx lib/cocanwiki_ok.cmx +page_rss.cmo: lib/cocanwiki.cmo lib/cocanwiki_template.cmi lib/wikilib.cmi +page_rss.cmx: lib/cocanwiki.cmx lib/cocanwiki_template.cmx lib/wikilib.cmx pagestyle.cmo: lib/cocanwiki.cmo pagestyle.cmx: lib/cocanwiki.cmx preview.cmo: lib/cocanwiki.cmo lib/wikilib.cmi @@ -268,6 +274,10 @@ recent.cmo: lib/cocanwiki.cmo lib/cocanwiki_date.cmo \ lib/cocanwiki_template.cmi recent.cmx: lib/cocanwiki.cmx lib/cocanwiki_date.cmx \ lib/cocanwiki_template.cmx +recent_rss.cmo: lib/cocanwiki.cmo lib/cocanwiki_date.cmo \ + lib/cocanwiki_template.cmi +recent_rss.cmx: lib/cocanwiki.cmx lib/cocanwiki_date.cmx \ + lib/cocanwiki_template.cmx recently_visited.cmo: lib/cocanwiki.cmo lib/cocanwiki_template.cmi recently_visited.cmx: lib/cocanwiki.cmx lib/cocanwiki_template.cmx restore.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmi \ @@ -280,8 +290,6 @@ restore_form.cmo: lib/cocanwiki.cmo lib/cocanwiki_diff.cmi \ lib/cocanwiki_ok.cmo lib/cocanwiki_template.cmi restore_form.cmx: lib/cocanwiki.cmx lib/cocanwiki_diff.cmx \ lib/cocanwiki_ok.cmx lib/cocanwiki_template.cmx -rss.cmo: lib/cocanwiki.cmo lib/cocanwiki_template.cmi lib/wikilib.cmi -rss.cmx: lib/cocanwiki.cmx lib/cocanwiki_template.cmx lib/wikilib.cmx search.cmo: lib/cocanwiki.cmo search.cmx: lib/cocanwiki.cmx send_feedback.cmo: lib/cocanwiki.cmo lib/cocanwiki_ok.cmo \ diff --git a/scripts/history.ml b/scripts/history.ml index 556a6ad..a08707d 100644 --- a/scripts/history.ml +++ b/scripts/history.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: history.ml,v 1.8 2004/09/21 13:01:16 rich Exp $ + * $Id: history.ml,v 1.9 2004/11/01 17:46:21 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 @@ -33,6 +33,7 @@ let run r (q : cgi) (dbh : Dbi.connection) hostid _ _ = let page = q#param "page" in let page = if page = "" then "index" else page in + template#set "page" page; let sth = dbh#prepare_cached diff --git a/scripts/history_rss.ml b/scripts/history_rss.ml new file mode 100644 index 0000000..11590e9 --- /dev/null +++ b/scripts/history_rss.ml @@ -0,0 +1,103 @@ +(* COCANWIKI - a wiki written in Objective CAML. + * Written by Richard W.M. Jones . + * Copyright (C) 2004 Merjis Ltd. + * $Id: history_rss.ml,v 1.1 2004/11/01 17:46:21 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + *) + +open Apache +open Registry +open Cgi +open Printf + +open Cocanwiki +open Cocanwiki_template +open Cocanwiki_date + +let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} _ = + let template = get_template dbh hostid "history_rss.xml" in + + let page = q#param "page" in + let page = if page = "" then "index" else page in + template#set "page" page; + + template#set "hostname" hostname; + + let sth = + dbh#prepare_cached + "select p.id, p.url, p.url_deleted, p.title, p.last_modified_date, + p.logged_ip, u.name + from pages p left outer join users u on p.logged_user = u.id + where p.hostid = ? and (p.url = ? or p.url_deleted = ?) + order by p.last_modified_date desc" in + sth#execute [`Int hostid; `String page; `String page]; + + let table = + sth#map + (function + | [`Int version; `String url; _; `String title; + `Timestamp last_modified_date; logged_ip; logged_user ] -> + let date = printable_date_time last_modified_date in + let has_logged_ip, logged_ip = + match logged_ip with + `Null -> false, "" + | `String ip -> true, ip + | _ -> assert false in + let has_logged_user, logged_user = + match logged_user with + `Null -> false, "" + | `String name -> true, name + | _ -> assert false in + [ "version", Template.VarString (string_of_int version); + "url", Template.VarString url; + "title", Template.VarString title; + "last_modified_date", Template.VarString date; + "has_logged_ip", Template.VarConditional has_logged_ip; + "logged_ip", Template.VarString logged_ip; + "has_logged_user", Template.VarConditional has_logged_user; + "logged_user", Template.VarString logged_user; + "is_live", Template.VarConditional true ] + | [`Int version; `Null; `String url; `String title; + `Timestamp last_modified_date; logged_ip; logged_user ] -> + let date = printable_date_time last_modified_date in + let has_logged_ip, logged_ip = + match logged_ip with + `Null -> false, "" + | `String ip -> true, ip + | _ -> assert false in + let has_logged_user, logged_user = + match logged_user with + `Null -> false, "" + | `String name -> true, name + | _ -> assert false in + [ "version", Template.VarString (string_of_int version); + "url", Template.VarString url; + "title", Template.VarString title; + "last_modified_date", Template.VarString date; + "has_logged_ip", Template.VarConditional has_logged_ip; + "logged_ip", Template.VarString logged_ip; + "has_logged_user", Template.VarConditional has_logged_user; + "logged_user", Template.VarString logged_user; + "is_live", Template.VarConditional false ] + | _ -> assert false) in + + template#table "history" table; + + q#template template + +let () = + register_script ~restrict:[CanEdit] run diff --git a/scripts/rss.ml b/scripts/page_rss.ml similarity index 98% rename from scripts/rss.ml rename to scripts/page_rss.ml index 379c36a..b9e1df0 100644 --- a/scripts/rss.ml +++ b/scripts/page_rss.ml @@ -1,7 +1,7 @@ (* COCANWIKI - a wiki written in Objective CAML. * Written by Richard W.M. Jones . * Copyright (C) 2004 Merjis Ltd. - * $Id: rss.ml,v 1.2 2004/10/04 15:19:56 rich Exp $ + * $Id: page_rss.ml,v 1.1 2004/11/01 17:46:21 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 diff --git a/scripts/recent_rss.ml b/scripts/recent_rss.ml new file mode 100644 index 0000000..08fde14 --- /dev/null +++ b/scripts/recent_rss.ml @@ -0,0 +1,103 @@ +(* COCANWIKI - a wiki written in Objective CAML. + * Written by Richard W.M. Jones . + * Copyright (C) 2004 Merjis Ltd. + * $Id: recent_rss.ml,v 1.1 2004/11/01 17:46:21 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 + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; see the file COPYING. If not, write to + * the Free Software Foundation, Inc., 59 Temple Place - Suite 330, + * Boston, MA 02111-1307, USA. + *) + +open Apache +open Registry +open Cgi +open Printf + +open Cocanwiki +open Cocanwiki_template +open Cocanwiki_date + +let limit = 30 + +let run r (q : cgi) (dbh : Dbi.connection) hostid {hostname = hostname} _ = + let template = get_template dbh hostid "recent_rss.xml" in + + template#set "hostname" hostname; + + (* Get the changes. *) + let sth = + dbh#prepare_cached + "select p.id, p.url, p.url_deleted, p.title, p.last_modified_date, + p.logged_ip, u.name + from pages p left outer join users u on p.logged_user = u.id + where p.hostid = ? + order by p.last_modified_date desc + limit ?" in + sth#execute [`Int hostid; `Int limit]; + + let table = + sth#map + (function + | [`Int version; `String url; _; `String title; + `Timestamp last_modified_date; logged_ip; logged_user] -> + let date = printable_date_time last_modified_date in + let has_logged_ip, logged_ip = + match logged_ip with + `Null -> false, "" + | `String ip -> true, ip + | _ -> assert false in + let has_logged_user, logged_user = + match logged_user with + `Null -> false, "" + | `String name -> true, name + | _ -> assert false in + [ "version", Template.VarString (string_of_int version); + "url", Template.VarString url; + "title", Template.VarString title; + "last_modified_date", Template.VarString date; + "has_logged_ip", Template.VarConditional has_logged_ip; + "logged_ip", Template.VarString logged_ip; + "has_logged_user", Template.VarConditional has_logged_user; + "logged_user", Template.VarString logged_user; + "is_live", Template.VarConditional true ] + | [`Int version; `Null; `String url; `String title; + `Timestamp last_modified_date; logged_ip; logged_user] -> + let date = printable_date_time last_modified_date in + let has_logged_ip, logged_ip = + match logged_ip with + `Null -> false, "" + | `String ip -> true, ip + | _ -> assert false in + let has_logged_user, logged_user = + match logged_user with + `Null -> false, "" + | `String name -> true, name + | _ -> assert false in + [ "version", Template.VarString (string_of_int version); + "url", Template.VarString url; + "title", Template.VarString title; + "last_modified_date", Template.VarString date; + "has_logged_ip", Template.VarConditional has_logged_ip; + "logged_ip", Template.VarString logged_ip; + "has_logged_user", Template.VarConditional has_logged_user; + "logged_user", Template.VarString logged_user; + "is_live", Template.VarConditional false ] + | _ -> assert false) in + + template#table "recent_changes" table; + + q#template template + +let () = + register_script ~restrict:[CanEdit] run diff --git a/templates/history.html b/templates/history.html index 9c2fe9f..b99e91e 100644 --- a/templates/history.html +++ b/templates/history.html @@ -10,6 +10,10 @@

Versions of this page

+ +
    ::table(history)::
  • diff --git a/templates/history_rss.xml b/templates/history_rss.xml new file mode 100644 index 0000000..bd96368 --- /dev/null +++ b/templates/history_rss.xml @@ -0,0 +1,29 @@ + + + + Version of page ::page_html:: + http://::hostname_html_tag::/::page_html_tag:: + en-GB + + + ::table(history):: + + ::end:: + + + +::table(history):: + + ::title_html:: (version ::version::) changed by ::logged_user:: ::logged_ip:: + http://::hostname_html_tag::/::page_html_tag::?version=::version:: + + <a href="/::url_html_tag::/diff?version=::version::">Differences</a> + + + + +::end:: + diff --git a/templates/rss.xml b/templates/page_rss.xml similarity index 100% rename from templates/rss.xml rename to templates/page_rss.xml diff --git a/templates/recent.html b/templates/recent.html index fe8b461..1e2b5e7 100644 --- a/templates/recent.html +++ b/templates/recent.html @@ -18,6 +18,7 @@ ::if(has_next)::
  • Show next ::limit::
  • ::end:: +
  • RSS feed of this page
    diff --git a/templates/recent_rss.xml b/templates/recent_rss.xml new file mode 100644 index 0000000..c0d6e18 --- /dev/null +++ b/templates/recent_rss.xml @@ -0,0 +1,29 @@ + + + + Recent changes at ::hostname_html:: + http://::hostname_html_tag::/ + en-GB + + + ::table(recent_changes):: + + ::end:: + + + +::table(recent_changes):: + + ::title_html:: (version ::version::) changed by ::logged_user:: ::logged_ip:: + http://::hostname_html_tag::/::url_html_tag::?version=::version:: + + <a href="/::url_html_tag::/diff?version=::version::">Differences</a> + + + + +::end:: + -- 1.8.3.1