The core is now rewritten and working

This commit is contained in:
mmk2410 2015-06-10 12:45:02 +02:00
parent 9054fc3598
commit 7ba332052e
17 changed files with 312 additions and 230 deletions

View File

@ -0,0 +1,12 @@
%TITLE: Version 2.0
%DATE: 27 March 2015
This version introduces some very imporant features:
- **Own page for every article**
- Social **sharing buttons** (at the moment: google+, twitter, facebook but more will follow)
- **Disqus** integration
- Local **config file** -> no more editing the index file
pBlog 2.0 is only partially compatible with prior versions. You don't have to change anything in the posts or intro file (in case you have one), but to switch to version 2.0 you have to replace your index.php with the new one. With this step all your settings like the title will be lost and you have to set them in the new config.php file. For more questions write me a mail to marcelmichaelkapfer@yahoo.co.nz.
In the near future I will spend more time in writing a documentation about the blog engine and adding more comments (especially in the css file).

View File

@ -0,0 +1,4 @@
%TITLE: Version 2.1
%DATE: 29 March 2015
This version includes fixes for the article links. You only have to replace the hrefgenerator.php file in the res folder.

View File

@ -0,0 +1,4 @@
%TITLE: About the Future of pBlog
%DATE: 29 March 2015
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

@ -3,11 +3,11 @@
// Every line has an description about what you can change here. Don't delete any strings. You can set your value after the '=' sign and between the apostrophes.
// Make sure that every line ends with an semicolon (';').
// Blog Title - Set here an individual title of your blog by replacing pBlog with it.
$blogtitle = 'pBlog';
$blogtitle = 'Rangitaki Blog';
// Blog Author - Set here your name
$blogauthor = 'Marcel Kapfer';
// Blog description
$blogdescription = 'pBlog - A php blog engine without any database dependency';
$blogdescription = 'Rangitaki - A php blog engine without any database dependency';
// Home - set yes if you want to link to your homepage and no if not
$bloghome = 'yes';
// Home URL - Set here the url to your main page. Either relative (e.g. '../') or absolute ('http://github.com')
@ -21,5 +21,5 @@ $blogdisqus = 'no';
// Disqus shortname - Provide here your Disqus shortname. Without one, this won't work
$blogdisqusname = '';
// Footer - set here the text for your footer (e.g. a copyright info). You can replace the whole text after the '=' with your own one.
$blogfooter = 'pBlog ' . date("Y") . ' <a href="https://github.com/mmk2410/pBlog" target="blank">github.com/mmk2410/pBlog</a>';
$blogfooter = 'Rangitaki ' . date("Y") . ' <a href="http://marcel-kapfer.de/rangitaki" target="blank">marcel-kapfer.de/rangitaki</a>';
?>

202
index.php
View File

