From 3d905e56388940c12dd6538cb24c7fb7a1582142 Mon Sep 17 00:00:00 2001 From: Danang Probo Sayekti Date: Thu, 9 Jan 2014 09:52:37 +0700 Subject: [PATCH] Various minor changes Various minor changes for better code readability. --- .htaccess | 80 ++++++++++++++++++++------------------ system/includes/functions.php | 54 ++++++++++++------------- themes/default/404-search.html.php | 4 -- themes/default/404.html.php | 4 -- themes/default/css/style.css | 3 +- themes/default/layout.html.php | 3 +- themes/default/post.html.php | 4 +- 7 files changed, 75 insertions(+), 77 deletions(-) diff --git a/.htaccess b/.htaccess index 29a659a..60f30d1 100644 --- a/.htaccess +++ b/.htaccess @@ -1,52 +1,54 @@ -# Requires mod_expires to be enabled. +# Requires mod_expires to be enabled. Uncomment to enable mod_expires. - ExpiresActive on - ExpiresDefault "access plus 1 month" + # Uncomment below to activate mode_expires + # ExpiresActive on + + # ExpiresDefault "access plus 1 month" - # CSS - ExpiresByType text/css "access plus 1 year" + # For CSS uncomment below + # ExpiresByType text/css "access plus 1 year" - # Data interchange - ExpiresByType application/json "access plus 0 seconds" - ExpiresByType application/xml "access plus 0 seconds" - ExpiresByType text/xml "access plus 0 seconds" + # For Data interchange uncomment below + # ExpiresByType application/json "access plus 0 seconds" + # ExpiresByType application/xml "access plus 0 seconds" + # ExpiresByType text/xml "access plus 0 seconds" - # Favicon (cannot be renamed!) - ExpiresByType image/x-icon "access plus 1 week" + # For Favicon uncomment below + # ExpiresByType image/x-icon "access plus 1 week" - # HTML components (HTCs) - ExpiresByType text/x-component "access plus 1 month" + # For HTML components (HTCs) uncomment below + # ExpiresByType text/x-component "access plus 1 month" - # HTML - ExpiresByType text/html "access plus 0 seconds" + # For HTML uncomment below + # ExpiresByType text/html "access plus 0 seconds" - # JavaScript - ExpiresByType application/javascript "access plus 1 year" + # For JavaScript uncomment below + # ExpiresByType application/javascript "access plus 1 year" - # Manifest files - ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" - ExpiresByType text/cache-manifest "access plus 0 seconds" + # For Manifest files uncomment below + # ExpiresByType application/x-web-app-manifest+json "access plus 0 seconds" + # ExpiresByType text/cache-manifest "access plus 0 seconds" - # Media - ExpiresByType audio/ogg "access plus 1 month" - ExpiresByType image/gif "access plus 1 month" - ExpiresByType image/jpeg "access plus 1 month" - ExpiresByType image/png "access plus 1 month" - ExpiresByType video/mp4 "access plus 1 month" - ExpiresByType video/ogg "access plus 1 month" - ExpiresByType video/webm "access plus 1 month" + # For Media uncomment below + # ExpiresByType audio/ogg "access plus 1 month" + # ExpiresByType image/gif "access plus 1 month" + # ExpiresByType image/jpeg "access plus 1 month" + # ExpiresByType image/png "access plus 1 month" + # ExpiresByType video/mp4 "access plus 1 month" + # ExpiresByType video/ogg "access plus 1 month" + # ExpiresByType video/webm "access plus 1 month" - # Web feeds - ExpiresByType application/atom+xml "access plus 1 hour" - ExpiresByType application/rss+xml "access plus 1 hour" + # For Web feeds uncomment below + # ExpiresByType application/atom+xml "access plus 1 hour" + # ExpiresByType application/rss+xml "access plus 1 hour" - # Web fonts - ExpiresByType application/font-woff "access plus 1 month" - ExpiresByType application/vnd.ms-fontobject "access plus 1 month" - ExpiresByType application/x-font-ttf "access plus 1 month" - ExpiresByType font/opentype "access plus 1 month" - ExpiresByType image/svg+xml "access plus 1 month" + # For Web fonts + # ExpiresByType application/font-woff "access plus 1 month" + # ExpiresByType application/vnd.ms-fontobject "access plus 1 month" + # ExpiresByType application/x-font-ttf "access plus 1 month" + # ExpiresByType font/opentype "access plus 1 month" + # ExpiresByType image/svg+xml "access plus 1 month" @@ -63,6 +65,10 @@ # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] # RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301] +# If your site is running in a VirtualDocumentRoot at http://example.com/, +# uncomment the following line: +# RewriteBase / + # Pass all requests not referring directly to files in the filesystem to index.php. RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d diff --git a/system/includes/functions.php b/system/includes/functions.php index fbaa1ad..66c9546 100644 --- a/system/includes/functions.php +++ b/system/includes/functions.php @@ -15,8 +15,7 @@ function get_post_names(){ if(empty($_cache)){ - // Get the names of all the - // posts (newest first): + // Get the names of all the posts $_cache = glob('content/*/blog/*.md', GLOB_NOSORT); } @@ -73,7 +72,7 @@ function get_posts($posts, $page = 1, $perpage = 0){ // Create a new instance of the markdown parser $md = new MarkdownParser(); - foreach($posts as $k=>$v){ + foreach($posts as $index => $v){ $post = new stdClass; @@ -128,10 +127,10 @@ function get_posts($posts, $page = 1, $perpage = 0){ } else { - // Extract a specific page with results - $tmp = array_slice($posts, ($page-1) * $perpage, $perpage); + // Extract a specific page with results + $tmp = array_slice($posts, ($page-1) * $perpage, $perpage); - return $tmp; + return $tmp; } } @@ -543,7 +542,6 @@ function get_bio($names, $author){ } } - krsort($tmp); return $tmp; } @@ -660,13 +658,15 @@ function has_pagination($total, $perpage, $page = 1){ function get_description($text) { $string = explode('

