Skip to content

Commit

Permalink
Add support for putting nuggets in RSS feeds
Browse files Browse the repository at this point in the history
  • Loading branch information
garvinhicking committed Jun 23, 2014
1 parent 59f90ea commit a36eece
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
4 changes: 4 additions & 0 deletions serendipity_event_page_nugget/ChangeLog
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
1.11:
-----

Add support for putting nuggets in RSS feeds
2 changes: 1 addition & 1 deletion serendipity_event_page_nugget/lang_en.inc.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@
@define('PLUGIN_PAGE_NUGGET_LANG', 'Choose language');
@define('PLUGIN_PAGE_NUGGET_ALL', 'All Languages');
@define('PLUGIN_PAGE_NUGGET_NOSHOW', ' It does not show up on the actual page.');

@define('PLUGIN_PAGE_NUGGET_RSS', 'RSS/Atom feeds');
?>
25 changes: 22 additions & 3 deletions serendipity_event_page_nugget/serendipity_event_page_nugget.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function introspect(&$propbag)
$propbag->add('description', PLUGIN_PAGE_NUGGET_DESC);
$propbag->add('stackable', true);
$propbag->add('author', 'Wesley Hwang-Chung');
$propbag->add('version', '1.10');
$propbag->add('version', '1.11');
$propbag->add('requirements', array(
'serendipity' => '0.8',
'smarty' => '2.6.7',
Expand All @@ -34,7 +34,8 @@ function introspect(&$propbag)
'entries_header' => true,
'entry_display' => true,
'entries_footer' => true,
'frontend_footer' => true));
'frontend_footer' => true,
'frontend_display' => true));
$propbag->add('configuration', array('title', 'placement', 'language', 'content', 'markup', 'show_where'));
}

Expand All @@ -54,7 +55,8 @@ function introspect_config_item($name, &$propbag)
'top' => PLUGIN_PAGE_NUGGET_TOP,
'art_foot' => PLUGIN_PAGE_NUGGET_ART_FOOT,
'bottom' => PLUGIN_PAGE_NUGGET_BOTTOM,
'foot' => PLUGIN_PAGE_NUGGET_FOOT);
'foot' => PLUGIN_PAGE_NUGGET_FOOT,
'rss' => PLUGIN_PAGE_NUGGET_RSS);
$propbag->add('type', 'select');
$propbag->add('select_values', $select);
$propbag->add('name', PLUGIN_PAGE_NUGGET_PLACE);
Expand Down Expand Up @@ -135,8 +137,25 @@ function event_hook($event, &$bag, &$eventData, $addData = null) {
$placement = $this->get_config('placement', 'top');
$language = $this->get_config('language', 'all');
$show_where = $this->get_config('show_where', 'both');

// if the language doesn't match, do not display
if ($language != 'all' && $serendipity['lang'] != $language) return false;

// RSS-Feed special case
if ($event == 'frontend_display' && $addData['from'] == 'functions_entries:printEntries_rss') {
if ($placement == 'rss') {
if ($this->get_config('markup', 'true') == 'true' && $event != 'frontend_header') {
$entry = array('html_nugget' => $this->get_config('content'));
serendipity_plugin_api::hook_event('frontend_display', $entry);
$eventData['body'] .= $entry['html_nugget'];
} else {
$eventData['body'] .= $this->get_config('content');
}
}

return true;
}

// where to show
if ($show_where == 'extended' && (!isset($serendipity['GET']['id']) || !is_numeric($serendipity['GET']['id']))) {
return false;
Expand Down

0 comments on commit a36eece

Please sign in to comment.