From 88c741c09b664260f826ff947bfaab071ac70d05 Mon Sep 17 00:00:00 2001 From: Christian Weiske Date: Wed, 3 Feb 2016 21:12:17 +0100 Subject: add site search, highlighting --- README.rst | 6 ++++++ bin/index.php | 1 + data/templates/search.htm | 3 ++- data/templates/search/hit.htm | 3 ++- data/templates/search/list.htm | 8 +++++++- src/phinde/Elasticsearch.php | 31 +++++++++++++++++++++++++++++-- src/phinde/Helper.php | 9 +++++++++ www/css/phinde.css | 3 +++ www/index.php | 27 ++++++++++++++++++++++++--- 9 files changed, 83 insertions(+), 8 deletions(-) diff --git a/README.rst b/README.rst index 121893c..ba8a681 100644 --- a/README.rst +++ b/README.rst @@ -1,3 +1,9 @@ +Features +======== +- Site search + + - Query: ``foo bar site:www.example.org/dir/`` + Dependencies ============ - PHP 5.5+ diff --git a/bin/index.php b/bin/index.php index eb82df2..8ac08ce 100755 --- a/bin/index.php +++ b/bin/index.php @@ -61,6 +61,7 @@ $doc = new \DOMDocument(); $sx = simplexml_import_dom($doc); $indexDoc->url = $url; +$indexDoc->schemalessUrl = Helper::noSchema($url); $indexDoc->type = 'html'; $indexDoc->subtype = ''; $indexDoc->mimetype = $mimetype; diff --git a/data/templates/search.htm b/data/templates/search.htm index 8eb077b..4f3a252 100644 --- a/data/templates/search.htm +++ b/data/templates/search.htm @@ -12,7 +12,8 @@ diff --git a/data/templates/search/hit.htm b/data/templates/search/hit.htm index 4981017..dababcb 100644 --- a/data/templates/search/hit.htm +++ b/data/templates/search/hit.htm @@ -1,7 +1,7 @@ {% set doc = hit._source %}
  • - {{doc.title}} + {{doc.htmlTitle|raw}} {% if doc.author.name %} by @@ -19,5 +19,6 @@ {% if doc.modate %} {{doc.extra.day|date("Y-m-d")}} {% endif %} + {{doc.htmlText|raw}}
  • diff --git a/data/templates/search/list.htm b/data/templates/search/list.htm index ef8d454..97584d6 100644 --- a/data/templates/search/list.htm +++ b/data/templates/search/list.htm @@ -4,7 +4,13 @@

    {% else %}

    - Found {{hitcount}} search results for "{{query}}" in {{queryTime}}: + Found {{hitcount}} search + {% if hitcount == 1 %}result{% else %}results{%endif%} + for "{{cleanQuery}}" + {% if site %} + on {{site}} + {% endif %} + in {{queryTime}}: