Skip to content

Commit

Permalink
Homepage: Revised front page design; use jQuery XML parsing for build…
Browse files Browse the repository at this point in the history
… events

Sadly it seems that phpBB's Atom feed is completely uncached, so for
the news feeds we'll use Google's Feed API service (which implements
the cache that phpBB should have...).

However this means that we can't extract the feed "source" URI from
the JSON response which Google serves (in the case of an Atom feed
for a subforum phpBB encodes the source using the 'domain' attribute
of the category tag, which is not interpreted by Google's service).
  • Loading branch information
danij-deng committed Jul 14, 2013
1 parent 2703ee0 commit 69c1f9a
Show file tree
Hide file tree
Showing 2 changed files with 126 additions and 68 deletions.
2 changes: 1 addition & 1 deletion web/classes/frontcontroller.class.php
Expand Up @@ -447,7 +447,7 @@ private function outputFooter()
{
?>
<p class="disclaimer"><a href="mailto:webmaster@dengine.net" title="Contact Webmaster">Webmaster</a> - Site design &copy; <?php echo date('Y'); ?> Deng Team - Built by <a href="mailto:<?php echo $this->siteAuthorEmail(); ?>" title="Contact <?php echo $this->siteAuthor(); ?>"><?php echo $this->siteAuthor(); ?></a></p>
<p class="disclaimer">The Doomsday Engine is licensed under the terms of the <a href="http://www.gnu.org/licenses/gpl.html" rel="nofollow">GNU/GPL License ver 2</a>. The Doomsday Engine logo is Copyright &copy; 2005-<?php echo date('Y'); ?>, the deng team.</p>
<p class="disclaimer">The Doomsday Engine is licensed under the terms of the <a href="http://www.gnu.org/licenses/gpl.html" rel="nofollow">GNU/GPL License ver 2</a>. The Doomsday Engine logo is Copyright &copy; 2005-<?php echo date('Y'); ?>, the Deng Team.</p>
<hr />
<?php

Expand Down
192 changes: 125 additions & 67 deletions web/plugins/z#home/home.php
Expand Up @@ -155,108 +155,166 @@ public function execute($args=NULL)

(function (e) {
e.fn.interpretFeed = function (t) {
var n = {
feedUri: "http://rss.cnn.com/rss/edition.rss",
maxItems: 5,
maxContentChars: 0,
showContent: true,
showPubDate: true,
generateItemHtml: 0
var n = { feedUri: 'http://rss.cnn.com/rss/edition.rss',
dataType: 'xml',
maxItems: 5,
clearOnSuccess: true,
useGoogleApi: false,
generateItemHtml: 0
};
if (t) {
if(t) {
e.extend(n, t);
}
var r = e(this).attr("id");
var i;
//e("#" + r).empty().append('<div style="padding:3px;"><img src="images/loader.gif" /></div>');
e.ajax({
url: "http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=" + n.maxItems + "&output=json&q=" + encodeURIComponent(n.feedUri) + "&hl=en&callback=?",
dataType: "json",
success: function (t) {
//e("#" + r).empty();
var html = "";
e.each(t.responseData.feed.entries, function (e, t) {
html += '<li>' + n.generateItemHtml(n, t) + '</li>';
});
e("#" + r).append('<ol style="list-style-type: none;">' + html + "</ol>");
}
})
var r = e(this).attr('id');

if(n.useGoogleApi)
{
e.ajax({
url: 'http://ajax.googleapis.com/ajax/services/feed/load?v=1.0&num=' + n.maxItems + '&output=json&q=' + encodeURIComponent(n.feedUri) + '&hl=en&callback=?',
dataType: n.dataType,
success: function (t) {

if(n.clearOnSuccess)
{
e("#" + r).empty();
}

var html = "";
e.each(t.responseData.feed.entries, function (e, t) {
html += n.generateItemHtml(n, t);
});
e("#" + r).append('<ol style="list-style-type: none;">' + html + "</ol>");
}
});
}
else
{
e.ajax({
url: n.feedUri,
dataType: n.dataType,
success: function (t) {

if(n.clearOnSuccess)
{
e("#" + r).empty();
}

var xml = $(t);

var html = "";
xml.find('item').slice(0, n.maxItems).each(function() {
var self = $(this),
item = { title: self.children('title').text(),
link: self.children('link').text(),
author: self.children('author').text(),
pubDate: self.children('pubDate').text(),
atomSummary: self.children('atom\\:summary').text(),
description: self.children('description').text(),
author: self.children('author').text()
}
html += n.generateItemHtml(n, item);
});

e('#' + r).append('<ol style="list-style-type: none;">' + html + '</ol>');
}
});
}
}
})(jQuery)

$(document).ready(function () {
$('#recentbuilds').interpretFeed({
feedUri: 'http://dl.dropboxusercontent.com/u/11948701/builds/events.rss',
dataType: 'xml',
maxItems: 3,
generateItemHtml : function(n, t) {
var html = '<a href="' + t.link + '" title="Read more about ' + t.title.toLowerCase() + ' in the repository">' + t.title + ' completed</a>';
var d = new Date(t.pubDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
html += ' ' + niceDate;
d.setDate(d.getDate() + 2);
var isNew = (new Date() < d);
return '<li' + (isNew? ' class="new"' : '') + '>' + html + '</li>';
}
});

$('#column1').interpretFeed({
feedUri: 'http://dengine.net/forums/rss.php?mode=news',
feedUri: 'http://dl.dropboxusercontent.com/u/11948701/builds/events.rss',
dataType: 'xml',
maxItems: 3,
clearOnSuccess: false,
generateItemHtml: function (n, t) {
var html = '<article class="block newspost"><header><h1><a href="' + t.link + '" title="Discuss &#39;' + t.title + '&#39; in the user forum">' + t.title + '</a></h1>';
if (n.showPubDate) {
var d = new Date(t.publishedDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
html += '<p><time datetime="' + d.toISOString() + '" pubdate>' + niceDate + '</time></p>';
}
var html = '<div class="block"><article class="buildevent"><header><h1><a href="' + t.link + '" title="Read more about ' + t.title + ' in the repository">' + t.title + '</a></h1>';

var d = new Date(t.pubDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
html += '<p><time datetime="' + d.toISOString() + '" pubdate>' + niceDate + '</time></p>';

html += '</header>';
if (n.showContent) {
/*if (n.DescCharacterLimit > 0 && t.content.length > n.DescCharacterLimit) {
html += '<div>' + t.content.substr(0, n.DescCharacterLimit) + "...</div>";
}
else*/ {
html += t.content;
}
}
html += t.atomSummary;
html += '</article>';
return html;
html += '<div class="links"><a href="' + n.feedUri + '" class="link-rss" title="Doomsday Engine build events are reported via RSS">All builds</a></div></div>';
return '<li>' + html + '</li>';
}
});

$('#column1').interpretFeed({
feedUri: 'http://dl.dropboxusercontent.com/u/11948701/builds/events.rss',
feedUri: 'http://dengine.net/forums/rss.php?mode=news',
dataType: 'json',
clearOnSuccess: false,
useGoogleApi: true,
maxItems: 3,
showContent: true,
generateItemHtml: function (n, t) {
var html = '<article class="block buildevent"><header><h1><a href="' + t.link + '" title="Read more about ' + t.title + ' in the repository">' + t.title + '</a></h1>';
var html = '<div class="block"><article class="newspost content"><header><h1><a href="' + t.link + '" title="Discuss &#39;' + t.title + '&#39; in the user forums">' + t.title + '</a></h1>';

var d = new Date(t.publishedDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
if (n.showPubDate) {
html += '<p><time datetime="' + d.toISOString() + '" pubdate>' + niceDate + '</time></p>';
}
html += '<p><time datetime="' + d.toISOString() + '" pubdate>' + niceDate + '</time></p>';

html += '</header>';
if (n.showContent) {
html += 'Build report for ' + t.title.toLowerCase() + ' started on ' + niceDate + '.';
}
html += t.content;
html += '</article>';
return html;
html += '<div class="links"><a href="' + n.feedUri + '" class="link-rss" title="Doomsday Engine news is also available via RSS">All news</a></div></div>';
return '<li>' + html + '</li>';
}
});

$('#column2').interpretFeed({
feedUri: 'http://dengine.net/forums/rss.php?f=24',
dataType: 'json',
clearOnSuccess: false,
useGoogleApi: true,
maxItems: 3,
generateItemHtml: function (n, t) {
var html = '<article class="block blogpost"><header><h1><a href="' + t.link + '" title="Discuss &#39;' + t.title + '&#39; in the user forum">' + t.title + '</a></h1>';
if (n.showPubDate) {
var d = new Date(t.publishedDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
html += '<p><time datetime="' + d.toISOString() + '" pubdate>' + niceDate + '</time></p>';
}
var html = '<div class="block"><article class="blogpost content"><header><h1><a href="' + t.link + '" title="Discuss &#39;' + t.title + '&#39; in the user forums">' + t.title + '</a></h1>';

var d = new Date(t.publishedDate);
var niceDate = $.datepicker.formatDate('MM d, yy', d);
html += '<p><time datetime="' + d.toISOString() + '" pubdate>' + niceDate + '</time></p>';

html += '</header>';
if (n.showContent) {
/*if (n.DescCharacterLimit > 0 && t.content.length > n.DescCharacterLimit) {
html += '<div>' + t.content.substr(0, n.DescCharacterLimit) + "...</div>";
}
else*/ {
html += t.content;
}
}
html += t.content;
html += '</article>';
return html;
html += '<div class="links"><a href="' + n.feedUri + '" class="link-rss" title="The Doomsday Engine development blog is also available via RSS">All blogs</a></div></div>';
return '<li>' + html + '</li>';
}
});
});

</script>
<div id="column1" class="twocolumn"></div>
<div id="column2" class="twocolumn"></div>
<aside id="status" role="complementary" class="block">
<div class="twocolumn"><article>
<header><h1><a href="/builds" title="View the complete index in the build repository">Most recent builds</a></h1>
<p><script>
<!--
var niceDate = $.datepicker.formatDate('MM d, yy', new Date());
document.write(niceDate);
//-->
</script></p></header><div id="recentbuilds">Contacting build repository...</div></article></div>
<div class="twocolumn"><article id="activeservers"></article></div>
<div class="clear"></div>
</aside>
<div id="column1" class="twocolumn collapsible"></div>
<div id="column2" class="twocolumn collapsible"></div>
<div class="clear"></div>
</div>
<?php
Expand Down

0 comments on commit 69c1f9a

Please sign in to comment.