Browse Source

Various minor changes

Various minor changes for better code readability.
pull/9/head
Danang Probo Sayekti 12 years ago
parent
commit
3d905e5638
7 changed files with 75 additions and 77 deletions
  1. +43
    -37
      .htaccess
  2. +27
    -27
      system/includes/functions.php
  3. +0
    -4
      themes/default/404-search.html.php
  4. +0
    -4
      themes/default/404.html.php
  5. +2
    -1
      themes/default/css/style.css
  6. +1
    -2
      themes/default/layout.html.php
  7. +2
    -2
      themes/default/post.html.php

+ 43
- 37
.htaccess View File

@ -1,52 +1,54 @@
# Requires mod_expires to be enabled.
# Requires mod_expires to be enabled. Uncomment to enable mod_expires.
<IfModule mod_expires.c> <IfModule mod_expires.c>
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"
</IfModule> </IfModule>
@ -63,6 +65,10 @@
# RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC] # RewriteCond %{HTTP_HOST} ^www\.(.+)$ [NC]
# RewriteRule ^ http://%1%{REQUEST_URI} [L,R=301] # 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. # Pass all requests not referring directly to files in the filesystem to index.php.
RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-d


+ 27
- 27
system/includes/functions.php View File

@ -15,8 +15,7 @@ function get_post_names(){
if(empty($_cache)){ 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); $_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 // Create a new instance of the markdown parser
$md = new MarkdownParser(); $md = new MarkdownParser();
foreach($posts as $k=>$v){
foreach($posts as $index => $v){
$post = new stdClass; $post = new stdClass;
@ -128,10 +127,10 @@ function get_posts($posts, $page = 1, $perpage = 0){
} }
else { 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; return $tmp;
} }
@ -660,13 +658,15 @@ function has_pagination($total, $perpage, $page = 1){
function get_description($text) { function get_description($text) {
$string = explode('</p>', $text); $string = explode('</p>', $text);
$string = preg_replace('/[^,;a-zA-Z0-9_.-]|[,;]$/s', ' ', strip_tags($string[0] . '</p>'));
$string = preg_replace('/[^A-Za-z0-9 !@#$%^&*(),.-]/u', ' ', strip_tags($string[0] . '</p>'));
$string = ltrim($string);
if (strlen($string) > 1) { if (strlen($string) > 1) {
return $string; return $string;
} }
else { 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')) { if (strlen($string) < config('description.char')) {
return $string; return $string;
} }
@ -681,12 +681,12 @@ function get_description($text) {
function get_teaser($text, $url) { function get_teaser($text, $url) {
if (strlen(strip_tags($text)) < config('teaser.char')) { 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 . '...' . ' <a class="readmore" href="' . $url . '#more">more</a>' ; $body = $string . '...' . ' <a class="readmore" href="' . $url . '#more">more</a>' ;
echo '<p>' . $body . '</p>'; echo '<p>' . $body . '</p>';
} }
else { 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'))); $string = substr($string, 0, strpos($string, ' ', config('teaser.char')));
$body = $string . '...' . ' <a class="readmore" href="' . $url . '#more">more</a>' ; $body = $string . '...' . ' <a class="readmore" href="' . $url . '#more">more</a>' ;
echo '<p>' . $body . '</p>'; echo '<p>' . $body . '</p>';
@ -698,38 +698,38 @@ function get_teaser($text, $url) {
function get_thumbnail($text) { function get_thumbnail($text) {
$default = config('default.thumbnail'); $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'); $vidTags = $dom->getElementsByTagName('iframe');
if ($imgTags->length > 0) {
$imgElement = $imgTags->item(0);
if ($imgTags->length > 0) {
$imgElement = $imgTags->item(0);
$imgSource = $imgElement->getAttribute('src'); $imgSource = $imgElement->getAttribute('src');
return '<div class="thumbnail" style="background-image:url(' . $imgSource . ');"></div>';
}
elseif ($vidTags->length > 0) {
$vidElement = $vidTags->item(0);
return '<div class="thumbnail" style="background-image:url(' . $imgSource . ');"></div>';
}
elseif ($vidTags->length > 0) {
$vidElement = $vidTags->item(0);
$vidSource = $vidElement->getAttribute('src'); $vidSource = $vidElement->getAttribute('src');
$fetch = explode("embed/", $vidSource);
$fetch = explode("embed/", $vidSource);
if(isset($fetch[1])) { if(isset($fetch[1])) {
$vidThumb = '//img.youtube.com/vi/' . $fetch[1] . '/default.jpg'; $vidThumb = '//img.youtube.com/vi/' . $fetch[1] . '/default.jpg';
return '<div class="thumbnail" style="background-image:url(' . $vidThumb . ');"></div>'; return '<div class="thumbnail" style="background-image:url(' . $vidThumb . ');"></div>';
} }
}
}
else { else {
if (!empty($default)) { if (!empty($default)) {
return '<div class="thumbnail" style="background-image:url(' . $default . ');"></div>'; return '<div class="thumbnail" style="background-image:url(' . $default . ');"></div>';
} }
}
}
} }
// Use base64 encode image to speed up page load time. // Use base64 encode image to speed up page load time.
function base64_encode_image($filename=string,$filetype=string) { 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 // Social links


+ 0
- 4
themes/default/404-search.html.php View File

@ -7,13 +7,10 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" user-scalable="no" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" user-scalable="no" />
<title>Search results not found! - <?php echo config('blog.title') ?></title> <title>Search results not found! - <?php echo config('blog.title') ?></title>
<link href="<?php echo site_url() ?>themes/default/css/style.css" rel="stylesheet" /> <link href="<?php echo site_url() ?>themes/default/css/style.css" rel="stylesheet" />
<!-- Include the Open Sans font --> <!-- Include the Open Sans font -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" /> <link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" />
</head> </head>
<body> <body>
<div class="center message"> <div class="center message">
<h1>Search results not found!</h1> <h1>Search results not found!</h1>
<div class="search"> <div class="search">
@ -25,6 +22,5 @@
</div> </div>
<p>Please search again, or would you like to try our <a href="<?php echo site_url() ?>">homepage</a> instead?</p> <p>Please search again, or would you like to try our <a href="<?php echo site_url() ?>">homepage</a> instead?</p>
</div> </div>
</body> </body>
</html> </html>

+ 0
- 4
themes/default/404.html.php View File

@ -7,17 +7,13 @@
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" user-scalable="no" /> <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" user-scalable="no" />
<title>404 Not Found - <?php echo config('blog.title') ?></title> <title>404 Not Found - <?php echo config('blog.title') ?></title>
<link href="<?php echo site_url() ?>themes/default/css/style.css" rel="stylesheet" /> <link href="<?php echo site_url() ?>themes/default/css/style.css" rel="stylesheet" />
<!-- Include the Open Sans font --> <!-- Include the Open Sans font -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" /> <link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" />
</head> </head>
<body> <body>
<div class="center message"> <div class="center message">
<h1>This page doesn't exist!</h1> <h1>This page doesn't exist!</h1>
<p>Would you like to try our <a href="<?php echo site_url() ?>">homepage</a> instead?</p> <p>Would you like to try our <a href="<?php echo site_url() ?>">homepage</a> instead?</p>
</div> </div>
</body> </body>
</html> </html>

+ 2
- 1
themes/default/css/style.css View File

@ -583,7 +583,8 @@ aside .copyright p{
display: inline-block; display: inline-block;
width: 18px; width: 18px;
height: 18px; height: 18px;
margin: 2px;
margin: 0;
padding: 0 5px;
vertical-align: middle; vertical-align: middle;
-o-transition: all .3s; -o-transition: all .3s;
-moz-transition: all .3s; -moz-transition: all .3s;


+ 1
- 2
themes/default/layout.html.php View File

@ -12,7 +12,6 @@
<link href="<?php echo site_url() ?>themes/default/css/style.css" rel="stylesheet" /> <link href="<?php echo site_url() ?>themes/default/css/style.css" rel="stylesheet" />
<link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" /> <link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" />
<?php if (publisher() == true):?><link href="<?php echo publisher() ?>" rel="publisher" /><?php endif;?> <?php if (publisher() == true):?><link href="<?php echo publisher() ?>" rel="publisher" /><?php endif;?>
<!--[if lt IE 9]> <!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]--> <![endif]-->
@ -43,4 +42,4 @@
</section> </section>
<?php if (analytics() == true):?><?php echo analytics() ?><?php endif;?> <?php if (analytics() == true):?><?php echo analytics() ?><?php endif;?>
</body> </body>
</html>
</html>

+ 2
- 2
themes/default/post.html.php View File

@ -1,6 +1,6 @@
<?php if (!empty($breadcrumb)):?><div class="breadcrumb" xmlns:v="http://rdf.data-vocabulary.org/#"><?php echo $breadcrumb ?></div><?php endif;?> <?php if (!empty($breadcrumb)):?><div class="breadcrumb" xmlns:v="http://rdf.data-vocabulary.org/#"><?php echo $breadcrumb ?></div><?php endif;?>
<div class="post" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting"> <div class="post" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<div class="main">
<div class="main">
<?php if ($type == 'blogpost'):?> <?php if ($type == 'blogpost'):?>
<a name="more"></a> <a name="more"></a>
<?php endif;?> <?php endif;?>
@ -27,7 +27,7 @@
</div> </div>
</div> </div>
<?php endif;?> <?php endif;?>
<div class="comments border">
<div class="comments border">
<?php if ($type == 'blogpost'):?> <?php if ($type == 'blogpost'):?>
<?php if (disqus(null, null) == true):?> <?php if (disqus(null, null) == true):?>
<div id="disqus_thread"></div> <div id="disqus_thread"></div>


Loading…
Cancel
Save