[Gnucash-changes] r14304 - htdocs/trunk - Valid Atom 1.0: Correctly escape HTML content. All required constructs emitted. Emit anchors on {, old}news items for links from atom feed.

Joshua Sled jsled at cvs.gnucash.org
Sat Jun 3 15:14:20 EDT 2006


Author: jsled
Date: 2006-06-03 15:14:19 -0400 (Sat, 03 Jun 2006)
New Revision: 14304
Trac: http://svn.gnucash.org/trac/changeset/14304

Modified:
   htdocs/trunk/README
   htdocs/trunk/atom-feed.php
   htdocs/trunk/index.phtml
   htdocs/trunk/news/news-script.php
   htdocs/trunk/oldnews.phtml
Log:
Valid Atom 1.0:  Correctly escape HTML content.  All required constructs emitted. Emit anchors on {,old}news items for links from atom feed.


Modified: htdocs/trunk/README
===================================================================
--- htdocs/trunk/README	2006-06-03 14:55:51 UTC (rev 14303)
+++ htdocs/trunk/README	2006-06-03 19:14:19 UTC (rev 14304)
@@ -7,7 +7,6 @@
 - atom (/rss) generator
 - re-work page content for new-style translations (one big block)
   - re-flow existing po-file content.
-- get gettext working on www.gnucash.org
 - update features screenshots
 - revise docs.phtml
 

Modified: htdocs/trunk/atom-feed.php
===================================================================
--- htdocs/trunk/atom-feed.php	2006-06-03 14:55:51 UTC (rev 14303)
+++ htdocs/trunk/atom-feed.php	2006-06-03 19:14:19 UTC (rev 14304)
@@ -1,7 +1,6 @@
 <?php
   // TODO:
   // - reasonable permalinks
-
   include("local.php");
 
   $contentType = "application/atom+xml";
@@ -12,11 +11,12 @@
   }
   $charset = "iso-8859-1";
   header("Content-Type: $contentType; charset=$charset");
+
+  $entry_count = 10;
+  $newsdir = "${top_dir}/news/";
 ?>
 <?="<?xml version=\"1.0\" encoding=\"$charset\"?>"?>
 <?php
-  $entry_count = 10;
-  $newsdir = "${top_dir}/news/";
   include("$top_dir/news/news-script.php");
 ?>
 
@@ -27,13 +27,14 @@
   <logo>http://www.gnucash.org/images/gnucash_logo.png</logo>
   <link href="http://www.gnucash.org/" />
   <link rel="self" href="atom-feed.php" />
-
   <?php
   $news_items = get_news($newsdir, $newsdir);
   $news_items = array_slice($news_items, 0, $entry_count);
   reset($news_items);
-  $most_recent = null;
+  $most_recent = file(key($news_items));
+  $most_recent_update = chop($most_recent[1]);
   ?>
+  <updated><?= date(DATE_ATOM, strtotime($most_recent_update)) ?></updated>
 
   <?php for (reset($news_items); $key = key($news_items); next($news_items))
   {
@@ -41,22 +42,23 @@
     $n = count($fa);
     $title = strip_tags(chop($fa[0]));
     $update_date = chop($fa[1]);
-    if ($most_recent == null || $update_date > $most_recent )
-    {
-      $most_recent = $update_date;
-    }
-  ?>
+    ?>
   <entry>
     <id>urn:x-gnucash:news:<?= urlencode($key) ?></id>
     <title><?= $title ?></title>
-    <updated><?= str_replace(' ', 'T', $update_date) ?>:00-08:00</updated>
+    <link href="<?=${top_dir}?>/#<?=generate_anchor($key);?>" />
+    <author>
+      <name>GnuCash Developers</name>
+      <email>gnucash-devel at gnucash.org</email>
+    </author>
+    <updated><?= date(DATE_ATOM, strtotime($update_date)) ?></updated>
     <content type="html">
         <? for ($i=2; $i<$n; $i++) {
-            print urlencode($fa[$i]);
+            print htmlentities($fa[$i]);
         } ?>
     </content>
   </entry>
-  <?php } ?>
+  <?php
+  } ?>
 
-  <updated><?= str_replace(' ', 'T', $most_recent) ?>:00-08:00</updated>
 </feed>

Modified: htdocs/trunk/index.phtml
===================================================================
--- htdocs/trunk/index.phtml	2006-06-03 14:55:51 UTC (rev 14303)
+++ htdocs/trunk/index.phtml	2006-06-03 19:14:19 UTC (rev 14304)
@@ -43,8 +43,8 @@
   # News will continue to be translated separately because 
   # of the .txt format. 
   # for english, the lang and en news path are identical
-  $en_newspath  =  $top_dir."/news/";
-  $lang_newspath  =  $top_dir."/news/".$lang_dir."/";
+  $en_newspath  =  $top_dir."/news";
+  $lang_newspath  =  $top_dir."/news/".$lang_dir;
   $oldnews = false;
   include("$top_dir/news/news-script.php");
   emit_news($en_newspath, $lang_newspath, $oldnews);

Modified: htdocs/trunk/news/news-script.php
===================================================================
--- htdocs/trunk/news/news-script.php	2006-06-03 14:55:51 UTC (rev 14303)
+++ htdocs/trunk/news/news-script.php	2006-06-03 19:14:19 UTC (rev 14304)
@@ -90,6 +90,10 @@
     return $newsfile;
 }
 
+function generate_anchor($news_key)
+{
+  return urlencode(substr($news_key, strpos($news_key, '/', 2)+1));
+}
 
 function emit_news($en_newspath, $lang_newspath, $oldnews)
 {
@@ -122,7 +126,7 @@
 <div class="newsborder">
   <div class="newsheader">
     <img alt="news panel" src="<?=${top_dir}?>/images/icons/document.txt.gif" width="16" height="16" alt="[news]"/>&nbsp;
-    <?= $fa[0]; ?> - <b><?= $newsfile[$key] ?></b>
+    <a name="<?=generate_anchor($key)?>"><?= $fa[0]; ?> - <b><?= $newsfile[$key] ?></b></a>
   </div>
   <div class="newsinner">
   <? for ($i=2; $i<$n; $i++)  {

Modified: htdocs/trunk/oldnews.phtml
===================================================================
--- htdocs/trunk/oldnews.phtml	2006-06-03 14:55:51 UTC (rev 14303)
+++ htdocs/trunk/oldnews.phtml	2006-06-03 19:14:19 UTC (rev 14304)
@@ -19,8 +19,8 @@
   # News will continue to be translated separately because 
   # of the .txt format. 
   # for english, the lang and en news path are identical
-  $en_newspath  =  $top_dir."/news/";
-  $lang_newspath  =  $top_dir."/news/".$lang_dir."/";
+  $en_newspath  =  $top_dir."/news";
+  $lang_newspath  =  $top_dir."/news/".$lang_dir;
   $oldnews = true;
   include("$top_dir/news/news-script.php");
   emit_news($en_newspath, $lang_newspath, $oldnews);



More information about the gnucash-changes mailing list