Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Microformats tweaks #546

Merged
merged 2 commits into from Jun 17, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 12 additions & 7 deletions sources/controllers/News.controller.php
Expand Up @@ -134,8 +134,8 @@ function action_showfeed()
$context['optimize_msg']['lowest'] = 'm.id_msg >= ' . max(0, $modSettings['maxMsgID'] - 100 - $_GET['limit'] * 5);
}

// Show in rss or proprietary format?
$xml_format = isset($_GET['type']) && in_array($_GET['type'], array('smf', 'rss', 'rss2', 'atom', 'rdf', 'webslice')) ? $_GET['type'] : 'smf';
// If format isn't set, rss2 is default
$xml_format = isset($_GET['type']) && in_array($_GET['type'], array('rss', 'rss2', 'atom', 'rdf', 'webslice')) ? $_GET['type'] : 'rss2';

// @todo Birthdays?

Expand All @@ -153,7 +153,7 @@ function action_showfeed()
if (empty($_GET['sa']) || !isset($subActions[$_GET['sa']]))
$_GET['sa'] = 'recent';

// @todo Temp - webslices doesn't do everything yet.
// @todo Temp - webslices doesn't do everything yet. (only recent posts)
if ($xml_format == 'webslice' && $_GET['sa'] != 'recent')
$xml_format = 'rss2';
// If this is webslices we kinda cheat - we allow a template that we call direct for the HTML, and we override the CDATA.
Expand Down Expand Up @@ -194,7 +194,7 @@ function action_showfeed()
else
ob_start();

if ($xml_format == 'smf' || isset($_REQUEST['debug']))
if (isset($_REQUEST['debug']))
header('Content-Type: text/xml; charset=UTF-8');
elseif ($xml_format == 'rss' || $xml_format == 'rss2' || $xml_format == 'webslice')
header('Content-Type: application/rss+xml; charset=UTF-8');
Expand Down Expand Up @@ -234,6 +234,11 @@ function action_showfeed()
}
elseif ($xml_format == 'webslice')
{
// Format specification http://msdn.microsoft.com/en-us/library/cc304073%28VS.85%29.aspx
// Known browsers to support webslices: IE8, IE9, Firefox with Webchunks addon.
// It uses RSS 2.

// We send a feed with recent posts, and alerts for PMs for logged in users
$context['recent_posts_data'] = $xml;
$context['can_pm_read'] = allowedTo('pm_read');

Expand Down Expand Up @@ -282,8 +287,8 @@ function action_showfeed()
echo '
</feed>';
}
//@todo to not change much, rdf by default, maybe better use rss?
else //if ($xml_format == 'rdf')
// rdf by default
else
{
echo '
<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns="http://purl.org/rss/1.0/">
Expand Down Expand Up @@ -999,4 +1004,4 @@ function dumpTags($data, $i, $tag = null, $xml_format = '')
echo fix_possible_url($val), '</', $key, '>';
}
}
}
}
4 changes: 3 additions & 1 deletion themes/default/BoardIndex.template.php
Expand Up @@ -220,6 +220,8 @@ function template_info_center()
// This is the "Recent Posts" bar.
if (!empty($settings['number_recent_posts']) && (!empty($context['latest_posts']) || !empty($context['latest_post'])))
{
// Show the Recent Posts title, and attach webslices feed to this section
// The format requires: hslice, entry-title and entry-content classes
echo '
<div class="title_barIC">
<h4 class="titlebg">
Expand Down Expand Up @@ -492,4 +494,4 @@ function template_news_fader()
}
});
// ]]></script>';
}
}
15 changes: 13 additions & 2 deletions themes/default/Xml.template.php
Expand Up @@ -391,6 +391,9 @@ function template_generic_xml_recursive($xml_data, $parent_ident, $child_ident,
echo "\n", str_repeat("\t", $level), '</', $parent_ident, '>';
}

/**
* Output before webslices content
*/
function template_webslice_header_above()
{
global $settings;
Expand All @@ -399,21 +402,28 @@ function template_webslice_header_above()
<link rel="stylesheet" href="', $settings['default_theme_url'], '/css/wireless.css" />';
}

/**
* Output after webslices content
*/
function template_webslice_header_below()
{
}

// This shows a webslice of the recent posts.
/**
* This shows a webslice of the recent posts.
*/
function template_webslice_recent_posts()
{
global $context, $scripturl, $txt;

// @todo test if this works
echo '
<div style="width: 100%; height: 100%; border: 1px solid black; padding: 0; margin: 0 0 0 0; font: 100.01%/100% Verdana, Helvetica, sans-serif;">
<div style="background: #080436; color: #ffffff; padding: 4px;">
', cleanXml($txt['recent_posts']), '
</div>';

// Recent posts bit
$alternate = 0;
foreach ($context['recent_posts_data'] as $item)
{
Expand All @@ -429,6 +439,7 @@ function template_webslice_recent_posts()
<div style="width: 100%; height: 100%; border: 0; padding: 0; margin: 0 0 0 0; font: 100.01%/100% Verdana, Helvetica, sans-serif;">
<div style="font-size: xx-small;" class="righttext">';

// Send alerts for the logged in user if they have new PMs
if ($context['user']['is_guest'])
echo '
<a href="', $scripturl, '?action=login">', $txt['login'], '</a>';
Expand All @@ -453,4 +464,4 @@ function template_xml_draft()
<drafts>
<draft id="', $context['id_draft'], '"><![CDATA[', $txt['draft_saved_on'], ': ', relativeTime($context['draft_saved_on']), ']]></draft>
</drafts>';
}
}