Skip to content

Commit

Permalink
docker: initial configuration and demo app
Browse files Browse the repository at this point in the history
* 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
tiborsimko committed Jan 30, 2015
1 parent 613a790 commit 110a52d
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
dist/
build/
docs/_build/
.eggs
15 changes: 15 additions & 0 deletions Dockerfile
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
59 changes: 59 additions & 0 deletions examples/simple/app.py
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)
16 changes: 16 additions & 0 deletions fig.yml
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
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
#
# This file is part of Flask-Menu
# Copyright (C) 2013, 2014 CERN.
# Copyright (C) 2013, 2014, 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
Expand Down Expand Up @@ -52,7 +52,7 @@ def run_tests(self):
'pytest-cov>=1.8.0',
'pytest-pep8>=1.0.6',
'pytest>=2.6.1',
'coverage'
'coverage<4.0a1'
]

setup(
Expand Down

0 comments on commit 110a52d

Please sign in to comment.