ene sprembe + dodan rss plugin

master
Uros Gu 2021-05-11 12:53:49 +02:00
parent 3993f6710b
commit 0c696b3e83
10 changed files with 159 additions and 3 deletions

View File

@ -3,4 +3,5 @@
``` ```
http://zapatista.kompot.si http://zapatista.kompot.si
``` ```
[http://zapatista.kompot.si](http://zapatista.kompot.si)
<http://zapatista.kompot.si>

Binary file not shown.

View File

@ -59,3 +59,4 @@ DummyPlugin.enabled: false # Force the plugin "DummyPlugin" to be disab
# Custom # Custom
# #
my_custom_setting: Hello World! # You can access custom settings in themes using {{ config.my_custom_setting }} 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

View File

@ -5,5 +5,3 @@ title: Navigation bar
- [Domov](%base_url%) - [Domov](%base_url%)
- [Kdo smo?](%base_url%?kdosmo) - [Kdo smo?](%base_url%?kdosmo)
- [Izjava za življenje](%base_url%?izjava) - [Izjava za življenje](%base_url%?izjava)
- [Novice](%base_url%?novice/gora)

View File

@ -0,0 +1,9 @@
---
Title: Kolaž dobrodošlice iz Evrope
Description: Video kolaž dobrodošlic iz različnih koncev Evrope!
Date: 2021-05-10
---
<iframe width="560" height="315" sandbox="allow-same-origin allow-scripts allow-popups" src="https://video.anartist.org/videos/embed/470f5abd-55e4-4708-a685-5715063387ea" frameborder="0" allowfullscreen></iframe>

View File

@ -0,0 +1,10 @@
---
Title: Za življenje
Description: Domači video izjave za življenje
Date: 2021-05-10
---
<iframe id="ytID" width="500" height="480" src="https://www.youtube.com/embed/nDak_hsICsY" frameborder="0" allowfullscreen></iframe> <script> var parrentYt = document.getElementById("ytID").parentElement; console.log(parrentYt); document.getElementById("ytID").width= parrentYt.offsetWidth; </script>

View File

@ -0,0 +1,7 @@
---
Title: Kolaž dobrodošlice iz Evrope
---
<iframe width="560" sandbox="allow-same-origin allow-scripts allow-popups" src="https://video.anartist.org/videos/embed/470f5abd-55e4-4708-a685-5715063387ea" frameborder="0" allowfullscreen></iframe>

View File

@ -0,0 +1,4 @@
---
Title: Izjava za življenje
---
<audio src=%assets_url%/ZaZivljenje-slo-CL.mp3 controls></audio>

View File

@ -0,0 +1,125 @@
<?php
/**
* RSS to Markdown *
* @package Pico
* @subpackage Rss_to_md
* @version 1.0
* @author Tom Hopcraft <tom@admirecreative.co.uk>
*/
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('<pre>' . ($vardump ? var_dump($item) : print_r($item, true)) . '</pre>');
} else {
echo '<pre>';
($vardump ? var_dump($item) : print_r($item));
echo '</pre>';
}
}
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);
}
}
}
}

View File

@ -48,6 +48,7 @@
{% for page in pages("novice/")|sort_by("date")|reverse if not page.hidden %} {% for page in pages("novice/")|sort_by("date")|reverse if not page.hidden %}
<div class="post"> <div class="post">
<h3><a href="{{ page.url }}">{{ page.title }}</a></h3> <h3><a href="{{ page.url }}">{{ page.title }}</a></h3>
<p>{{ page.description }}</p>
<p class="date">{{ page.date_formatted }}</p> <p class="date">{{ page.date_formatted }}</p>
</div> </div>
{% endfor %} {% endfor %}