', $text); - $string = preg_replace('/[^,;a-zA-Z0-9_.-]|[,;]$/s', ' ', strip_tags($string[0] . '

')); + $string = preg_replace('/[^A-Za-z0-9 !@#$%^&*(),.-]/u', ' ', strip_tags($string[0] . '

')); + $string = ltrim($string); if (strlen($string) > 1) { return $string; } else { - $string = preg_replace('/[^,;a-zA-Z0-9_.-]|[,;]$/s', ' ', strip_tags($text)); + $string = preg_replace('/[^A-Za-z0-9 !@#$%^&*(),.-]/u', ' ', strip_tags($text)); + $string = ltrim($string); if (strlen($string) < config('description.char')) { return $string; } @@ -681,12 +681,12 @@ function get_description($text) { function get_teaser($text, $url) { if (strlen(strip_tags($text)) < config('teaser.char')) { - $string = preg_replace('/[^,;a-zA-Z0-9_.-]|[,;]$/s', ' ', strip_tags($text)); + $string = preg_replace('/\s\s+/', ' ', strip_tags($text)); $body = $string . '...' . ' more' ; echo '

' . $body . '

'; } else { - $string = preg_replace('/[^,;a-zA-Z0-9_.-]|[,;]$/s', ' ', strip_tags($text)); + $string = preg_replace('/\s\s+/', ' ', strip_tags($text)); $string = substr($string, 0, strpos($string, ' ', config('teaser.char'))); $body = $string . '...' . ' more' ; echo '

' . $body . '

'; @@ -698,38 +698,38 @@ function get_teaser($text, $url) { function get_thumbnail($text) { $default = config('default.thumbnail'); - $dom = new DOMDocument(); - $dom->loadHtml($text); - $imgTags = $dom->getElementsByTagName('img'); + $dom = new DOMDocument(); + $dom->loadHtml($text); + $imgTags = $dom->getElementsByTagName('img'); $vidTags = $dom->getElementsByTagName('iframe'); - if ($imgTags->length > 0) { - $imgElement = $imgTags->item(0); + if ($imgTags->length > 0) { + $imgElement = $imgTags->item(0); $imgSource = $imgElement->getAttribute('src'); - return '
'; - } - elseif ($vidTags->length > 0) { - $vidElement = $vidTags->item(0); + return '
'; + } + elseif ($vidTags->length > 0) { + $vidElement = $vidTags->item(0); $vidSource = $vidElement->getAttribute('src'); - $fetch = explode("embed/", $vidSource); + $fetch = explode("embed/", $vidSource); if(isset($fetch[1])) { $vidThumb = '//img.youtube.com/vi/' . $fetch[1] . '/default.jpg'; return '
'; } - } + } else { if (!empty($default)) { return '
'; } - } + } } // Use base64 encode image to speed up page load time. function base64_encode_image($filename=string,$filetype=string) { - if ($filename) { - $imgbinary = fread(fopen($filename, "r"), filesize($filename)); - return 'data:image/' . $filetype . ';base64,' . base64_encode($imgbinary); - } + if ($filename) { + $imgbinary = fread(fopen($filename, "r"), filesize($filename)); + return 'data:image/' . $filetype . ';base64,' . base64_encode($imgbinary); + } } // Social links diff --git a/themes/default/404-search.html.php b/themes/default/404-search.html.php index ef06950..ceab6f6 100644 --- a/themes/default/404-search.html.php +++ b/themes/default/404-search.html.php @@ -7,13 +7,10 @@ Search results not found! - <?php echo config('blog.title') ?> - - -

Search results not found!

Please search again, or would you like to try our homepage instead?

- \ No newline at end of file diff --git a/themes/default/404.html.php b/themes/default/404.html.php index c2837f5..664a3db 100644 --- a/themes/default/404.html.php +++ b/themes/default/404.html.php @@ -7,17 +7,13 @@ 404 Not Found - <?php echo config('blog.title') ?> - - -

This page doesn't exist!

Would you like to try our homepage instead?

- \ No newline at end of file diff --git a/themes/default/css/style.css b/themes/default/css/style.css index 6387f46..3084728 100644 --- a/themes/default/css/style.css +++ b/themes/default/css/style.css @@ -583,7 +583,8 @@ aside .copyright p{ display: inline-block; width: 18px; height: 18px; - margin: 2px; + margin: 0; + padding: 0 5px; vertical-align: middle; -o-transition: all .3s; -moz-transition: all .3s; diff --git a/themes/default/layout.html.php b/themes/default/layout.html.php index b098414..ce3fda2 100644 --- a/themes/default/layout.html.php +++ b/themes/default/layout.html.php @@ -12,7 +12,6 @@ - @@ -43,4 +42,4 @@ - + \ No newline at end of file diff --git a/themes/default/post.html.php b/themes/default/post.html.php index 3ea1b82..7223f09 100644 --- a/themes/default/post.html.php +++ b/themes/default/post.html.php @@ -1,6 +1,6 @@
-
+
@@ -27,7 +27,7 @@
-
+