Skip to content

Commit

Permalink
V0.2 Minification + App compilation directly from appadmin interface …
Browse files Browse the repository at this point in the history
…(on state tab)
  • Loading branch information
Unitech committed Apr 29, 2011
1 parent efa043b commit 7219df0
Show file tree
Hide file tree
Showing 48 changed files with 229 additions and 288,925 deletions.
51 changes: 27 additions & 24 deletions README
@@ -1,37 +1,40 @@

#
# Web2Py Template
#
# Including CSS/JS Minification, logger and other things
#
+------------ Web2Py Template -----------+


### Add JS and CSS files on models/minification.py.
This Web2Py application template include :

Actually there are :
+++++++++++++ CSS/JS combination/minification + App compilation directly on 'appadmin'

1# Include all your JS and CSS files in models/extra.py

js_files = [
URL('static', 'js/jquery-1.5.2.js'),
URL('static', 'js/main.js')
URL('static', 'js/main.js'),
URL('static', 'js/shit.js')
]
css_files = [
URL('static', 'css/base.css')
]

An example of working inclusion is in views/layouts/layout.html :

{{# Js files are included from db/minification.py }}
{{for _item in js_files or []:}}
<script src="{{=_item}}"></script>
{{pass}}

{{# Css files}}
{{for _item in css_files:}}
<link rel="stylesheet" href="{{=_item}}">
{{pass}}


### To differenciate a production environ there is an environ variable to set

export PRODUCTION='True'
2# Then in the view include
{{include 'layouts/js_css_include_from_extra.html'}}


+++++++++++++ A new tree organization

├── models
│   ├── db_conf.py // Configuration Mail + Auth
│   ├── db.py // Distinction between Prod or not (disbling migration & co)
│   ├── db_tables.py // DB models declaration
│   └── extra.py // File to include (JS and CSS)
└── views
├── appadmin.html
├── default
│   └── index.html
├── __init__.py
└── layouts
├── admin_layout.html
├── layout.html
└── web2py_ajax.htm

29 changes: 28 additions & 1 deletion controllers/appadmin.py
Expand Up @@ -11,6 +11,13 @@
import gluon.contenttype
import gluon.fileutils


from gluon.admin import *
from gluon.fileutils import abspath
from glob import glob
import shutil
import platform

# ## critical --- make a copy of the environment

global_env = copy.copy(globals())
Expand Down Expand Up @@ -287,8 +294,28 @@ def update():
# ###########################################################


from gluon.compileapp import compile_application, remove_compiled_application

def state():
return dict()
form = FORM(
P(TAG.BUTTON("Switch to production ?", _type="submit", _name="prod", _value="prod")),
P(TAG.BUTTON("Switch to development ?", _type="submit", _name="dev", _value="dev"))
)
if form.accepts(request.vars, session):
if request.vars.prod:
os.environ['PRODUCTION'] = 'True'
global css_files
global js_files
compress = local_import('pack', reload=True)
compress.process_css(css_files, request.folder, 'min.css')
compress.process_js(js_files, request.folder, 'min.js')
c = app_compile(request.application, request)
if request.vars.dev:
os.environ['PRODUCTION'] = ''
remove_compiled_application(apath(request.application, r=request))

redirect(URL(r=request))
return dict(form=form)

def ccache():
form = FORM(
Expand Down
28 changes: 10 additions & 18 deletions databases/c8b669d15150d7109e5f7ab36744a5b7_auth_user.table
@@ -1,38 +1,30 @@
(dp1
S'username'
S'first_name'
p2
S'CHAR(128)'
p3
sS'first_name'
sS'last_name'
p4
S'CHAR(512)'
S'CHAR(128)'
p5
sS'last_name'
sS'email'
p6
S'CHAR(512)'
p7
sS'registration_id'
sS'reset_password_key'
p8
S'CHAR(512)'
p9
sS'email'
sS'password'
p10
S'CHAR(128) UNIQUE'
S'CHAR(512)'
p11
sS'reset_password_key'
sS'registration_key'
p12
S'CHAR(512)'
p13
sS'password'
p14
S'CHAR(512)'
p15
sS'registration_key'
p16
S'CHAR(512)'
p17
sS'id'
p18
p14
S'INTEGER PRIMARY KEY AUTOINCREMENT'
p19
p15
s.
24 changes: 11 additions & 13 deletions databases/sql.log
@@ -1,31 +1,29 @@
timestamp: 2011-04-28T17:19:26.530050
timestamp: 2011-04-29T14:08:21.572181
CREATE TABLE auth_user(
id INTEGER PRIMARY KEY AUTOINCREMENT,
username CHAR(128),
email CHAR(128) UNIQUE,
first_name CHAR(512),
last_name CHAR(512),
first_name CHAR(128),
last_name CHAR(128),
email CHAR(512),
password CHAR(512),
registration_key CHAR(512),
reset_password_key CHAR(512),
registration_id CHAR(512)
reset_password_key CHAR(512)
);
success!
timestamp: 2011-04-28T17:19:26.536746
timestamp: 2011-04-29T14:08:21.588977
CREATE TABLE auth_group(
id INTEGER PRIMARY KEY AUTOINCREMENT,
role CHAR(512),
description TEXT
);
success!
timestamp: 2011-04-28T17:19:26.539330
timestamp: 2011-04-29T14:08:21.590916
CREATE TABLE auth_membership(
id INTEGER PRIMARY KEY AUTOINCREMENT,
user_id INTEGER REFERENCES auth_user(id) ON DELETE CASCADE,
group_id INTEGER REFERENCES auth_group(id) ON DELETE CASCADE
);
success!
timestamp: 2011-04-28T17:19:26.541494
timestamp: 2011-04-29T14:08:21.593043
CREATE TABLE auth_permission(
id INTEGER PRIMARY KEY AUTOINCREMENT,
group_id INTEGER REFERENCES auth_group(id) ON DELETE CASCADE,
Expand All @@ -34,7 +32,7 @@ CREATE TABLE auth_permission(
record_id INTEGER
);
success!
timestamp: 2011-04-28T17:19:26.547203
timestamp: 2011-04-29T14:08:21.595209
CREATE TABLE auth_event(
id INTEGER PRIMARY KEY AUTOINCREMENT,
time_stamp TIMESTAMP,
Expand All @@ -44,7 +42,7 @@ CREATE TABLE auth_event(
description TEXT
);
success!
timestamp: 2011-04-28T17:19:26.555055
timestamp: 2011-04-29T14:08:21.600177
CREATE TABLE articles(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title CHAR(128),
Expand All @@ -59,7 +57,7 @@ CREATE TABLE articles(
user_name CHAR(512)
);
success!
timestamp: 2011-04-28T17:19:26.558177
timestamp: 2011-04-29T14:08:21.616785
CREATE TABLE comments(
id INTEGER PRIMARY KEY AUTOINCREMENT,
title CHAR(128),
Expand Down
Binary file modified databases/storage.sqlite
Binary file not shown.

0 comments on commit 7219df0

Please sign in to comment.