Theme support, clean up, code formating and improvement
This commit is contained in:
parent
17b76633c0
commit
bdfd878b58
17 changed files with 722 additions and 403 deletions
|
@ -30,17 +30,16 @@
|
|||
* @author mmk2410 <marcelmichaelkapfer@yahoo.co.nz>
|
||||
*/
|
||||
class ArticleGenerator {
|
||||
|
||||
function newArticle($directory, $articlefile, $blog)
|
||||
{
|
||||
|
||||
|
||||
function newArticle ($directory, $articlefile, $blog) {
|
||||
|
||||
$article = file_get_contents($directory . $articlefile);
|
||||
|
||||
|
||||
echo "<section class='card'>";
|
||||
|
||||
if(substr($article, 0, 6) == "%TITLE"){
|
||||
|
||||
if (substr($article, 0, 6) == "%TITLE") {
|
||||
$title = substr($article, 8, strpos($article, "\n") - 8);
|
||||
if($blog == ""){
|
||||
if ($blog == "") {
|
||||
$link = "./?article=" . substr($articlefile, 0, -3);
|
||||
} else {
|
||||
$link = "./?blog=$blog&article=" . substr($articlefile, 0, -3);
|
||||
|
@ -48,68 +47,68 @@ class ArticleGenerator {
|
|||
echo "<a href='$link' class='headline'>$title</a>";
|
||||
$article = substr($article, strpos($article, "\n") + 1);
|
||||
}
|
||||
|
||||
if(substr($article, 0, 5) == "%DATE"){
|
||||
|
||||
if (substr($article, 0, 5) == "%DATE") {
|
||||
$date = substr($article, 7, strpos($article, "\n") - 7);
|
||||
echo "<span class='date'>$date</span>";
|
||||
$article = substr($article, strpos($article, "\n") + 1);
|
||||
}
|
||||
|
||||
if(substr($article, 0, 7) == "%AUTHOR"){
|
||||
|
||||
if (substr($article, 0, 7) == "%AUTHOR") {
|
||||
$author = substr($article, 9, strpos($article, "\n") - 9);
|
||||
$article = substr($article, strpos($article, "\n") + 1);
|
||||
}
|
||||
|
||||
if(substr($article, 0, 5) == "%TAGS"){
|
||||
|
||||
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 "<div class='articletext'>";
|
||||
|
||||
|
||||
echo Parsedown::instance()
|
||||
->setBreaksEnabled(true)
|
||||
->text($article);
|
||||
|
||||
|
||||
echo "</div>";
|
||||
|
||||
if($author != ""){
|
||||
|
||||
if ($author != "") {
|
||||
echo "<span class='author'>$author</span>";
|
||||
}
|
||||
|
||||
|
||||
foreach ($tags as $tag) {
|
||||
if($_GET['blog'] == ""){
|
||||
$blogurl = filter_input(INPUT_GET, "blog");
|
||||
if ($blogurl == "") {
|
||||
echo "<a class='tag' href='./?tag=$tag'>$tag</a> ";
|
||||
} else {
|
||||
echo "<a class='tag' href='./?blog=$blog&tag=$tag'>$tag</a> ";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
echo "</section>" . "\n";
|
||||
|
||||
}
|
||||
|
||||
function getTags($directory, $articlefile){
|
||||
|
||||
function getTags($directory, $articlefile) {
|
||||
$article = file_get_contents($directory . $articlefile);
|
||||
if(substr($article, 0, 6) == "%TITLE"){
|
||||
if (substr($article, 0, 6) == "%TITLE") {
|
||||
$article = substr($article, strpos($article, "\n") + 1);
|
||||
}
|
||||
|
||||
if(substr($article, 0, 5) == "%DATE"){
|
||||
|
||||
if (substr($article, 0, 5) == "%DATE") {
|
||||
$article = substr($article, strpos($article, "\n") + 1);
|
||||
}
|
||||
|
||||
if(substr($article, 0, 7) == "%AUTHOR"){
|
||||
|
||||
if (substr($article, 0, 7) == "%AUTHOR") {
|
||||
$article = substr($article, strpos($article, "\n") + 1);
|
||||
}
|
||||
if(substr($article, 0, 5) == "%TAGS"){
|
||||
if (substr($article, 0, 5) == "%TAGS") {
|
||||
$tags = substr($article, 7, strpos($article, "\n") - 7);
|
||||
$tags = explode(", ", $tags);
|
||||
}
|
||||
return $tags;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2015 mmk.
|
||||
* Copyright 2015 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
|
||||
|
@ -27,24 +27,22 @@
|
|||
/**
|
||||
* Description of BlogListGenerator
|
||||
*
|
||||
* @author mmk
|
||||
* @author mmk2410 <marcelmichaelkapfer@yahoo.co.nz>
|
||||
*/
|
||||
class BlogListGenerator {
|
||||
|
||||
function listBlog($directory, $blogname, $blogmaintitle)
|
||||
{
|
||||
|
||||
function listBlog($directory, $blogname, $blogmaintitle) {
|
||||
$blog = file_get_contents($directory . $blogname);
|
||||
$blog = $blog . "\n";
|
||||
if(substr($blog, 0, 6) == "%TITLE"){
|
||||
if (substr($blog, 0, 6) == "%TITLE") {
|
||||
$blog = substr($blog, 8, strpos($blog, "\n") - 8);
|
||||
if($blog == "main"){
|
||||
if ($blog == "main") {
|
||||
echo "<a class='nav-item' href='./'>$blogmaintitle</a>";
|
||||
} else {
|
||||
$link = "./?blog=" . substr($blogname, 0, -3);
|
||||
echo "<a class='nav-item' href='$link'>$blog</a>";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
-->
|
||||
|
||||
<?php if($blogdisqus){ ?>
|
||||
<?php if ($blogdisqus) { ?>
|
||||
<section class="card">
|
||||
<div id="disqus_thread"></div>
|
||||
<script type="text/javascript">
|
||||
|
@ -30,8 +30,10 @@ THE SOFTWARE.
|
|||
var disqus_shortname = '<?php echo $blogdisqus; ?>';
|
||||
|
||||
/* * * DON'T EDIT BELOW THIS LINE * * */
|
||||
(function() {
|
||||
var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
|
||||
(function () {
|
||||
var dsq = document.createElement('script');
|
||||
dsq.type = 'text/javascript';
|
||||
dsq.async = true;
|
||||
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
|
||||
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
|
||||
})();
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
<?php
|
||||
|
||||
/*
|
||||
/*
|
||||
* The MIT License
|
||||
*
|
||||
* Copyright 2015 mmk.
|
||||
* Copyright 2015 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
|
||||
|
@ -25,20 +24,27 @@
|
|||
*/
|
||||
|
||||
|
||||
if($bloganalytics){
|
||||
?>
|
||||
if ($bloganalytics) {
|
||||
?>
|
||||
<script>
|
||||
|
||||
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
|
||||
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
|
||||
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
|
||||
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
|
||||
|
||||
(function (i, s, o, g, r, a, m) {
|
||||
i['GoogleAnalyticsObject'] = r;
|
||||
i[r] = i[r] || function () {
|
||||
(i[r].q = i[r].q || []).push(arguments);
|
||||
}, i[r].l = 1 * new Date();
|
||||
a = s.createElement(o),
|
||||
m = s.getElementsByTagName(o)[0];
|
||||
a.async = 1;
|
||||
a.src = g;
|
||||
m.parentNode.insertBefore(a, m);
|
||||
})(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');
|
||||
|
||||
ga('create', '<?php echo $bloganalytics; ?>', 'auto');
|
||||
ga('send', 'pageview');
|
||||
|
||||
|
||||
</script>
|
||||
|
||||
<?php
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
Reference in a new issue