Skip to content

Commit 01b6e67

Browse files
committed
Merge pull request #16 from iromli/static
Static file, URL, and entrypoint
2 parents a0594a3 + 25d5a99 commit 01b6e67

9 files changed

Lines changed: 46 additions & 157 deletions

File tree

README.md

Lines changed: 8 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
[![Stories in Ready](https://badge.waffle.io/timlinux/user_map.png?label=ready)](https://waffle.io/timlinux/user_map)
2-
[![Build Status](http://jenkins.linfiniti.com/buildStatus/icon?job=UserMap)](http://jenkins.linfiniti.com/job/UserMap/)
3-
41
User Map
52
========
63

74
A simple flask application for creating user community maps.
85

6+
Hacking
7+
-------
8+
99
By default, this app reads configuration from `users/default_config.py`.
1010
To override values set in default config, simply copy the contents
1111
of `users/default_config.py` and save it elsewhere.
@@ -14,20 +14,18 @@ of `users/default_config.py` and save it elsewhere.
1414

1515
Then edit the custom config file, setting appropriate values as needed.
1616

17-
To run in debug mode (which will also serve up static content),
18-
use the `-d` flag:
17+
To run the development server:
1918

20-
USERS_CONFIG=/path/to/custom/config.py python runserver.py -d
19+
USERS_CONFIG=/path/to/custom/config.py python manage.py runserver
2120

2221
Each config item is overridable through environment variable.
23-
For instance, if you want to suppress email delivery,
24-
simply set appropriate value:
22+
For instance, if you want to suppress email delivery, simply set appropriate value:
2523

26-
USERS_MAIL_SUPPRESS_SEND=True python runserver
24+
USERS_MAIL_SUPPRESS_SEND=True python manage.py runserver
2725

2826
To run testcases:
2927

30-
USERS_CONFIG=/path/to/custom/config.py MAIL_SUPPRESS_SEND=True ./runtests.sh
28+
USERS_CONFIG=/path/to/custom/config.py USERS_MAIL_SUPPRESS_SEND=True ./runtests.sh
3129

3230
Collaboration
3331
-------------
@@ -38,28 +36,6 @@ Collaboration
3836
4. Once it done, submit your pull request (PR) against upstream `develop` branch.
3937
5. Our maintainers will review your PR. If it's good — all tests passed and proposed feature is in our roadmap — your PR will be merged.
4038

41-
Deployment using Docker
42-
-----------------------
43-
44-
If you are using docker, you can create a Docker image for this app easily as
45-
follows:
46-
47-
```
48-
wget -O Dockerfile https://raw.github.com/timlinux/user_map/master/docker/Dockerfile
49-
wget -O sources.list https://raw.github.com/timlinux/user_map/master/docker/sources.list
50-
wget -O post-setup.sh https://raw.github.com/timlinux/user_map/master/docker/post-setup.sh
51-
chmod +x post-setup.sh
52-
53-
docker build -t linfiniti/user_map:base .
54-
docker run -d -p 8099:80 -t linfiniti/user_map:base -n user_map -D
55-
```
56-
57-
If you are on a Hetzner server, consider replacing the second line above with:
58-
59-
```
60-
wget -O sources.list https://raw.github.com/timlinux/user_map/master/docker/hetzner-sources.list
61-
```
62-
6339
Authors
6440
-------
6541

manage.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
from flask.ext.script import Manager
2+
3+
from users import APP
4+
5+
if __name__ == "__main__":
6+
manager = Manager(APP)
7+
manager.run()

requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
Flask==0.10.1
22
Flask-Mail==0.9.0
3+
Flask-Script==2.0.5
34
Jinja2==2.7.3
45
MarkupSafe==0.23
56
Werkzeug==0.9.6

runserver.py

Lines changed: 0 additions & 29 deletions
This file was deleted.

users/__init__.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -68,25 +68,10 @@ def setup_logger():
6868

6969
APP = Flask(__name__)
7070

71-
#: Load configuration from any possible means.
72-
#: To override default configuration defined in ``users.default_config``,
73-
#: simply copy the contents of ``config.py`` file,
74-
#: and save it into a file.
75-
#:
76-
#: .. sourcecode:: sh
77-
#:
78-
#: USERS_CONFIG=/path/to/config.py python runserver.py
79-
#:
80-
#: Another way of doing it is by setting environment variable for each
81-
#: config item.
82-
#:
83-
#: .. sourcecode:: sh
84-
#:
85-
#: USERS_CONFIG=/path/to/config.py USERS_MAIL_SUPPRESS_SEND=True \
86-
#: python runserver.py
87-
#:
71+
# Load configuration from any possible means.
8872
AppConfig(APP, default_settings="users.default_config")
8973

74+
# Mailer
9075
mail = Mail(APP)
9176

9277
# backward-compat

users/static.py

Lines changed: 0 additions & 46 deletions
This file was deleted.

users/templates/html/base.html

Lines changed: 18 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -6,31 +6,24 @@
66
<link rel="shortcut icon" href="{{ project_favicon_file }}">
77
<title>{% block title %}{{ project_name | safe }} User Map{% endblock %}</title>
88
{% block head_resources %}
9-
<link rel="stylesheet" href="/users/static/css/bootstrap.css"
10-
type="text/css" static="screen, projection"/>
11-
<link rel="stylesheet" href="/users/static/css/leaflet.css"/>
12-
<!--[if lte IE 8]>
13-
<link rel="stylesheet" href="/users/static/css/leaflet.ie.css" />
14-
<![endif]-->
15-
<link rel="stylesheet" href="/users/static/css/leaflet.label.css"/>
16-
<link rel="stylesheet" href="/users/static/css/user-map.css"
17-
type="text/css"/>
18-
<script language="javascript"
19-
type="text/javascript" src="/users/static/js/jquery.js"></script>
20-
<script language="javascript"
21-
type="text/javascript" src="/users/static/js/bootstrap.min.js"></script>
22-
<script src="/users/static/js/leaflet.js"></script>
23-
<script src="/users/static/js/leaflet.label.js"></script>
24-
<script language="javascript"
25-
type="text/javascript" src="/users/static/js/user-map.js"></script>
26-
<script language="javascript"
27-
type="text/javascript" src="/users/static/js/user-map-component.js"></script>
28-
<script language="javascript"
29-
type="text/javascript" src="/users/static/js/user-map-state.js"></script>
30-
<script language="javascript"
31-
type="text/javascript" src="/users/static/js/user-map-utilities.js"></script>
32-
<script language="javascript"
33-
type="text/javascript" src="/users/static/js/validate.js"></script>
9+
<link rel="stylesheet" href="{{ url_for('static', filename='css/bootstrap.css') }}" type="text/css" static="screen, projection"/>
10+
<link rel="stylesheet" href="{{ url_for('static', filename='css/leaflet.css') }}"/>
11+
<!--[if lte IE 8]>
12+
<link rel="stylesheet" href="{{ url_for('static', filename='css/leaflet.ie.css') }}"/>
13+
<![endif]-->
14+
<link rel="stylesheet" href="{{ url_for('static', filename='css/leaflet.label.css') }}"/>
15+
<link rel="stylesheet" href="{{ url_for('static', filename='css/user-map.css') }}" />
16+
17+
<script language="javascript" type="text/javascript" src="{{ url_for('static', filename='js/jquery.js') }}"></script>
18+
<script language="javascript" type="text/javascript" src="{{ url_for('static', filename='js/bootstrap.min.js') }}"></script>
19+
<script language="javascript" type="text/javascript" src="{{ url_for('static', filename='js/leaflet.js') }}"></script>
20+
<script language="javascript" type="text/javascript" src="{{ url_for('static', filename='js/leaflet.label.js') }}"></script>
21+
22+
<script language="javascript" type="text/javascript" src="{{ url_for('static', filename='js/user-map.js') }}"></script>
23+
<script language="javascript" type="text/javascript" src="{{ url_for('static', filename='js/user-map-component.js') }}"></script>
24+
<script language="javascript" type="text/javascript" src="{{ url_for('static', filename='js/user-map-state.js') }}"></script>
25+
<script language="javascript" type="text/javascript" src="{{ url_for('static', filename='js/user-map-utilities.js') }}"></script>
26+
<script language="javascript" type="text/javascript" src="{{ url_for('static', filename='js/validate.js') }}"></script>
3427
{% endblock head_resources %}
3528
</head>
3629
<body>

users/templates/html/index.html

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
{% extends "html/base.html" %}
22

33
{% block head_resources %}
4-
{{ super() }}
5-
<link rel="stylesheet" href="/users/static/css/MarkerCluster.css"/>
6-
<link rel="stylesheet" href="/users/static/css/MarkerCluster.user-map.css"/>
7-
<!--[if lte IE 8]><link rel="stylesheet" href="/users/static/css//MarkerCluster.user-map.ie.css" /><![endif]-->
8-
<script src="/users/static/js/leaflet.markercluster-src.js"></script>
4+
{{ super() }}
5+
<link rel="stylesheet" href="{{ url_for('static', filename='css/MarkerCluster.css') }}" />
6+
<link rel="stylesheet" href="{{ url_for('static', filename='css/MarkerCluster.user-map.css') }}" />
7+
<!--[if lte IE 8]>
8+
<link rel="stylesheet" href="{{ url_for('static', filename='css/MarkerCluster.user-map.ie.css') }}" />
9+
<![endif]-->
10+
<script src="{{ url_for('static', filename='js/leaflet.markercluster-src.js') }}"></script>
911
{% endblock head_resources %}
1012

1113
{% block body %}

users/views.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ def add_user_view():
153153
body = render_template(
154154
'text/registration_confirmation_email.txt',
155155
project_name=APP.config['PROJECT_NAME'],
156-
url=APP.config['PUBLIC_URL'],
156+
url=APP.config["PUBLIC_URL"],
157157
user=added_user)
158158
recipient = added_user['email']
159159
send_async_mail(
@@ -307,7 +307,7 @@ def delete_user_view(guid):
307307
"""
308308
# Delete User
309309
delete_user(guid)
310-
return APP.config['PUBLIC_URL']
310+
return APP.config["PUBLIC_URL"]
311311

312312

313313
@APP.route('/download')
@@ -362,7 +362,7 @@ def reminder_view():
362362
body = render_template(
363363
'text/registration_confirmation_email.txt',
364364
project_name=APP.config['PROJECT_NAME'],
365-
url=APP.config['PUBLIC_URL'],
365+
url=APP.config["PUBLIC_URL"],
366366
user=user)
367367
send_async_mail(
368368
sender=MAIL_ADMIN,

0 commit comments

Comments
 (0)