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>
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>
@ -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


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

@ -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('</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) {
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 . '...' . ' <a class="readmore" href="' . $url . '#more">more</a>' ;
echo '<p>' . $body . '</p>';
}
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 . '...' . ' <a class="readmore" href="' . $url . '#more">more</a>' ;
echo '<p>' . $body . '</p>';
@ -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 '<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');
$fetch = explode("embed/", $vidSource);
$fetch = explode("embed/", $vidSource);
if(isset($fetch[1])) {
$vidThumb = '//img.youtube.com/vi/' . $fetch[1] . '/default.jpg';
return '<div class="thumbnail" style="background-image:url(' . $vidThumb . ');"></div>';
}
}
}
else {
if (!empty($default)) {
return '<div class="thumbnail" style="background-image:url(' . $default . ');"></div>';
}
}
}
}
// 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


+ 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" />
<title>Search results not found! - <?php echo config('blog.title') ?></title>
<link href="<?php echo site_url() ?>themes/default/css/style.css" rel="stylesheet" />
<!-- Include the Open Sans font -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" />
</head>
<body>
<div class="center message">
<h1>Search results not found!</h1>
<div class="search">
@ -25,6 +22,5 @@
</div>
<p>Please search again, or would you like to try our <a href="<?php echo site_url() ?>">homepage</a> instead?</p>
</div>
</body>
</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" />
<title>404 Not Found - <?php echo config('blog.title') ?></title>
<link href="<?php echo site_url() ?>themes/default/css/style.css" rel="stylesheet" />
<!-- Include the Open Sans font -->
<link href="http://fonts.googleapis.com/css?family=Open+Sans+Condensed:700&subset=latin,cyrillic-ext" rel="stylesheet" />
</head>
<body>
<div class="center message">
<h1>This page doesn't exist!</h1>
<p>Would you like to try our <a href="<?php echo site_url() ?>">homepage</a> instead?</p>
</div>
</body>
</html>

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

@ -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;


+ 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="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;?>
<!--[if lt IE 9]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
@ -43,4 +42,4 @@
</section>
<?php if (analytics() == true):?><?php echo analytics() ?><?php endif;?>
</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;?>
<div class="post" itemprop="blogPost" itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<div class="main">
<div class="main">
<?php if ($type == 'blogpost'):?>
<a name="more"></a>
<?php endif;?>
@ -27,7 +27,7 @@
</div>
</div>
<?php endif;?>
<div class="comments border">
<div class="comments border">
<?php if ($type == 'blogpost'):?>
<?php if (disqus(null, null) == true):?>
<div id="disqus_thread"></div>


Loading…
Cancel
Save