@ -36,14 +36,14 @@ THE SOFTWARE.
<meta http-equiv="CACHE-CONTROL" content="no-cache" />
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<!--CSS no change needed-->
<link rel="stylesheet" type="text/css" href="res/blog.css" />
<link rel="stylesheet" type="text/css" href="res/css/blog.css" />
<link href='http://fonts.googleapis.com/css?family=Roboto:400,500,700,300,400italic,100,100italic,900' rel='stylesheet' type='text/css'>
<link rel="shortcut icon" href="res/favicon.png">
</head>
<body>
<div class="header">
<nobr><a href="index.php" class="title"><?php echo $blogtitle; ?></a></nobr>
<nobr><a href="./" class="title"><?php echo $blogtitle; ?></a></nobr>
<?php if($_GET['article'] == '' && $bloghome == 'yes'){ ?>
<a href="<?php echo $bloghomeurl; ?>" class="home"><?php echo $bloghomename; ?></a>
<?php } ?>
@ -51,9 +51,9 @@ THE SOFTWARE.
<section>
<span class="text">
<?php
require_once 'res/Parsedown.php';
require_once 'res/umlautconverter.php';
require_once 'res/hrefgenerator.php';
require_once 'res/php/Parsedown.php';
require_once 'res/php/hrefgenerator.php';
require_once 'res/php/ArticleGenerator.php';
if(file_exists('md/intro.md') && $_GET['article'] == "" && $blogintro == "yes"){
$file = file_get_contents('md/intro.md');
$intro = Parsedown::instance()
@ -66,193 +66,19 @@ THE SOFTWARE.
?>
</span>
</section>
<!--DON'T CHANGE ANYTHING HERE!-->
<?php
$xml = simplexml_load_file('xml/posts.xml');
$titleArray;
$i = 0;
foreach ($xml->post as $post){
$href = $post->title;
$HrefGenerator = new HrefGenerator;
$href = $HrefGenerator->createHref($href);
$titleArray[$i] = $href;
$i = $i + 1;
}
if($_GET['article'] != ""){
$an = array_search($_GET['article'], $titleArray, true);
$post = $xml->post[$an];
?>
<section>
<span class="texttitlemono">
<?php
$title = $post->title;
$UmlautConverter = new UmlautConverter;
$title = $UmlautConverter->convert($title);
echo $title;
?>
<br>
</span>
<small>
<?php
$pubdate = $post->pubdate;
$UmlautConverter = new UmlautConverter;
$pubdate = $UmlautConverter->convert($pubdate);
echo $pubdate;
?>
</small>
<p class="text">
<?php
$content = Parsedown::instance()
->setBreaksEnabled(true)
->text($post->content);
$UmlautConverter = new UmlautConverter;
$content = $UmlautConverter->convert($content);
echo $content;
?>
</p>
<p align="right">
<?php
foreach ($post->otherlinks->otherlb as $olb){
?>
<a class="button_white" target="_blank" href="
<?php
$otherurl = $olb->otherurl;
$UmlautConverter = new UmlautConverter;
$otherurl = $UmlautConverter->convert($otherurl);
echo $otherurl;
?>
">
<?php
$otherlink = $olb->otherlink;
$UmlautConverter = new UmlautConverter;
$otherlink = $UmlautConverter->convert($otherlink);
echo $otherlink;
?>
</a>
<?php
if($_GET['article'] == ""){
$articles = scandir("./articles/", 1);
foreach ($articles as $article) {
if(strlen($article) >= 3 && substr($article, -3) == ".md"){
ArticleGenerator::newArticle("./articles/", $article);
}
}
foreach($post->mainlink as $mainlink){
?>
<a class="button_color" target="_blank" href="
<?php
$mainurl = $post->mainurl;
$UmlautConverter = new UmlautConverter;
$mainurl = $UmlautConverter->convert($mainurl);
echo $mainurl;
?>
">
<?php
$mainlink = $post->mainlink;
$UmlautConverter = new UmlautConverter;
$mainlink = $UmlautConverter->convert($mainlink);
echo $mainlink;
?>
</a>
<?php } ?>
</p>
<?php include 'res/SocialBar.php'; ?>
<?php if($blogdisqus == 'yes' && $blogdisqusname != ''){ ?>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES * * */
var disqus_shortname = '<?php echo $blogdisqusname; ?>';
/* * * DON'T EDIT BELOW THIS LINE * * */
(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);
})();
</script>
<?php } ?>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
</section>
<?php
} else {
ArticleGenerator::newArticle("./articles/", $_GET['article'] . ".md");
include './res/php/SocialBar.php';
}
?>
<?php
foreach ($xml->post as $post){
?>
<section>
<a class="texttitle" href="
<?php
$href = $post->title;
$HrefGenerator = new HrefGenerator;
$href = $HrefGenerator->createHref($href);
echo 'index.php?article=' . $href;
?>
">
<?php
$title = $post->title;
$UmlautConverter = new UmlautConverter;
$title = $UmlautConverter->convert($title);
echo $title;
?>
<br>
</a>
<small>
<?php
$pubdate = $post->pubdate;
$UmlautConverter = new UmlautConverter;
$pubdate = $UmlautConverter->convert($pubdate);
echo $pubdate;
?>
</small>
<p class="text">
<?php
$content = Parsedown::instance()
->setBreaksEnabled(true)
->text($post->content);
$UmlautConverter = new UmlautConverter;
$content = $UmlautConverter->convert($content);
echo $content;
?>
</p>
<p align="right">
<?php
foreach ($post->otherlinks->otherlb as $olb){
?>
<a class="button_white" target="_blank" href="
<?php
$otherurl = $olb->otherurl;
$UmlautConverter = new UmlautConverter;
$otherurl = $UmlautConverter->convert($otherurl);
echo $otherurl;
?>
">
<?php
$otherlink = $olb->otherlink;
$UmlautConverter = new UmlautConverter;
$otherlink = $UmlautConverter->convert($otherlink);
echo $otherlink;
?>
</a>
<?php
}
foreach($post->mainlink as $mainlink){
?>
<a class="button_color" target="_blank" href="
<?php
$mainurl = $post->mainurl;
$UmlautConverter = new UmlautConverter;
$mainurl = $UmlautConverter->convert($mainurl);
echo $mainurl;
?>
">
<?php
$mainlink = $post->mainlink;
$UmlautConverter = new UmlautConverter;
$mainlink = $UmlautConverter->convert($mainlink);
echo $mainlink;
?>
</a>
<?php } ?>
</p>
</section>
<?php
}
}
?>
<div class="box_container">
<p class="cc">
<?php echo $blogfooter ?>

