*.sqlite3
*~
all-static/
-DataTables-1.9.4/
+all-templates/
#################### compute emacs tags
# list files under git but exclude third-party stuff like bootstrap and jquery
myfiles: force
- @git ls-files | egrep -v 'insert(_|-)above|static/bootstrap|/jquery/|datatables/'
+ @git ls-files | egrep -v 'insert(_|-)above|/third-party/|/play/'
# in general it's right to rely on the contents as reported by git
tags: force
ftags: force
find . -type f | fgrep -v '/.git/' | xargs etags
-list-html: force
- @find . -type f -name '*.html'
-list-js: force
- @find . -type f -name '*.js' | grep -v '/all-static/'
-list-css: force
- @find . -type f -name '*.css' | grep -v '/all-static/'
-list-img: force
- @find . -type f -name '*.png' | grep -v '/all-static/'
+#################### third-party layout is kind of special
+# because we have differents versions and all
+THIRD-PARTY-RESOURCES =
+# ignore variants, use the main symlink third-party/bootstrap
+THIRD-PARTY-RESOURCES += $(shell ls third-party/bootstrap/*/*)
+# just the single js as identified with a symlink
+THIRD-PARTY-RESOURCES += $(shell ls third-party/datatables/js/dataTables.js)
+# likewise
+THIRD-PARTY-RESOURCES += $(shell ls third-party/jquery/js/jquery.js)
+# spin comes in plain or min, + the jquery plugin, and our own settings
+THIRD-PARTY-RESOURCES += $(shell ls third-party/spin/*.js)
-list-all list-resources: list-html list-js list-css list-img
+thirdparty-js:
+ @find $(THIRD-PARTY-RESOURCES) -name '*.js'
+thirdparty-css:
+ @find $(THIRD-PARTY-RESOURCES) -name '*.css'
+thirdparty-img:
+ @find $(THIRD-PARTY-RESOURCES) -name '*.png'
+
+# we might have any of these as templates - e.g. ./engine/templates/plugin-setenv.js
+# so if there's a /templates/ in the path ignore the file
+other-js: force
+ @find . -type f -name '*.js' | egrep -v '/all-(static|templates)/|/third-party/|/templates/'
+other-css: force
+ @find . -type f -name '*.css' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
+other-img: force
+ @find . -type f -name '*.png' | egrep -v 'all-(static|templates)/|/third-party/|/templates/'
+
+list-js: thirdparty-js other-js
+list-css: thirdparty-css other-css
+list-img: thirdparty-img other-img
+
+# having templates in a templates/ subdir is fine most of the time except for plugins
+list-templates: force
+ @find plugins -type f -name '*.html'
#################### manage static contents (extract from all the modules into the single all-static location)
-static: force
- ./manage.py collectstatic --noinput
+static run-static static-run: force
+ mkdir -p ./all-static/js all-static/css all-static/img
+ ln -sf $(foreach x,$(shell $(MAKE) list-js),../../$(x)) ./all-static/js
+ ln -sf $(foreach x,$(shell $(MAKE) list-css),../../$(x)) ./all-static/css
+ ln -sf $(foreach x,$(shell $(MAKE) list-img),../../$(x)) ./all-static/img
+# rsync -av $(shell $(MAKE) list-js) ./all-static/js
+# rsync -av $(shell $(MAKE) list-css) ./all-static/css
+# rsync -av $(shell $(MAKE) list-img) ./all-static/img
+
+clean-static static-clean: force
+ rm -rf ./all-static
+
+all-static: clean-static run-static
+
+#################### manage templates for the plugin area
+templates run-templates templates-run: force
+ mkdir -p all-templates
+ ln -sf $(foreach x,$(shell $(MAKE) list-templates),.../$(x)) ./all-templates
+# rsync -av $(shell $(MAKE) list-templates) ./all-templates
+
+clean-templates templates-clean: force
+ rm -rf ./all-templates
-clean-static: force
- rm -rf ./all-static/
+all-templates: clean-templates run-templates
-allst: clean-static static
+####################
+list-all list-resources: list-templates list-js list-css list-img
#################### sync : push current code on a (devel) box running myslice
SSHURL:=root@$(MYSLICEBOX):/
### rsync options
# the config file should probably not be overridden ??
# --exclude settings.py
-LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc' --exclude devel --exclude DataTables-1.9.4 --exclude all-static --exclude '*.sqlite3'
+LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc' --exclude config.py --exclude all-static --exclude all-templates --exclude '*.sqlite3'
# usual excludes
RSYNC_EXCLUDES := --exclude .git --exclude '*~' --exclude TAGS --exclude .DS_Store $(LOCAL_RSYNC_EXCLUDES)
# make -n will propagate as rsync -n
RSYNC := rsync -a -v $(RSYNC_COND_DRY_RUN) $(RSYNC_EXCLUDES)
# xxx until we come up with a packaging this is going to be a wild guess
+# on debian04 I have stuff in /usr/share/myslice and a symlink in /root/myslice
#INSTALLED=/usr/share/myslice
INSTALLED=/root/myslice
-This file documents the contents of this module
+his file documents the contents of this module
See the devel/ subdir for more devel-oriented doc.
* init django
$ manage.py syncdb
-[[ at this point point it *might* be needed to run
-$ make allst
- but as far as running a local server is concerned you should be good without that
- feedback on this is appreciated]]
+
+* gather static files
+$ make static
* run a local server:
$ manage.py runserver 0.0.0.0:8000
+-- or -- my advice:
+$ devel/server-loop.sh
+when you just need to hit ^C yourself when your static files need to be refreshed - see below
* use it from your browser
+.......... NOTES on using the development server
+. first off, running manage.py runserver is provided by django as a development convenience but SHOULD NOT be used in production
+. second, when you do use it for developement purposes, please be aware that:
+.. the recommended layout for the various files and pieces (py, html, js and css) qith django is really painful
+ we should use e.g. plugins/simplelist.py, plugins/templates/plugins.html, plugins/static/js/simplelist.js and plugins/static/css/simplelist.css
+.. as that does not make sense IMHO, I've rewritten the tool for gathering these pieces in such a layout but from a completely flat codebase
+ I mean I want to be able to store all the files building a plugin in a single (git) directory
+ Of course it's a completely different matter once the service is packaged and installed, these files of course get properly separated.
+.. as a result it is a little bit less convenient to use the development server
+ when you change the layout of your static and template files, you might need to re-run 'make static', so it is recommended to use
+ devel/server-loop.sh instead
+
==================== Status
* insert_above:
a third-party django app for adding on-the-fly mentions to css or js files that need to go in the header
-* templates/
- * some global templates (django templates, i.e. (essentially html) fragments that can be specializied)
- more on this below
+* trash/
+ rough/preliminary views in here - as the name suggests this is temporary
-* static/
+* views/
+ will receive actual views over time
+ currently has some global html templates as well
+
+* third-party/
* third party stuff (bootstrapfs, jquery, datatables)
* + some global static files (css, js, images..)
see more about that below too
========== automatically generated
* all-static: (generated, no need to source-control)
- this is where 'manage.py collectstatic' will gather all your static contents if you run a local server
+ this is where 'make static' will gather all your static contents if you run a local server
make has convenience targets to refresh this area
- $ make clean-static
$ make static
+ $ make clean-static
* myslice.sqlite3
this is where django stores its own stuff, as per settings.py
-
-==================== conventions for templates and static
+==================== conventions for templates
* templates:
we store this under templates/ within the corresponding app, e.g.
auth/templates/login.html
- for now this is mostly about html, but the engine can be used for rendering anything including js(on) or whatever..
+ for now this is mostly about html, but the engine can be used for rendering anything
+ including js(on) or whatever..
+
+==================== conventions for static files
* static files:
we chose to have all static files (images, but also javascript and stylesheets) in the various
hostname | grep -q '^z' && port=8080 || port=80
[[ -n "$@" ]] && port=$1
+make all-static all-templates
while true; do
./manage.py runserver 0.0.0.0:$port
+ make static templates
done
DEVELOPER_ROOT=os.path.expanduser("~/git/myslice-django")
-PRODUCTION_ROOT="/root/myslice"
+PRODUCTION_ROOT="/usr/share/myslice"
####################
ADMINS = (
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
-STATIC_ROOT = os.path.join(ROOT,'all-static')
+STATIC_ROOT = os.path.join(ROOT,'django-static')
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
- os.path.join(ROOT,'static'),
+ os.path.join(ROOT,'all-static'),
)
# List of finder classes that know how to find static files in
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
- os.path.join(ROOT,"templates"),
+ os.path.join(ROOT,"all-templates"),
)
INSTALLED_APPS = (
'auth',
'engine',
'plugins',
+ 'views',
'trash',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
class Tabs (Composite):
def requirements (self):
- return { 'js_files' : 'bootstrap/js/bootstrap.js',
- 'css_files' : ['bootstrap/css/bootstrap.css',
- 'css/tabs.css',
- ] }
+ return { 'js_files' : 'js/bootstrap.js',
+ 'css_files' : ['css/bootstrap.css', 'css/tabs.css', ]
+ }
def template_file (self):
return "tabs.html"
@login_required
def tab_view (request):
- prelude=Prelude( js_files='bootstrap/js/bootstrap.js', css_files='bootstrap/css/bootstrap.css')
+ prelude=Prelude( js_files='js/bootstrap.js', css_files='css/bootstrap.css')
prelude_env = prelude.template_env()
tab_env = {'title':'Page for playing with Tabs',
'topmenu_items': topmenu_items('tab',request),
<style type="text/css">{# In case we need to add raw css code #}{% container prelude_css %}</style>
{{ header_prelude }}
</head>{# let's add these ones no matter what #}
-{% insert_str prelude "jquery/js/jquery.js" %}
+{% insert_str prelude "js/jquery.js" %}
{# {% insert prelude_js %} jQuery.noConflict(); {% endinsert %} #}
{% insert_str prelude "js/plugin-init.js" %}
{% insert_str prelude "css/myslice.css" %}
{# <a id='menu_logo' href="/"><img class="logo" src="{{ STATIC_URL }}img/myslice-logo.png" alt="MySlice" /></a> #}
-{% insert_str prelude "bootstrap/js/bootstrap.js" %}
-{% insert_str prelude "bootstrap/css/bootstrap.css" %}
+{% insert_str prelude "js/bootstrap.js" %}
+{% insert_str prelude "css/bootstrap.css" %}
{% insert_str prelude "css/topmenu.css" %}
<div id='topmenu' class="navbar navbar-fixed-top">