From a273a4faf736eb12ac578ab4f21b6f779b3abd2f Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Fri, 1 Jan 2016 22:10:52 +0700 Subject: [PATCH] Happy New Year! The ported version of Twenty Fifteen and Twenty Sixteen include with the package. Maintenance and bugs fixes. --- cache/installedVersion.json | 2 +- config/config.ini.example | 7 +- system/admin/admin.php | 18 +- system/htmly.php | 73 +- system/includes/functions.php | 226 +- themes/blog/css/styles.css | 6 + themes/blog/layout.html.php | 8 + themes/blog/main.html.php | 2 +- themes/clean/css/style.css | 4 +- themes/clean/layout.html.php | 1 + themes/clean/main.html.php | 5 +- themes/default/main.html.php | 5 +- themes/logs/css/style.css | 2 +- themes/logs/layout.html.php | 4 + themes/logs/main.html.php | 5 +- themes/twentyfifteen/404-search.html.php | 11 + themes/twentyfifteen/404.html.php | 9 + themes/twentyfifteen/LICENSE.txt | 22 + themes/twentyfifteen/README.md | 11 + themes/twentyfifteen/css/font.css | 60 + themes/twentyfifteen/css/ie.css | 948 ++++ themes/twentyfifteen/css/ie7.css | 89 + themes/twentyfifteen/css/style.css | 6126 +++++++++++++++++++++++ themes/twentyfifteen/genericons/COPYING.txt | 9 + themes/twentyfifteen/genericons/Genericons.eot | Bin 0 -> 22760 bytes themes/twentyfifteen/genericons/Genericons.svg | 543 ++ themes/twentyfifteen/genericons/Genericons.ttf | Bin 0 -> 22576 bytes themes/twentyfifteen/genericons/Genericons.woff | Bin 0 -> 14360 bytes themes/twentyfifteen/genericons/LICENSE.txt | 339 ++ themes/twentyfifteen/genericons/README.md | 152 + themes/twentyfifteen/genericons/genericons.css | 209 + themes/twentyfifteen/images/avatar.png | Bin 0 -> 4691 bytes themes/twentyfifteen/js/functions.js | 178 + themes/twentyfifteen/js/html5.js | 9 + themes/twentyfifteen/js/jquery-migrate.js | 2 + themes/twentyfifteen/js/jquery.js | 4 + themes/twentyfifteen/js/skip-link-focus-fix.js | 26 + themes/twentyfifteen/layout.html.php | 140 + themes/twentyfifteen/main.html.php | 89 + themes/twentyfifteen/no-posts.html.php | 1 + themes/twentyfifteen/post.html.php | 91 + themes/twentyfifteen/profile.html.php | 45 + themes/twentyfifteen/static.html.php | 9 + themes/twentysixteen/404-search.html.php | 17 + themes/twentysixteen/404.html.php | 15 + themes/twentysixteen/LICENSE.txt | 22 + themes/twentysixteen/README.md | 11 + themes/twentysixteen/css/ie.css | 48 + themes/twentysixteen/css/ie7.css | 176 + themes/twentysixteen/css/ie8.css | 226 + themes/twentysixteen/css/rtl.css | 754 +++ themes/twentysixteen/css/style.css | 4056 +++++++++++++++ themes/twentysixteen/genericons/COPYING.txt | 9 + themes/twentysixteen/genericons/Genericons.eot | Bin 0 -> 22374 bytes themes/twentysixteen/genericons/Genericons.svg | 537 ++ themes/twentysixteen/genericons/Genericons.ttf | Bin 0 -> 22188 bytes themes/twentysixteen/genericons/Genericons.woff | Bin 0 -> 13988 bytes themes/twentysixteen/genericons/LICENSE.txt | 339 ++ themes/twentysixteen/genericons/README.md | 218 + themes/twentysixteen/genericons/genericons.css | 263 + themes/twentysixteen/img/avatar.png | Bin 0 -> 4691 bytes themes/twentysixteen/js/functions.js | 200 + themes/twentysixteen/js/html5.js | 326 ++ themes/twentysixteen/js/jquery-migrate.js | 2 + themes/twentysixteen/js/jquery.js | 6 + themes/twentysixteen/js/skip-link-focus-fix.js | 36 + themes/twentysixteen/layout.html.php | 162 + themes/twentysixteen/main.html.php | 80 + themes/twentysixteen/no-posts.html.php | 5 + themes/twentysixteen/post.html.php | 101 + themes/twentysixteen/profile.html.php | 45 + themes/twentysixteen/static.html.php | 18 + 72 files changed, 17132 insertions(+), 30 deletions(-) create mode 100644 themes/twentyfifteen/404-search.html.php create mode 100644 themes/twentyfifteen/404.html.php create mode 100644 themes/twentyfifteen/LICENSE.txt create mode 100644 themes/twentyfifteen/README.md create mode 100644 themes/twentyfifteen/css/font.css create mode 100644 themes/twentyfifteen/css/ie.css create mode 100644 themes/twentyfifteen/css/ie7.css create mode 100644 themes/twentyfifteen/css/style.css create mode 100644 themes/twentyfifteen/genericons/COPYING.txt create mode 100644 themes/twentyfifteen/genericons/Genericons.eot create mode 100644 themes/twentyfifteen/genericons/Genericons.svg create mode 100644 themes/twentyfifteen/genericons/Genericons.ttf create mode 100644 themes/twentyfifteen/genericons/Genericons.woff create mode 100644 themes/twentyfifteen/genericons/LICENSE.txt create mode 100644 themes/twentyfifteen/genericons/README.md create mode 100644 themes/twentyfifteen/genericons/genericons.css create mode 100644 themes/twentyfifteen/images/avatar.png create mode 100644 themes/twentyfifteen/js/functions.js create mode 100644 themes/twentyfifteen/js/html5.js create mode 100644 themes/twentyfifteen/js/jquery-migrate.js create mode 100644 themes/twentyfifteen/js/jquery.js create mode 100644 themes/twentyfifteen/js/skip-link-focus-fix.js create mode 100644 themes/twentyfifteen/layout.html.php create mode 100644 themes/twentyfifteen/main.html.php create mode 100644 themes/twentyfifteen/no-posts.html.php create mode 100644 themes/twentyfifteen/post.html.php create mode 100644 themes/twentyfifteen/profile.html.php create mode 100644 themes/twentyfifteen/static.html.php create mode 100644 themes/twentysixteen/404-search.html.php create mode 100644 themes/twentysixteen/404.html.php create mode 100644 themes/twentysixteen/LICENSE.txt create mode 100644 themes/twentysixteen/README.md create mode 100644 themes/twentysixteen/css/ie.css create mode 100644 themes/twentysixteen/css/ie7.css create mode 100644 themes/twentysixteen/css/ie8.css create mode 100644 themes/twentysixteen/css/rtl.css create mode 100644 themes/twentysixteen/css/style.css create mode 100644 themes/twentysixteen/genericons/COPYING.txt create mode 100644 themes/twentysixteen/genericons/Genericons.eot create mode 100644 themes/twentysixteen/genericons/Genericons.svg create mode 100644 themes/twentysixteen/genericons/Genericons.ttf create mode 100644 themes/twentysixteen/genericons/Genericons.woff create mode 100644 themes/twentysixteen/genericons/LICENSE.txt create mode 100644 themes/twentysixteen/genericons/README.md create mode 100644 themes/twentysixteen/genericons/genericons.css create mode 100644 themes/twentysixteen/img/avatar.png create mode 100644 themes/twentysixteen/js/functions.js create mode 100644 themes/twentysixteen/js/html5.js create mode 100644 themes/twentysixteen/js/jquery-migrate.js create mode 100644 themes/twentysixteen/js/jquery.js create mode 100644 themes/twentysixteen/js/skip-link-focus-fix.js create mode 100644 themes/twentysixteen/layout.html.php create mode 100644 themes/twentysixteen/main.html.php create mode 100644 themes/twentysixteen/no-posts.html.php create mode 100644 themes/twentysixteen/post.html.php create mode 100644 themes/twentysixteen/profile.html.php create mode 100644 themes/twentysixteen/static.html.php diff --git a/cache/installedVersion.json b/cache/installedVersion.json index 4bec5dd..53efec0 100644 --- a/cache/installedVersion.json +++ b/cache/installedVersion.json @@ -1,4 +1,4 @@ { "id": 782014, - "tag_name": "v2.6.9" + "tag_name": "v2.7.0" } diff --git a/config/config.ini.example b/config/config.ini.example index 5e1130b..d3d8f0f 100644 --- a/config/config.ini.example +++ b/config/config.ini.example @@ -67,6 +67,7 @@ tag.perpage = "10" archive.perpage = "10" search.perpage = "10" profile.perpage = "10" +type.perpage = "10" json.count = "10" ; Category info @@ -87,6 +88,9 @@ author.info = "true" ; Teaser type: set "trimmed" or "full". teaser.type = "trimmed" +; Read more link text for "full" teaser type +read.more = "Read more" + ; Teaser character count teaser.char = "200" @@ -116,6 +120,7 @@ sitemap.priority.archiveDay = "0.5" sitemap.priority.archiveMonth = "0.5" sitemap.priority.archiveYear = "0.5" sitemap.priority.author = "0.5" +sitemap.priority.type = "0.5" ; Also install pre-release prerelease = "false" @@ -133,7 +138,7 @@ generation.time = "false" cache.timestamp = "false" ; Set the theme here -views.root = "themes/blog" +views.root = "themes/twentysixteen" ; Framework config. No need to edit. views.layout = "layout" diff --git a/system/admin/admin.php b/system/admin/admin.php index ebc888a..c97c5fe 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -136,7 +136,7 @@ function add_content($title, $tag, $url, $content, $user, $description = null, $ save_tag_i18n($post_tag, $post_tagmd); rebuilt_cache('all'); - clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename, $category); + clear_post_cache($post_date, $post_tag, $post_url, $dir . $filename, $category, $type); if (empty($draft)) { $redirect = site_url() . 'admin/mine'; @@ -281,7 +281,7 @@ function edit_content($title, $tag, $url, $content, $oldfile, $destination = nul save_tag_i18n($post_tag, $post_tagmd); rebuilt_cache('all'); - clear_post_cache($dt, $post_tag, $post_url, $newfile, $category); + clear_post_cache($dt, $post_tag, $post_url, $newfile, $category, $type); if ($destination == 'post') { if(!empty($revertPost)) { $drafturl = site_url() . 'admin/draft'; @@ -553,8 +553,9 @@ function delete_post($file, $destination) // Get cache file $arr = explode('_', $file); $replaced = substr($arr[0], 0, strrpos($arr[0], '/')) . '/'; + $str = explode('/', $replaced); $dt = str_replace($replaced, '', $arr[0]); - clear_post_cache($dt, $arr[1], str_replace('.md', '', $arr[2]), $file, $arr[count($str) - 3]); + clear_post_cache($dt, $arr[1], str_replace('.md', '', $arr[2]), $file, $str[count($str) - 3], $str[count($str) - 2]); if (!empty($deleted_content)) { unlink($deleted_content); @@ -802,7 +803,7 @@ function get_backup_files() } } -function clear_post_cache($post_date, $post_tag, $post_url, $filename, $category) +function clear_post_cache($post_date, $post_tag, $post_url, $filename, $category, $type) { $b = str_replace('/', '#', site_path() . '/'); $c = explode(',', $post_tag); @@ -880,6 +881,15 @@ function clear_post_cache($post_date, $post_tag, $post_url, $filename, $category foreach (glob('cache/page/' . $b . 'category#' . $category . '~*.cache', GLOB_NOSORT) as $file) { unlink($file); } + + // Delete type + $tp = 'cache/page/' . $b . 'type#' . $type . '.cache'; + if (file_exists($tp)) { + unlink($tp); + } + foreach (glob('cache/page/' . $b . 'type#' . $type . '~*.cache', GLOB_NOSORT) as $file) { + unlink($file); + } // Get cache post author $arr = explode('_', $filename); diff --git a/system/htmly.php b/system/htmly.php index 44ec00c..4c65b00 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -1524,6 +1524,75 @@ post('/category/:category/delete', function () { } }); +// Show the type page +get('/type/:type', function ($type) { + + if (isset($_GET['search'])) { + $search = $_GET['search']; + $url = site_url() . 'search/' . remove_accent($search); + header("Location: $url"); + } + + if (!login()) { + file_cache($_SERVER['REQUEST_URI']); + } + + $page = from($_GET, 'page'); + $page = $page ? (int)$page : 1; + $perpage = config('type.perpage'); + + if (empty($perpage)) { + $perpage = 10; + } + + $posts = get_type($type, $page, $perpage); + + $total = get_typecount($type); + + $ttype = new stdClass; + $ttype->title = $type; + + if (empty($posts) || $page < 1) { + // a non-existing page + not_found(); + } + + $vroot = rtrim(config('views.root'), '/'); + + $lt = $vroot . '/layout--type--'. strtolower($type) .'.html.php'; + $ls = $vroot . '/layout--type.html.php'; + if (file_exists($lt)) { + $layout = 'layout--type--' . strtolower($type); + } else if (file_exists($ls)) { + $layout = 'layout--type'; + } else { + $layout = ''; + } + + $pv = $vroot . '/main--type--'. strtolower($type) .'.html.php'; + $ps = $vroot . '/main--type.html.php'; + if (file_exists($pv)) { + $pview = 'main--type--' . strtolower($type); + } else if (file_exists($ps)) { + $pview = 'main--type'; + } else { + $pview = 'main'; + } + + render($pview, array( + 'title' => 'Posts with type: ' . ucfirst($type) . ' - ' . blog_title(), + 'description' => 'All posts with type: ' . ucfirst($type) . ' on ' . blog_title() . '.', + 'canonical' => site_url() . 'type/' . strtolower($type), + 'page' => $page, + 'posts' => $posts, + 'type' => $ttype, + 'bodyclass' => 'intype', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » ' . ucfirst($type), + 'pagination' => has_pagination($total, $perpage, $page), + 'is_type' => true, + ), $layout); +}); + // Show the tag page get('/tag/:tag', function ($tag) { @@ -2144,7 +2213,7 @@ get('/:static', function ($static) { header("Location: $url"); } - if ($static === 'sitemap.xml' || $static === 'sitemap.base.xml' || $static === 'sitemap.post.xml' || $static === 'sitemap.static.xml' || $static === 'sitemap.tag.xml' || $static === 'sitemap.archive.xml' || $static === 'sitemap.author.xml' || $static === 'sitemap.category.xml') { + if ($static === 'sitemap.xml' || $static === 'sitemap.base.xml' || $static === 'sitemap.post.xml' || $static === 'sitemap.static.xml' || $static === 'sitemap.tag.xml' || $static === 'sitemap.archive.xml' || $static === 'sitemap.author.xml' || $static === 'sitemap.category.xml' || $static === 'sitemap.type.xml') { header('Content-Type: text/xml'); @@ -2164,6 +2233,8 @@ get('/:static', function ($static) { generate_sitemap('author'); } elseif ($static === 'sitemap.category.xml') { generate_sitemap('category'); + } elseif ($static === 'sitemap.type.xml') { + generate_sitemap('type'); } die; diff --git a/system/includes/functions.php b/system/includes/functions.php index e32c379..cb0ffe3 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -342,9 +342,14 @@ function get_posts($posts, $page = 1, $perpage = 0) $post->tag = implode(' ', $url); $post->tagb = implode(' » ', $bc); - + $post->related = rtrim($arr[1], ','); - + + $more = explode('', $content); + if (isset($more['1'])) { + $content = $more['0'] . '
' . "\n\n" . '' . $more['1']; + } + // Get the contents and convert it to HTML $post->body = MarkdownExtra::defaultTransform(remove_html_comments($content)); @@ -549,6 +554,71 @@ function default_category() return $tmp[] = $desc; } +// Return category list + +function category_list() { + + $arr = get_category_info(null); + $cat = array(); + $list = array(); + + foreach ($arr as $a) { + $cat[] = array($a->md, $a->title); + } + array_push($cat, array('uncategorized', 'Uncategorized')); + asort($cat); + + echo ''; + +} + +// Return type page. +function get_type($type, $page, $perpage) +{ + $posts = get_post_sorted(); + + $tmp = array(); + + if (empty($perpage)) { + $perpage = 10; + } + + foreach ($posts as $index => $v) { + + $filepath = $v['dirname'] . '/' . $v['basename']; + + // Extract the date + $arr = explode('_', $filepath); + + // Replaced string + $replaced = substr($arr[0], 0, strrpos($arr[0], '/')) . '/'; + + // Author string + $str = explode('/', $replaced); + $tp = $str[count($str) - 2]; + + if (strtolower($type) === strtolower($tp)) { + $tmp[] = $v; + } + } + + if (empty($tmp)) { + not_found(); + } + + $tmp = array_unique($tmp, SORT_REGULAR); + + return $tmp = get_posts($tmp, $page, $perpage); +} + // Return tag page. function get_tag($tag, $page, $perpage, $random) { @@ -910,7 +980,7 @@ function get_count($var, $str) return count($tmp); } -// Return tag count. Matching $var and $str provided. +// Return category count. Matching $var and $str provided. function get_categorycount($var) { $posts = get_post_sorted(); @@ -938,7 +1008,36 @@ function get_categorycount($var) return count($tmp); } -// Return tag count. Matching $var and $str provided. +// Return type count. Matching $var and $str provided. +function get_typecount($var) +{ + $posts = get_post_sorted(); + + $tmp = array(); + + foreach ($posts as $index => $v) { + + $filepath = $v['dirname'] . '/' . $v['basename']; + + // Extract the date + $arr = explode('_', $filepath); + + // Replaced string + $replaced = substr($arr[0], 0, strrpos($arr[0], '/')) . '/'; + + // Author string + $str = explode('/', $replaced); + $tp = '/' . $str[count($str) - 2] . '/'; + if (stripos($tp, "$var") !== false) { + $tmp[] = $v; + } + } + + return count($tmp); +} + + +// Return draft count. Matching $var and $str provided. function get_draftcount($var) { $posts = get_draft_posts(); @@ -1058,6 +1157,53 @@ function recent_posts($custom = null, $count = null) } } +// Return recent posts lists +function recent_type($type, $custom = null, $count = null) +{ + if (empty($count)) { + $count = config('recent.count'); + if (empty($count)) { + $count = 5; + } + } + + $dir = 'cache/widget'; + $filename = 'cache/widget/recent.' . $type . '.cache'; + $tmp = array(); + $posts = array(); + + if (is_dir($dir) === false) { + mkdir($dir, 0775, true); + } + + if (file_exists($filename)) { + $posts = unserialize(file_get_contents($filename)); + if (count($posts) != $count) { + $posts = get_type($type, 1, $count); + $tmp = serialize($posts); + file_put_contents($filename, print_r($tmp, true)); + } + } else { + $posts = get_type($type, 1, $count); + $tmp = serialize($posts); + file_put_contents($filename, print_r($tmp, true)); + } + + if (!empty($custom)) { + return $posts; + } else { + + echo ''; + } +} + // Return popular posts lists function popular_posts($custom = null, $count = null) { @@ -1487,9 +1633,15 @@ function get_description($string, $char = null) } // Get the teaser -function get_teaser($string, $char = null) +function get_teaser($string, $url = null, $char = null) { + $teaserType = config('teaser.type'); + $more = config('read.more'); + + if(empty($more)) { + $more = 'Read more'; + } if(empty($char)) { $char = config('teaser.char'); @@ -1499,7 +1651,14 @@ function get_teaser($string, $char = null) } if ($teaserType === 'full') { - echo $string; + $readMore = explode('', $string); + if (isset($readMore['1'])) { + $patterns = array('
', '


'); + $string = str_replace($patterns, '', $readMore['0']); + return $string . ''; + } else { + return $string; + } } elseif (strlen(strip_tags($string)) < $char) { $string = preg_replace('/\s\s+/', ' ', strip_tags($string)); $string = ltrim(rtrim($string)); @@ -1846,7 +2005,7 @@ function get_menu($custom) if (!empty($posts)) { - krsort($posts); + asort($posts); echo '