View File

@ -54,7 +54,7 @@ img{
right: 0;
float: center;
z-index: 40;
background: #de3e0b;
background: #ff4415;
width: 100%;
box-shadow: 0px 0px 4px 4px rgba(189, 189, 189, 0.5);
-moz-box-shadow: 0px 0px 4px 4px rgba(189, 189, 189, 0.5);
@ -78,7 +78,7 @@ img{
font-size: 14px;
line-height: 20px;
letter-spacing: 0.01px;
color: #de3e0b;
color: #ff4415;
text-decoration: none;
}
section{
@ -128,10 +128,10 @@ Usage: <a class=".text_button_flat_colored">YOUR TEXT</a>
height: 40px;
padding: 8px;
color: #FFFFFF;
background-color: #de3e0b;
background-color: #ff4415;
border-width: 1px;
border-style: solid;
border-color: #de3e0b;
border-color: #ff4415;
border-radius: 3px;
margin: 4px;
margin-bottom: 5px;
@ -184,7 +184,7 @@ code{
}
.texttitle:hover{
color: #de3e0b;
color: #ff4415;
}
.texttitlemono{

195
res/css/design.scss Normal file
View File

@ -0,0 +1,195 @@
/*
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.
*/
/*
Created on : Jun 10, 2015, 9:57:04 AM
Author : mmk2410
*/
$primary-color: #ff4415;
$font-family: 'Roboto', sans-serif;
body{
margin-right: 15%;
margin-left: 15%;
margin-bottom: 0px;
margin-top: 100px;
font-family: $font-family;
font-size: 14px;
line-height: 20px;
letter-spacing: 0.01px;
background-color: #ffffff;
color: rgba(0, 0, 0, 0.87);
}
img{
max-width: 100%;
max-height: 400px;
display: block;
margin-left: auto;
margin-right: auto;
}
.header{
position: absolute;
top: 0;
left: 0;
right: 0;
float: center;
z-index: 40;
background: $primary-color;
width: 100%;
box-shadow: 0px 0px 4px 4px rgba(189, 189, 189, 0.5);
-moz-box-shadow: 0px 0px 4px 4px rgba(189, 189, 189, 0.5);
-webkit-box-shadow: 0px 0px 4px 4px rgba(189, 189, 189, 0.5);
height: 60px;
padding-right: 0px;
padding-top: 0px;
white-space: nowrap;
}
.text{
font-family: $font-family;
font-size: 14px;
line-height: 20px;
letter-spacing: 0.01px;
background-color: #ffffff;
z-index: 10;
color: rgba(0, 0, 0, 0.87);
}
.text a{
font-family: $font-family;
font-size: 14px;
line-height: 20px;
letter-spacing: 0.01px;
color: $primary-color;
text-decoration: none;
}
section{
margin-bottom: 50px;
}
.title{
padding-left:15%;
height: 60px;
line-height: 60px;
display:inline-block;
text-decoration: none;
color: #FFFFFF;
vertical-align: middle;
font-size: 24px;
overflow-x: hidden;
max-width: 35%;
}
.home{
float: right;
padding-right: 15%;
height: 60px;
line-height: 60px;
vertical-align: middle;
color: #fff;
overflow-x: hidden;
font-size: 20px;
display: inline-block;
text-decoration: none;
max-width: 35%;
}
code{
background-color: #e8e6e6;
padding: 5px;
}
.texttitle{
font-family: $font-family;
font-weight: 500;
font-size: 20px;
color: rgb(33, 33, 33);
line-height: 24px;
letter-spacing: 0.05px;
text-decoration: none;
}
.texttitle:hover{
color: $primary-color;
}
.texttitlemono{
font-family: $font-family;
font-weight: 500;
font-size: 20px;
color: rgb(33, 33, 33);
line-height: 24px;
letter-spacing: 0.05px;
text-decoration: none;
}
.cc{
font-family: $font-family;
font-size: 12px;
line-height: 14px;
letter-spacing: 0.01px;
text-align: center;
}
.cc a{
font-family: 'Roboto', sans-serif;
font-size: 12px;
line-height: 14px;
letter-spacing: 0.01px;
color: rgba(0, 0, 0, 0.87);
text-decoration: none;
}
.cc a:hover{
text-decoration: underline;
}
.socialbar{
display: inline-block;
height: 68px;
margin-top: 10px;
}
.socialimg{
height: 40px;
display: inline-block;
padding-right: 5px;
}
@media screen and (max-width: 700px){
body {
margin-right: 40px;
margin-left: 20px;
}
.title{
padding-left: 10px;
max-width: 45%;
}
.home{
padding-right: 10px;
max-width: 45%;
}
}

View File

Before

Width:  |  Height:  |  Size: 1.5 KiB

After

Width:  |  Height:  |  Size: 1.5 KiB

View File

Before

Width:  |  Height:  |  Size: 5.8 KiB

After

Width:  |  Height:  |  Size: 5.8 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

@ -1,48 +1,25 @@
<?php
/*
/*
* The MIT License
*
* Copyright 2015 mmk2410.
*
*
* 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,
* FINESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* 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.
*
*/
/**
* This is a small tool for converting german umlauts into HTML codes.
* This fixes the error that one some servers weird sings are displayed.
*
* @author Marcel Kapfer <marcelmichaelkapfer@yahoo.co.nz>
*/
class UmlautConverter
{
function convert($text)
{
$output = str_replace("ä","&auml;",$text);
$output = str_replace("Ä","&Auml;",$output);
$output = str_replace("ö","&ouml;",$output);
$output = str_replace("Ö","&Ouml;",$output);
$output = str_replace("ü","&uuml;",$output);
$output = str_replace("Ü","&Uuml;",$output);
$output = str_replace("ß","&szlig;",$output);
return $output;
}
}

View File

@ -0,0 +1,64 @@
<?php
/*
* The MIT License
*
* 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
* 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 ArticleGenerator
*
* @author mmk2410 <marcelmichaelkapfer@yahoo.co.nz>
*/
class ArticleGenerator {
function newArticle($directory, $articlefile)
{
$article = file_get_contents($directory . $articlefile);
echo "<section>";
if(substr($article, 0, 6) == "%TITLE"){
$title = substr($article, 8, strpos($article, "\n") - 8);
$link = "./?article=" . substr($articlefile, 0, -3);
echo "<h2><a href='$link'>$title</a></h2>";
$article = substr($article, strpos($article, "\n") + 1);
}
if(substr($article, 0, 5) == "%DATE"){
$date = substr($article, 7, strpos($article, "\n") - 7);
echo "<small>$date</small>";
$article = substr($article, strpos($article, "\n") + 1);
}
//TODO Code detection
echo Parsedown::instance()
->setBreaksEnabled(true)
->text($article);
echo "</section>" . "\n";
}
}

View File

@ -6,9 +6,9 @@
<div class="socialbar">
<!--Twitter-->
<a href="https://twitter.com/intent/tweet?text=Check out: <?php echo $post->title; ?> &url=<?php echo $url; ?>&original_referer=" target="blank"><img src="res/twttr.svg" class="socialimg"/></a>
<a href="https://twitter.com/intent/tweet?text=Check out: <?php echo $post->title; ?> &url=<?php echo $url; ?>&original_referer=" target="blank"><img src="res/img/twttr.svg" class="socialimg"/></a>
<!--Google+-->
<a href="https://plus.google.com/share?url=<?php echo $url; ?>&hl=en-US" target="blank"><img src="res/gplus.svg" class="socialimg" /></a>
<a href="https://plus.google.com/share?url=<?php echo $url; ?>&hl=en-US" target="blank"><img src="res/img/gplus.svg" class="socialimg" /></a>
<!--Facebook-->
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $url; ?>&t=<?php echo $post->title; ?>" target="blank"><img src="res/fb.png" class="socialimg" /></a>
<a href="https://www.facebook.com/sharer/sharer.php?u=<?php echo $url; ?>&t=<?php echo $post->title; ?>" target="blank"><img src="res/img/fb.png" class="socialimg" /></a>
</div>

View File

@ -29,7 +29,7 @@
* This is a small tool for converting the title of a post into someting usable
* as an url. This is used for the article urls.
*
* @author Marcel Kapfer <marcelmichaelkapfer@yahoo.co.nz>
* @author mmk2410 <marcelmichaelkapfer@yahoo.co.nz>
*/
class HrefGenerator {