From 0ae529b163173bbae9cbd0039b8738c66e0f0114 Mon Sep 17 00:00:00 2001 From: mmk2410 Date: Fri, 12 Jun 2015 10:31:28 +0200 Subject: [PATCH] Tags --- articles/main/2015-03-27-09-34-Version-2.0.md | 1 + ...5-03-29-21-34-About-the-Future-of-pBlog.md | 1 + ...06-11-15-55-What-else-we-are-developing.md | 1 + index.php | 14 ++++++- res/php/ArticleGenerator.php | 38 ++++++++++++++++++- 5 files changed, 52 insertions(+), 3 deletions(-) diff --git a/articles/main/2015-03-27-09-34-Version-2.0.md b/articles/main/2015-03-27-09-34-Version-2.0.md index 5a20f9e..df1b19b 100644 --- a/articles/main/2015-03-27-09-34-Version-2.0.md +++ b/articles/main/2015-03-27-09-34-Version-2.0.md @@ -1,5 +1,6 @@ %TITLE: Version 2.0 %DATE: 27 March 2015 +%TAGS: 0.2-Series This version introduces some very imporant features: - **Own page for every article** diff --git a/articles/main/2015-03-29-21-34-About-the-Future-of-pBlog.md b/articles/main/2015-03-29-21-34-About-the-Future-of-pBlog.md index 67b6ca2..28bfb82 100644 --- a/articles/main/2015-03-29-21-34-About-the-Future-of-pBlog.md +++ b/articles/main/2015-03-29-21-34-About-the-Future-of-pBlog.md @@ -1,5 +1,6 @@ %TITLE: About the Future of pBlog %DATE: 29 March 2015 %AUTHOR: Marcel Michael Kapfer +%TAGS: Important, 0.2-Series 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. \ No newline at end of file diff --git a/articles/other-projects/2015-06-11-15-55-What-else-we-are-developing.md b/articles/other-projects/2015-06-11-15-55-What-else-we-are-developing.md index fba42ee..e34754f 100644 --- a/articles/other-projects/2015-06-11-15-55-What-else-we-are-developing.md +++ b/articles/other-projects/2015-06-11-15-55-What-else-we-are-developing.md @@ -1,5 +1,6 @@ %TITLE: What else are we working on? %DATE: 11 June 2015 +%TAGS: Future Near the Rangitaki PHP blogging engine there are other projects were working on or where we will start development soon: diff --git a/index.php b/index.php index 04e49f3..5962f8f 100644 --- a/index.php +++ b/index.php @@ -83,7 +83,7 @@ THE SOFTWARE. = 3 && substr($article, -3) == ".md"){ + ArticleGenerator::newArticle($articlesdir, $article, $_GET['blog']); + } + } + } + } else if($_GET['article'] == ""){ $articles = scandir($articlesdir, 1); foreach ($articles as $article) { if(strlen($article) >= 3 && substr($article, -3) == ".md"){ diff --git a/res/php/ArticleGenerator.php b/res/php/ArticleGenerator.php index e2f1ebd..96222ac 100644 --- a/res/php/ArticleGenerator.php +++ b/res/php/ArticleGenerator.php @@ -60,16 +60,52 @@ class ArticleGenerator { $article = substr($article, strpos($article, "\n") + 1); } + if(substr($article, 0, 5) == "%TAGS"){ + $tags = substr($article, 7, strpos($article, "\n") - 7); + $tags = explode(", ", $tags); + $article = substr($article, strpos($article, "\n") + 1); + } + //TODO Code detection echo Parsedown::instance() ->setBreaksEnabled(true) ->text($article); - echo "$author"; + echo "$author
"; + + foreach ($tags as $tag) { + if($_GET['blog'] == ""){ + echo "$tag "; + } else { + echo "$tag "; + } + } + + echo "
"; echo "" . "\n"; } + function getTags($directory, $articlefile){ + $article = file_get_contents($directory . $articlefile); + if(substr($article, 0, 6) == "%TITLE"){ + $article = substr($article, strpos($article, "\n") + 1); + } + + if(substr($article, 0, 5) == "%DATE"){ + $article = substr($article, strpos($article, "\n") + 1); + } + + if(substr($article, 0, 7) == "%AUTHOR"){ + $article = substr($article, strpos($article, "\n") + 1); + } + if(substr($article, 0, 5) == "%TAGS"){ + $tags = substr($article, 7, strpos($article, "\n") - 7); + $tags = explode(", ", $tags); + } + return $tags; + } + }