mirror of
https://github.com/danpros/htmly.git
synced 2026-04-20 12:36:23 +05:30
Search form + perfomance
Improve search form + perfomance.
This commit is contained in:
parent
7deab5e802
commit
f51f27d4d9
6 changed files with 28 additions and 33 deletions
|
|
@ -510,12 +510,9 @@ function get_bio($names, $author){
|
|||
foreach($names as $index => $v){
|
||||
|
||||
$post = new stdClass;
|
||||
|
||||
// Extract the array
|
||||
$arr = explode('_', $v);
|
||||
|
||||
// Replaced string
|
||||
$replaced = substr($arr[0], 0,strrpos($arr[0], '/')) . '/';
|
||||
$replaced = substr($v, 0,strrpos($v, '/')) . '/';
|
||||
|
||||
// Author string
|
||||
$str = explode('/', $replaced);
|
||||
|
|
@ -523,7 +520,7 @@ function get_bio($names, $author){
|
|||
|
||||
if($author === $profile){
|
||||
// Profile URL
|
||||
$url = str_replace($replaced,'',$arr[0]);
|
||||
$url = str_replace($replaced,'',$v);
|
||||
$post->url = site_url() . 'author/' . $profile;
|
||||
|
||||
// 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() {
|
||||
|
||||
$posts = get_spage_names();
|
||||
|
|
@ -859,13 +870,13 @@ function get_menu() {
|
|||
echo '<li><a href="' . site_url() . '">Home</a></li>';
|
||||
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>';
|
||||
|
|
|
|||
|
|
@ -14,11 +14,7 @@
|
|||
<div class="center message">
|
||||
<h1>Search results not found!</h1>
|
||||
<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>
|
||||
<p>Please search again, or would you like to try our <a href="<?php echo site_url() ?>">homepage</a> instead?</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -25,11 +25,7 @@
|
|||
<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="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 class="social"><?php echo social() ?></div>
|
||||
<div class="menu"><?php echo menu() ?></div>
|
||||
|
|
|
|||
|
|
@ -14,11 +14,7 @@
|
|||
<div class="center message">
|
||||
<h1>Search results not found!</h1>
|
||||
<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>
|
||||
<p>Please search again, or would you like to try our <a href="<?php echo site_url() ?>">homepage</a> instead?</p>
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -596,7 +596,7 @@ h1.title-post a:hover, h2.title-index a:hover {
|
|||
margin-bottom: 1.2em;
|
||||
}
|
||||
|
||||
#search-form-404 {
|
||||
.search-404 #search-form {
|
||||
float:none;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -26,11 +26,7 @@
|
|||
<div class="container">
|
||||
<nav id="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>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue