Skip to content

Commit

Permalink
New version of the applcation. Renamed to minimal.
Browse files Browse the repository at this point in the history
This commit changes the name of the application to minimal, as well as it uses a Blueprint for serving the static files. This last change solves the problem of dealing with the static files via Apache Alias directives.
  • Loading branch information
teleyinex committed May 22, 2012
1 parent ea7852d commit 99544a8
Show file tree
Hide file tree
Showing 30 changed files with 102 additions and 32 deletions.
42 changes: 35 additions & 7 deletions README.md
@@ -1,10 +1,38 @@
Simple Flask web application to create web page prototypes using Twitter
Bootstrap as the CSS framework.
Minimal is a small web application that allows you to create web pages
really fast and easily with a beautiful interface thanks to [Bootstrap](http://twitter.github.com/bootstrap/.)

This application saves you time creating a prototype, as you will not have to
write every header, footer, etc. Everything is configured using global
variables and different partials: _navbar.html, _footer.html, etc.
write every header, footer, etc for every HTML page. Everything is configured using global
variables and different partials: _navbar.html, _footer.html, etc. take
a look at the templates folder

Take a look at the templates (it uses Jinja2), and copy and paste the
index.html to create new pages. Then, all you have to do is add more routes in
web.py.
For example, by default Minimal serves an index page that can be overriden just
copying and pasting the index.html.template into a file named index.html.
Adding a new page is as simple as creating a new file in the template folder,
and requesting it via the URL http://domain/newpage.html

Minimal allows you to focus just in the HTML content, as the header and the
footer are already provided by the application.

Minimal it also has support for Google Analytics, so you only have to paste the
tracking code in the configuration file for tracking all the pages that you
have created.

Finally, as Minimal is created using the micro-framework [Flask](http://flask.pocoo.org/) it is really easy to extend the application, as there are several plugins that can enhance the user experience.

# Installation

In order to install it you have to follow the next steps:

* Clone the repository
* Create a virtualenv for the application: virtualenv env
* Activate it: . env/bin/activate
* Install the required libraries in the virtualenv: pip install -r
requirements.txt
* Create a settings file for the server: cp settings_local.py.tmpl to
settings_local.py
* Launch the demo server: python minimal/app.py

If you want to deploy it using Apache2, you only have to check the **contrib**
folder, where you will find the WSGI application and the Apache2 configuration
site.
14 changes: 14 additions & 0 deletions contrib/apache2/minimal-site
@@ -0,0 +1,14 @@
<VirtualHost *:80>
ServerName example.com

DocumentRoot /home/user/minimal
WSGIDaemonProcess pybossa user=user1 group=group1 threads=5
WSGIScriptAlias / /home/user/pybossa/contrib/minimal.wsgi

<Directory /home/user/minimal>
WSGIProcessGroup minimal
WSGIApplicationGroup %{GLOBAL}
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
9 changes: 9 additions & 0 deletions contrib/minimal.wsgi
@@ -0,0 +1,9 @@
# Activate the virtual env
activate_this = '/home/teleyinex/Proyectos/public_html/minimal/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
# Import sys to add the path of minimal
import sys
sys.path.insert(0,'/home/teleyinex/Proyectos/minimal')
# Run the web-app
from minimal.app import app as application
application.debug = True
10 changes: 10 additions & 0 deletions contrib/minimal.wsgi.template
@@ -0,0 +1,10 @@
# Activate the virtual env
activate_this = '/home/user/minimal/env/bin/activate_this.py'
execfile(activate_this, dict(__file__=activate_this))
# Import sys to add the path of minimal
import sys
sys.path.insert(0,'/home/user/minimal')
# Run the web-app
from minimal.app import app as application
# Uncomment to see the errors in the Apache log file
# application.debug = True
File renamed without changes.
21 changes: 9 additions & 12 deletions web/app.py → minimal/app.py
@@ -1,34 +1,31 @@
# This file is part of flask-web.
# This file is part of minimal.
#
# flask-web is free software: you can redistribute it and/or modify
# minimal is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# flask-web is distributed in the hope that it will be useful,
# minimal is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with flask-web. If not, see <http://www.gnu.org/licenses/>.
# along with minimal. If not, see <http://www.gnu.org/licenses/>.

import os
from flask import Flask, render_template, abort, request
from datetime import datetime
from views.assets import assets

app = Flask(__name__)
print assets.static_folder
app.register_blueprint(assets, url_prefix="/assets")

import settings_local as settings

# Set up the configuration values for the application
def configure_app(app):
app.config.from_object(settings)
# parent directory
here = os.path.dirname(os.path.abspath( __file__ ))
config_path = os.path.join(os.path.dirname(here), 'settings_local.py')
if os.path.exists(config_path):
app.config.from_pyfile(config_path)
app.config.from_object(settings)

# Pass all these variables to all the views
@app.context_processor
Expand Down Expand Up @@ -63,5 +60,5 @@ def page(page):
return abort(404)

if __name__ == '__main__':
configure_app(app)
#configure_app(app)
app.run()
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
3 changes: 3 additions & 0 deletions minimal/static/css/style.css
@@ -0,0 +1,3 @@
footer {
text-align: center;
}
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Expand Up @@ -3,5 +3,6 @@

<footer>
<p>&copy; {{ copyright }} {{ year }}</p>
<p>Powered by <a href=http://github.com/teleyinex/minimal>Minimal</a></p>
</footer>
{% endblock %}
File renamed without changes.
Expand Up @@ -8,26 +8,27 @@
<meta name="author" content="{{ copyright }}">

<!-- Le styles -->
<link href="{{ url_for('static', filename='bootstrap/css/bootstrap.css')}}" rel="stylesheet">
<link href="{{ url_for('assets.static', filename='bootstrap/css/bootstrap.css')}}" rel="stylesheet">
<style type="text/css">
body {
padding-top: 60px;
padding-bottom: 40px;
}
</style>
<link href="{{ url_for('static', filename='bootstrap/css/bootstrap-responsive.css') }}" rel="stylesheet">
<link href="{{ url_for('assets.static', filename='bootstrap/css/bootstrap-responsive.css') }}" rel="stylesheet">
<link href="{{ url_for('assets.static', filename='css/style.css') }}" rel="stylesheet">

<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- Le fav and touch icons -->
<link rel="shortcut icon" href="{{ url_for('static', filename='bootstrap/ico/favicon.ico')}}">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ url_for('static', filename='bootstrap/ico/apple-touch-icon-144-precomposed.png') }}">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="{{ url_for('static', filename='bootstrap/ico/apple-touch-icon-114-precomposed.png') }}">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="{{ url_for('static', filename='bootstrap/ico/apple-touch-icon-72-precomposed.png') }}">
<link rel="apple-touch-icon-precomposed" href="{{ url_for('static', filename='bootstrap/ico/apple-touch-icon-57-precomposed.png') }}">
<link rel="shortcut icon" href="{{ url_for('assets.static', filename='bootstrap/ico/favicon.ico')}}">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="{{ url_for('assets.static', filename='bootstrap/ico/apple-touch-icon-144-precomposed.png') }}">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="{{ url_for('assets.static', filename='bootstrap/ico/apple-touch-icon-114-precomposed.png') }}">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="{{ url_for('assets.static', filename='bootstrap/ico/apple-touch-icon-72-precomposed.png') }}">
<link rel="apple-touch-icon-precomposed" href="{{ url_for('assets.static', filename='bootstrap/ico/apple-touch-icon-57-precomposed.png') }}">

