diff --git a/.gitignore b/.gitignore index 3189517..427b7fc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ nbproject/ .idea/ completer.hist -feed/ +/feed/ node_modules/ diff --git a/CHANGELOG.md b/CHANGELOG.md index 264e7cf..32a0eb5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,13 +7,15 @@ - [S] release are always compared to the previous [S] release. +## Version 1.4.4 (2016-06-03) [S] + - **[FIX]** Error when trying to create a feed + ## Version 1.4.3 (2016-05-21) [S] - **[FIX]** Missing space in drawer between "Blogs on" and blogname - **[FIX]** Background layer was not removed if drawer was closed - **[FEATURE]** nextDESIGN theme added to delivered themes - **[NOTE]** The update script to 1.4.3 works with 1.4.0, 1.4.1 and 1.4.2 - ## Version 1.4.2 (2016-05-18) [S] - [FIX]: Password verification not implemented in RCC login page diff --git a/package.json b/package.json index a89095f..9f99af3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rangitaki", - "version": "1.4.3", + "version": "1.4.4", "description": "A simple PHP blogging engine without any database dependencies", "main": "index.php", "scripts": { diff --git a/rcc/feed/index.php b/rcc/feed/index.php index f98b79b..ed7e56a 100644 --- a/rcc/feed/index.php +++ b/rcc/feed/index.php @@ -6,13 +6,13 @@ * @package Rcc * @author Marcel Kapfer (mmk2410) * @license MIT License - * @link https://github.com/mmk2410/rangitaki + * @link https://gitlab.com/mmk2410/rangitaki * * Feed Generator * * The MIT License * - * Copyright 2015 mmk2410. + * Copyright 2015 - 2016 (c) mmk2410. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal @@ -36,27 +36,35 @@ date_default_timezone_set('UTC'); require "../../vendor/autoload.php"; -require_once "../../config.php"; +require "../../res/php/Config.php"; require_once "../../res/php/ArticleGenerator.php"; -use PicoFeed\Syndication\Atom; +use PicoFeed\Syndication\AtomFeedBuilder; +use PicoFeed\Syndication\AtomItemBuilder; +use \mmk2410\rbe\config\Config as Config; + +$config = new Config('../../config.yaml', '../../vendor/autoload.php'); +$settings = $config->getConfig(); + +include '../ssl.php'; session_start(); if ($_SESSION['login']) { - $art_dir = "./../../articles/" . $_GET['blog'] . "/"; $feed_path = "./../../feed/" . $_GET['blog'] . ".atom"; - $writer = new Atom(); + if ($_GET['blog'] == "main") { + $blogtitle = $settings['blog']['title']; + } else { + $blogtitl = $settings['blog']['title'] . " - " . ucwords($_GET['blog']); + } - $writer->title = $blogtitle; - $writer->site_url = $blogurl; - $writer->feed_url = $blogurl . "/feed/" . $_GET['blog'] . ".atom"; - $writer->author = array( - 'name' => $blogauthor, - 'url' => $blogurl, - 'email' => '' - ); + $feedBuilder = AtomFeedBuilder::create() + ->withTitle($blogtitle) + ->withAuthor($settings['blog']['author']) + ->withFeedUrl($settings['blog']['url'] . "/feed/" . $_GET['blog'] . ".atom") + ->withSiteUrl($settings['blog']['url']) + ->withDate(new DateTime(date(DATE_ATOM))); $articles = scandir($art_dir, 1); @@ -71,25 +79,45 @@ if ($_SESSION['login']) { $text = Parsedown::instance() ->setBreaksEnabled(true)// with linebreaks ->text($file); - $writer->items[] = array( - 'title' => ArticleGenerator::getTitle($art_dir, $article), - 'updated' => strtotime( - ArticleGenerator::getDate($art_dir . $article) - ), - 'url' => $blogurl . "./?article=" . - substr($article, 0, strlen($article) - 3), - 'summary'=> ArticleGenerator::getSummary( - $art_dir, $article - ), - 'content' => $text - ); + if (new DateTime(date(DATE_ATOM, strtotime($datestring))) != null) { + $date = new DateTime( + date( + DATE_ATOM, + strtotime($datestring) + ) + ); + } else { + $date = new DateTime(date(DATE_ATOM)); + } + $date = new DateTime(date(DATE_ATOM)); + $feedBuilder + ->withItem(AtomItemBuilder::create($feedBuilder) + ->withTitle( + ArticleGenerator::getTitle($art_dir, $article) + ) + ->withUrl( + $settings['blog']['url'] . "./?article=" . substr($article, 0, strlen($article) - 3) + ) + ->withAuthor( + ArticleGenerator::getAuthor($art_dir, $article) + ) + ->withPublishedDate( + parseDate(ArticleGenerator::getDate($art_dir, $article)) + ) + ->withUpdatedDate( + parseDate(ArticleGenerator::getDate($art_dir, $article)) + ) + ->withSummary( + ArticleGenerator::getSummary($art_dir, $article) + ) + ->withContent($text)); $amount += 1; } } } - $feed = $writer->execute(); + $feed = $feedBuilder->build(); $file = fopen($feed_path, "w"); @@ -102,4 +130,19 @@ if ($_SESSION['login']) { echo "0"; } -?> + +function parseDate($datestring) +{ + $datetime = new DateTime(date(DATE_ATOM)); + try { + $datetime = new DateTime( + date( + DATE_ATOM, + strtotime($datestring) + ) + ); + } catch (Exception $e) { + $datetime = new DateTime(date(DATE_ATOM)); + } + return $datetime; +} diff --git a/rcc/ssl.php b/rcc/ssl.php index 0923208..9c2f971 100644 --- a/rcc/ssl.php +++ b/rcc/ssl.php @@ -3,7 +3,7 @@ // License: MIT License // SSL Verification -if ($settings["rcc"]["debug"] != "on") { +if (isset($settings["rcc"]["debug"]) && $settings["rcc"]["debug"] != "on") { if (empty($_SERVER['HTTPS']) || $_SERVER['HTTPS'] != "on") { header('HTTP/1.1 400 Bad Request'); exit(); diff --git a/update-scripts/1-4-3_1-4-4.sh b/update-scripts/1-4-3_1-4-4.sh new file mode 100755 index 0000000..1573ae3 --- /dev/null +++ b/update-scripts/1-4-3_1-4-4.sh @@ -0,0 +1,51 @@ +#!/bin/bash +# Update script for Rangitaki from version 1.4.3 to 1.4.4 + +version="1.4.4" +new="./rbe-new" + +echo -n "Downloading version $version from GitLab... " +git clone -q https://gitlab.com/mmk2410/rangitaki.git "$new" + +if [[ $1 == "--debug" ]]; then + cd $new + git checkout -q master + cd ../ +fi +echo "done" + +echo -n "Updating RCC... " +mv ./rcc/password.php ./password.php +rm -rf ./rcc/ +mv $new/rcc ./ +rm ./rcc/password.php +mv ./password.php ./rcc/password.php +echo "done" + +echo -n "Updating npm... " +mv $new/package.json ./ +echo "done" + +echo -n "Updating Changelog... " + +if [ -f ./CHANGELOG.txt ]; then + rm CHANGELOG.txt +fi + +mv $new/CHANGELOG.md ./ +echo "done" + +echo -n "Cleaning up... " +if [[ $1 != "--debug" ]]; then + echo -n "Cleaning up... " + rm -rf $new + echo "done" +fi + +if [ -d "./update-scripts" ]; then + echo -n "Remove obsolete update scripts folder... " + rm -rf "./update-scripts" + echo "done" +fi + +echo "Your Rangitaki installation is updated to version $version"