Theme support, clean up, code formating and improvement

This commit is contained in:
mmk2410 2015-06-18 20:45:49 +02:00
parent 17b76633c0
commit bdfd878b58
17 changed files with 722 additions and 403 deletions

42
res/css/no-nav.css Normal file
View file

@ -0,0 +1,42 @@
/*
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.
*/
/*
Created on : Jun 18, 2015, 7:07:45 PM
Author : mmk2410
*/
.nav{
display: none;
}
@media screen and (min-width: 1440px) {
.header {
left: 0px;
}
.main{
margin-left: 0px;
width: 100%;
}
}

View file

@ -29,15 +29,11 @@ THE SOFTWARE.
/* BODY */
body{
font-family: "Roboto", sans-serif;
background: #f6f6f6;
color: #383838;
margin-top: 94px;
}
.main{
height: 100%;
width: 100% - 300px;
margin-left: 0px;
}
@ -54,14 +50,12 @@ body{
}
/* HEADER */
.header{
background-color: #ff4415;
position: fixed;
top: 0px;
right: 0px;
left: 0px;
width: 100%;
height: 64px;
box-shadow: 2px 0px 2px 2px rgba(62, 62, 62, 0.45);
position: absolute;
}
.title{
@ -71,7 +65,6 @@ body{
line-height: 64px;
vertical-align: middle;
left: 75px;
position: absolute;
}
.nav-img{
@ -88,15 +81,11 @@ body{
height: 100%;
top: 0px;
left: -300px;
background-color: #fff;
padding-top: 64px;
border-right: 1px solid #e0e0e0;
transition: background-color 125ms ease-in-out 0ms;
z-index: 40;
}
.nav-item, .nav-item-static{
color: #383838;
text-decoration: none;
text-indent: 0;
display: inline-block;
@ -110,17 +99,11 @@ body{
}
.nav-item{
font-weight: 600;
cursor: pointer;
}
.nav-item:active{
background-color: #e2e2e2;
}
.divider{
width: 100%;
border-bottom: 1px solid #e0e0e0;
}
/* MAIN */
@ -129,33 +112,22 @@ body{
margin-right: auto;
margin-left: auto;
width: 75%;
background: #fff;
border-radius: 2px;
padding: 24px;
box-shadow: 0px 1px 1.5px 1.5px rgba(62, 62, 62, 0.3);
margin-bottom: 40px;
max-width: 1160px;
}
.card a{
color: #ff4415;
text-decoration: none;
border-bottom: 1px solid transparent;
border-bottom-color: transparent;
transition: border-bottom-color 150ms ease-in-out 100ms;
}
.card a:hover{
border-bottom-color: #ff4415;
}
.headline{
font-size: 24px;
color: #383838!important;
text-decoration: none;
display: block;
padding-bottom: 8px;
border-bottom: none!important;
}
@ -165,21 +137,19 @@ body{
}
.date{
font-size: 13px;
}
.articletext{
font-size: 14px;
line-height: 24px;
}
.author{
font-size: 13px;
display: block;
}
.tag{
font-size: 13px;
}
/* FAB */
@ -194,8 +164,6 @@ body{
height: 60px;
width: 60px;
border-radius: 30px;
background-color: #ff4415;
box-shadow: 0px 1px 1.5px 1.5px rgba(62, 62, 62, 0.3);
cursor: pointer;
}
@ -211,8 +179,6 @@ body{
margin-right: auto;
margin-left: auto;
margin-bottom: 25px;
background-color: #fff;
box-shadow: 0px 1px 1.5px 1.5px rgba(62, 62, 62, 0.3);
display: none;
}
@ -224,49 +190,44 @@ body{
/* FOOTER */
.footer{
font-size: 12px;
text-align: center;
}
.footer a{
color: #383838;
text-decoration: none;
border-bottom: 1px solid transparent;
border-bottom-color: transparent;
transition: border-bottom-color 150ms ease-in-out 100ms;
}
.footer a:hover{
border-bottom-color: #383838;
}
@media screen and (min-width: 1440px) {
.nav{
left: 0px;
}
.nav-img{
display: none;
}
.header{
left: 300px;
}
.main{
margin-left: 300px;
width: calc(100% - 300px);
}
}
@media screen and (max-width: 720px){
.card{
width: 82%;
}
}

View file

@ -22,11 +22,11 @@
* THE SOFTWARE.
*/
var main = function(){
var main = function () {
var fabActive = false;
$('.fabmenu').click(function(){
if(!(fabActive)){
$('.fabmenu').click(function () {
if (!(fabActive)) {
fabFadeIn();
fabActive = true;
} else {
@ -34,52 +34,52 @@ var main = function(){
fabActive = false;
}
});
var navOpen = false;
$('.nav-img, .overlay').click(function(){
if(!(navOpen)){
openNav();
navOpen = true;
} else {
closeNav();
navOpen = false;
}
$('.nav-img, .overlay').click(function () {
if (!(navOpen)) {
openNav();
navOpen = true;
} else {
closeNav();
navOpen = false;
}
});
};
$(document).ready(main);
function goBack(){
function goBack() {
history.go(-1);
}
function fabFadeIn(){
function fabFadeIn() {
$('.subfab').fadeIn(125);
$('.fab-img').fadeOut(60, function callback(){
$('.fab-img').attr("src", "http://c2/rangitaki/res/img/close.svg");
$('.fab-img').fadeOut(60, function callback() {
$('.fab-img').attr("src", "http://c2/rangitaki/res/img/close.svg");
});
$('.fab-img').fadeIn(60);
}
function fabFadeOut(){
$('.subfab').fadeOut(125);
$('.fab-img').fadeOut(60, function callback(){
$('.fab-img').attr("src", "http://c2/rangitaki/res/img/share.svg");
function fabFadeOut() {
$('.subfab').fadeOut(125);
$('.fab-img').fadeOut(60, function callback() {
$('.fab-img').attr("src", "http://c2/rangitaki/res/img/share.svg");
});
$('.fab-img').fadeIn(60);
}
function openNav(){
$('.nav').animate({"left":"0px"}, 125);
function openNav() {
$('.nav').animate({"left": "0px"}, 125);
$('.overlay').show();
$('.overlay').animate({"opacity":"0.4"}, 125);
$('.overlay').animate({"opacity": "0.4"}, 125);
}
function closeNav(){
$('.nav').animate({"left":"-300px"}, 125);
$('.overlay').animate({"opacity":"0.0"}, 125, function(){
function closeNav() {
$('.nav').animate({"left": "-300px"}, 125);
$('.overlay').animate({"opacity": "0.0"}, 125, function () {
$('.overlay').hide();
});
}

View file

@ -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;
}
}

View file

@ -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>";
}
}
}
}

View file

@ -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);
})();

View file

@ -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
}
?>