<!-- Le Google Analytics -->
{% include 'helpers/_googleanalytics.html' %}
Expand All @@ -47,8 +48,8 @@
<!-- Le javascript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="{{ url_for('static', filename='js/jquery.min.js') }}"></script>
<script src="{{ url_for('static', filename='bootstrap/js/bootstrap.min.js')}} "></script>
<script src="{{ url_for('assets.static', filename='js/jquery.min.js') }}"></script>
<script src="{{ url_for('assets.static', filename='bootstrap/js/bootstrap.min.js')}} "></script>

</body>
{% if carousel %}
Expand Down
Empty file added minimal/views/__init__.py
Empty file.
3 changes: 3 additions & 0 deletions minimal/views/assets.py
@@ -0,0 +1,3 @@
from flask import Blueprint

assets = Blueprint('assets', __name__, static_folder='../static')
2 changes: 2 additions & 0 deletions minimal/views/static/prueba.css
@@ -0,0 +1,2 @@
body {
}
4 changes: 2 additions & 2 deletions test/base.py
@@ -1,5 +1,5 @@
from web import app
from web import settings_local as settings
from minimal import app
from minimal import settings_local as settings

webapp = app.app
webapp.config.from_object(settings)
Expand Down
6 changes: 4 additions & 2 deletions test/tests.py
Expand Up @@ -12,15 +12,15 @@ def setUpClass(self):
self.file_name = str(random.randint(0,100)) + "_test.html"
self.msg = str(random.randint(0,1000)) + "Random Test"
# Create a random page to be served by the server
f = open("web/templates/" + self.file_name ,"w")
f = open("minimal/templates/" + self.file_name ,"w")
f.write(self.msg)
f.close()

@classmethod
def tearDownClass(self):
"""Delete created pages for the tests"""
# Delete random page
os.remove("web/templates/{}".format(self.file_name))
os.remove("minimal/templates/{}".format(self.file_name))

def test_01_index_template(self):
"""Test index template page works"""
Expand All @@ -40,6 +40,8 @@ def test_03_styles(self):
res = self.webapp.get('/')
assert 'bootstrap.css' in res.data, res.data
assert 'bootstrap-responsive.css' in res.data, res.data
# Check that the Blueprint is serving the static data
assert 'assets/static' in res.data, res.data

def test_04_googleanalytics(self):
"""Test Google Analaytics is included"""
Expand Down

0 comments on commit 99544a8

Please sign in to comment.