Config switch to YAML
This commit is contained in:
parent
edca0cc8cc
commit
ac65f5ee70
4 changed files with 58 additions and 52 deletions
96
index.php
96
index.php
|
@ -1,15 +1,11 @@
|
||||||
<!DOCTYPE HTML>
|
<!DOCTYPE HTML>
|
||||||
<!--
|
<!--
|
||||||
Rangitaki Blogging Engine
|
Rangitaki Blogging Engine
|
||||||
GitHub: https://github.com/mmk2410/Rangitaki
|
Code: https://gitlab.com/mmk2410/rangitaki
|
||||||
|
Issus and Project Management: https://phab.mmk2410.org
|
||||||
Web: https://marcel-kapfer.de/rangitaki
|
Web: https://marcel-kapfer.de/rangitaki
|
||||||
Twitter: @Rangitaki
|
2015 - 2016 Marcel Kapfer (mmk2410)
|
||||||
Google+: +Rangitaki
|
License: MIT
|
||||||
-->
|
|
||||||
<!--
|
|
||||||
COPYRIGHT (c) 2015 mmk2410
|
|
||||||
|
|
||||||
MIT License
|
|
||||||
-->
|
-->
|
||||||
<html>
|
<html>
|
||||||
<?php
|
<?php
|
||||||
|
@ -28,8 +24,14 @@ MIT License
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
require __DIR__ . '/vendor/autoload.php'; // loading composer libs
|
require __DIR__ . '/vendor/autoload.php'; // loading composer libs
|
||||||
|
|
||||||
require 'config.php'; // Config file (this must be the first line)
|
require './res/php/Config.php';
|
||||||
require './lang/' . $language . ".php"; // Language file
|
use mmk2410\rbe\config\Config as Config;
|
||||||
|
|
||||||
|
$configParser = new Config('config.yaml', 'vendor/autoload.php');
|
||||||
|
|
||||||
|
$config = $configParser->getConfig();
|
||||||
|
|
||||||
|
require './lang/' . $config["language"] . ".php"; // Language file
|
||||||
require_once 'res/php/ArticleGenerator.php'; // The article generator
|
require_once 'res/php/ArticleGenerator.php'; // The article generator
|
||||||
require_once './res/php/BlogListGenerator.php'; // and the blog list generator
|
require_once './res/php/BlogListGenerator.php'; // and the blog list generator
|
||||||
|
|
||||||
|
@ -42,16 +44,16 @@ $url = "http://" . filter_input(INPUT_SERVER, "HTTP_HOST") .
|
||||||
$pagenumber = filter_input(INPUT_GET, "page"); // get the pagenumber
|
$pagenumber = filter_input(INPUT_GET, "page"); // get the pagenumber
|
||||||
|
|
||||||
// Pagination algorithm
|
// Pagination algorithm
|
||||||
if ($pagination == 0) {
|
if ($config["design"]["pagination"] == 0) {
|
||||||
$pagination = false;
|
$config["design"]["pagination"] = false;
|
||||||
} else {
|
} else {
|
||||||
// pag_max: the newest post to show on a page
|
// pag_max: the newest post to show on a page
|
||||||
$pag_max = $pagination * ( $pagenumber + 1 );
|
$pag_max = $config["design"]["pagination"] * ( $pagenumber + 1 );
|
||||||
// pag_min: the oldest post to show on a page
|
// pag_min: the oldest post to show on a page
|
||||||
$pag_min = $pag_max - $pagination;
|
$pag_min = $pag_max - $config["design"]["pagination"];
|
||||||
if ($pagenumber > 0) {
|
if ($pagenumber > 0) {
|
||||||
// Disable the blog intro if not on first page
|
// Disable the blog intro if not on first page
|
||||||
$blogintro = "no";
|
$config["blog"]["intro"] = "off";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,10 +74,10 @@ if (isset($getarticle)) {
|
||||||
= ArticleGenerator::getTitle($articlesdir, $getarticle . '.md');
|
= ArticleGenerator::getTitle($articlesdir, $getarticle . '.md');
|
||||||
}
|
}
|
||||||
// Make sure that the entry has a title, because main.md hasn't one
|
// Make sure that the entry has a title, because main.md hasn't one
|
||||||
if (empty($blogmainname)) {
|
if (empty($config["blog"]["mainname"])) {
|
||||||
$blogmaintitle = $blogtitle;
|
$blogmaintitle = $config["blog"]["title"];
|
||||||
} else {
|
} else {
|
||||||
$blogmaintitle = $blogmainname;
|
$blogmaintitle = $config["blog"]["mainname"];
|
||||||
}
|
}
|
||||||
if (isset($getblog)) {
|
if (isset($getblog)) {
|
||||||
$subblogtitle = BlogListGenerator::getName('./blogs/' . $getblog . '.md');
|
$subblogtitle = BlogListGenerator::getName('./blogs/' . $getblog . '.md');
|
||||||
|
@ -90,18 +92,18 @@ if (isset($getarticle)) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// url of the feed
|
// url of the feed
|
||||||
$feedurl = $blogurl . "/feed/" . $blog . ".atom";
|
$feedurl = $config["blog"]["url"] . "/feed/" . $blog . ".atom";
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title><?php echo $blogtitle . " » " .$hd_subblog_title; ?></title>
|
<title><?php echo $config["blog"]["title"] . " » " .$hd_subblog_title; ?></title>
|
||||||
<!--Metatags-->
|
<!--Metatags-->
|
||||||
<meta name="author"
|
<meta name="author"
|
||||||
content="<?php echo $blogauthor; // Set the blog author ?>"/>
|
content="<?php echo $config["blog"]["author"]; // Set the blog author ?>"/>
|
||||||
<meta name="description"
|
<meta name="description"
|
||||||
content="<?php echo $blogdescription; // the blog description ?>"/>
|
content="<?php echo $config["blog"]["description"]; // the blog description ?>"/>
|
||||||
<!-- Meta tag for responsive ui-->
|
<!-- Meta tag for responsive ui-->
|
||||||
<meta name='viewport'
|
<meta name='viewport'
|
||||||
content='width=device-width, initial-scale=1.0,
|
content='width=device-width, initial-scale=1.0,
|
||||||
|
@ -110,15 +112,15 @@ $feedurl = $blogurl . "/feed/" . $blog . ".atom";
|
||||||
<meta property="og:title" content="<?php echo $hd_subblog_title; ?>"/>
|
<meta property="og:title" content="<?php echo $hd_subblog_title; ?>"/>
|
||||||
<meta property="og:type" content="website"/>
|
<meta property="og:type" content="website"/>
|
||||||
<meta property="og:url" content="<?php echo $url; ?>"/>
|
<meta property="og:url" content="<?php echo $url; ?>"/>
|
||||||
<meta property="og:image" content="<?php echo $favicon; ?>"/>
|
<meta property="og:image" content="<?php echo $config['design']['favicon']; ?>"/>
|
||||||
<meta property="og:description" content="<?php echo $blogdescription; ?>"/>
|
<meta property="og:description" content="<?php echo $config['blog']['description']; ?>"/>
|
||||||
<meta property="og:locale:alternate" content="<?php echo $lang; ?>"/>
|
<meta property="og:locale:alternate" content="<?php echo $lang; ?>"/>
|
||||||
<!-- Twitter meta tags -->
|
<!-- Twitter meta tags -->
|
||||||
<meta name="twitter:card" content="summary"/>
|
<meta name="twitter:card" content="summary"/>
|
||||||
<meta name="twitter:site" content="<?php echo $twitter; ?>"/>
|
<meta name="twitter:site" content="<?php echo $twitter; ?>"/>
|
||||||
<meta name="twitter:title" content="<?php echo $hd_subblog_title; ?>"/>
|
<meta name="twitter:title" content="<?php echo $hd_subblog_title; ?>"/>
|
||||||
<meta name="twitter:description" content="<?php echo $blogdescription; ?>"/>
|
<meta name="twitter:description" content="<?php echo $config['blog']['description']; ?>"/>
|
||||||
<meta name="twitter:image" content="<?php echo $favicon; ?>"/>
|
<meta name="twitter:image" content="<?php echo $config['design']['favicon']; ?>"/>
|
||||||
<meta name="twitter:url" content="<?php echo $url; ?>"/>
|
<meta name="twitter:url" content="<?php echo $url; ?>"/>
|
||||||
<!-- atom feed -->
|
<!-- atom feed -->
|
||||||
<?php
|
<?php
|
||||||
|
@ -136,10 +138,10 @@ $feedurl = $blogurl . "/feed/" . $blog . ".atom";
|
||||||
<!-- stylesheet for code highlighting-->
|
<!-- stylesheet for code highlighting-->
|
||||||
<link rel="stylesheet" href="./res/css/github-gist.css">
|
<link rel="stylesheet" href="./res/css/github-gist.css">
|
||||||
<link rel="stylesheet" type="text/css"
|
<link rel="stylesheet" type="text/css"
|
||||||
href="themes/<?php echo $theme; // getting the theme stylesheet?>.css"/>
|
href="themes/<?php echo $config['design']['theme']; // getting the theme stylesheet?>.css"/>
|
||||||
<?php
|
<?php
|
||||||
// Checking if the drawer is enabled
|
// Checking if the drawer is enabled
|
||||||
if ($nav_drawer == 'no') {
|
if ($config["design"]["drawer"] != 'on') {
|
||||||
// Loading additional stylesheet for disabling the drawer?>
|
// Loading additional stylesheet for disabling the drawer?>
|
||||||
<link rel="stylesheet" type="text/css" href="res/css/no-nav.css"/>
|
<link rel="stylesheet" type="text/css" href="res/css/no-nav.css"/>
|
||||||
<?php
|
<?php
|
||||||
|
@ -150,8 +152,8 @@ $feedurl = $blogurl . "/feed/" . $blog . ".atom";
|
||||||
type='text/css'> <!--Font-->
|
type='text/css'> <!--Font-->
|
||||||
<!--Favicons-->
|
<!--Favicons-->
|
||||||
<link rel="shortcut icon" type="image/x-icon"
|
<link rel="shortcut icon" type="image/x-icon"
|
||||||
href="<?php echo $favicon; ?>"/>
|
href="<?php echo $config['design']['favicon']; ?>"/>
|
||||||
<link rel="apple-touch-icon-precomposed" href="<?php echo $favicon; ?>">
|
<link rel="apple-touch-icon-precomposed" href="<?php echo $config['design']['favicon']; ?>">
|
||||||
<!-- JavaScript Pt. 1: HightlightJS (get and load): Code highlighting-->
|
<!-- JavaScript Pt. 1: HightlightJS (get and load): Code highlighting-->
|
||||||
<script src="./res/js/highlight.pack.js"></script>
|
<script src="./res/js/highlight.pack.js"></script>
|
||||||
<script>hljs.initHighlightingOnLoad();</script>
|
<script>hljs.initHighlightingOnLoad();</script>
|
||||||
|
@ -160,7 +162,7 @@ $feedurl = $blogurl . "/feed/" . $blog . ".atom";
|
||||||
<body>
|
<body>
|
||||||
<?php
|
<?php
|
||||||
// Checking if the navigation drawer is enabled. If not -> skip it
|
// Checking if the navigation drawer is enabled. If not -> skip it
|
||||||
if ($nav_drawer == "yes") {
|
if ($config["design"]["drawer"] == "on") {
|
||||||
?>
|
?>
|
||||||
<!--
|
<!--
|
||||||
Darken the background when fading the drawer in. See also the JS file
|
Darken the background when fading the drawer in. See also the JS file
|
||||||
|
@ -181,8 +183,8 @@ if ($nav_drawer == "yes") {
|
||||||
echo "<section>";
|
echo "<section>";
|
||||||
// 1. Set localized string 2. Set blogtitle
|
// 1. Set localized string 2. Set blogtitle
|
||||||
echo "<div class='nav-item-static'>" .
|
echo "<div class='nav-item-static'>" .
|
||||||
$BLOGLANG['Blogs on'] .
|
$BLOGLANG['Blogs on'] . $config["blog"]["title"] .
|
||||||
" $blogtitle:</div>";
|
":</div>";
|
||||||
// iterating through the blogs/ directory
|
// iterating through the blogs/ directory
|
||||||
foreach ($blogs as $navblog) {
|
foreach ($blogs as $navblog) {
|
||||||
// check if filename is larger than three chars and if the
|
// check if filename is larger than three chars and if the
|
||||||
|
@ -192,7 +194,7 @@ if ($nav_drawer == "yes") {
|
||||||
if ($navblog != "main.md") { // excluding main blog
|
if ($navblog != "main.md") { // excluding main blog
|
||||||
// creating navigation item
|
// creating navigation item
|
||||||
BlogListGenerator::listBlog(
|
BlogListGenerator::listBlog(
|
||||||
"./blogs/", $navblog, $blogtitle
|
"./blogs/", $navblog, $config["blog"]["title"]
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -215,11 +217,11 @@ if ($nav_drawer == "yes") {
|
||||||
<a class="nav-item" onclick="goBack()">Go back</a>
|
<a class="nav-item" onclick="goBack()">Go back</a>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
if ($bloghome == "yes") { // If a blog home is existend
|
if ($config["blog"]["home"] == "on") { // If a blog home is existend
|
||||||
?>
|
?>
|
||||||
<div class="divider"></div>
|
<div class="divider"></div>
|
||||||
<a class="nav-item" href="<?php echo $bloghomeurl; ?>">
|
<a class="nav-item" href="<?php echo $config['blog']['homeurl']; ?>">
|
||||||
<?php echo $bloghomename; ?>
|
<?php echo $config['blog']['homename']; ?>
|
||||||
</a>
|
</a>
|
||||||
<?php
|
<?php
|
||||||
}
|
}
|
||||||
|
@ -246,13 +248,13 @@ if ($nav_drawer == "yes") {
|
||||||
<img src="./res/img/menu.svg" class="nav-img"/>
|
<img src="./res/img/menu.svg" class="nav-img"/>
|
||||||
<!-- Blog title with subblog title and links to each one-->
|
<!-- Blog title with subblog title and links to each one-->
|
||||||
<!-- link to main blog-->
|
<!-- link to main blog-->
|
||||||
<nobr><span class="title"><a href="./"><?php echo $blogtitle; ?>
|
<nobr><span class="title"><a href="./"><?php echo $config["blog"]["title"]; ?>
|
||||||
<?php
|
<?php
|
||||||
if (empty($getblog)) { // if not on a subblog
|
if (empty($getblog)) { // if not on a subblog
|
||||||
if (!empty($blogmainname)) {
|
if (!empty($config['blog']['mainname'])) {
|
||||||
// If you see a › (square) here : This is not a bug,
|
// If you see a › (square) here : This is not a bug,
|
||||||
// but a missing sign in your font
|
// but a missing sign in your font
|
||||||
echo "›" . $blogmainname;
|
echo "›" . $config['blog']['mainname'];
|
||||||
}
|
}
|
||||||
} else { // On subblog: set also a link to the subblog
|
} else { // On subblog: set also a link to the subblog
|
||||||
?>
|
?>
|
||||||
|
@ -276,7 +278,7 @@ if ($nav_drawer == "yes") {
|
||||||
// Blog Intro text
|
// Blog Intro text
|
||||||
if (file_exists("blogs/$blog.md")
|
if (file_exists("blogs/$blog.md")
|
||||||
&& $getarticle == ""
|
&& $getarticle == ""
|
||||||
&& $blogintro == "yes"
|
&& $config["blog"]["intro"] == "on"
|
||||||
&& $gettag == ""
|
&& $gettag == ""
|
||||||
) {
|
) {
|
||||||
// only shown if not in article or tag view
|
// only shown if not in article or tag view
|
||||||
|
@ -332,7 +334,7 @@ if ($nav_drawer == "yes") {
|
||||||
// check if the file is a article file
|
// check if the file is a article file
|
||||||
if (strlen($article) >= 3 && substr($article, -3) == ".md") {
|
if (strlen($article) >= 3 && substr($article, -3) == ".md") {
|
||||||
// generate the article
|
// generate the article
|
||||||
if ($pagination) {
|
if ($config["design"]["pagination"]) {
|
||||||
if ($posts_amount < $pag_max && $posts_amount >= $pag_min) {
|
if ($posts_amount < $pag_max && $posts_amount >= $pag_min) {
|
||||||
ArticleGenerator::newArticle(
|
ArticleGenerator::newArticle(
|
||||||
$articlesdir, $article, $getblog
|
$articlesdir, $article, $getblog
|
||||||
|
@ -346,7 +348,7 @@ if ($nav_drawer == "yes") {
|
||||||
}
|
}
|
||||||
$posts_amount++;
|
$posts_amount++;
|
||||||
}
|
}
|
||||||
if ($pagination) {
|
if ($config["design"]["pagination"]) {
|
||||||
include './res/php/Pagination.php';
|
include './res/php/Pagination.php';
|
||||||
}
|
}
|
||||||
} elseif (isset($getarticle)) { // ARTICLE VIEW
|
} elseif (isset($getarticle)) { // ARTICLE VIEW
|
||||||
|
@ -360,16 +362,16 @@ if ($nav_drawer == "yes") {
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
<div class="footer">
|
<div class="footer">
|
||||||
<?php echo $blogfooter; //print the blog footer?>
|
<?php echo $config["blog"]["footer"]; //print the blog footer?>
|
||||||
</div>
|
</div>
|
||||||
<?php
|
<?php
|
||||||
// show the fab if it's enabled
|
// show the fab if it's enabled
|
||||||
if ($sharefab == "yes") {
|
if ($config["design"]["fab"] == "on") {
|
||||||
?>
|
?>
|
||||||
<div class="fabmenu">
|
<div class="fabmenu">
|
||||||
<div class="subfab"><!--Email subfab-->
|
<div class="subfab"><!--Email subfab-->
|
||||||
<a href='mailto:?subject=<?php
|
<a href='mailto:?subject=<?php
|
||||||
echo $blogtitle;
|
echo $config["blog"]["title"];
|
||||||
?>&body=<?php
|
?>&body=<?php
|
||||||
echo $BLOGLANG['Check out this blog'];
|
echo $BLOGLANG['Check out this blog'];
|
||||||
?>: <?php
|
?>: <?php
|
||||||
|
@ -398,7 +400,7 @@ if ($nav_drawer == "yes") {
|
||||||
<a href='https://www.facebook.com/sharer/sharer.php?u=<?php
|
<a href='https://www.facebook.com/sharer/sharer.php?u=<?php
|
||||||
echo $url;
|
echo $url;
|
||||||
?>&t=<?php
|
?>&t=<?php
|
||||||
echo "echo $blogtitle"
|
echo "echo " . $config["blog"]["title"];
|
||||||
?>' target="blank">
|
?>' target="blank">
|
||||||
<img src="./res/img/facebook.svg" class="subfab-img"/>
|
<img src="./res/img/facebook.svg" class="subfab-img"/>
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -64,17 +64,21 @@
|
||||||
|
|
||||||
<div class="main">
|
<div class="main">
|
||||||
<?php
|
<?php
|
||||||
require '../config.php';
|
require '../res/php/Config.php';
|
||||||
|
use mmk2410\rbe\config\Config as Config;
|
||||||
|
|
||||||
if ($rcc == "yes") {
|
$configParser = new Config('../config.yaml', '../vendor/autoload.php');
|
||||||
|
|
||||||
|
$config = $configParser->getConfig();
|
||||||
|
|
||||||
|
if ($config["rcc"]["rcc"] == "on") {
|
||||||
include 'password.php';
|
include 'password.php';
|
||||||
session_start();
|
session_start();
|
||||||
|
|
||||||
if (isset($_POST['passwd'])) {
|
if (isset($_POST['passwd'])) {
|
||||||
$passwd = $_POST['passwd'];
|
$passwd = $_POST['passwd'];
|
||||||
$_SESSION['passwd'] = $_POST['passwd'];
|
$_SESSION['passwd'] = $_POST['passwd'];
|
||||||
} else if (isset($_SESSION['passwd'])) {
|
} elseif (isset($_SESSION['passwd'])) {
|
||||||
$passwd = $_SESSION['passwd'];
|
$passwd = $_SESSION['passwd'];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ THE SOFTWARE.
|
||||||
<div id="disqus_thread"></div>
|
<div id="disqus_thread"></div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
/* * * CONFIGURATION VARIABLES * * */
|
/* * * CONFIGURATION VARIABLES * * */
|
||||||
var disqus_shortname = '<?php echo $blogdisqus; ?>';
|
var disqus_shortname = '<?php echo $config['blog']['disqus']; ?>';
|
||||||
|
|
||||||
/* * * DON'T EDIT BELOW THIS LINE * * */
|
/* * * DON'T EDIT BELOW THIS LINE * * */
|
||||||
(function () {
|
(function () {
|
||||||
|
|
|
@ -26,7 +26,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
if ($bloganalytics) { // check if google analytics is enabled
|
if ($config["blog"]["analytics"]) { // check if google analytics is enabled
|
||||||
if (!($_SERVER['HTTP_DNT'] == 1)) {
|
if (!($_SERVER['HTTP_DNT'] == 1)) {
|
||||||
?>
|
?>
|
||||||
<script>
|
<script>
|
||||||
|
|
Reference in a new issue