[Xfce4-commits] <www:nick/gettext> Add news item support, needs some new items tho.

Nick Schermer noreply at xfce.org
Fri Jan 14 21:48:04 CET 2011


Updating branch refs/heads/nick/gettext
         to 4a959b77974abd622476d3447656bfbea0613498 (commit)
       from 2b01638aa0e21b2324065c6b1ac3ea298fc03d0b (commit)

commit 4a959b77974abd622476d3447656bfbea0613498
Author: Nick Schermer <nick at xfce.org>
Date:   Fri Jan 14 21:46:52 2011 +0100

    Add news item support, needs some new items tho.

 index.php            |    7 ++++
 pages/about/news.php |   85 +++++++++++++++++++++++++++++---------------------
 pages/feed.php       |   58 ++++++++++++++++++++++++++++++++++
 pages/frontpage.php  |    2 +-
 pages/header.php     |    3 ++
 pages/news-array.php |   16 +++++++++
 style/news.css       |   30 +++++++++++++++++
 7 files changed, 164 insertions(+), 37 deletions(-)

diff --git a/index.php b/index.php
index a620737..8e8b274 100644
--- a/index.php
+++ b/index.php
@@ -19,6 +19,13 @@ $uri = trim (strtolower ($uri_a[0]), '/');
 /* lookup to page from the uri */
 $content_file = lookup_page ($uri);
 
+/* news feed handling */
+if ($uri == 'feed')
+{
+  include ($content_file);
+  exit;
+}
+
 /* load the page content in a buffer (we don't need it yet,
  * but we do need some variables for the header) */
 ob_start ();
diff --git a/pages/about/news.php b/pages/about/news.php
index 04af346..99d424a 100644
--- a/pages/about/news.php
+++ b/pages/about/news.php
@@ -1,36 +1,49 @@
-<?php $head['title'] = R_('News') ?>
-
-<h1><?php echo $head['title'] ?></h1>
-
-
-
-<h2 id="2010-11-14"><?php E_('Xfce 4.8pre1 Released') ?></h2>
-<span>14 januari 2010</span>
-<p>
-  <?php E_('The Xfce development team is proud to announce the first preview release for Xfce 4.8. Together with this preview release, the Xfce project announces the feature freeze for the final 4.8 release which is set to be pushed out to the world on January 16th, 2011.') ?>
-</p>
-<p>
-  <?php E_('This release incorporates major changes to the core of the Xfce desktop environment and hopefully succeeds in fulfilling a number of long time requests. Among the most notable updates is that we have ported the entire Xfce core (Thunar, xfdesktop and thunar-volman in particular) from ThunarVFS to GIO, bringing remote filesystems to the Xfce desktop. The panel has been rewritten from scratch and provides better launcher management and improved multi-head support. The list of new panel features is too long to mention in its entirety here. Thanks to the new menu library garcon (formerly known as libxfce4menu, but rewritten once again) we now support menu editing via a third-party menu editor such as Alacarte (we do not ship our own yet). Our core libraries have been streamlined a bit, a good examplle being the newly introduced libxfce4ui library which is meant to replace libxfcegui4.') ?>
-</p>
-<p>
-  <?php E_('Perhaps the most important achievement we will accomplish with Xfce 4.8 is that, despite suffering from the small size of the development team from time to time, the core of the desktop environment has been aligned with today\'s desktop technologies such as GIO, ConsoleKit, PolicyKit, udev and many more. A lot of old cruft like has been stripped from the core as well, as has happened with HAL and ThunarVFS (which is still around for compatibility reasons).') ?>
-</p>
-<p>
-  <?php E_('Thanks to the awesome Transifex translation platform, our language teams have been able to update their translations at an incredible pace. Please include them when praising this release!') ?>
-</p>
-<p>
-  <?php E_('A complete list of all changes since the latest stable release is available <a href="/documentation/changelogs/4.8pre1">here</a>.') ?>
-</p>
-<p>
-  <?php E_('Kind regards and thanks to everyone who has contributed to this release,<br />The Xfce development team.') ?>
-</p>
-
-<h2 id="2009-00-00"><?php E_('Xfce 4.2.1.1 released') ?></h2>
-<p>
-  <?php E_('Xfce 4.2.1.1 has been released quickly after 4.2.1. It includes a fix for a bad bug where panel loses its configuration when saving the session in 4.2.1. The Sourceforge server has been updated, and other mirrors will follow soon.') ?>
-</p>
-
-<h2 id="2008-00-00"><?php E_('Xfce 4.2.1 released') ?></h2>
-<p>
-  <?php E_('Xfce 4.2.1 is available. This is a maintenance release. Download locations can be found on this page, and a changelog is available here.') ?>
-</p>
+<?php
+
+include ('pages/news-array.php');
+
+$head['title'] = R_('News');
+$head['stylesheet'] = array ('/style/news.css');
+$head['feed'] = '/feed';
+
+$toc['anchors'] = array ();
+
+echo '<h1>'.$head['title'].'</h1>';
+
+if (isset ($_GET['id']))
+  $only_stamp = (int) $_GET['id'];
+else
+  $only_stamp = 0;
+
+$has_items = false;
+
+foreach ($news as $item)
+{
+  $stamp = strtotime ($item['date']);
+
+  if ($only_stamp > 0 && $only_stamp != $stamp)
+    continue;
+
+  echo '<h2 id="'.$stamp.'">'.$item['title'].'</h2>'."\n";
+
+  echo '<div class="post-date"><span class="post-month">'. date ('M', $stamp).
+       '</span> <span class="post-day">'. date ('d', $stamp).
+       '<br />'.date ('Y', $stamp).'</span></div>';
+
+  echo '<div class="post-wrap">';
+  foreach ($item['content'] as $p)
+    echo '<p>'.$p.'</p>'."\n";
+  echo '</div>';
+
+  $toc['anchors'] += array ($stamp => $item['title']);
+  $has_items = true;
+}
+
+if (!$has_items)
+{
+  echo '<p>'.R_('No news articles found.').'</p>';
+}
+
+?>
+
+
diff --git a/pages/feed.php b/pages/feed.php
new file mode 100644
index 0000000..6685f5d
--- /dev/null
+++ b/pages/feed.php
@@ -0,0 +1,58 @@
+<?php
+
+include ('pages/news-array.php');
+
+function escape_content($str)
+{
+  $search = array ('<a href="/','<', '>', '"');
+  $replace = array ('<a href="http://www.xfce.org/', '<', '>','"');
+
+  return str_replace ($search, $replace, $str);
+}
+
+$item_limit = 10;
+
+/* the default rss date/time format */
+$format = 'D, d M Y H:i:s \G\M\T';
+
+header ('Content-type: application/xml; charset="utf-8"', true);
+
+/* start creating the xml content */
+echo '<?xml version="1.0" encoding="UTF-8"?>'.
+     '<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" '.
+     'xmlns:wfw="http://wellformedweb.org/CommentAPI/" '.
+     'xmlns:dc="http://purl.org/dc/elements/1.1/" '.
+     'version="2.0">'.
+     '<channel>'.
+       '<title>'.R_('Xfce News').'</title>'.
+       '<description>'.R_('Xfce release announcements').'</description>'.
+       '<link>http://www.xfce.org/about/news</link>'.
+       '<copyright>Olivier Fourdan 1996 - '. date ('Y') .'</copyright>'.
+       '<language>". $lang ."</language>'.
+       '<generator>Xfce feed spawner</generator>';
+
+foreach ($news as $item)
+{
+    $stamp = strtotime ($item['date']);
+
+    echo '<item>'.
+           '<title>'.$item['title'].'</title>'.
+           '<description>'. escape_content ($item['content'][0]) .'</description>'.
+           '<content:encoded><![CDATA[';
+
+    foreach ($item['content'] as $p)
+            echo '<p>'.$p.'</p>';
+
+    echo   ']]></content:encoded>'.
+           '<link>http://www.xfce.org/about/news/?id='.$stamp.'</link>'.
+           '<dc:creator>'. $item['author'] .'</dc:creator>'.
+           '<pubDate>'. date ($format, $stamp) .'</pubDate>'.
+           '<category>Xfce News</category>'.
+           '<guid isPermaLink="false">http://www.xfce.org/about/news/?id='.$stamp.'</guid>'.
+         '</item>';
+
+    if ($item_limit-- < 0)
+      break;
+}
+
+echo '</channel></rss>';
diff --git a/pages/frontpage.php b/pages/frontpage.php
index 8c3c2b0..bd8662b 100644
--- a/pages/frontpage.php
+++ b/pages/frontpage.php
@@ -3,6 +3,6 @@
 $head['description'] = 'Xfce Desktop Environment';
 $head['keywords'] = 'desktop environment, window manager, desktop, speed, lightweight, gtk+, open source, xforms common environment';
 $head['stylesheet'] = array ('/style/home.css');
