diff --git a/config/config.php b/config/config.php new file mode 100644 index 0000000..48e73ee --- /dev/null +++ b/config/config.php @@ -0,0 +1,6 @@ + \ No newline at end of file diff --git a/config/config.yml b/config/config.yml index 3d854b2..8564c08 100644 --- a/config/config.yml +++ b/config/config.yml @@ -59,4 +59,3 @@ DummyPlugin.enabled: false # Force the plugin "DummyPlugin" to be disab # Custom # my_custom_setting: Hello World! # You can access custom settings in themes using {{ config.my_custom_setting }} -rss_feed: http://enlacezapatista.ezln.org.mx/feed diff --git a/plugins/rss_content.php b/plugins/rss_content.php new file mode 100644 index 0000000..96fc995 --- /dev/null +++ b/plugins/rss_content.php @@ -0,0 +1,65 @@ + + */ +class Rss_Content { + + public function __construct() { + + } + + // Get the settings from config.php + public function config_loaded(&$settings) { + + $this->config = $settings; + + } + + //Set the twig variable + public function before_render(&$twig_vars, &$twig) { + + $twig_vars['rss_content'] = $this->rss_content(); + + } + + /** + * Get the rss data and set the array + * @return array + */ + private function rss_content() { + + // include the config + $config = $this->config; + + // get the feed url + if (isset($config['rss_feed'])) { + $url = $config['rss_feed']; + } + + // set date format to default + $date_format = $config['date_format']; + + // build the array + $rss = new DOMDocument(); + $rss->load($url); + $feed = array(); + + foreach ($rss->getElementsByTagName('item') as $node) { + $item = array ( + 'title' => $node->getElementsByTagName('title')->item(0)->nodeValue, + //'description' => $node->getElementsByTagName('description')->item(0)->nodeValue, + "description" => html_entity_decode($node->getElementsByTagName('description')->item(0)->nodeValue), + 'link' => $node->getElementsByTagName('link')->item(0)->nodeValue, + 'date' => date($date_format, strtotime($node->getElementsByTagName('pubDate')->item(0)->nodeValue)), + ); + array_push($feed, $item); + } + return $feed; + } + +} diff --git a/plugins/rss_to_md.php b/plugins/rss_to_md.php deleted file mode 100644 index efd968e..0000000 --- a/plugins/rss_to_md.php +++ /dev/null @@ -1,125 +0,0 @@ - - */ - -class Rss_to_md { - - public function __construct() { - - } - - // Get the settings from config.php - public function config_loaded(&$settings) { - - $this->config = $settings; - - } - - //Set the twig variable - public function before_render(&$twig_vars, &$twig) { - - $twig_vars['rss_to_md'] = $this->rss_to_md(); - - } - - /** - * Get the rss data - */ - - private function rss_to_md() { - - /* ============================= - Debugging - @description: Debug an array - @lastupdated: 26/02/2014 - @updatedby: James Kemp - - $item string/array - $die boolean Should we kill PHP after showing the debug data? - $vardump boolean - ============================= */ - - function d($item, $die = true, $vardump = false) { - if($die) { - die('
' . ($vardump ? var_dump($item) : print_r($item, true)) . '
'); - } else { - echo '
';
-                    ($vardump ? var_dump($item) : print_r($item));
-                echo '
'; - } - } - - if (isset($_GET['importer'])) { - - // include the config - $config = $this->config; - - // get the feed url - if (isset($config['rss_feed'])) { - $url = $config['rss_feed']; - } - - // set date format to default - $date_format = $config['date_format']; - - // build the array - $rss = new DOMDocument(); - $rss->load($url); - - //d($rss); - - function seoUrl($string) { - //Lower case everything - $string = strtolower($string); - //Make alphanumeric (removes all other characters) - $string = preg_replace("/[^a-z0-9_\s-]/", "", $string); - //Clean up multiple dashes or whitespaces - $string = preg_replace("/[\s-]+/", " ", $string); - //Convert whitespaces and underscore to dash - $string = preg_replace("/[\s_]/", "-", $string); - return $string; - } - - foreach ($rss->getElementsByTagName('item') as $node) { - - $title = $node->getElementsByTagName('title')->item(0)->nodeValue; - $date = date($date_format, strtotime($node->getElementsByTagName('pubDate')->item(0)->nodeValue)); - $description = $node->getElementsByTagName('description')->item(0)->nodeValue; - $permalink = seoUrl($title); - $rssLink = $node->getElementsByTagName('link')->item(0)->nodeValue; - - $postMd = fopen('content/sidebars/'.$permalink.".md", "w") or die("Unable to open file!"); - // open meta - $content = "/*\n"; - fwrite($postMd, $content); - - $content = 'Title: '.$title."\n"; - fwrite($postMd, $content); - - $content = 'Date: '.$date."\n"; - fwrite($postMd, $content); - - $content = 'Link: '.$rssLink."\n"; - fwrite($postMd, $content); - - // close meta - $content = "*/\n\n"; - fwrite($postMd, $content); - // close meta - $content = $description."\n"; - fwrite($postMd, $content); - - fclose($postMd); - } - - } - - } - -} diff --git a/themes/Travelify-tr00_popravljena/images/rss.png b/themes/Travelify-tr00_popravljena/images/rss.png new file mode 100644 index 0000000..9707305 Binary files /dev/null and b/themes/Travelify-tr00_popravljena/images/rss.png differ diff --git a/themes/Travelify-tr00_popravljena/index-novice.twig b/themes/Travelify-tr00_popravljena/index-novice.twig index 1147a69..fa6442b 100644 --- a/themes/Travelify-tr00_popravljena/index-novice.twig +++ b/themes/Travelify-tr00_popravljena/index-novice.twig @@ -75,6 +75,7 @@ {% endif %} {% endfor %} + {{ include('rss_feed.twig') }} diff --git a/themes/Travelify-tr00_popravljena/index.twig b/themes/Travelify-tr00_popravljena/index.twig index 40a5d0d..272f005 100644 --- a/themes/Travelify-tr00_popravljena/index.twig +++ b/themes/Travelify-tr00_popravljena/index.twig @@ -1,6 +1,5 @@ - {% if meta.title %}{{ meta.title }}{% else %}{{ site_title }}{% endif %} @@ -66,6 +65,7 @@ {% endif %} {% endfor %} + {{ include('rss_feed.twig') }} diff --git a/themes/Travelify-tr00_popravljena/rss_feed.twig b/themes/Travelify-tr00_popravljena/rss_feed.twig new file mode 100644 index 0000000..153e65f --- /dev/null +++ b/themes/Travelify-tr00_popravljena/rss_feed.twig @@ -0,0 +1,11 @@ + \ No newline at end of file diff --git a/themes/Travelify-tr00_popravljena/styles/style.css b/themes/Travelify-tr00_popravljena/styles/style.css index 5a2530b..4659669 100644 --- a/themes/Travelify-tr00_popravljena/styles/style.css +++ b/themes/Travelify-tr00_popravljena/styles/style.css @@ -2569,3 +2569,6 @@ header .container { .video { position: relative; padding-bottom: 56.25%; padding-top: 30px; height: 0; overflow: hidden; } .video iframe, .video-container object, .video-container embed { position: absolute; top: 0; left: 0; width: 100%; height: 100%; } +/* RSS feed ikonca */ +.rss_ikonca {border:0; padding-top:0.5rem;} +