very rough layout with header/content-main/content-related
authorThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 27 Nov 2012 20:29:22 +0000 (21:29 +0100)
committerThierry Parmentelat <thierry.parmentelat@inria.fr>
Tue, 27 Nov 2012 20:29:22 +0000 (21:29 +0100)
14 files changed:
Makefile
README [new file with mode: 0644]
auth/templates/login.html [moved from auth/templates/auth.html with 100% similarity]
auth/views.py
myslice/static/css/mymenu.css
myslice/static/css/myslice.css [new file with mode: 0644]
myslice/static/img/myslice-logo.png
myslice/templates/mymenu.html
myslice/templates/myslice-base.html [deleted file]
myslice/templates/myslice.html [new file with mode: 0644]
myslice/urls.py
slice/templates/slice.html
slice/views.py
templates/myslice.html [deleted file]

index 80fcc4f..d18ae06 100644 (file)
--- 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 (file)
index 0000000..a956b99
--- /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..
+
+
+
index 3004c2e..11f773b 100644 (file)
@@ -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))
index cddbfe8..06e3781 100644 (file)
@@ -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 (file)
index 0000000..4173ccc
--- /dev/null
@@ -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;
+}
index f6b5de4..74413e5 100644 (file)
Binary files a/myslice/static/img/myslice-logo.png and b/myslice/static/img/myslice-logo.png differ
index 990b6a7..d19b19d 100644 (file)
@@ -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 #}
 
-<img class="logo" src="{{ STATIC_URL }}img/myslice-logo.png" alt="MySlice" />
+<div id='mymenu'>
 <ul id='mymenu'>
+<li>
+  <a href="/"><img class="logo mymenu" src="{{ STATIC_URL }}img/myslice-logo.png" alt="MySlice" /></a>
+</li>
 {% for d in menu_items %}
+  {% if d.current %}
+  <li class='current'> <a href="{{ d.href }}"> {{ d.label }} </a> </li>
+  {% else %}
   <li class='other'> <a href="{{ d.href }}"> {{ d.label }} </a> </li>
-{% endfor %}
+  {% endif %}
+  {% endfor %}
 </ul>
+</div>
 
diff --git a/myslice/templates/myslice-base.html b/myslice/templates/myslice-base.html
deleted file mode 100644 (file)
index 26dda51..0000000
+++ /dev/null
@@ -1,37 +0,0 @@
-{# This is required by insert_above #}
-{% insert_handler %}
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html> <head>
-<title> MySlice - slice page with python var foo = {{ foo }} </title>
-{# This is where insert_str will end up #}
-{% media_container prelude %}
-<script>
-{% container raw_js %}
-</script>
-<style>
-{% container raw_css %}
-</style>
-</head>
-
-{# let's add this one no matter what #}
-{% insert_str prelude "css/miscell.css" %}
-
-<body>
-{% block menu %} <div class='menu'> {{ menu }} </div> {% endblock %}
-
-{% block left %}
-<div class='left'>
-  {{ left|default:"The left area" }}
-</div>
-{% endblock %}
-
-{% block main %}
-<div class='main'>  <h1>Again, python var foo = {{ foo }} </h1>
-  {{ main }}
-</div>
-<hr>
-{% block content %} and more stuff if needed {% endblock %}
-{% endblock %}
-
-</body>
-</html>
diff --git a/myslice/templates/myslice.html b/myslice/templates/myslice.html
new file mode 100644 (file)
index 0000000..1a49a39
--- /dev/null
@@ -0,0 +1,53 @@
+{# This is required by insert_above #}
+{% insert_handler %}
+<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
+<html> <head>
+<title> MySlice - slice page with python var foo = {{ foo|default:"foo is undefined"}} </title>
+{# This is where insert_str will end up #}
+{% media_container prelude %}
+<script type="text/javascript">
+{# In case we need to add raw js code #}
+{% container raw_js %}
+</script>
+<style type="text/css">
+{# In case we need to add raw css code #}
+{% container raw_css %}
+</style>
+</head>
+
+{# let's add this one no matter what #}
+{% insert_str prelude "css/myslice.css" %}
+{% insert_str prelude "css/miscell.css" %}
+
+<body>
+
+{% block container %}
+<div id='container'>
+
+    <div id='header'>
+    {% block header %}
+      {% include 'mymenu.html' %}
+    {% endblock header %}
+    </div>
+
+    {% block column_wrap %}
+    <div id='column-wrap'>
+    <div id='content-main'>
+      {% block content_main %}
+      "The main content area (set block 'content_main')"
+      {% endblock content_main %}
+    </div>
+
+    <div id='content-related'>
+      {% block content_related %}
+      "The related content area (set block 'related_main')"
+      {% endblock content_related %}
+    </div>
+    </div>
+    {% endblock column_wrap %}
+
+</div>
+{% endblock container %}
+
+</body>
+</html>
index 21681ea..91c8145 100644 (file)
@@ -22,4 +22,5 @@ urlpatterns = patterns(
     (r'^login/?$', 'auth.views.login_user'),
     (r'^slice/?$', 'slice.views.fake_view'),
     (r'^slice/(?P<name>\w+)/?$', 'slice.views.fake_view'),
+    (r'^sample/?$', 'slice.views.sample'),
 )
index 3ca50c8..2d4aa33 100644 (file)
@@ -1,10 +1,7 @@
-{% extends 'myslice-base.html' %}
+{% extends 'myslice.html' %}
 
 {% block content %}
 <p>The URL variable name= {{ name }} </p>
 {{ content_string|safe }}
 {% endblock content %}
 
-{% block menu %}
-{% include 'mymenu.html' %}
-{% endblock menu %}
index e55e06e..8eefd1d 100644 (file)
@@ -19,3 +19,11 @@ Lorem <span class='bold'>ipsum dolor</span> 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 (file)
index ff08592..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
-<html> <head>
-<title> {{ title }} </title>
-{{ 
-</head>
-
-<body>
-<div class='wrapper'>
-
-  <div class='top'> 
-  {% block top %}
-        <div class="header">
-          <a href="/" alt="Home"><img class="logo" src="{{ STATIC_URL }}myslice-logo.png" alt="MySlice" /></a>
-        </div>
-  {% endblock top %}
-  </div>
-  <div class='menubar'> 
-  {% block menubar %}
-    <h1> Empty menubar for now </h1>
-  {% endblock menubar %}
-  </div>
-  <div class='centered content'> 
-  {% block content %}
-    Welcome...
-  {% endblock content %}
-  </div>
-</div>
-</body> </html>