From: Thierry Parmentelat Date: Tue, 27 Nov 2012 20:29:22 +0000 (+0100) Subject: very rough layout with header/content-main/content-related X-Git-Tag: myslice-django-0.1-1~188 X-Git-Url: http://git.onelab.eu/?p=myslice.git;a=commitdiff_plain;h=b743d1af89ac416e7905a2b86c1749530e5829c8 very rough layout with header/content-main/content-related --- diff --git a/Makefile b/Makefile index 80fcc4f1..d18ae06d 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,10 @@ -all: tags +### +all: + @echo no default target force: +#################### compute emacs tags # in general it's right to rely on the contents as reported by git tags: force git ls-files | xargs etags @@ -10,8 +13,46 @@ tags: force ftags: force find . -type f | fgrep -v '/.git/' | xargs etags +#################### manage static contents (extract from all the modules into the single all-static location) static: force ./manage.py collectstatic --noinput clean-static: force rm -rf ./all-static/ + +#################### sync : push current code on a (devel) box running myslice +SSHURL:=root@$(MYSLICEBOX):/ +SSHCOMMAND:=ssh root@$(MYSLICEBOX) + +### rsync options +# the config file should probably not be overridden +LOCAL_RSYNC_EXCLUDES := --exclude '*.pyc' --exclude settings.py --exclude devel +# usual excludes +RSYNC_EXCLUDES := --exclude .git --exclude '*~' --exclude TAGS --exclude .DS_Store $(LOCAL_RSYNC_EXCLUDES) +# make -n will propagate as rsync -n +RSYNC_COND_DRY_RUN := $(if $(findstring n,$(MAKEFLAGS)),--dry-run,) +# putting it together +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 +INSTALLED=/usr/share/myslice + +sync: +ifeq (,$(MYSLICEBOX)) + @echo "you need to set MYSLICEBOX, like in e.g." + @echo " $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@"" + @exit 1 +else + +$(RSYNC) ./ $(SSHURL)/$(INSTALLED)/ +endif + +# xxx likewise until we run this under apache it's probably hard to restart from here +restart: +ifeq (,$(MYSLICEBOX)) + @echo "you need to set MYSLICEBOX, like in e.g." + @echo " $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@"" + @exit 1 +else + @echo "$@" target not yet implemented; exit; @$(SSHCOMMAND) /etc/init.d/apache2 restart +endif + diff --git a/README b/README new file mode 100644 index 00000000..a956b99a --- /dev/null +++ b/README @@ -0,0 +1,46 @@ +The contents of this module: + +==================== 1st level subdirs +* myslice: + this is the sjango project', where to look for + . settings + . urls + . common static files + +* 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 + much like our past drupal_set_html_head() + +* auth: + a django 'app' that deals with authentication + +* slice: + a django app for dealing with slice views + +* devel: + only for various notes and other utiliy scripts + +* 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 + make has convenience targets to refresh this area + $ make clean-static + $ make static +==================== conventions + +* templates: + we store this under templates/ within the corresponding app, e.g. + auth/templates/login.html + for now this is only about html, but the engine can be used for rendering anything including json or whatever.. + +* static files: + we chose to have all static files (images, but also javascript and stylesheets) in the various + proj or app where they belong, under a static/ subdir that has this structure: + where-it-belongs/ + static/ + img/ + css/ + js/ + the stuff I have so far is in myslice/ because it looks common to all apps.. + + + diff --git a/auth/templates/auth.html b/auth/templates/login.html similarity index 100% rename from auth/templates/auth.html rename to auth/templates/login.html diff --git a/auth/views.py b/auth/views.py index 3004c2eb..11f773bb 100644 --- a/auth/views.py +++ b/auth/views.py @@ -21,5 +21,5 @@ def login_user(request): else: state = "Your username and/or password were incorrect." - return render_to_response('auth.html',{'state':state, 'username': username}, + return render_to_response('login.html',{'state':state, 'username': username}, context_instance=RequestContext(request)) diff --git a/myslice/static/css/mymenu.css b/myslice/static/css/mymenu.css index cddbfe8e..06e37819 100644 --- a/myslice/static/css/mymenu.css +++ b/myslice/static/css/mymenu.css @@ -1,8 +1,23 @@ -ul#mymenu { +ul#mymenu { display: block; } +ul#mymenu>li { display: block; + float: left; + padding: 5px; +} + +/* +div.mymenu { position: fixed; display: block; padding:0; margin:0; - bottom: 10px; + top: 10px; right: 10px; + background-color: #abc; +} + +ul.mymenu { + list-style-type: none; + margin: 0; + padding: 0; } +*/ diff --git a/myslice/static/css/myslice.css b/myslice/static/css/myslice.css new file mode 100644 index 00000000..4173ccc4 --- /dev/null +++ b/myslice/static/css/myslice.css @@ -0,0 +1,28 @@ +#header { + position: fixed; + display: block; + margin:0; + top: 0px; + left: 0px; + right: 0px; + height: 60px; + background-color: #fc9; +} + +#column-wrap { + margin-top: 60px; + display: table; + table-layout: fixed; + border-collapse: collapse; +} +#content-main, #content-related { + display: table-cell; + position: static; + padding: 10px; +} +#content-main { + width: 100%; +} +#content-related { + width: 200px; +} diff --git a/myslice/static/img/myslice-logo.png b/myslice/static/img/myslice-logo.png index f6b5de4f..74413e51 100644 Binary files a/myslice/static/img/myslice-logo.png and b/myslice/static/img/myslice-logo.png differ diff --git a/myslice/templates/mymenu.html b/myslice/templates/mymenu.html index 990b6a77..d19b19d1 100644 --- a/myslice/templates/mymenu.html +++ b/myslice/templates/mymenu.html @@ -1,13 +1,21 @@ {% insert_str prelude "js/mymenu.js" %} {% insert_str prelude "css/mymenu.css" %} {# this shows how to add raw js code #} -{% insert raw_js %} "some script useful for mymenu" {% endinsert %} +{# {% insert raw_js %} "some script useful for mymenu" {% endinsert %} #} {# use the raw_css container for css style #} - +
+
diff --git a/myslice/templates/myslice-base.html b/myslice/templates/myslice-base.html deleted file mode 100644 index 26dda516..00000000 --- a/myslice/templates/myslice-base.html +++ /dev/null @@ -1,37 +0,0 @@ -{# This is required by insert_above #} -{% insert_handler %} - - - MySlice - slice page with python var foo = {{ foo }} -{# This is where insert_str will end up #} -{% media_container prelude %} - - - - -{# let's add this one no matter what #} -{% insert_str prelude "css/miscell.css" %} - - -{% block menu %} {% endblock %} - -{% block left %} -
- {{ left|default:"The left area" }} -
-{% endblock %} - -{% block main %} -

Again, python var foo = {{ foo }}

- {{ main }} -
-
-{% block content %} and more stuff if needed {% endblock %} -{% endblock %} - - - diff --git a/myslice/templates/myslice.html b/myslice/templates/myslice.html new file mode 100644 index 00000000..1a49a393 --- /dev/null +++ b/myslice/templates/myslice.html @@ -0,0 +1,53 @@ +{# This is required by insert_above #} +{% insert_handler %} + + + MySlice - slice page with python var foo = {{ foo|default:"foo is undefined"}} +{# This is where insert_str will end up #} +{% media_container prelude %} + + + + +{# let's add this one no matter what #} +{% insert_str prelude "css/myslice.css" %} +{% insert_str prelude "css/miscell.css" %} + + + +{% block container %} +
+ + + + {% block column_wrap %} +
+
+ {% block content_main %} + "The main content area (set block 'content_main')" + {% endblock content_main %} +
+ + +
+ {% endblock column_wrap %} + +
+{% endblock container %} + + + diff --git a/myslice/urls.py b/myslice/urls.py index 21681ea0..91c81457 100644 --- a/myslice/urls.py +++ b/myslice/urls.py @@ -22,4 +22,5 @@ urlpatterns = patterns( (r'^login/?$', 'auth.views.login_user'), (r'^slice/?$', 'slice.views.fake_view'), (r'^slice/(?P\w+)/?$', 'slice.views.fake_view'), + (r'^sample/?$', 'slice.views.sample'), ) diff --git a/slice/templates/slice.html b/slice/templates/slice.html index 3ca50c87..2d4aa335 100644 --- a/slice/templates/slice.html +++ b/slice/templates/slice.html @@ -1,10 +1,7 @@ -{% extends 'myslice-base.html' %} +{% extends 'myslice.html' %} {% block content %}

The URL variable name= {{ name }}

{{ content_string|safe }} {% endblock content %} -{% block menu %} -{% include 'mymenu.html' %} -{% endblock menu %} diff --git a/slice/views.py b/slice/views.py index e55e06e8..8eefd1d3 100644 --- a/slice/views.py +++ b/slice/views.py @@ -19,3 +19,11 @@ Lorem ipsum dolor sit amet, consectetuer adipiscing el context_instance=RequestContext(request)) return result + +def sample (request): + return render_to_response ('sample.html', + { 'menu_items': + [ { 'label':'Some label', 'href': '/url1/','current':True, }, + { 'label':'Another topic ', 'href': '/other/'}, + ]}, + context_instance=RequestContext(request)) diff --git a/templates/myslice.html b/templates/myslice.html deleted file mode 100644 index ff08592e..00000000 --- a/templates/myslice.html +++ /dev/null @@ -1,28 +0,0 @@ - - - {{ title }} -{{ - - - -
- -
- {% block top %} -
- -
- {% endblock top %} -
- -
- {% block content %} - Welcome... - {% endblock content %} -
-
-