Multiple Blogs, Author

This commit is contained in:
mmk2410 2015-06-11 17:32:58 +02:00
parent 6d97a486d5
commit ac16378dd8
9 changed files with 125 additions and 7 deletions

View File

@ -1,4 +1,5 @@
%TITLE: About the Future of pBlog
%DATE: 29 March 2015
%AUTHOR: Marcel Michael Kapfer
I figured out that there will be many changes in the engine which will require many changes in the files (especially the posts file) and in the filestructure. I can't say right now which things will change and what you have to change. Out of this reason. I change the Version numbers and add an zero in front of them. So instead of 2.1 the latest version is now 0.2.1. The 0.2.x series is now on GitHub as an own branch and will recive bugfix updates. The series 0.3, 0.4, 0.5 and so own will be development releases which won't be compatible to the 0.2 series. I recommend current users to stay on 0.2.x - at least until the 1.0 release. I'm verry sorry for this and in case that there are requests I may write a small script that will help you switch to version 1.0.

View File

@ -0,0 +1,9 @@
%TITLE: What else are we working on?
%DATE: 11 June 2015
Near the Rangitaki PHP blogging engine there are other projects were working on or where we will start development soon:
- Rangitaki JavaScript blogging engine
- Rangitaki PHP framework
- Rangitaki JavaScript framework
- Rangitaki Polymer elements

14
blogs/main.md Normal file
View File

@ -0,0 +1,14 @@
%TITLE: main
This is the Blog of the Blog Engine **Rangitaki**
Rangitaki is based on PHP, XML and Markdown. It is easy to install and to configure.
The latest Version of the 0.2 series is **0.2.2**
The latest Version of the development stream isn' ready yet.
** !IMPORTANT! Please read [this](index.php?article=About-the-Future-of-pBlog) for more information about the different versions of pBlog.**
You can find the source code on [GitHub](https://github.com/mmk2410/Rangitaki).

1
blogs/other-projects.md Normal file
View File

@ -0,0 +1 @@
%TITLE: Other projects

View File

@ -51,13 +51,42 @@ THE SOFTWARE.
<a href="<?php echo $bloghomeurl; ?>" class="home"><?php echo $bloghomename; ?></a>
<?php } ?>
</div>
<?php
if($_GET['article'] == ""){
echo "<section>";
echo "<h4>Blogs of $blogtitle:</h4>";
require_once './res/php/BlogListGenerator.php';
$blogs = scandir("./blogs/");
foreach ($blogs as $blog){
if(strlen($blog) >= 3 && substr($blog, -3) == ".md"){
if($_GET['blog'] == ""){
if($blog != "main.md"){
BlogListGenerator::listBlog("./blogs/", $blog, $blogtitle);
}
} else {
if($_GET['blog'] . ".md" != $blog){
BlogListGenerator::listBlog("./blogs/", $blog, $blogtitle);
}
}
}
}
echo "</section>";
}
if($_GET['blog'] == ""){
$blog = "main";
} else {
$blog = $_GET['blog'];
}
?>
<section>
<span class="text">
<?php
require_once 'res/php/Parsedown.php';
require_once 'res/php/ArticleGenerator.php';
if(file_exists('md/intro.md') && $_GET['article'] == "" && $blogintro == "yes"){
$file = file_get_contents('md/intro.md');
if(file_exists("blogs/$blog.md") && $_GET['article'] == "" && $blogintro == "yes"){
$file = file_get_contents("blogs/$blog.md");
$file = $file . "\n";
$file = substr($file, strpos($file, "\n"));
$intro = Parsedown::instance()
->setBreaksEnabled(true)
->text($file);
@ -67,15 +96,16 @@ THE SOFTWARE.
</span>
</section>
<?php
$articlesdir = "./articles/$blog/";
if($_GET['article'] == ""){
$articles = scandir("./articles/", 1);
$articles = scandir($articlesdir, 1);
foreach ($articles as $article) {
if(strlen($article) >= 3 && substr($article, -3) == ".md"){
ArticleGenerator::newArticle("./articles/", $article);
ArticleGenerator::newArticle($articlesdir, $article, $_GET['blog']);
}
}
} else {
ArticleGenerator::newArticle("./articles/", $_GET['article'] . ".md");
ArticleGenerator::newArticle($articlesdir, $_GET['article'] . ".md", $_GET['blog']);
include './res/php/SocialBar.php';
include './res/php/Disqus.php';
}

View File

@ -31,7 +31,7 @@
*/
class ArticleGenerator {
function newArticle($directory, $articlefile)
function newArticle($directory, $articlefile, $blog)
{
$article = file_get_contents($directory . $articlefile);
@ -40,7 +40,11 @@ class ArticleGenerator {
if(substr($article, 0, 6) == "%TITLE"){
$title = substr($article, 8, strpos($article, "\n") - 8);
$link = "./?article=" . substr($articlefile, 0, -3);
if($blog == ""){
$link = "./?article=" . substr($articlefile, 0, -3);
} else {
$link = "./?blog=$blog&article=" . substr($articlefile, 0, -3);
}
echo "<h2><a href='$link'>$title</a></h2>";
$article = substr($article, strpos($article, "\n") + 1);
}
@ -51,12 +55,19 @@ class ArticleGenerator {
$article = substr($article, strpos($article, "\n") + 1);
}
if(substr($article, 0, 7) == "%AUTHOR"){
$author = substr($article, 9, strpos($article, "\n") - 9);
$article = substr($article, strpos($article, "\n") + 1);
}
//TODO Code detection
echo Parsedown::instance()
->setBreaksEnabled(true)
->text($article);
echo "<small>$author</small>";
echo "</section>" . "\n";
}

View File

@ -0,0 +1,52 @@
<?php
/*
* The MIT License
*
* Copyright 2015 mmk.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE.
*/
/**
* Description of BlogListGenerator
*
* @author mmk
*/
class BlogListGenerator {
function listBlog($directory, $blogname, $blogmaintitle)
{
echo "<p>";
$blog = file_get_contents($directory . $blogname);
$blog = $blog . "\n";
if(substr($blog, 0, 6) == "%TITLE"){
$blog = substr($blog, 8, strpos($blog, "\n") - 8);
if($blog == "main"){
echo "<a href='./'>$blogmaintitle</a>";
} else {
$link = "./?blog=" . substr($blogname, 0, -3);
echo "<a href='$link'>$blog</a>";
}
}
echo "</p>";
}
}