forked from inveniosoftware/flask-menu
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docker: initial configuration and demo app
* Initial release of docker/fig configuration. E.g. how to run tests while developing: `fig build && fig run web python setup.py test`. * Adds simple demo application showing Flask-Menu in action. E.g. how to see it running: `fig up && firefox http://0.0.0.0:5000/first`. * NOTE Also sets the upper limit on the version of `coverage` since the latest one was found to be failing. Signed-off-by: Tibor Simko <tibor.simko@cern.ch>
- Loading branch information
1 parent
613a790
commit 110a52d
Showing
5 changed files
with
93 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
dist/ | ||
build/ | ||
docs/_build/ | ||
.eggs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Flask-Menu | ||
# Copyright (C) 2015 CERN. | ||
# | ||
# Flask-Menu is free software; you can redistribute it and/or modify | ||
# it under the terms of the Revised BSD License; see LICENSE file for | ||
# more details. | ||
|
||
FROM python:2.7 | ||
ADD . /code | ||
WORKDIR /code | ||
RUN pip install pep257 | ||
RUN pip install sphinx | ||
RUN python setup.py develop |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Flask-Menu | ||
# Copyright (C) 2015 CERN. | ||
# | ||
# Flask-Menu is free software; you can redistribute it and/or modify | ||
# it under the terms of the Revised BSD License; see LICENSE file for | ||
# more details. | ||
|
||
"""A simple demo application showing Flask-Menu in action. | ||
Usage: | ||
$ fig up | ||
$ firefox http://0.0.0.0:5000/ | ||
$ firefox http://0.0.0.0:5000/first | ||
$ firefox http://0.0.0.0:5000/second | ||
""" | ||
|
||
from flask import Flask | ||
from flask import render_template_string | ||
from flask.ext import menu | ||
|
||
app = Flask(__name__) | ||
menu.Menu(app=app) | ||
|
||
|
||
def tmpl_show_menu(): | ||
"""Show menu with current page decorated by asterisk.""" | ||
return render_template_string( | ||
""" | ||
{%- for item in current_menu.children %} | ||
{% if item.active %}*{% endif %}{{ item.text }} | ||
{% endfor -%} | ||
""") | ||
|
||
|
||
@app.route('/') | ||
@menu.register_menu(app, '.', 'Home') | ||
def index(): | ||
"""Home page.""" | ||
return tmpl_show_menu() | ||
|
||
|
||
@app.route('/first') | ||
@menu.register_menu(app, '.first', 'First', order=0) | ||
def first(): | ||
"""First page.""" | ||
return tmpl_show_menu() | ||
|
||
|
||
@app.route('/second') | ||
@menu.register_menu(app, '.second', 'Second', order=1) | ||
def second(): | ||
"""Second page.""" | ||
return tmpl_show_menu() | ||
|
||
|
||
if __name__ == '__main__': | ||
app.run(host="0.0.0.0", debug=True) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# -*- coding: utf-8 -*- | ||
# | ||
# This file is part of Flask-Menu | ||
# Copyright (C) 2015 CERN. | ||
# | ||
# Flask-Menu is free software; you can redistribute it and/or modify | ||
# it under the terms of the Revised BSD License; see LICENSE file for | ||
# more details. | ||
|
||
web: | ||
build: . | ||
command: python examples/simple/app.py | ||
ports: | ||
- "5000:5000" | ||
volumes: | ||
- .:/code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters