diff --git a/system/admin/views/layout.html.php b/system/admin/views/layout.html.php index 3ad773b..a23a2c0 100644 --- a/system/admin/views/layout.html.php +++ b/system/admin/views/layout.html.php @@ -1,16 +1,7 @@ - <?php echo $title; ?> - - - - - - - - - + diff --git a/system/htmly.php b/system/htmly.php index 5d7f84a..3af95d9 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -26,29 +26,25 @@ get('/index', function () { $total = ''; + $tl = blog_tagline(); + + if($tl){ $tagline = ' - ' . $tl;} else {$tagline = '';} + if(empty($posts) || $page < 1){ // a non-existing page render('no-posts',array( - 'title' => config('blog.title'), - 'canonical' => site_url(), - 'description' => config('blog.description'), + 'head_contents' => head_contents(blog_title() . $tagline, blog_description(), site_url()), 'bodyclass' => 'noposts', )); die; } - $tl = config('blog.tagline'); - - if($tl){ $tagline = ' - ' . $tl;} else {$tagline = '';} - render('main',array( - 'title' => config('blog.title') . $tagline, + 'head_contents' => head_contents(blog_title() . $tagline, blog_description(), site_url()), 'page' => $page, 'posts' => $posts, - 'canonical' => config('site.url'), - 'description' => config('blog.description'), 'bodyclass' => 'infront', 'breadcrumb' => '', 'pagination' => has_pagination($total, $perpage, $page) @@ -70,12 +66,10 @@ post('/login', function() { config('views.root', 'system/admin/views'); render('login',array( + 'head_contents' => head_contents('Login - ' . blog_title(), 'Login page on ' .blog_title(), site_url()), 'error' => '', - 'title' => 'Login - ' . config('blog.title'), - 'canonical' => config('site.url'), - 'description' => 'Login page on ' .config('blog.title'), 'bodyclass' => 'editprofile', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Login' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Login' )); } } @@ -91,14 +85,12 @@ post('/login', function() { config('views.root', 'system/admin/views'); render('login',array( + 'head_contents' => head_contents('Login - ' . blog_title(), 'Login page on ' .blog_title(), site_url()), 'error' => '', - 'title' => 'Login - ' . config('blog.title'), 'username' => $user, 'password' => $pass, - 'canonical' => config('site.url'), - 'description' => 'Login page on ' .config('blog.title'), 'bodyclass' => 'editprofile', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Login' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Login' )); } @@ -139,13 +131,11 @@ get('/:year/:month/:name', function($year, $month, $name){ } render('post',array( - 'title' => $current->title .' - ' . config('blog.title'), + 'head_contents' => head_contents($current->title .' - ' . blog_title(), $description = get_description($current->body), $current->url), 'p' => $current, 'authorinfo' => '

by ' . $bio->title . '

' . $bio->body . '
', - 'canonical' => $current->url, - 'description' => $description = get_description($current->body), 'bodyclass' => 'inpost', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title, 'prev' => has_prev($prev), 'next' => has_next($next), 'type' => 'blogpost', @@ -171,22 +161,18 @@ get('/:year/:month/:name/edit', function($year, $month, $name){ if($user === $current->author || $role === 'admin') { render('edit-post',array( - 'title' => $current->title .' - ' . config('blog.title'), + 'head_contents' => head_contents('Edit post - ' . blog_title(), blog_description(), site_url()), 'p' => $current, - 'canonical' => $current->url, - 'description' => $description = get_description($current->body), 'bodyclass' => 'editpost', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title + 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title )); } else { render('denied',array( - 'title' => $current->title .' - ' . config('blog.title'), + 'head_contents' => head_contents('Edit post - ' . blog_title(), blog_description(), site_url()), 'p' => $current, - 'canonical' => $current->url, - 'description' => $description = get_description($current->body), 'bodyclass' => 'denied', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title + 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title )); } } @@ -228,17 +214,15 @@ post('/:year/:month/:name/edit', function() { config('views.root', 'system/admin/views'); render('edit-post',array( + 'head_contents' => head_contents('Edit post - ' . blog_title(), blog_description(), site_url()), 'error' => '', - 'title' => 'Edit post - ' . config('blog.title'), 'oldfile' => $oldfile, 'postTitle' => $title, 'postTag' => $tag, 'postUrl' => $url, 'postContent' => $content, - 'canonical' => config('site.url'), - 'description' => 'Adit post on ' .config('blog.title'), 'bodyclass' => 'editpost', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Edit post' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Edit post' )); } @@ -264,22 +248,18 @@ get('/:year/:month/:name/delete', function($year, $month, $name){ if($user === $current->author || $role === 'admin') { render('delete-post',array( - 'title' => $current->title .' - ' . config('blog.title'), + 'head_contents' => head_contents('Delete post - ' . blog_title(), blog_description(), site_url()), 'p' => $current, - 'canonical' => $current->url, - 'description' => $description = get_description($current->body), 'bodyclass' => 'deletepost', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title + 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title )); } else { render('denied',array( - 'title' => $current->title .' - ' . config('blog.title'), + 'head_contents' => head_contents('Delete post - ' . blog_title(), blog_description(), site_url()), 'p' => $current, - 'canonical' => $current->url, - 'description' => $description = get_description($current->body), 'bodyclass' => 'deletepost', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title + 'breadcrumb' => '' .config('breadcrumb.home'). ' » '. $current->tagb . ' » ' . $current->title )); } } @@ -320,30 +300,26 @@ get('/author/:profile', function($profile){ if(empty($posts) || $page < 1){ render('profile',array( - 'title' => 'Profile for: '. $bio->title .' - ' . config('blog.title'), + 'head_contents' => head_contents('Profile for: '. $bio->title .' - ' . blog_title(), 'Profile page and all posts by ' . $bio->title . ' on ' . blog_title() . '.', site_url() . 'author/' . $profile), 'page' => $page, 'posts' => null, 'bio' => $bio->body, 'name' => $bio->title, - 'canonical' => config('site.url') . '/author/' . $profile, - 'description' => 'Profile page and all posts by ' . $bio->title . ' on ' . config('blog.title') . '.', 'bodyclass' => 'inprofile', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, 'pagination' => has_pagination($total, $perpage, $page) )); die; } render('profile',array( - 'title' => 'Profile for: '. $bio->title .' - ' . config('blog.title'), + 'head_contents' => head_contents('Profile for: '. $bio->title .' - ' . blog_title(), 'Profile page and all posts by ' . $bio->title . ' on ' . blog_title() . '.', site_url() . 'author/' . $profile), 'page' => $page, 'posts' => $posts, 'bio' => $bio->body, 'name' => $bio->title, - 'canonical' => config('site.url') . '/author/' . $profile, - 'description' => 'Profile page and all posts by ' . $bio->title . ' on ' . config('blog.title') . '.', 'bodyclass' => 'inprofile', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, 'pagination' => has_pagination($total, $perpage, $page) )); }); @@ -355,11 +331,9 @@ get('/edit/profile', function(){ config('views.root', 'system/admin/views'); render('edit-profile',array( - 'title' => 'Edit profile - ' . config('blog.title'), - 'canonical' => config('site.url') . '/profile', - 'description' => 'Edit profile.', + 'head_contents' => head_contents('Edit profile - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'editprofile', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Edit profile', + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Edit profile', )); } else { @@ -388,14 +362,12 @@ post('/edit/profile', function() { config('views.root', 'system/admin/views'); render('edit-profile',array( + 'head_contents' => head_contents('Edit profile - ' . blog_title(), blog_description(), site_url()), 'error' => '', - 'title' => 'Edit profile - ' . config('blog.title'), 'postTitle' => $title, 'postContent' => $content, - 'canonical' => config('site.url'), - 'description' => 'Edit profile on ' .config('blog.title'), 'bodyclass' => 'editprofile', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Edit profile' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Edit profile' )); } @@ -423,26 +395,22 @@ get('/admin/posts', function () { // a non-existing page render('no-posts',array( - 'title' => config('blog.title'), - 'canonical' => site_url(), - 'description' => config('blog.description'), + 'head_contents' => head_contents('All blog posts - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'noposts', )); die; } - $tl = config('blog.tagline'); + $tl = blog_tagline(); if($tl){ $tagline = ' - ' . $tl;} else {$tagline = '';} render('posts-list',array( - 'title' => config('blog.title') . $tagline, + 'head_contents' => head_contents('All blog posts - ' . blog_title(), blog_description(), site_url()), 'heading' => 'All blog posts', 'page' => $page, 'posts' => $posts, - 'canonical' => config('site.url'), - 'description' => config('blog.description'), 'bodyclass' => 'all-posts', 'breadcrumb' => '', 'pagination' => has_pagination($total, $perpage, $page) @@ -450,9 +418,7 @@ get('/admin/posts', function () { } else { render('denied',array( - 'title' => config('blog.title'), - 'canonical' => config('site.url'), - 'description' => config('blog.description'), + 'head_contents' => head_contents('All blog posts - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'denied', 'breadcrumb' => '', )); @@ -492,32 +458,28 @@ get('/admin/mine', function(){ if(empty($posts) || $page < 1){ render('user-posts',array( - 'title' => 'All posts by: '. $bio->title .' - ' . config('blog.title'), + 'head_contents' => head_contents('My blog posts - ' . blog_title(), blog_description(), site_url()), 'page' => $page, 'heading' => 'My posts', 'posts' => null, 'bio' => $bio->body, 'name' => $bio->title, - 'canonical' => config('site.url') . '/admin/posts', - 'description' => 'All posts by ' . $bio->title . ' on ' . config('blog.title') . '.', 'bodyclass' => 'userposts', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, 'pagination' => has_pagination($total, $perpage, $page) )); die; } render('user-posts',array( - 'title' => 'All posts by: '. $bio->title .' - ' . config('blog.title'), + 'head_contents' => head_contents('My blog posts - ' . blog_title(), blog_description(), site_url()), 'heading' => 'My posts', 'page' => $page, 'posts' => $posts, 'bio' => $bio->body, 'name' => $bio->title, - 'canonical' => config('site.url') . '/admin/posts', - 'description' => 'All posts by ' . $bio->title . ' on ' . config('blog.title') . '.', 'bodyclass' => 'userposts', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Profile for: ' . $bio->title, 'pagination' => has_pagination($total, $perpage, $page) )); } @@ -563,11 +525,9 @@ get('/:static', function($static){ if(login()) { config('views.root', 'system/admin/views'); render('main', array( - 'title' => 'Admin - ' . config('blog.title'), - 'canonical' => config('site.url') . '/admin', - 'description' => 'Admin page from ' . config('blog.title') . '.', + 'head_contents' => head_contents('Admin - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'adminfront', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Admin' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Admin' )); } else { @@ -579,11 +539,9 @@ get('/:static', function($static){ elseif($static === 'login') { config('views.root', 'system/admin/views'); render('login', array( - 'title' => 'Login - ' . config('blog.title'), - 'canonical' => config('site.url') . '/login', - 'description' => 'Login page from ' . config('blog.title') . '.', + 'head_contents' => head_contents('Login - ' . blog_title(), 'Login page from ' . blog_title() . '.', site_url() . '/login'), 'bodyclass' => 'inlogin', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Login' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Login' )); die; } @@ -591,11 +549,9 @@ get('/:static', function($static){ if(login()) { config('views.root', 'system/admin/views'); render('logout', array( - 'title' => 'Logout - ' . config('blog.title'), - 'canonical' => config('site.url') . '/logout', - 'description' => 'Logout page from ' . config('blog.title') . '.', + 'head_contents' => head_contents('Logout - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'inlogout', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Logout' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Logout' )); } else { @@ -614,11 +570,9 @@ get('/:static', function($static){ $post = $post[0]; render('static',array( - 'title' => $post->title .' - ' . config('blog.title'), - 'canonical' => $post->url, - 'description' => $description = get_description($post->body), + 'head_contents' => head_contents($post->title .' - ' . blog_title(), $description = get_description($post->body), $post->url), 'bodyclass' => 'inpage', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » ' . $post->title, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » ' . $post->title, 'p' => $post, 'type' => 'staticpage', )); @@ -641,11 +595,9 @@ get('/:static/edit', function($static){ $post = $post[0]; render('edit-page',array( - 'title' => $post->title .' - ' . config('blog.title'), - 'canonical' => $post->url, - 'description' => $description = get_description($post->body), + 'head_contents' => head_contents('Edit page - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'editpage', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » ' . $post->title, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » ' . $post->title, 'p' => $post, 'type' => 'staticpage', )); @@ -684,16 +636,14 @@ post('/:static/edit', function() { config('views.root', 'system/admin/views'); render('edit-page',array( + 'head_contents' => head_contents('Edit page - ' . blog_title(), blog_description(), site_url()), 'error' => '', - 'title' => 'Edit page - ' . config('blog.title'), 'oldfile' => $oldfile, 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, - 'canonical' => config('site.url'), - 'description' => 'Edit page on ' .config('blog.title'), 'bodyclass' => 'editpage', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Edit page' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Edit page' )); } @@ -714,11 +664,9 @@ get('/:static/delete', function($static){ $post = $post[0]; render('delete-page',array( - 'title' => $post->title .' - ' . config('blog.title'), - 'canonical' => $post->url, - 'description' => $description = get_description($post->body), + 'head_contents' => head_contents('Delete page - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'deletepage', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » ' . $post->title, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » ' . $post->title, 'p' => $post, 'type' => 'staticpage', )); @@ -746,11 +694,9 @@ get('/add/post', function(){ config('views.root', 'system/admin/views'); render('add-post',array( - 'title' => 'Add post - ' . config('blog.title'), - 'canonical' => config('site.url') . '/add/post', - 'description' => 'Add post on ' .config('blog.title'), + 'head_contents' => head_contents('Add post - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'addpost', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add post' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add post' )); } else { @@ -789,16 +735,14 @@ post('/add/post', function(){ } config('views.root', 'system/admin/views'); render('add-post',array( + 'head_contents' => head_contents('Add post - ' . blog_title(), blog_description(), site_url()), 'error' => '', - 'title' => 'Add post - ' . config('blog.title'), 'postTitle' => $title, 'postTag' => $tag, 'postUrl' => $url, 'postContent' => $content, - 'canonical' => config('site.url') . '/add/post', - 'description' => 'Add post on ' .config('blog.title'), 'bodyclass' => 'addpost', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add post' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add post' )); } @@ -812,11 +756,9 @@ get('/add/page', function(){ config('views.root', 'system/admin/views'); render('add-page',array( - 'title' => 'Add static page - ' . config('blog.title'), - 'canonical' => config('site.url') . '/add/page', - 'description' => 'Add static page on ' .config('blog.title'), + 'head_contents' => head_contents('Add page - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'addpage', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add page' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add page' )); } else { @@ -850,15 +792,13 @@ post('/add/page', function(){ } config('views.root', 'system/admin/views'); render('add-page',array( + 'head_contents' => head_contents('Add page - ' . blog_title(), blog_description(), site_url()), 'error' => '', - 'title' => 'Add page - ' . config('blog.title'), 'postTitle' => $title, 'postUrl' => $url, 'postContent' => $content, - 'canonical' => config('site.url') . '/add/page', - 'description' => 'Add page on ' .config('blog.title'), 'bodyclass' => 'addpage', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add page' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Add page' )); } @@ -869,11 +809,9 @@ get('/admin/import',function(){ if(login()) { config('views.root', 'system/admin/views'); render('import', array( - 'title' => 'Import feed - ' . config('blog.title'), - 'canonical' => config('site.url') . '/import', - 'description' => 'Import feed to ' . config('blog.title') . '.', + 'head_contents' => head_contents('Import feed - ' . blog_title(), blog_description(), site_url()), 'bodyclass' => 'importfeed', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Import feed' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Import feed' )); } else { @@ -898,12 +836,10 @@ post('/admin/import', function() { config('views.root', 'system/admin/views'); render('import',array( + 'head_contents' => head_contents('Import feed - ' . blog_title(), blog_description(), site_url()), 'error' => '', - 'title' => 'Import feed - ' . config('blog.title'), - 'canonical' => config('site.url'), - 'description' => 'Import feed on ' .config('blog.title'), 'bodyclass' => 'editprofile', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Import feed' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Import feed' )); } } @@ -916,13 +852,11 @@ post('/admin/import', function() { config('views.root', 'system/admin/views'); render('import',array( + 'head_contents' => head_contents('Import feed - ' . blog_title(), blog_description(), site_url()), 'error' => '', - 'title' => 'Login - ' . config('blog.title'), 'url' => $url, - 'canonical' => config('site.url'), - 'description' => 'Login page on ' .config('blog.title'), 'bodyclass' => 'editprofile', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Login' + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Login' )); } @@ -945,13 +879,11 @@ get('/tag/:tag',function($tag){ } render('main',array( - 'title' => 'Posts tagged: ' . $tag .' - ' . config('blog.title'), + 'head_contents' => head_contents('Posts tagged: ' . $tag .' - ' . blog_title(), 'All posts tagged: ' . $tag . ' on '. blog_title() . '.', site_url() . 'tag/' . $tag), 'page' => $page, 'posts' => $posts, - 'canonical' => config('site.url') . '/tag/' . $tag, - 'description' => 'All posts tagged: ' . $tag . ' on '. config('blog.title') . '.', 'bodyclass' => 'intag', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Posts tagged: ' . $tag, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Posts tagged: ' . $tag, 'pagination' => has_pagination($total, $perpage, $page) )); }); @@ -991,13 +923,11 @@ get('/archive/:req',function($req){ } render('main',array( - 'title' => 'Archive for: ' . $timestamp .' - ' . config('blog.title'), + 'head_contents' => head_contents('Archive for: ' . $timestamp .' - ' . blog_title(), 'Archive page for: ' . $timestamp . ' on ' . blog_title() . '.', site_url() . 'archive/' . $req), 'page' => $page, 'posts' => $posts, - 'canonical' => config('site.url') . '/archive/' . $req, - 'description' => 'Archive page for: ' . $timestamp . ' on ' . config('blog.title') . '.', 'bodyclass' => 'inarchive', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Archive for: ' . $timestamp, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Archive for: ' . $timestamp, 'pagination' => has_pagination($total, $perpage, $page) )); }); @@ -1023,13 +953,11 @@ get('/search/:keyword', function($keyword){ } render('main',array( - 'title' => 'Search results for: ' . $keyword . ' - ' . config('blog.title'), + 'head_contents' => head_contents('Search results for: ' . $keyword . ' - ' . blog_title(), 'Search results for: ' . $keyword . ' on '. blog_title() . '.', site_url() . 'search/' . $keyword), 'page' => $page, 'posts' => $posts, - 'canonical' => config('site.url') . '/search/' . $keyword, - 'description' => 'Search results for: ' . $keyword . ' on '. config('blog.title') . '.', 'bodyclass' => 'insearch', - 'breadcrumb' => '' .config('breadcrumb.home'). ' » Search results for: ' . $keyword, + 'breadcrumb' => '' .config('breadcrumb.home'). ' » Search results for: ' . $keyword, 'pagination' => has_pagination($total, $perpage, $page) )); diff --git a/system/includes/functions.php b/system/includes/functions.php index 367f675..d58c3db 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -741,39 +741,42 @@ function get_teaser($text, $url) { // Get thumbnail from image and Youtube. function get_thumbnail($text) { - $teaserType = config('teaser.type'); - - if (strlen(strip_tags($text)) > config('teaser.char') && $teaserType === 'trimmed') { - - libxml_use_internal_errors(true); - $default = config('default.thumbnail'); - $dom = new DOMDocument(); - $dom->loadHtml($text); - $imgTags = $dom->getElementsByTagName('img'); - $vidTags = $dom->getElementsByTagName('iframe'); - if ($imgTags->length > 0) { - $imgElement = $imgTags->item(0); - $imgSource = $imgElement->getAttribute('src'); - return '
'; - } - elseif ($vidTags->length > 0) { - $vidElement = $vidTags->item(0); - $vidSource = $vidElement->getAttribute('src'); - $fetch = explode("embed/", $vidSource); - if(isset($fetch[1])) { - $vidThumb = '//img.youtube.com/vi/' . $fetch[1] . '/default.jpg'; - return '
'; + if (config('img.thumbnail') == 'true') { + + $teaserType = config('teaser.type'); + + if (strlen(strip_tags($text)) > config('teaser.char') && $teaserType === 'trimmed') { + + libxml_use_internal_errors(true); + $default = config('default.thumbnail'); + $dom = new DOMDocument(); + $dom->loadHtml($text); + $imgTags = $dom->getElementsByTagName('img'); + $vidTags = $dom->getElementsByTagName('iframe'); + if ($imgTags->length > 0) { + $imgElement = $imgTags->item(0); + $imgSource = $imgElement->getAttribute('src'); + return '
'; } - } - else { - if (!empty($default)) { - return '
'; + elseif ($vidTags->length > 0) { + $vidElement = $vidTags->item(0); + $vidSource = $vidElement->getAttribute('src'); + $fetch = explode("embed/", $vidSource); + if(isset($fetch[1])) { + $vidThumb = '//img.youtube.com/vi/' . $fetch[1] . '/default.jpg'; + return '
'; + } + } + else { + if (!empty($default)) { + return '
'; + } } + } + else { - } - else { - + } } } @@ -832,7 +835,7 @@ function social(){ // Copyright function copyright(){ - $blogcp = config('blog.copyright'); + $blogcp = blog_copyright(); $credit = 'Proudly powered by HTMLy.'; if (!empty($blogcp)) { @@ -845,7 +848,7 @@ function copyright(){ } // Disqus on post. -function disqus($title, $url){ +function disqus($title=null, $url=null){ $disqus = config('disqus.shortname'); $script = << @@ -1011,8 +1014,8 @@ function generate_rss($posts){ $rssLength = config('rss.char'); $channel - ->title(config('blog.title')) - ->description(config('blog.description')) + ->title(blog_title()) + ->description(blog_description()) ->url(site_url()) ->appendTo($feed); @@ -1285,20 +1288,20 @@ function generate_opml(){ $opml_data = array( 'head' => array( - 'title' => config('blog.title') . ' OPML File', - 'ownerName' => config('blog.title'), - 'ownerId' => config('site.url') + 'title' => blog_title() . ' OPML File', + 'ownerName' => blog_title(), + 'ownerId' => site_url() ), 'body' => array( array( - 'text' => config('blog.title'), - 'description' => config('blog.description'), - 'htmlUrl' => config('site.url'), + 'text' => blog_title(), + 'description' => blog_description(), + 'htmlUrl' => site_url(), 'language' => 'unknown', - 'title' => config('blog.title'), + 'title' => blog_title(), 'type' => 'rss', 'version' => 'RSS2', - 'xmlUrl' => config('site.url') . '/feed/rss' + 'xmlUrl' => site_url() . 'feed/rss' ) ) ); @@ -1312,6 +1315,53 @@ function generate_json($posts){ return json_encode($posts); } +// TRUE if the current page is the front page. +function is_front() { + $req = $_SERVER['REQUEST_URI']; + if($req == site_path() . '/') { + return true; + } + else { + return false; + } +} + +// Return blog title +function blog_title() { + return config('blog.title'); +} + +// Return blog tagline +function blog_tagline() { + return config('blog.tagline'); +} + +// Return blog description +function blog_description() { + return config('blog.description'); +} + +// Return blog copyright +function blog_copyright() { + return config('blog.copyright'); +} + +function head_contents($title, $description, $canonical) { + $output = ''; + $title = '' . $title . ''; + $favicon = ''; + $charset = ''; + $generator = ''; + $xua = ''; + $viewport = ''; + $description = ''; + $sitemap = ''; + $canonical = ''; + $feed = ''; + $output .= $title ."\n". $favicon ."\n". $charset ."\n". $generator ."\n". $xua ."\n". $viewport ."\n". $description ."\n". $sitemap ."\n". $canonical ."\n". $feed ."\n"; + return $output; +} + // Return toolbar function toolbar() { $user = $_SESSION['user']; diff --git a/themes/clean/main.html.php b/themes/clean/main.html.php index c625f36..f06f75a 100644 --- a/themes/clean/main.html.php +++ b/themes/clean/main.html.php @@ -18,9 +18,7 @@

title ?>

- Posted in tag ?> by - Comments
- - body)?> - + body)?> body, $p->url)?>
@@ -36,6 +34,6 @@ - + \ No newline at end of file diff --git a/themes/clean/post.html.php b/themes/clean/post.html.php index 36b0cfd..7cad6f9 100644 --- a/themes/clean/post.html.php +++ b/themes/clean/post.html.php @@ -28,7 +28,7 @@ tag)?>
- +
@@ -41,7 +41,7 @@ - + title, $p->url) ?> \ No newline at end of file diff --git a/themes/default/layout.html.php b/themes/default/layout.html.php index 2f85e4c..b1021ff 100644 --- a/themes/default/layout.html.php +++ b/themes/default/layout.html.php @@ -1,19 +1,10 @@ - <?php echo $title; ?> - - - - - - - - - + - + @@ -63,6 +54,6 @@ - + \ No newline at end of file diff --git a/themes/default/main.html.php b/themes/default/main.html.php index c625f36..f06f75a 100644 --- a/themes/default/main.html.php +++ b/themes/default/main.html.php @@ -18,9 +18,7 @@

title ?>

- Posted in tag ?> by - Comments
- - body)?> - + body)?> body, $p->url)?>
@@ -36,6 +34,6 @@ - + \ No newline at end of file diff --git a/themes/default/post.html.php b/themes/default/post.html.php index 36b0cfd..7cad6f9 100644 --- a/themes/default/post.html.php +++ b/themes/default/post.html.php @@ -28,7 +28,7 @@ tag)?>
- +
@@ -41,7 +41,7 @@ - + title, $p->url) ?> \ No newline at end of file