mirror of
https://github.com/Oreolek/oreolek.ru.git
synced 2024-04-29 15:49:24 +03:00
parent
b8794cc1b6
commit
84343b496f
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,5 +1,6 @@
|
|||
application/config/database.php
|
||||
application/config/auth.php
|
||||
application/config/stats.php
|
||||
application/config/sphinxql.php
|
||||
application/cache
|
||||
application/logs
|
||||
|
|
3
.gitmodules
vendored
3
.gitmodules
vendored
|
@ -25,3 +25,6 @@
|
|||
[submodule "modules/kostache"]
|
||||
path = modules/kostache
|
||||
url = git://github.com/zombor/KOstache.git
|
||||
[submodule "modules/sphinxql"]
|
||||
path = modules/sphinxql
|
||||
url = git://github.com/x10d/kohana-sphinxql.git
|
||||
|
|
|
@ -4,6 +4,11 @@ License is [AGPL 3.0.](http://www.tldrlegal.com/l/AGPL3)
|
|||
|
||||
Oreolek.
|
||||
|
||||
## Requirements
|
||||
* Kohana 3.3
|
||||
* MySQL or MariaDB
|
||||
* Sphinx
|
||||
|
||||
## Installation
|
||||
|
||||
* `git clone` - I assume you are familiar with this command
|
||||
|
|
|
@ -114,6 +114,7 @@ Kohana::modules(array(
|
|||
'debug-toolbar' => MODPATH.'debug-toolbar', // Debug toolbar
|
||||
'image' => MODPATH.'image', // Image manipulation
|
||||
'kostache' => MODPATH.'kostache', // Logic-less Mustache views
|
||||
'sphinxql' => MODPATH.'sphinxql', // Full-text search via Sphinx
|
||||
// 'cache' => MODPATH.'cache', // Caching with multiple backends
|
||||
// 'codebench' => MODPATH.'codebench', // Benchmarking tool
|
||||
// 'unittest' => MODPATH.'unittest', // Unit testing
|
||||
|
|
|
@ -270,4 +270,22 @@ class Controller_Post extends Controller_Layout {
|
|||
->limit(10)
|
||||
->find_all();
|
||||
}
|
||||
|
||||
public function action_search()
|
||||
{
|
||||
$term = $this->request->post('term');
|
||||
if ($term == '')
|
||||
{
|
||||
$this->redirect('');
|
||||
}
|
||||
$sphinxql = new SphinxQL();
|
||||
$query = $sphinxql->new_query();
|
||||
$query->add_index('index1')
|
||||
->add_field('name')
|
||||
->add_field('content')
|
||||
->search($term);
|
||||
$this->template = new View_Index;
|
||||
$this->template->title = 'Результаты поиска';
|
||||
$this->template->items = $query->execute();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -120,4 +120,9 @@ class View_Layout {
|
|||
}
|
||||
return $output;
|
||||
}
|
||||
|
||||
public function search_url()
|
||||
{
|
||||
return Route::url('default', array('controller' => 'Post', 'action' => 'search'));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -12,9 +12,12 @@
|
|||
<h1>{{site_title}}</h1>
|
||||
</div>
|
||||
<div class = "navigation">
|
||||
<form action="{{search_url}}" method="POST">
|
||||
<input type="text" placeholder="Поиск записей" name="term">
|
||||
</form>
|
||||
<ul>
|
||||
{{#navigation}}
|
||||
<li><a href="{{url}}">{{title}}</a></li>
|
||||
<li><a href="{{url}}">{{title}}</a></li>
|
||||
{{/navigation}}
|
||||
</ul>
|
||||
</div>
|
||||
|
|
1
modules/sphinxql
Submodule
1
modules/sphinxql
Submodule
|
@ -0,0 +1 @@
|
|||
Subproject commit 0d6e016ffae2bd9da4a642bc5e6388efb2979d7b
|
Loading…
Reference in a new issue