website rev 746
mainpage: Add a feed grid (feeds are cached by a script and cron)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Sun Jan 23 23:01:40 2011 +0100 (2011-01-23) |
parents | f5c1b6da6403 |
children | 35688e566dbe |
files | index.php libs/get-feed.php libs/get-latest.sh libs/js/slideshow.js scripts/get-latest.sh scripts/get_feed.php scripts/slideshow.js slitaz.css |
line diff
1.1 --- a/index.php Sun Jan 23 11:21:24 2011 +0100 1.2 +++ b/index.php Sun Jan 23 23:01:40 2011 +0100 1.3 @@ -3,7 +3,7 @@ 1.4 <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 1.5 <head> 1.6 <title>SliTaz GNU/Linux</title> 1.7 - <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> 1.8 + <meta http-equiv="content-type" content="text/html; charset=utf-8" /> 1.9 <meta name="description" content="SliTaz GNU/Linux LiveCD operating system" /> 1.10 <meta name="keywords" lang="en" content="System, libre, gnu, linux, logiciels opensource, livecd" /> 1.11 <meta name="robots" content="index, follow, all" /> 1.12 @@ -18,13 +18,13 @@ 1.13 <link rel="alternate" type="application/rss+xml" title="SliTaz Website feed" href="en/rss.xml" /> 1.14 <link rel="alternate" type="application/atom+xml" title="SliTaz Labs feed" href="http://labs.slitaz.org/news?format=atom" /> 1.15 <link rel="alternate" type="application/rss+xml" title="SliTaz SCN feed" href="http://scn.slitaz.org/rss.xml" /> 1.16 - <script type="text/javascript" src="scripts/slideshow.js"></script> 1.17 + <script type="text/javascript" src="libs/js/slideshow.js"></script> 1.18 <link rel="Content" href="#content" /> 1.19 </head> 1.20 <body> 1.21 1.22 <?php 1.23 - require_once("scripts/get_feed.php"); 1.24 + require_once("libs/get-feed.php"); 1.25 ?> 1.26 1.27 <!-- Header --> 1.28 @@ -123,6 +123,9 @@ 1.29 title="Chinese" alt="cn" /></a> 1.30 </div> 1.31 1.32 +<!-- End of news --> 1.33 +</div> 1.34 + 1.35 <h2>Latest Tweet</h2> 1.36 <div id="twitter"> 1.37 <script src="http://widgets.twimg.com/j/2/widget.js"></script> 1.38 @@ -158,27 +161,35 @@ 1.39 </script> 1.40 </div> 1.41 1.42 +<h2>Feed Grid</h2> 1.43 + 1.44 +<div class="feed-grid"> 1.45 + <div class="right_box"> 1.46 + <h3><img src="pics/website/feed.png" alt=".png" />Community Network</h3> 1.47 + <?php get_rss_feed("/var/cache/slitaz/website/scn.xml"); ?> 1.48 + </div> 1.49 + <div class="left_box"> 1.50 + <h3><img src="pics/website/feed.png" alt=".png" />Support Forum</h3> 1.51 + <?php get_forum_rss_feed("/var/cache/slitaz/website/forum.xml"); ?> 1.52 + </div> 1.53 +</div> 1.54 +<div class="feed-grid"> 1.55 + <div class="right_box"> 1.56 + <h3><img src="pics/website/feed.png" alt=".png" />Documentation</h3> 1.57 + <?php get_rss_feed("/var/cache/slitaz/website/doc.xml"); ?> 1.58 + </div> 1.59 + <div class="left_box"> 1.60 + <h3><img src="pics/website/feed.png" alt=".png" />Bug Tracker</h3> 1.61 + <?php get_atom_feed("/var/cache/slitaz/website/bugs.xml"); ?> 1.62 + </div> 1.63 +</div> 1.64 + 1.65 <!-- We display the 5 last commit and build for cooking --> 1.66 1.67 <?php 1.68 include("/var/cache/slitaz/website/latest.html"); 1.69 ?> 1.70 1.71 -<h2>Community Network Feed</h2> 1.72 -<div class="feedbox"> 1.73 - <div> 1.74 - <?php get_feed("http://scn.slitaz.org/rss.xml"); ?> 1.75 - </div> 1.76 - <div style="height: auto;"> 1.77 - <p style="margin: 4px 0 0; font-size: 12px; float: right;"> 1.78 - <a href="http://scn.slitaz.org/user/register">Join the community</a> 1.79 - </p> 1.80 - </div> 1.81 -</div> 1.82 - 1.83 -<!-- End of news --> 1.84 -</div> 1.85 - 1.86 <h2>Spread SliTaz</h2> 1.87 <p> 1.88 One way to help the project is to make SliTaz even more popular.
2.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 2.2 +++ b/libs/get-feed.php Sun Jan 23 23:01:40 2011 +0100 2.3 @@ -0,0 +1,43 @@ 2.4 +<?php 2.5 + 2.6 +// Read RSS Feed 2.7 +function get_rss_feed($feed_url) { 2.8 + $content = file_get_contents($feed_url); 2.9 + $x = new SimpleXmlElement($content); 2.10 + // We look for last item, channel may not have a PubDate* 2.11 + $up = ($x->channel->item->pubDate); 2.12 + echo "<span>Updated: " . substr("$up", 5, 12) . "</span>\n"; 2.13 + echo "<ul>\n"; 2.14 + foreach($x->channel->item as $entry) { 2.15 + echo " <li><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></li>\n"; 2.16 + } 2.17 + echo "</ul>\n"; 2.18 +} 2.19 + 2.20 +// Read Forum RSS Feed 2.21 +function get_forum_rss_feed($feed_url) { 2.22 + $content = file_get_contents($feed_url); 2.23 + $x = new SimpleXmlElement($content); 2.24 + $up = ($x->channel->pubDate); 2.25 + echo "<span>Updated: " . substr("$up", 5, 6) . (date( ' Y ')) . "</span>\n"; 2.26 + echo "<ul>\n"; 2.27 + foreach($x->channel->item as $entry) { 2.28 + echo " <li><a href='$entry->link' title='$entry->title'>" . $entry->title . "</a></li>\n"; 2.29 + } 2.30 + echo "</ul>\n"; 2.31 +} 2.32 + 2.33 +// Read Atom Feed 2.34 +function get_atom_feed($feed_url) { 2.35 + $content = file_get_contents($feed_url); 2.36 + $x = new SimpleXmlElement($content); 2.37 + $up = ($x->updated); 2.38 + echo "<span>Updated: " . substr("$up", 0, 10) . "</span>\n"; 2.39 + echo "<ul>\n"; 2.40 + foreach($x->entry as $entry) { 2.41 + echo " <li><a href='$entry->id' title='$entry->title'>" . $entry->title . "</a></li>\n"; 2.42 + } 2.43 + echo "</ul>\n"; 2.44 +} 2.45 + 2.46 +?>
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 3.2 +++ b/libs/get-latest.sh Sun Jan 23 23:01:40 2011 +0100 3.3 @@ -0,0 +1,54 @@ 3.4 +#!/bin/sh 3.5 +# 3.6 +# Get latest commits and packages to display on the website main page. 3.7 +# On Tank, this script is executed by cron each hour. 3.8 +# 3.9 + 3.10 +REPO="/home/slitaz/repos/wok" 3.11 +URL="http://hg.slitaz.org/wok" 3.12 +PKGS="/home/slitaz/cooking/packages" 3.13 +CACHE="/var/cache/slitaz/website" 3.14 +OUTPUT="$CACHE/latest.html" 3.15 + 3.16 +# Feed URL's 3.17 +SCN_FEED='http://scn.slitaz.org/rss.xml' 3.18 +DOC_FEED='http://doc.slitaz.org/feed.php' 3.19 +FORUM_FEED='http://forum.slitaz.org/discussions/feed.rss' 3.20 +BUGS_FEED='http://labs.slitaz.org/issues.atom?query_id=' 3.21 + 3.22 +# Clean cache 3.23 +mkdir -p $CACHE && cd $CACHE 3.24 +rm *.xml 3.25 + 3.26 +# Cache all feeds to save bandwitch (update by cron) 3.27 +wget -O scn.xml $SCN_FEED 3.28 +wget -O doc.xml $DOC_FEED 3.29 +wget -O forum.xml $FORUM_FEED 3.30 +wget -O bugs.xml $BUGS_FEED 3.31 + 3.32 +# Latest Hg commits 3.33 +echo -n "Getting latest commits... " 3.34 +echo '<div class="feed-grid"><div class="right_box">' > $OUTPUT 3.35 +echo '<h3><img src="pics/website/feed.png" alt=".png" />Latest commits</h3>' >> $OUTPUT 3.36 +echo '<ul>' >> $OUTPUT 3.37 +hg log --repository $REPO --limit 5 --no-merges \ 3.38 + --template " <li><strong>{date|shortdate}</strong> \ 3.39 +- <a href=\"$URL/rev/{rev}\">{desc}</a></li>\n" >> $OUTPUT 2> /dev/null 3.40 +echo '</ul>' >> $OUTPUT 3.41 +echo '</div>' >> $OUTPUT 3.42 +echo "Done" 3.43 + 3.44 +# Latest cooked packages by the build bot. 3.45 +echo -n "Getting latest cooked packages... " 3.46 +echo '<div class="left_box">' >> $OUTPUT 3.47 +echo '<h3><img src="pics/website/feed.png" alt=".png" />Latest cooked packages</h3>' >> $OUTPUT 3.48 +echo '<ul>' >> $OUTPUT 3.49 +cd $PKGS && ls -1t *.tazpkg | head -5 | \ 3.50 +while read file 3.51 +do 3.52 + echo -n ' <li><strong>'$(stat -c '%y' $PKGS/$file | \ 3.53 + cut -d ' ' -f 1); echo "</strong> - $file</li>" 3.54 +done >> $OUTPUT 3.55 +echo '</ul>' >> $OUTPUT 3.56 +echo '</div></div>' >> $OUTPUT 3.57 +echo "Done"
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/libs/js/slideshow.js Sun Jan 23 23:01:40 2011 +0100 4.3 @@ -0,0 +1,57 @@ 4.4 + 4.5 +window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init); 4.6 + 4.7 +var d=document, imgs = new Array(), zInterval = null, current=0, pause=false; 4.8 + 4.9 +function so_init() 4.10 +{ 4.11 + if(!d.getElementById || !d.createElement)return; 4.12 + 4.13 + imgs = d.getElementById('slideshow').getElementsByTagName('img'); 4.14 + for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0; 4.15 + imgs[0].style.display = 'block'; 4.16 + imgs[0].xOpacity = .99; 4.17 + 4.18 + setTimeout(so_xfade,4000); 4.19 +} 4.20 + 4.21 +function so_xfade() 4.22 +{ 4.23 + cOpacity = imgs[current].xOpacity; 4.24 + nIndex = imgs[current+1]?current+1:0; 4.25 + nOpacity = imgs[nIndex].xOpacity; 4.26 + 4.27 + cOpacity-=.05; 4.28 + nOpacity+=.05; 4.29 + 4.30 + imgs[nIndex].style.display = 'block'; 4.31 + imgs[current].xOpacity = cOpacity; 4.32 + imgs[nIndex].xOpacity = nOpacity; 4.33 + 4.34 + setOpacity(imgs[current]); 4.35 + setOpacity(imgs[nIndex]); 4.36 + 4.37 + if(cOpacity<=0) 4.38 + { 4.39 + imgs[current].style.display = 'none'; 4.40 + current = nIndex; 4.41 + setTimeout(so_xfade,4000); 4.42 + } 4.43 + else 4.44 + { 4.45 + setTimeout(so_xfade,60); 4.46 + } 4.47 + 4.48 + function setOpacity(obj) 4.49 + { 4.50 + if(obj.xOpacity>.99) 4.51 + { 4.52 + obj.xOpacity = .99; 4.53 + return; 4.54 + } 4.55 + 4.56 + obj.style.opacity = obj.xOpacity; 4.57 + obj.style.MozOpacity = obj.xOpacity; 4.58 + obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')'; 4.59 + } 4.60 +}
5.1 --- a/scripts/get-latest.sh Sun Jan 23 11:21:24 2011 +0100 5.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 5.3 @@ -1,35 +0,0 @@ 5.4 -#!/bin/sh 5.5 -# 5.6 -# Get latest commits and packages to display on the website main page. 5.7 -# On Tank, this script is executed by cron each hour. 5.8 -# 5.9 - 5.10 -REPO="/home/slitaz/repos/wok" 5.11 -URL="http://hg.slitaz.org/wok" 5.12 -PKGS="/home/slitaz/cooking/packages" 5.13 -OUTPUT="/var/cache/slitaz/website/latest.html" 5.14 - 5.15 -mkdir -p /var/cache/slitaz/website 5.16 - 5.17 -# Latest Hg commits 5.18 -echo -n "Getting latest commits... " 5.19 -echo '<h2>Latest commits</h2>' > $OUTPUT 5.20 -echo "<ul>" >> $OUTPUT 5.21 -hg log --repository $REPO --limit 5 --no-merges \ 5.22 - --template " <li><strong>{date|shortdate}</strong> \ 5.23 -- <a href=\"$URL/rev/{rev}\">{desc}</a></li>\n" >> $OUTPUT 2> /dev/null 5.24 -echo "</ul>" >> $OUTPUT 5.25 -echo "Done" 5.26 - 5.27 -# Latest cooked packages by the build bot. 5.28 -echo -n "Getting latest cooked packages... " 5.29 -echo '<h2>Latest cooked packages</h2>' >> $OUTPUT 5.30 -echo "<ul>" >> $OUTPUT 5.31 -cd $PKGS && ls -1t *.tazpkg | head -5 | \ 5.32 -while read file 5.33 -do 5.34 - echo -n ' <li><strong>'$(stat -c '%y' $PKGS/$file | \ 5.35 - cut -d ' ' -f 1); echo "</strong> - $file</li>" 5.36 -done >> $OUTPUT 5.37 -echo "</ul>" >> $OUTPUT 5.38 -echo "Done"
6.1 --- a/scripts/get_feed.php Sun Jan 23 11:21:24 2011 +0100 6.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 6.3 @@ -1,19 +0,0 @@ 6.4 -<?php 6.5 - 6.6 -// Read Feed 6.7 -function get_feed($feed_url) { 6.8 - $content = file_get_contents($feed_url); 6.9 - $x = new SimpleXmlElement($content); 6.10 - echo "<ul>"; 6.11 - foreach($x->channel->item as $entry) { 6.12 - echo " 6.13 - <li> 6.14 - <strong><a href='$entry->link' 6.15 - title='$entry->title'>" . $entry->title . "</a></strong> 6.16 - <p>$entry->description</p> 6.17 - </li>"; 6.18 - } 6.19 - echo "</ul>"; 6.20 -} 6.21 - 6.22 -?>
7.1 --- a/scripts/slideshow.js Sun Jan 23 11:21:24 2011 +0100 7.2 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 7.3 @@ -1,57 +0,0 @@ 7.4 - 7.5 -window.addEventListener?window.addEventListener('load',so_init,false):window.attachEvent('onload',so_init); 7.6 - 7.7 -var d=document, imgs = new Array(), zInterval = null, current=0, pause=false; 7.8 - 7.9 -function so_init() 7.10 -{ 7.11 - if(!d.getElementById || !d.createElement)return; 7.12 - 7.13 - imgs = d.getElementById('slideshow').getElementsByTagName('img'); 7.14 - for(i=1;i<imgs.length;i++) imgs[i].xOpacity = 0; 7.15 - imgs[0].style.display = 'block'; 7.16 - imgs[0].xOpacity = .99; 7.17 - 7.18 - setTimeout(so_xfade,4000); 7.19 -} 7.20 - 7.21 -function so_xfade() 7.22 -{ 7.23 - cOpacity = imgs[current].xOpacity; 7.24 - nIndex = imgs[current+1]?current+1:0; 7.25 - nOpacity = imgs[nIndex].xOpacity; 7.26 - 7.27 - cOpacity-=.05; 7.28 - nOpacity+=.05; 7.29 - 7.30 - imgs[nIndex].style.display = 'block'; 7.31 - imgs[current].xOpacity = cOpacity; 7.32 - imgs[nIndex].xOpacity = nOpacity; 7.33 - 7.34 - setOpacity(imgs[current]); 7.35 - setOpacity(imgs[nIndex]); 7.36 - 7.37 - if(cOpacity<=0) 7.38 - { 7.39 - imgs[current].style.display = 'none'; 7.40 - current = nIndex; 7.41 - setTimeout(so_xfade,4000); 7.42 - } 7.43 - else 7.44 - { 7.45 - setTimeout(so_xfade,60); 7.46 - } 7.47 - 7.48 - function setOpacity(obj) 7.49 - { 7.50 - if(obj.xOpacity>.99) 7.51 - { 7.52 - obj.xOpacity = .99; 7.53 - return; 7.54 - } 7.55 - 7.56 - obj.style.opacity = obj.xOpacity; 7.57 - obj.style.MozOpacity = obj.xOpacity; 7.58 - obj.style.filter = 'alpha(opacity=' + (obj.xOpacity*100) + ')'; 7.59 - } 7.60 -}
8.1 --- a/slitaz.css Sun Jan 23 11:21:24 2011 +0100 8.2 +++ b/slitaz.css Sun Jan 23 23:01:40 2011 +0100 8.3 @@ -288,7 +288,7 @@ 8.4 -ms-transform: rotate(-45deg) skew(15deg, 15deg); 8.5 transform: rotate(-45deg) skew(15deg, 15deg); 8.6 } 8.7 -#twitter, .feedbox { 8.8 +#twitter { 8.9 margin-top: 20px; 8.10 -moz-border-radius: 8px; 8.11 -webkit-border-radius: 8px; 8.12 @@ -297,16 +297,10 @@ 8.13 -webkit-box-shadow: 0 1px 3px #666; 8.14 box-shadow: 0 1px 3px #666; 8.15 } 8.16 -.feedbox { 8.17 - background-color: #f9f9f9; 8.18 - padding: 10px 20px; 8.19 - margin: 20px 100px; 8.20 -} 8.21 -.feedbox div { 8.22 - height: 320px; 8.23 - overflow: auto; 8.24 -} 8.25 -.feedbox ul { list-style-type: none; margin: 0; } 8.26 +.feed-grid { height: 180px; overflow: hidden; } 8.27 +.feed-grid h3 { margin: 15px 0 0; } 8.28 +.feed-grid span { font-size: 10px; color: #888; margin-left: 24px; } 8.29 +.feed-grid ul { color: #888; } 8.30 8.31 /* Clouds */ 8.32 #cloud {