From db786347c675e7814187159dbdd8211371579e5f Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Sun, 5 Jul 2015 21:29:02 +0700 Subject: [PATCH] Improvements Styling, performance tweak, and bugs fixes. --- system/admin/admin.php | 36 +++++++++++++++++++++++++++-------- system/admin/views/add-post.html.php | 4 ++-- system/admin/views/edit-post.html.php | 4 ++-- system/admin/views/update.html.php | 19 ++++++++++++++++++ system/htmly.php | 22 ++++++++++++++++++--- system/includes/functions.php | 21 +++++--------------- themes/clean/css/style.css | 20 +++++++++++++++++++ themes/clean/main.html.php | 22 ++++++++++----------- themes/clean/post.html.php | 22 ++++++++++----------- themes/default/css/style.css | 20 +++++++++++++++++++ themes/default/layout.html.php | 2 +- themes/default/main.html.php | 22 ++++++++++----------- themes/default/post.html.php | 22 ++++++++++----------- themes/logs/css/style.css | 20 +++++++++++++++++++ themes/logs/layout.html.php | 4 +--- themes/logs/main.html.php | 22 ++++++++++----------- themes/logs/post.html.php | 22 ++++++++++----------- 17 files changed, 197 insertions(+), 107 deletions(-) create mode 100644 system/admin/views/update.html.php diff --git a/system/admin/admin.php b/system/admin/admin.php index 4e037da..7e61521 100644 --- a/system/admin/admin.php +++ b/system/admin/admin.php @@ -86,7 +86,7 @@ function remove_accent($str) } // Edit blog posts -function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $fi, $vid) +function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, $description = null, $date = null, $img, $vid) { $oldurl = explode('_', $oldfile); if ($date !== null) { @@ -94,17 +94,27 @@ function edit_post($title, $tag, $url, $content, $oldfile, $destination = null, } $post_title = $title; - $post_fi = $fi; + $post_img = $img; $post_vid = str_replace(array("http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"), "", $vid); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } - $post_content = '' . $post_description . "\n\n" . $content; - $post_content = '' . "\n\n" . '' . "\n\n" . $post_content; + if ($img !== null) { + $post_img = "\n"; + } else { + $post_img = ""; + } + if ($vid !== null) { + $post_vid = "\n"; + } else { + $post_vid = ""; + } + $post_content = '' . $post_description . $post_img . $post_vid ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { if (get_magic_quotes_gpc()) { @@ -182,22 +192,32 @@ function edit_page($title, $url, $content, $oldfile, $destination = null, $descr } // Add blog post -function add_post($title, $tag, $url, $content, $user, $description = null, $fi, $vid) +function add_post($title, $tag, $url, $content, $user, $description = null, $img, $vid) { $post_date = date('Y-m-d-H-i-s'); $post_title = $title; - $post_fi = $fi; + $post_img = $img; $post_vid = str_replace(array("http://", "https://", "www.", "youtube", ".com", "/watch?v=", "/embed/"), "", $vid); $post_tag = preg_replace(array('/[^a-zA-Z0-9,.\-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($tag)); + $post_tag = rtrim($post_tag, ','); $post_url = strtolower(preg_replace(array('/[^a-zA-Z0-9 \-\p{L}]/u', '/[ -]+/', '/^-|-$/'), array('', '-', ''), remove_accent($url))); if ($description !== null) { $post_description = "\n"; } else { $post_description = ""; } - $post_content = '' . $post_description . "\n\n" . $content; - $post_content = '' . "\n\n" . '' . "\n\n" . $post_content; + if ($img !== null) { + $post_img = "\n"; + } else { + $post_img = ""; + } + if ($vid !== null) { + $post_vid = "\n"; + } else { + $post_vid = ""; + } + $post_content = '' . $post_description . $post_img . $post_vid ."\n\n" . $content; if (!empty($post_title) && !empty($post_tag) && !empty($post_url) && !empty($post_content)) { if (get_magic_quotes_gpc()) { diff --git a/system/admin/views/add-post.html.php b/system/admin/views/add-post.html.php index c99142f..c666f47 100644 --- a/system/admin/views/add-post.html.php +++ b/system/admin/views/add-post.html.php @@ -29,8 +29,8 @@ echo $p->description; } ?>

