Don't forget the date\!
authorrich <rich>
Thu, 7 Dec 2006 17:16:17 +0000 (17:16 +0000)
committerrich <rich>
Thu, 7 Dec 2006 17:16:17 +0000 (17:16 +0000)
html/_css/rss.css
scripts/lib/cocanwiki_func_rss.ml
templates/cocanwiki_func_rss.html

index 796a7d1..b914fd8 100644 (file)
@@ -1,5 +1,5 @@
 /* RSS feeds ({{rss}} function).
- * $Id: rss.css,v 1.1 2006/12/07 17:05:47 rich Exp $
+ * $Id: rss.css,v 1.2 2006/12/07 17:16:17 rich Exp $
  */
 
 p.rss_description a {
@@ -10,4 +10,8 @@ p.rss_description a {
 span.rss_item_description a {
   color: black;
   text-decoration: none;
+}
+
+span.rss_item_date {
+  font-size: 75%;
 }
\ No newline at end of file
index 761c2c1..dafeba7 100644 (file)
@@ -1,5 +1,5 @@
 (* An RSS feed reader function.
- * $Id: cocanwiki_func_rss.ml,v 1.1 2006/12/07 17:05:47 rich Exp $
+ * $Id: cocanwiki_func_rss.ml,v 1.2 2006/12/07 17:16:17 rich Exp $
  *)
 
 open Printf
@@ -24,6 +24,7 @@ open Cocanwiki_template
  *                 description      Blog description
  *                 items            Items in the feed
  *                 item_title       Title of items
+ *                 item_date        Date and time of items
  *                 item_link        Link to items
  *                 item_description Description of items
  *               Default is everything.
@@ -44,9 +45,10 @@ let refresh_re = Pcre.regexp "^(\\d+)(h|d)$"
 exception Error of string
 
 type show = Title | Link | Description
-         | Items | Item_title | Item_link | Item_description
+         | Items | Item_title | Item_date | Item_link | Item_description
 let default_show = [ Title; Link; Description;
-                    Items; Item_title; Item_link; Item_description ]
+                    Items; Item_title; Item_date;
+                    Item_link; Item_description ]
 
 let event_system = Unixqueue.create_unix_event_system ()
 let connection =
@@ -85,7 +87,7 @@ let rss r dbh hostid arg =
      *)
     let rows =
       PGSQL(dbh) "select enable_rss_func from hosts where id = $hostid" in
-    if rows <> [Some true] then
+    if rows <> [true] then
       raise (Error "RSS is disabled on this host.  You have to enable it manually by setting enable_rss_func for the relevant row in the hosts table.  RSS introduces a potential security hole (cross-site scripting) and should not be used where you have untrusted editors or with untrusted RSS feeds.");
 
     let arg = match arg with
@@ -155,6 +157,7 @@ let rss r dbh hostid arg =
          | "description" -> Description
          | "items" -> Items
          | "item_title" -> Item_title
+         | "item_date" -> Item_date
          | "item_link" -> Item_link
          | "item_description" -> Item_description
          | str ->
@@ -170,6 +173,7 @@ let rss r dbh hostid arg =
     template#conditional "show_description" false;
     template#conditional "show_items" false;
     template#conditional "show_item_title" false;
+    template#conditional "show_item_date" false;
     template#conditional "show_item_link" false;
     template#conditional "show_item_description" false;
     List.iter (
@@ -179,6 +183,7 @@ let rss r dbh hostid arg =
       | Description -> template#conditional "show_description" true
       | Items -> template#conditional "show_items" true
       | Item_title -> template#conditional "show_item_title" true
+      | Item_date -> template#conditional "show_item_date" true
       | Item_link -> template#conditional "show_item_link" true
       | Item_description -> template#conditional "show_item_description" true
     ) show;
index 32c485d..1ab2452 100644 (file)
@@ -16,7 +16,9 @@
 <li>
   ::if(show_item_title)::
   <span class="rss_item_title">::if(show_item_link)::<a href="::link_html_tag::">::end::::title::::if(show_item_link)::</a>::end::</span>
-  ::end:: <br/>
+  ::end::
+  <span class="rss_item_date">::date_html::</span>
+  <br/>
 
   ::if(show_item_description)::
   <span class="rss_item_description">::if(show_item_link)::<a href="::link_html_tag::">::end::::description::::if(show_item_link)::</a>::end::</span>