From da809a5e534494e30050cc4be295449d515dffd5 Mon Sep 17 00:00:00 2001 From: Alex Hunt Date: Sat, 16 Dec 2017 15:01:30 -0500 Subject: [PATCH] Adding favicon to static folder --- .gitignore | 1 + blueprints/api.py | 35 +++++++++++++++++++++++++++++++++++ blueprints/search.py | 8 ++++++++ templates/editor.html | 2 +- templates/index.html | 2 +- templates/search.html | 14 ++++++++++++++ webpack.config.js | 6 +++++- 7 files changed, 65 insertions(+), 3 deletions(-) create mode 100644 blueprints/search.py create mode 100644 templates/search.html diff --git a/.gitignore b/.gitignore index b72783a..d4935a6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,7 @@ /lib /bin /include +/icon /node_modules *.pyc pip-selfcheck.json diff --git a/blueprints/api.py b/blueprints/api.py index f82146e..2dd48aa 100644 --- a/blueprints/api.py +++ b/blueprints/api.py @@ -86,6 +86,33 @@ def renumber_chapters(): es_update_number(chapter['id'], index + 1) return chapters +def es_search_text(body): + search = es.search( + index='joyce', + # _source_exclude=['text'], + body={ + 'from': 0, 'size': 10, + 'query': { + 'match': { + 'text': { + 'query': body, + 'analyzer': 'html_analyzer' + } + } + }, + 'highlight' : { + 'fields' : { + 'text': { + 'matched_fields': 'text', + 'type': 'unified', + } + } + } + } + ) + return search['hits']['hits'] + + # # Chapter API Routes # @@ -152,3 +179,11 @@ def delete_note(id): es_delete_document('note', id) return jsonify(es_document_list('note')) +# +# Search API Routes +# + +""" Basic Text Search """ +@api.route('/search/', methods=['POST']) +def search_text(): + return jsonify(es_search_text(request.data)) diff --git a/blueprints/search.py b/blueprints/search.py new file mode 100644 index 0000000..71bd4cd --- /dev/null +++ b/blueprints/search.py @@ -0,0 +1,8 @@ +from flask import Blueprint, render_template, abort +from jinja2 import TemplateNotFound + +search = Blueprint('search', __name__) + +@search.route('/') +def show_search(): + return render_template('search.html') \ No newline at end of file diff --git a/templates/editor.html b/templates/editor.html index a0fc2e5..9736e9c 100644 --- a/templates/editor.html +++ b/templates/editor.html @@ -2,8 +2,8 @@ Joyce - Editor - + diff --git a/templates/index.html b/templates/index.html index 58cdf5a..9976fee 100644 --- a/templates/index.html +++ b/templates/index.html @@ -2,8 +2,8 @@ Joyce - Reader - + diff --git a/templates/search.html b/templates/search.html new file mode 100644 index 0000000..24c69ae --- /dev/null +++ b/templates/search.html @@ -0,0 +1,14 @@ + + + Joyce - Search + + + + + + +
+
+ + + \ No newline at end of file diff --git a/webpack.config.js b/webpack.config.js index 1998538..9bbd95f 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -6,7 +6,7 @@ const path = require('path') const rootAssetPath = './src/' let pathsToClean = [ - 'static/' + 'static/js' ] module.exports = { @@ -18,6 +18,10 @@ module.exports = { editor: [ rootAssetPath + 'editor', rootAssetPath + 'stylesheets/' + 'editor.scss' + ], + search: [ + rootAssetPath + 'search', + rootAssetPath + 'stylesheets/' + 'search.scss' ] }, output: {