Browse Source

Search form + perfomance

Improve search form + perfomance.
pull/9/head
Danang Probo Sayekti 12 years ago
parent
commit
f51f27d4d9
6 changed files with 28 additions and 33 deletions
  1. +23
    -12
      system/includes/functions.php
  2. +1
    -5
      themes/clean/404-search.html.php
  3. +1
    -5
      themes/clean/layout.html.php
  4. +1
    -5
      themes/default/404-search.html.php
  5. +1
    -1
      themes/default/css/style.css
  6. +1
    -5
      themes/default/layout.html.php

+ 23
- 12
system/includes/functions.php View File

@ -510,12 +510,9 @@ function get_bio($names, $author){
foreach($names as $index => $v){ foreach($names as $index => $v){
$post = new stdClass; $post = new stdClass;
// Extract the array
$arr = explode('_', $v);
// Replaced string // Replaced string
$replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/';
$replaced = substr($v, 0,strrpos($v, '/')) . '/';
// Author string // Author string
$str = explode('/', $replaced); $str = explode('/', $replaced);
@ -523,7 +520,7 @@ function get_bio($names, $author){
if($author === $profile){ if($author === $profile){
// Profile URL // Profile URL
$url = str_replace($replaced,'',$arr[0]);
$url = str_replace($replaced,'',$v);
$post->url = site_url() . 'author/' . $profile; $post->url = site_url() . 'author/' . $profile;
// Get the contents and convert it to HTML // Get the contents and convert it to HTML
@ -849,7 +846,21 @@ function menu(){
} }
} }
// Auto generated menu from static page
// Menu
function search() {
echo <<<EOF
<form id="search-form" method="get">
<input type="text" class="search-input" name="search" value="Search" onfocus="if (this.value == 'Search') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search';}">
<input type="submit" value="Search" class="search-button">
</form>
EOF;
if(isset($_GET['search'])) {
$url = site_url() . 'search/' . $_GET['search'];
header ("Location: $url");
}
}
// Auto generate menu from static page
function get_menu() { function get_menu() {
$posts = get_spage_names(); $posts = get_spage_names();
@ -859,13 +870,13 @@ function get_menu() {
echo '<li><a href="' . site_url() . '">Home</a></li>'; echo '<li><a href="' . site_url() . '">Home</a></li>';
foreach($posts as $index => $v){ foreach($posts as $index => $v){
// Replaced string
$replaced = substr($v, 0, strrpos($v, '/')) . '/';
// Replaced string
$replaced = substr($v, 0, strrpos($v, '/')) . '/';
// The static page URL
$title = str_replace($replaced,'',$v);
$url = site_url() . str_replace('.md','',$title);
echo '<li><a href="' . $url . '">' . ucfirst(str_replace('.md','',$title)) . '</a></li>';
// The static page URL
$title = str_replace($replaced,'',$v);
$url = site_url() . str_replace('.md','',$title);
echo '<li><a href="' . $url . '">' . ucfirst(str_replace('.md','',$title)) . '</a></li>';
} }
echo '</ul>'; echo '</ul>';


+ 1
- 5
themes/clean/404-search.html.php View File

@ -14,11 +14,7 @@
<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">
<form id="search-form" method="get">
<input type="text" class="search-input" name="search" value="Search..." onfocus="if (this.value == 'Search...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search...';}">
<input type="submit" value="Search" class="search-button">
</form>
<?php if(isset($_GET['search'])) {$url = site_url() . 'search/' . $_GET['search']; header ("Location: $url");} ?>
<?php echo search() ?>
</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>


+ 1
- 5
themes/clean/layout.html.php View File

@ -25,11 +25,7 @@
<h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo config('blog.title') ?></a></h1> <h1 class="blog-title"><a href="<?php echo site_url() ?>"><?php echo config('blog.title') ?></a></h1>
<div class="description"><p><?php echo config('blog.description')?></p></div> <div class="description"><p><?php echo config('blog.description')?></p></div>
<div class="search"> <div class="search">
<form id="search-form" method="get">
<input type="text" class="search-input" name="search" value="Search..." onfocus="if (this.value == 'Search...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search...';}">
<input type="submit" value="Search" class="search-button">
</form>
<?php if(isset($_GET['search'])) {$url = site_url() . 'search/' . $_GET['search']; header ("Location: $url");} ?>
<?php echo search() ?>
</div> </div>
<div class="social"><?php echo social() ?></div> <div class="social"><?php echo social() ?></div>
<div class="menu"><?php echo menu() ?></div> <div class="menu"><?php echo menu() ?></div>


+ 1
- 5
themes/default/404-search.html.php View File

@ -14,11 +14,7 @@
<div class="center message"> <div class="center message">
<h1>Search results not found!</h1> <h1>Search results not found!</h1>
<div class="search-404"> <div class="search-404">
<form id="search-form-404" method="get">
<input type="text" class="search-input" name="search" value="Search..." onfocus="if (this.value == 'Search...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search...';}">
<input type="submit" value="Search" class="search-button">
</form>
<?php if(isset($_GET['search'])) {$url = site_url() . 'search/' . $_GET['search']; header ("Location: $url");} ?>
<?php echo search() ?>
</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>


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

@ -596,7 +596,7 @@ h1.title-post a:hover, h2.title-index a:hover {
margin-bottom: 1.2em; margin-bottom: 1.2em;
} }
#search-form-404 {
.search-404 #search-form {
float:none; float:none;
} }


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

@ -26,11 +26,7 @@
<div class="container"> <div class="container">
<nav id="menu"> <nav id="menu">
<?php echo menu() ?> <?php echo menu() ?>
<form id="search-form" method="get">
<input type="text" class="search-input" name="search" value="Search..." onfocus="if (this.value == 'Search...') {this.value = '';}" onblur="if (this.value == '') {this.value = 'Search...';}">
<input type="submit" value="Search" class="search-button">
</form>
<?php if(isset($_GET['search'])) {$url = site_url() . 'search/' . $_GET['search']; header ("Location: $url");} ?>
<?php echo search() ?>
</nav> </nav>
</div> </div>
</div> </div>


Loading…
Cancel
Save