commit c82bfef5406207d7679cc456b9cdc7f715442413 Author: Joel Pittet Date: Tue Apr 9 21:10:20 2013 -0700 undo and cleanup diff --git a/core/includes/common.inc b/core/includes/common.inc index 7602a9f..617d27b 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -1594,6 +1594,46 @@ function filter_xss_bad_protocol($string, $decode = TRUE) { */ /** + * Formats an RSS channel. + * + * Arbitrary elements may be added using the $args associative array. + */ +function format_rss_channel($title, $link, $description, $items, $langcode = NULL, $args = array()) { + $langcode = $langcode ? $langcode : language(LANGUAGE_TYPE_CONTENT)->langcode; + + $output = "\n"; + $output .= ' ' . check_plain($title) . "\n"; + $output .= ' ' . check_url($link) . "\n"; + + // The RSS 2.0 "spec" doesn't indicate HTML can be used in the description. + // We strip all HTML tags, but need to prevent double encoding from properly + // escaped source data (such as & becoming &). + $output .= ' ' . check_plain(decode_entities(strip_tags($description))) . "\n"; + $output .= ' ' . check_plain($langcode) . "\n"; + $output .= format_xml_elements($args); + $output .= $items; + $output .= "\n"; + + return $output; +} + +/** + * Formats a single RSS item. + * + * Arbitrary elements may be added using the $args associative array. + */ +function format_rss_item($title, $link, $description, $args = array()) { + $output = "\n"; + $output .= ' ' . check_plain($title) . "\n"; + $output .= ' ' . check_url($link) . "\n"; + $output .= ' ' . check_plain($description) . "\n"; + $output .= format_xml_elements($args); + $output .= "\n"; + + return $output; +} + +/** * Formats XML elements. * * @param $array diff --git a/core/modules/aggregator/aggregator.pages.inc b/core/modules/aggregator/aggregator.pages.inc index 181095f..8e14ae7 100644 --- a/core/modules/aggregator/aggregator.pages.inc +++ b/core/modules/aggregator/aggregator.pages.inc @@ -438,44 +438,44 @@ function template_preprocess_aggregator_page_rss(&$variables) { drupal_add_http_header('Content-Type', 'application/rss+xml; charset=utf-8'); - foreach ($feeds as &$feed) { - $feed->show_more = FALSE; - - switch ($feed_length) { - case 'teaser': - $summary = text_summary($feed->description, NULL, config('aggregator.settings')->get('items.teaser_length')); - if ($summary != $feed->description) { - $feed->show_more = TRUE; - } + $items = array(); + $feed_length = config('system.rss')->get('items.view_mode'); + foreach ($feeds as $feed) { + switch ($feed_length) { + case 'teaser': + $summary = text_summary($feed->description, NULL, config('aggregator.settings')->get('items.teaser_length')); + if ($summary != $feed->description) { + $summary = array( + $summary, + array( + '#prefix' => '

', + '#suffix' => "

\n", + '#theme' => 'link', + '#path' => check_url($feed->link), + '#title' => t('read more'), + ), + ); + } $feed->description = $summary; break; case 'title': $feed->description = ''; break; } - $feed->title = check_plain($feed->ftitle . ': ' . $feed->title); - $feed->link = check_url($feed->link); - $feed->description = check_plain($feed->description); - if (empty($feed->args) || !is_array($feed->args)) { - $feed->args = array(); - } - $feed->args += array('pubDate' => date('r', $feed->timestamp)); - $feed->args = format_xml_elements($feed->args); - + $items[] = format_rss_item($feed->ftitle . ': ' . $feed->title, $feed->link, $feed->description, array('pubDate' => date('r', $feed->timestamp))); } - + $site_name = config('system.site')->get('name'); $url = url((isset($category) ? 'aggregator/categories/' . $category->cid : 'aggregator'), array('absolute' => TRUE)); $description = isset($category) ? t('@site_name - aggregated feeds in category @title', array('@site_name' => $site_name, '@title' => $category->title)) : t('@site_name - aggregated feeds', array('@site_name' => $site_name)); - $variables['feed_length'] = config('system.rss')->get('items.view_mode'); $variables['title'] = check_plain(t('@site_name aggregator', array('@site_name' => $site_name))); $variables['link'] = check_url($url); // The RSS 2.0 "spec" doesn't indicate HTML can be used in the description. // We strip all HTML tags, but need to prevent double encoding from properly // escaped source data (such as & becoming &). $variables['description'] = check_plain(decode_entities(strip_tags($description))); - $variables['items'] = $feeds; + $variables['items'] = $items; $langcode = (isset($category['langcode']) ? $category['langcode'] : language(LANGUAGE_TYPE_CONTENT)->langcode); $variables['langcode'] = check_plain($langcode); diff --git a/core/modules/aggregator/templates/aggregator-feed-source.html.twig b/core/modules/aggregator/templates/aggregator-feed-source.html.twig index 653cd4d..33fac7e 100644 --- a/core/modules/aggregator/templates/aggregator-feed-source.html.twig +++ b/core/modules/aggregator/templates/aggregator-feed-source.html.twig @@ -30,6 +30,6 @@ {{ 'URL'|t }}: {{ source_url }}
- {{ 'Updated'|t }}: + {{ 'Updated'|t }}: {{ last_checked }}
diff --git a/core/modules/aggregator/templates/aggregator-page-opml.html.twig b/core/modules/aggregator/templates/aggregator-page-opml.html.twig index 3a9f28d..035d76c 100644 --- a/core/modules/aggregator/templates/aggregator-page-opml.html.twig +++ b/core/modules/aggregator/templates/aggregator-page-opml.html.twig @@ -24,7 +24,7 @@ {% for feed in feeds %} - + {% endfor %} diff --git a/core/modules/aggregator/templates/aggregator-page-rss.html.twig b/core/modules/aggregator/templates/aggregator-page-rss.html.twig index aefe283..9ad37ea 100644 --- a/core/modules/aggregator/templates/aggregator-page-rss.html.twig +++ b/core/modules/aggregator/templates/aggregator-page-rss.html.twig @@ -1,17 +1,17 @@ {# /** * @file - * Default theme implementation to present @todo. + * Default theme implementation for an RSS feed page. * * Available variables: - * - title: @todo - * - date: @todo - * - feeds: @todo - * - feed.title: @todo - * - feed.url: @todo + * - title: RSS channel title. + * - link: RSS channel link. + * - description: RSS channel description. + * - language: RSS channel language code. + * - items: RSS feed items. * * @see template_preprocess() - * @see template_preprocess_aggregator_page_opml() + * @see template_preprocess_aggregator_page_rss() * * @ingroup themeable */ @@ -19,23 +19,13 @@ - {{ title }} - {{ link }} - {{ description }} - {{ langcode }} - {{ args }} - {% for item in items %} - - {{ item.title }} - {{ item.link }} - - {{- item.description }} - {% if item.show_more %} -

{{ 'read more' | t }}

- {% endif %} -
- {{ item.args }} -
- {% endfor %} -
+ {{ title }} + {{ link }} + {{ description }} + {{ langcode }} + {{ args }} + {% for item in items %} + {{ item }} + {% endfor %} +
diff --git a/core/modules/aggregator/templates/aggregator-summary-item.html.twig b/core/modules/aggregator/templates/aggregator-summary-item.html.twig index 340a1d9..6e2d8b1 100644 --- a/core/modules/aggregator/templates/aggregator-summary-item.html.twig +++ b/core/modules/aggregator/templates/aggregator-summary-item.html.twig @@ -13,4 +13,4 @@ * @ingroup themeable */ #} -{{ url }} {{ age }} \ No newline at end of file +{{ url }} {{ age }} diff --git a/core/modules/aggregator/templates/aggregator-summary-items.html.twig b/core/modules/aggregator/templates/aggregator-summary-items.html.twig index 68c2326..5376fda 100644 --- a/core/modules/aggregator/templates/aggregator-summary-items.html.twig +++ b/core/modules/aggregator/templates/aggregator-summary-items.html.twig @@ -20,5 +20,5 @@

{{ title }}

{{ summary_list }} diff --git a/core/modules/node/node.module b/core/modules/node/node.module index f8b42fb..36dcfe0 100644 --- a/core/modules/node/node.module +++ b/core/modules/node/node.module @@ -2098,7 +2098,7 @@ function node_feed($nids = FALSE, $channel = array()) { // Load all nodes to be rendered. $nodes = node_load_multiple($nids); - $items = array(); + $items = ''; foreach ($nodes as $node) { $item_text = ''; @@ -2124,13 +2124,8 @@ function node_feed($nids = FALSE, $channel = array()) { $build['links']['#weight'] = 1000; $item_text .= drupal_render($build); } - $item = new stdClass(); - $item->title = $node->label(); - $item->link = $node->link; - $item->description = $item_text; - $item->args = $node->rss_elements; - $items[] = $item; + $items .= format_rss_item($node->label(), $node->link, $item_text, $node->rss_elements); } $channel_defaults = array( @@ -2138,17 +2133,17 @@ function node_feed($nids = FALSE, $channel = array()) { 'title' => config('system.site')->get('name'), 'link' => $base_url, 'description' => $rss_config->get('channel.description'), - 'langcode' => $language_content->langcode, + 'language' => $language_content->langcode ); $channel_extras = array_diff_key($channel, $channel_defaults); $channel = array_merge($channel_defaults, $channel); - $build = array( - '#theme' => 'aggregator_page_rss', - '#category' => (object) $channel, - '#feeds' => $items, - ); - return $build; + $output = "\n"; + $output .= "\n"; + $output .= format_rss_channel($channel['title'], $channel['link'], $channel['description'], $items, $channel['language'], $channel_extras); + $output .= "\n"; + + return new Response($output, 200, array('Content-Type' => 'application/rss+xml; charset=utf-8')); } /**