From 8116c6799c0ff0d0187eca964807caf250cdf952 Mon Sep 17 00:00:00 2001 From: Eric Cook Date: Thu, 18 Dec 2014 15:25:49 -0600 Subject: [PATCH] Adds basic search functionality --- lincoln/templates/base.html | 16 +++++++++++++++- lincoln/templates/search_results.html | 11 +++++++++++ lincoln/views.py | 11 +++++++++++ 3 files changed, 37 insertions(+), 1 deletion(-) create mode 100644 lincoln/templates/search_results.html diff --git a/lincoln/templates/base.html b/lincoln/templates/base.html index 3fc6c99..a73fee2 100644 --- a/lincoln/templates/base.html +++ b/lincoln/templates/base.html @@ -24,6 +24,16 @@ + + @@ -40,10 +50,14 @@ Lincoln diff --git a/lincoln/templates/search_results.html b/lincoln/templates/search_results.html new file mode 100644 index 0000000..291a584 --- /dev/null +++ b/lincoln/templates/search_results.html @@ -0,0 +1,11 @@ +{% set title = "Search results" %} +{% set page = "search_results" %} +{% extends "base.html" %} +{% block content %} +

Search results

+
Blocks
+{% include "blocks_table.html" %} +

Transactions

+{% include "transaction_table.html" %} +{% endblock %} + diff --git a/lincoln/views.py b/lincoln/views.py index c1d37a4..d200ecf 100644 --- a/lincoln/views.py +++ b/lincoln/views.py @@ -52,3 +52,14 @@ def favicon(): return send_from_directory( os.path.join(root, 'static'), 'favicon.ico', mimetype='image/vnd.microsoft.icon') + +@main.route('/search/') +def search(query): + blob = core.lx(query) + + # Query for items + blocks = m.Block.query.filter(m.Block.hash.like(blob)).limit(10) + transactions = m.Transaction.query.filter(m.Transaction.txid.like(blob)).limit(10) + return render_template('search_results.html', + blocks=blocks, + transactions=transactions)