diff options
| author | horus | 2022-10-26 01:23:50 +0200 |
|---|---|---|
| committer | horus | 2022-10-26 01:23:50 +0200 |
| commit | 882c0eb89b375cbfdd9c04b236cbab0d3f39a128 (patch) | |
| tree | 676c16e7beafdb8c11311b41b2bc22014c99aad1 | |
| parent | 79070c8855e5f3b87484196d6ef607a05979bf6c (diff) | |
| download | moehring-882c0eb89b375cbfdd9c04b236cbab0d3f39a128.tar.gz | |
integrates ghrss
| -rw-r--r-- | .gitignore | 2 | ||||
| -rw-r--r-- | functions.php | 6 | ||||
| l--------- | public/feed/ghrss/index.php | 1 | ||||
| -rw-r--r-- | public/feed/index.php | 3 | ||||
| -rw-r--r-- | public/index.php | 14 | ||||
| -rw-r--r-- | views/feeds.html | 30 | ||||
| -rw-r--r-- | views/tools.html | 21 | ||||
| -rw-r--r-- | views/tools/ghrss/composer.json | 5 | ||||
| -rw-r--r-- | views/tools/ghrss/composer.lock | 84 | ||||
| -rw-r--r-- | views/tools/ghrss/feed.php | 47 | ||||
| -rw-r--r-- | views/tools/ghrss/ghrss.db.php | 14 | ||||
| -rw-r--r-- | views/tools/ghrss/index.html | 32 |
12 files changed, 254 insertions, 5 deletions
@@ -1,5 +1,7 @@ *.swp *~ +db_passwd.php + vendor/ img/ diff --git a/functions.php b/functions.php index 9bd65e4..8a31111 100644 --- a/functions.php +++ b/functions.php @@ -23,3 +23,9 @@ function str_ends_with( $haystack, $needle) { } return substr($haystack, -$len) === $needle; } + +function get_ghrss_feeds() { + require_once __DIR__ . '/views/tools/ghrss/ghrss.db.php'; + $result = $db->query("SELECT name FROM language ORDER BY name;"); + return $result->fetchAll(); +} diff --git a/public/feed/ghrss/index.php b/public/feed/ghrss/index.php new file mode 120000 index 0000000..49697a9 --- /dev/null +++ b/public/feed/ghrss/index.php @@ -0,0 +1 @@ +../../../views/tools/ghrss/feed.php
\ No newline at end of file diff --git a/public/feed/index.php b/public/feed/index.php new file mode 100644 index 0000000..d29aba0 --- /dev/null +++ b/public/feed/index.php @@ -0,0 +1,3 @@ +<?php + +header("Location: https://" . $_SERVER["HTTP_HOST"] . "/feeds/"); diff --git a/public/index.php b/public/index.php index 1de542e..c62faf5 100644 --- a/public/index.php +++ b/public/index.php @@ -15,6 +15,10 @@ case("/about/"): case("/projects/"): echo $twig->render('projects.html'); break; +case("/tool"): + header("Location: https://" . $_SERVER["HTTP_HOST"] . "/tools/"); + exit; + break; case("/tools/"): echo $twig->render('tools.html'); break; @@ -31,11 +35,17 @@ case("/tools/untrack/"): } echo $twig->render('tools/untrack/index.html', [ "url" => $_url ]); break; +case("/tools/tanz/"): + echo $twig->render('tools/bpm/index.html', [ "dances" => get_dances() ]); + break; +case("/feeds/"): + echo $twig->render('feeds.html'); + break; case("/tools/zeitumstellung/"): echo $twig->render('tools/zeitumstellung/index.html', [ "tc" => new Zeitumstellung() ]); break; -case("/tools/tanz/"): - echo $twig->render('tools/bpm/index.html', [ "dances" => get_dances() ]); +case("/tools/ghrss/"): + echo $twig->render('tools/ghrss/index.html', [ "data" => get_ghrss_feeds() ]); break; default: if ( str_ends_with($url, "/") ) { diff --git a/views/feeds.html b/views/feeds.html new file mode 100644 index 0000000..3776541 --- /dev/null +++ b/views/feeds.html @@ -0,0 +1,30 @@ +{% extends "snippets/layout.html" %} + +{% block title "feeds | Maximilian Möhring" %} + +{% block css %} +{% endblock %} +{% block main %} + +<div class="container"> + + <div class="flavor-text"> + <h1>iCal- / RSS-Feeds</h1> + <em>Fun fact: I structure my whole life around feeds!</em> + </div> + + <ul> + <li> + <a href="/feeds/zeitumstellung/" title="Zeitumstellung">Zeitumstellung - Als iCal-Feed für deinen Kalender</a> + </li> + <li> + <a href="/feed/dilbert/" title="Dilbert RSS Feed">Dilbert RSS Feed. With Images!</a> + </li> + <li> + <a href="/feeds/ghrss" title="GHRSS">Github Trending Repositories as RSS-Feed</a> + </li> + </ul> + +</div> + +{% endblock %} diff --git a/views/tools.html b/views/tools.html index 30c4697..d522d67 100644 --- a/views/tools.html +++ b/views/tools.html @@ -3,6 +3,9 @@ {% block title "tools | Maximilian Möhring" %} {% block css %} +.feed-flavor { + margin-top: 4rem; +} {% endblock %} {% block main %} @@ -15,7 +18,6 @@ <ul> <li> - <!--a href="https://faces.iamfabulous.de" title="Best faces on the net" rel="nofollow">Best faces on the net</a--> <a href="/tools/faces/" title="Best faces on the net">Best faces on the net</a> </li> <li> @@ -25,14 +27,27 @@ <a href="/tools/pizza/" title="Pizzarechner">Pizzarechner</a> </li> <li> - <a href="/tools/zeitumstellung/" title="Zeitumstellung">Zeitumstellung - Als iCal-Feed für deinen Kalender</a> + <a href="/tools/tanz/" title="BPM / Tanz">Click to count BPMs - Tanzbar?</a> </li> + </ul> + + <div class="flavor-text feed-flavor"> + <h1>iCal- / RSS-Feeds</h1> + <!-- + <em>Fun fact: I structure my whole life around feeds!</em> + --> + </div> + + <ul> <li> - <a href="/tools/tanz/" title="BPM / Tanz">BPM - Tanzbar?</a> + <a href="/tools/zeitumstellung/" title="Zeitumstellung">Zeitumstellung - Als iCal-Feed für deinen Kalender</a> </li> <li> <a href="/feed/dilbert/" title="Dilbert RSS Feed">Dilbert RSS Feed. With Images!</a> </li> + <li> + <a href="/tools/ghrss" title="GHRSS">Github Trending Repositories as RSS-Feed</a> + </li> </ul> </div> diff --git a/views/tools/ghrss/composer.json b/views/tools/ghrss/composer.json new file mode 100644 index 0000000..ba92705 --- /dev/null +++ b/views/tools/ghrss/composer.json @@ -0,0 +1,5 @@ +{ + "require": { + "tronice/php-rss-writer": "^1.6" + } +} diff --git a/views/tools/ghrss/composer.lock b/views/tools/ghrss/composer.lock new file mode 100644 index 0000000..1fc94a1 --- /dev/null +++ b/views/tools/ghrss/composer.lock @@ -0,0 +1,84 @@ +{ + "_readme": [ + "This file locks the dependencies of your project to a known state", + "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", + "This file is @generated automatically" + ], + "content-hash": "4114942d462b753781b80a9c5cdfb1f0", + "packages": [ + { + "name": "tronice/php-rss-writer", + "version": "1.6.3", + "source": { + "type": "git", + "url": "https://github.com/TRONICE/php-rss-writer.git", + "reference": "a5ef3db462b70f896778faff508fd88b71c051df" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/TRONICE/php-rss-writer/zipball/a5ef3db462b70f896778faff508fd88b71c051df", + "reference": "a5ef3db462b70f896778faff508fd88b71c051df", + "shasum": "" + }, + "require": { + "php": ">=5.4.0" + }, + "require-dev": { + "johnpupu/xoopsunit": ">=1.2", + "mockery/mockery": ">=0.9 <1.0", + "phpunit/phpunit": ">=4.8.36 <6.0" + }, + "type": "library", + "autoload": { + "psr-0": { + "Suin\\RSSWriter": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "suin", + "email": "suinyeze@gmail.com", + "role": "Author" + }, + { + "name": "John Chen", + "email": "john@tronice.com", + "homepage": "https://www.tronice.com", + "role": "Developer" + }, + { + "name": "Firch Tsai", + "email": "firch@tronice.com", + "homepage": "https://www.tronice.com", + "role": "Developer" + } + ], + "description": "Yet another simple RSS writer library for PHP 5.4 or later.", + "homepage": "https://github.com/TRONICE/php-rss-writer", + "keywords": [ + "feed", + "generator", + "php", + "rss", + "writer" + ], + "support": { + "source": "https://github.com/TRONICE/php-rss-writer/tree/1.6.3" + }, + "time": "2020-05-17T17:20:36+00:00" + } + ], + "packages-dev": [], + "aliases": [], + "minimum-stability": "stable", + "stability-flags": [], + "prefer-stable": false, + "prefer-lowest": false, + "platform": [], + "platform-dev": [], + "plugin-api-version": "2.0.0" +} diff --git a/views/tools/ghrss/feed.php b/views/tools/ghrss/feed.php new file mode 100644 index 0000000..7276200 --- /dev/null +++ b/views/tools/ghrss/feed.php @@ -0,0 +1,47 @@ +<?php + +use DiDom\Document; +use Suin\RSSWriter\Channel; +use Suin\RSSWriter\Feed; +use Suin\RSSWriter\Item; + +require_once __DIR__ . '/ghrss.db.php'; +require_once __DIR__ . '/vendor/autoload.php'; + +header("content-type: application/rss+xml"); + +if ( isset($_REQUEST["l"]) && "" != $_REQUEST["l"] ) { + $stmt = $db->prepare("SELECT * FROM entry_view WHERE language = ? ORDER BY created_at DESC LIMIT 20;"); + $stmt->execute([$_REQUEST["l"]]); +} else { + $stmt = $db->prepare("SELECT * FROM entry_view WHERE created_at >= NOW() - INTERVAL 2 DAY ORDER BY created_at DESC;"); + $stmt->execute([$_REQUEST["l"]]); +} +$result = $stmt->fetchAll(); + +$feed = new Feed(); + +$channel = new Channel(); +$channel + ->title("GHRSS") + ->description("Trending Repos from Github") + ->url( "https://www.maximilianmoehring.com/tools/ghrss/" ) + ->pubDate(strtotime(date("r", time()))) + ->lastBuildDate(strtotime(date("r", time()))) + ->ttl(5) + ->appendTo($feed); + +foreach($result as $item) { + $item_out = new Item(); + + $item_out + ->title($item["title"]) + ->description( "<p>" . $item["synopsis"] . "<br><em>" . $item["language"] . " / " . $item["update_period"] . " / " . $item["stars"] . " Stars</em></p>" ) + ->url($item["url"]) + ->pubDate(strtotime(date($item["created_at"]))) + ->author($item["owner"]) + ->appendTo($channel); +} + +echo $feed; + diff --git a/views/tools/ghrss/ghrss.db.php b/views/tools/ghrss/ghrss.db.php new file mode 100644 index 0000000..d96f881 --- /dev/null +++ b/views/tools/ghrss/ghrss.db.php @@ -0,0 +1,14 @@ +<?php + +require_once __DIR__ . '/db_passwd.php'; + +/** + * password is set in db_passwd.php + * + * $db_passwd = ""; + */ + +$db_name = "ghrss"; +$db_user = "ghrss_crawler"; + +$db = new PDO('mysql:host=192.168.122.1;dbname='.$db_name, $db_user, $db_passwd); diff --git a/views/tools/ghrss/index.html b/views/tools/ghrss/index.html new file mode 100644 index 0000000..1e64fa3 --- /dev/null +++ b/views/tools/ghrss/index.html @@ -0,0 +1,32 @@ +{% extends "snippets/layout.html" %} + +{% block description %} +{% endblock %} + +{% block title %} +GHRSS - Trending Repos +{% endblock %} + +{% block css %} +{% endblock %} + +{% block main %} +<div class="container" id="index"> + + <div class="flavor-text"> + <h1>Trending Repos from Github as RSS-Feed</h1> + <em>Choose your language, get the result of <a href="https://github.com/trending">github.com/trending</a> as RSS-Feed</em> + </div> + <ul> + {% for entry in data %} + <li> + <a class="" href="/feed/ghrss?l={{ entry.name }}">{{ entry.name | e }}</a> + </li> + {% endfor %} + <!-- a class="dropdown-item" href="/feed/">Give Me All Languages</a--> + </ul> + <p> + </p> + +</div> +{% endblock %} |
