This repository was archived by the owner on May 20, 2018. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +43
-0
lines changed
Expand file tree Collapse file tree 4 files changed +43
-0
lines changed Original file line number Diff line number Diff line change @@ -19,3 +19,7 @@ class ShareForm(Form):
1919class NotebookForm (Form ):
2020 title = StringField ('Title:' , validators = [Required ()])
2121 submit = SubmitField ('Submit' )
22+
23+ class SearchForm (Form ):
24+ search_field = StringField ()
25+ submit = SubmitField ('Search' )
Original file line number Diff line number Diff line change @@ -183,6 +183,18 @@ def notebook(id):
183183 abort (403 )
184184 return render_template ('app/notebook.html' , notebook = notebook , notes = notebook ._show_notes ())
185185
186+ @main .route ('/search' )
187+ @login_required
188+ def search ():
189+ form = SearchForm ()
190+ if request .args .get ('search_field' , '' ):
191+ query = request .args .get ('search_field' , '' )
192+ results = Note .query .search (query ).all ()
193+ if len (results ) == 0 :
194+ flash ('Hmm, we did not find any braindumps matching your search. Try again?' )
195+ return render_template ('app/search.html' , form = form , notes = results )
196+ return render_template ('app/search.html' , form = form )
197+
186198
187199@main .route ('/shutdown' )
188200def server_shutdown ():
Original file line number Diff line number Diff line change 2121 < li class ="sidebar-item ">
2222 < a href ="/ "> < img class ="app-logo " src ="{{ url_for('static', filename='images/logo.png')}} "> </ img > </ a >
2323 </ li >
24+ < li class ="sidebar-item " data-toggle ="tooltip " data-placement ="right " title ="Search ">
25+ < a href ="/search "> < span class ="nav-item glyphicon glyphicon-search " aria-hidden ="true "> </ a > </ span >
26+ </ li >
2427 < li class ="sidebar-item " data-toggle ="tooltip " data-placement ="right " title ="Add a Note ">
2528 < a href ="/add "> < span class ="nav-item glyphicon glyphicon-plus " aria-hidden ="true "> </ a > </ span >
2629 </ li >
Original file line number Diff line number Diff line change 1+ {% extends "app/app_base.html" %}
2+ {% import "bootstrap/wtf.html" as wtf %}
3+ {% import "_macros.html" as macros %}
4+
5+ {% block title %}BrainDump{% endblock %}
6+
7+ {% block page_content %}
8+
9+ < h1 class ="top "> Search for Anything </ h1 >
10+
11+ < form class ="form form-horizontal " action ="/search " role ="form ">
12+ {{ wtf.form_field(form.search_field) }}
13+ {{ wtf.form_field(form.submit, class="btn btn-default form-group") }}
14+ </ form >
15+
16+ {% include 'app/_notes.html' %}
17+
18+
19+ {% endblock %}
20+
21+ {% block scripts %}
22+ {{ super() }}
23+ < script src ="{{ url_for('static', filename='js/libs/marked.js') }} "> </ script >
24+ {% endblock %}
You can’t perform that action at this time.
0 commit comments