-
+$head['feed'] = '/feed';
 
 ?>
diff --git a/pages/header.php b/pages/header.php
index 32799e0..39d6967 100644
--- a/pages/header.php
+++ b/pages/header.php
@@ -23,6 +23,9 @@ else
 
         if (isset ($head['keywords']))
                 echo "\t<meta name=\"keywords\" content=\"".$head['keywords']."\" />\n";
+
+        if (isset ($head['feed']))
+                echo "\t<link rel=\"alternate\" type=\"application/rss+xml\" title=\"RSS 2.0\" href=\"".$head['feed']."\" />\n";
 ?>
 </head>
 
diff --git a/pages/news-array.php b/pages/news-array.php
new file mode 100644
index 0000000..41fcc6d
--- /dev/null
+++ b/pages/news-array.php
@@ -0,0 +1,16 @@
+<?php
+$news = array (
+	array ( 'title' => R_('Xfce 4.8pre1 released'),
+		'date' => '7 nov 2010',
+		'author' => 'Release Manager',
+		'content' => array (
+			R_('The Xfce development team is proud to announce the first preview release for Xfce 4.8. Together with this preview release, the Xfce project announces the feature freeze for the final 4.8 release which is set to be pushed out to the world on January 16th, 2011.'),
+			R_('This release incorporates major changes to the core of the Xfce desktop environment and hopefully succeeds in fulfilling a number of long time requests. Among the most notable updates is that we have ported the entire Xfce core (Thunar, xfdesktop and thunar-volman in particular) from ThunarVFS to GIO, bringing remote filesystems to the Xfce desktop. The panel has been rewritten from scratch and provides better launcher management and improved multi-head support. The list of new panel features is too long to mention in its entirety here. Thanks to the new menu library garcon (formerly known as libxfce4menu, but rewritten once again) we now support menu editing via a third-party menu editor such as Alacarte (we do not ship our own yet). Our core libraries have been streamlined a bit, a good examplle being the newly introduced libxfce4ui library which is meant to replace libxfcegui4.'),
+			R_('Perhaps the most important achievement we will accomplish with Xfce 4.8 is that, despite suffering from the small size of the development team from time to time, the core of the desktop environment has been aligned with today\'s desktop technologies such as GIO, ConsoleKit, PolicyKit, udev and many more. A lot of old cruft like has been stripped from the core as well, as has happened with HAL and ThunarVFS (which is still around for compatibility reasons).'),
+			R_('Thanks to the awesome Transifex translation platform, our language teams have been able to update their translations at an incredible pace. Please include them when praising this release!'),
+			R_('A complete list of all changes since the latest stable release is available <a href="/download/changelogs/4.8pre1">here</a>.'),
+			R_('Download the tarballs from here: <a href="http://archive.xfce.org/xfce/4.8pre1/">http://archive.xfce.org/xfce/4.8pre1/</a>.'),
+			R_('Kind regards and thanks to everyone who has contributed to this release,<br />The Xfce development team.'))
+	)
+)
+?>
diff --git a/style/news.css b/style/news.css
new file mode 100644
index 0000000..6d1e0f5
--- /dev/null
+++ b/style/news.css
@@ -0,0 +1,30 @@
+.post-date {
+	width: 50px;
+	height: 50px;
+	float: left;
+}
+.post-month {
+	text-transform: uppercase;
+	color: #fff;
+	text-align: center;
+	display:block;
+	padding: 2px;
+	background: #2284f2;
+	border-bottom: 1px dotted #2284f2;
+	
+}
+.post-day {
+	text-transform: uppercase;
+	color: #3d3d3d;
+	text-align: center;
+	display: block;
+	background: #fff;
+	border: 1px dotted #000;
+	border-top: 0;
+	padding: 2px;
+	line-height: 11px;
+}
+
+.post-wrap {
+	margin-left: 65px;
+}



More information about the Xfce4-commits mailing list