"Versions of this page" and "Recent changes" RSS feeds. Not been
authorrich <rich>
Mon, 1 Nov 2004 17:46:21 +0000 (17:46 +0000)
committerrich <rich>
Mon, 1 Nov 2004 17:46:21 +0000 (17:46 +0000)
able to check that these actually work yet however.

12 files changed:
MANIFEST
conf/cocanwiki.conf
scripts/.depend
scripts/history.ml
scripts/history_rss.ml [new file with mode: 0644]
scripts/page_rss.ml [moved from scripts/rss.ml with 98% similarity]
scripts/recent_rss.ml [new file with mode: 0644]
templates/history.html
templates/history_rss.xml [new file with mode: 0644]
templates/page_rss.xml [moved from templates/rss.xml with 100% similarity]
templates/recent.html
templates/recent_rss.xml [new file with mode: 0644]

index 4fa2701..999c0ac 100644 (file)
--- 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
index 69ac832..a0aab97 100644 (file)
@@ -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]
index 2f0ab5b..c12925f 100644 (file)
@@ -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 \
index 556a6ad..a08707d 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * 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 (file)
index 0000000..11590e9
--- /dev/null
@@ -0,0 +1,103 @@
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * 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
similarity index 98%
rename from scripts/rss.ml
rename to scripts/page_rss.ml
index 379c36a..b9e1df0 100644 (file)
@@ -1,7 +1,7 @@
 (* COCANWIKI - a wiki written in Objective CAML.
  * Written by Richard W.M. Jones <rich@merjis.com>.
  * 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 (file)
index 0000000..08fde14
--- /dev/null
@@ -0,0 +1,103 @@
+(* COCANWIKI - a wiki written in Objective CAML.
+ * Written by Richard W.M. Jones <rich@merjis.com>.
+ * 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
index 9c2fe9f..b99e91e 100644 (file)
 
 <h1><span>Versions of this page</span></h1>
 
+<ul class="menu">
+<li class="first"> <a href="history.rss">RSS feed of this page</a> </li>
+</ul>
+
 <ul id="history">
 ::table(history)::
 <li>
diff --git a/templates/history_rss.xml b/templates/history_rss.xml
new file mode 100644 (file)
index 0000000..bd96368
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF
+  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+  xmlns="http://purl.org/rss/1.0/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/">
+  <channel rdf:about="http://::hostname_html_tag::/::page_html_tag::">
+    <title>Version of page ::page_html::</title>
+    <link>http://::hostname_html_tag::/::page_html_tag::</link>
+    <language>en-GB</language>
+    <items>
+      <rdf:Seq>
+       ::table(history)::
+       <rdf:li rdf:resource="http://::hostname_html_tag::/::page_html_tag::?version=::version::"/>
+       ::end::
+      </rdf:Seq>
+    </items>
+  </channel>
+::table(history)::
+  <item rdf:about="http://::hostname_html_tag::/::page_html_tag::?version=::version::">
+    <title>::title_html:: (version ::version::) changed by ::logged_user:: ::logged_ip::</title>
+    <link>http://::hostname_html_tag::/::page_html_tag::?version=::version::</link>
+    <description>
+      &lt;a href="/::url_html_tag::/diff?version=::version::"&gt;Differences&lt;/a&gt;
+    </description>
+    <!-- <dc:creator> ... </dc:creator> -->
+    <!-- <dc:date> ... </dc:date> -->
+  </item>
+::end::
+</rdf:RDF>
similarity index 100%
rename from templates/rss.xml
rename to templates/page_rss.xml
index fe8b461..1e2b5e7 100644 (file)
@@ -18,6 +18,7 @@
 ::if(has_next)::
 <li> <a href="?offset=::next_offset::&limit=::limit::">Show next ::limit::</a> </li>
 ::end::
+<li> <a href="_recent.rss">RSS feed of this page</a> </li>
 </ul>
 
 <ul id="recent_changes">
diff --git a/templates/recent_rss.xml b/templates/recent_rss.xml
new file mode 100644 (file)
index 0000000..c0d6e18
--- /dev/null
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<rdf:RDF
+  xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
+  xmlns="http://purl.org/rss/1.0/"
+  xmlns:dc="http://purl.org/dc/elements/1.1/">
+  <channel rdf:about="http://::hostname_html_tag::/">
+    <title>Recent changes at ::hostname_html::</title>
+    <link>http://::hostname_html_tag::/</link>
+    <language>en-GB</language>
+    <items>
+      <rdf:Seq>
+       ::table(recent_changes)::
+       <rdf:li rdf:resource="http://::hostname_html_tag::/::url_html_tag::?version=::version::"/>
+       ::end::
+      </rdf:Seq>
+    </items>
+  </channel>
+::table(recent_changes)::
+  <item rdf:about="http://::hostname_html_tag::/::url_html_tag::?version=::version::">
+    <title>::title_html:: (version ::version::) changed by ::logged_user:: ::logged_ip::</title>
+    <link>http://::hostname_html_tag::/::url_html_tag::?version=::version::</link>
+    <description>
+      &lt;a href="/::url_html_tag::/diff?version=::version::"&gt;Differences&lt;/a&gt;
+    </description>
+    <!-- <dc:creator> ... </dc:creator> -->
+    <!-- <dc:date> ... </dc:date> -->
+  </item>
+::end::
+</rdf:RDF>