Disqus and Google Analytics added. Cleanup

This commit is contained in:
mmk2410 2015-06-10 18:41:51 +02:00
parent 7ba332052e
commit 39e843241b
4 changed files with 77 additions and 43 deletions

View file

@ -2,24 +2,26 @@
// This is the configuration file. You can configure here all necessary (and possible) options without editing the index.php file. // This is the configuration file. You can configure here all necessary (and possible) options without editing the index.php file.
// 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. // 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 (';'). // Make sure that every line ends with an semicolon (';').
// Blog Title - Set here an individual title of your blog by replacing pBlog with it. // Blog Title - Set here an individual title of your blog by replacing Rangitaki Blog with it.
$blogtitle = 'Rangitaki Blog'; $blogtitle = 'Rangitaki Blog';
// Blog Author - Set here your name // Blog Author - Set here your name
$blogauthor = 'Marcel Kapfer'; $blogauthor = 'Marcel Kapfer';
// Blog description // Blog description
$blogdescription = 'Rangitaki - A php blog engine without any database dependency'; $blogdescription = 'Rangitaki - A PHP blog engine without any database dependency';
// Blog favicon - enter here the path to your favicon
$blogfavicon = '../res/favicon.png';
// Home - set yes if you want to link to your homepage and no if not // Home - set yes if you want to link to your homepage and no if not
$bloghome = 'yes'; $bloghome = 'yes';
// Home URL - Set here the url to your main page. Either relative (e.g. '../') or absolute ('http://github.com') // Home URL - Set here the url to your main page. Either relative (e.g. '../') or absolute ('http://github.com')
$bloghomeurl = '../'; $bloghomeurl = '../';
// Home name - Set here an individual name for your main page // Home name - Set here an individual name for your main page
$bloghomename = 'Home'; $bloghomename = 'Home';
// Intro - set yes if you have a blog intro and no if you don't hve one // Intro - set yes if you have a blog intro and no if you don't have one
$blogintro = 'yes'; $blogintro = 'yes';
// Disqus - to enable disqus set this one to yes and provide your shortname // Disqus - Provide here your Disqus shortname. Leave empty if you don't want to use it.
$blogdisqus = 'no'; $blogdisqus = 'rangitaki';
// Disqus shortname - Provide here your Disqus shortname. Without one, this won't work // Google Analytics - Provide here your Google Analytics Tracking-ID. Leave empty if you don't want to use it.
$blogdisqusname = ''; $bloganalytics = 'UA-41767647-3';
// 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. // 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 = 'Rangitaki ' . date("Y") . ' <a href="http://marcel-kapfer.de/rangitaki" target="blank">marcel-kapfer.de/rangitaki</a>'; $blogfooter = 'Rangitaki ' . date("Y") . ' <a href="https://github.com/mmk2410/Rangitaki" target="blank">github.com/mmk2410/Rangitaki</a>';
?> ?>

View file

@ -52,7 +52,6 @@ THE SOFTWARE.
<span class="text"> <span class="text">
<?php <?php
require_once 'res/php/Parsedown.php'; require_once 'res/php/Parsedown.php';
require_once 'res/php/hrefgenerator.php';
require_once 'res/php/ArticleGenerator.php'; require_once 'res/php/ArticleGenerator.php';
if(file_exists('md/intro.md') && $_GET['article'] == "" && $blogintro == "yes"){ if(file_exists('md/intro.md') && $_GET['article'] == "" && $blogintro == "yes"){
$file = file_get_contents('md/intro.md'); $file = file_get_contents('md/intro.md');
@ -77,12 +76,16 @@ THE SOFTWARE.
} else { } else {
ArticleGenerator::newArticle("./articles/", $_GET['article'] . ".md"); ArticleGenerator::newArticle("./articles/", $_GET['article'] . ".md");
include './res/php/SocialBar.php'; include './res/php/SocialBar.php';
include './res/php/Disqus.php';
} }
?> ?>
<div class="box_container"> <div class="box_container">
<p class="cc"> <p class="cc">
<?php echo $blogfooter ?> <?php echo $blogfooter; ?>
</p> </p>
</div> </div>
<?php
include './res/php/GoogleAnalytics.php';
?>
</body> </body>
</html> </html>

39
res/php/Disqus.php Normal file
View file

@ -0,0 +1,39 @@
<!--
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.
-->
<?php if($blogdisqus){ ?>
<div id="disqus_thread"></div>
<script type="text/javascript">
/* * * CONFIGURATION VARIABLES * * */
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;
dsq.src = '//' + disqus_shortname + '.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
<noscript>Please enable JavaScript to view the <a href="https://disqus.com/?ref_noscript" rel="nofollow">comments powered by Disqus.</a></noscript>
<?php } ?>

View file

@ -3,7 +3,7 @@
/* /*
* The MIT License * The MIT License
* *
* Copyright 2015 mmk2410. * Copyright 2015 mmk.
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy * Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal * of this software and associated documentation files (the "Software"), to deal
@ -17,38 +17,28 @@
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * 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 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * 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 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
* THE SOFTWARE. * THE SOFTWARE.
*
*/ */
/**
* 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 mmk2410 <marcelmichaelkapfer@yahoo.co.nz>
*/
class HrefGenerator { if($bloganalytics){
?>
function createHref($text) <script>
{
$output = str_replace(" ", "-", $text);
$output = str_replace("ä","ae",$output);
$output = str_replace("Ä","Ae",$output);
$output = str_replace("ö","oe",$output);
$output = str_replace("Ö","Oe",$output);
$output = str_replace("ü","ue",$output);
$output = str_replace("Ü","Ue",$output);
$output = str_replace("ß","ss",$output);
$output = str_replace('"', "", $output);
$output = str_replace("'", "", $output);
$output = str_replace("?", "", $output);
$output = str_replace("#", "", $output);
return $output;
}
(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
} }
?>