- Featured Image (optional)


Embed Youtube Video (optional)


+ Featured Image (optional)


Embed Youtube Video (optional)


diff --git a/system/admin/views/update.html.php b/system/admin/views/update.html.php new file mode 100644 index 0000000..8365368 --- /dev/null +++ b/system/admin/views/update.html.php @@ -0,0 +1,19 @@ + 'danpros/htmly', + 'prerelease' => !!config("prerelease"), +)); + +if ($updater->able()) { + $info = $updater->getNewestInfo(); + echo '

Update Available

'; + echo '

Update to ' . $info['tag_name'] . '

'; +} else { + echo '

No Available Update

'; + echo '

You are using the latest HTMLy version.

'; +} \ No newline at end of file diff --git a/system/htmly.php b/system/htmly.php index 2b79512..9d64434 100644 --- a/system/htmly.php +++ b/system/htmly.php @@ -333,7 +333,7 @@ post('/:year/:month/:name/edit', function () { $proper = is_csrf_proper(from($_REQUEST, 'csrf_token')); $title = from($_REQUEST, 'title'); - $fi = from($_REQUEST, 'fi'); + $img = from($_REQUEST, 'img'); $vid = from($_REQUEST, 'vid'); $tag = from($_REQUEST, 'tag'); $url = from($_REQUEST, 'url'); @@ -352,7 +352,7 @@ post('/:year/:month/:name/edit', function () { if (empty($url)) { $url = $title; } - edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $fi, $vid); + edit_post($title, $tag, $url, $content, $oldfile, $destination, $description, $dateTime, $img, $vid); } else { $message['error'] = ''; if (empty($title)) { @@ -374,7 +374,7 @@ post('/:year/:month/:name/edit', function () { 'error' => '', 'oldfile' => $oldfile, 'postTitle' => $title, - 'postFi' => $fi, + 'postImg' => $img, 'postVid' => $vid, 'postTag' => $tag, 'postUrl' => $url, @@ -1292,6 +1292,22 @@ get('/feed/opml', function () { echo generate_opml(); }); +// Update page +get('/admin/update', function () { + if (login()) { + config('views.root', 'system/admin/views'); + render('update', array( + 'head_contents' => head_contents('Check for Update - ' . blog_title(), blog_description(), site_url()), + 'bodyclass' => 'updatepage', + 'breadcrumb' => '' . config('breadcrumb.home') . ' » Update HTMLy' + )); + } else { + $login = site_url() . 'login'; + header("location: $login"); + } + die; +}); + get('/admin/update/now/:csrf', function ($CSRF) { $proper = is_csrf_proper($CSRF); diff --git a/system/includes/functions.php b/system/includes/functions.php index 1e57b3b..63d7357 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -4,7 +4,6 @@ use \Michelf\MarkdownExtra; use \Suin\RSSWriter\Feed; use \Suin\RSSWriter\Channel; use \Suin\RSSWriter\Item; -use \Kanti\HubUpdater; // Get blog post path. Unsorted. Mostly used on widget. function get_post_unsorted() @@ -223,7 +222,7 @@ function get_posts($posts, $page = 1, $perpage = 0) $url = array(); $bc = array(); - $t = explode(',', $arr[1]); + $t = explode(',', rtrim($arr[1], ',')); foreach ($t as $tt) { $tag[] = array($tt, site_url() . 'tag/' . $tt); } @@ -243,7 +242,7 @@ function get_posts($posts, $page = 1, $perpage = 0) // Extract the title and body $post->title = get_content_tag('t', $content, 'Untitled: ' . date('l jS \of F Y', $post->date)); - $post->feature = get_content_tag('fi', $content); + $post->image = get_content_tag('img', $content); $post->video = get_content_tag('vid', $content); // Get the contents and convert it to HTML @@ -319,7 +318,7 @@ function get_tag($tag, $page, $perpage, $random) foreach ($posts as $index => $v) { $url = $v['filename']; $str = explode('_', $url); - $mtag = explode(',', $str[1]); + $mtag = explode(',', rtrim($str[1], ',')); $etag = explode(',', $tag); foreach ($mtag as $t) { foreach ($etag as $e) { @@ -727,7 +726,7 @@ function tag_cloud() $arr = explode('_', $v); - $data = $arr[1]; + $data = rtrim($arr[1], ','); $mtag = explode(',', $data); foreach ($mtag as $etag) { $tags[] = $etag; @@ -1646,13 +1645,6 @@ function toolbar() $role = user('role', $user); $base = site_url(); - $CSRF = get_csrf(); - - $updater = new HubUpdater(array( - 'name' => 'danpros/htmly', - 'prerelease' => !!config("prerelease"), - )); - echo << EOF; @@ -1669,10 +1661,7 @@ EOF; echo '
  • Backup
  • '; echo '
  • Config
  • '; echo '
  • Clear cache
  • '; - if ($updater->able()) { - $info = $updater->getNewestInfo(); - echo '
  • Update to ' . $info['tag_name'] . '
  • '; - } + echo '
  • Update
  • '; echo '
  • Logout
  • '; echo ''; diff --git a/themes/clean/css/style.css b/themes/clean/css/style.css index 7169e31..f1e0f6f 100644 --- a/themes/clean/css/style.css +++ b/themes/clean/css/style.css @@ -866,6 +866,26 @@ aside .copyright p { } +@media all and (max-width: 560px) { + + .featured-video { + position: relative; + padding-bottom: 56.25%; + padding-top: 30px; + height: 0; + overflow: hidden; + } + + .featured-video iframe, .featured-video object, .featured-video embed { + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + } + +} + /*---------------------------- Archive -----------------------------*/ diff --git a/themes/clean/main.html.php b/themes/clean/main.html.php index 9d92260..4be75d4 100644 --- a/themes/clean/main.html.php +++ b/themes/clean/main.html.php @@ -19,18 +19,6 @@ $len = count($posts); ?>

    title ?>

    - feature)) { ?> - - - video)) { ?> - - - Posted in tag ?> by @@ -41,6 +29,16 @@ $len = count($posts); ?> href=url ?>> Comments
    + image)) { ?> + + + video)) { ?> + +
    body) ?> body, $p->url) ?> diff --git a/themes/clean/post.html.php b/themes/clean/post.html.php index 7db2cfb..9727daa 100644 --- a/themes/clean/post.html.php +++ b/themes/clean/post.html.php @@ -10,18 +10,6 @@

    title ?>

    - feature)) { ?> - - - video)) { ?> - - - Posted in @@ -29,6 +17,16 @@ - Permalink
    + image)) { ?> + + + video)) { ?> + +
    body; ?>
    diff --git a/themes/default/css/style.css b/themes/default/css/style.css index f22ba8b..488106e 100644 --- a/themes/default/css/style.css +++ b/themes/default/css/style.css @@ -953,6 +953,26 @@ h1.title-post a:hover, h2.title-index a:hover { } +@media all and (max-width: 560px) { + + .featured-video { + position: relative; + padding-bottom: 56.25%; + padding-top: 30px; + height: 0; + overflow: hidden; + } + + .featured-video iframe, .featured-video object, .featured-video embed { + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; + } + +} + /*---------------------------- Archive -----------------------------*/ diff --git a/themes/default/layout.html.php b/themes/default/layout.html.php index 385ced8..7b222ef 100644 --- a/themes/default/layout.html.php +++ b/themes/default/layout.html.php @@ -3,7 +3,7 @@ - +