doc/book/en/A02c-maintemplate.en.txt
author Nicolas Chauvat <nicolas.chauvat@logilab.fr>
Sat, 22 Nov 2008 23:59:42 +0100
changeset 127 ae611743f5c6
parent 116 doc/book/en/01-06-maintemplate.en.txt@e2303f9b5bfa
child 273 5b3f9e09a6ea
permissions -rw-r--r--
[doc] divided book in parts
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     1
.. -*- coding: utf-8 -*-
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     2
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     3
Views & Templates
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 115
diff changeset
     4
-----------------
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     5
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     6
Look at ``lax/skel/ginco/web/views/basetemplates.py`` and you will
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     7
find the base templates used to generate HTML for your application.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
     8
81
f5886815126b punctuation stuff
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 74
diff changeset
     9
A page is composed as indicated on the schema below:
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    10
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    11
.. image:: images/lax-book.06-main-template-layout.en.png
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    12
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    13
In this section we will go through a couple of the primary templates
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    14
you must be interested in, that is to say, the HTMLPageHeader,
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    15
the HTMLPageFooter and the TheMainTemplate.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    16
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    17
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    18
HTMLPageHeader
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 115
diff changeset
    19
~~~~~~~~~~~~~~~
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    20
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    21
Let's use a different logo than the default one provided with LAX
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    22
and customize our header.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    23
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    24
Change logo
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 115
diff changeset
    25
```````````
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    26
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    27
The easiest way to use a different logo is to replace the existing
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    28
``logo.png`` in ``myapp/data`` by your prefered icon and refresh.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    29
By default all application will look for a ``logo.png`` to be 
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    30
rendered in the logo section.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    31
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    32
.. image:: images/lax-book.06-main-template-logo.en.png
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    33
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    34
[ADD]
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    35
customized external_resources in myapp/data cd crih for reference
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    36
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    37
[WRITE ME]
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    38
ADD how to use external_resources variables used in ginco/web/webconfig.py
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    39
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    40
Customize header
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 115
diff changeset
    41
`````````````````
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    42
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    43
Let's now move the search box in the header and remove the login form
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    44
from the header. We'll show how to move it to the left column of the application.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    45
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    46
Let's sat we do not want anymore the login menu to be in the header, but we 
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    47
prefer it to be in the left column just below the logo. As the left column is
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    48
rendered by ``TheMainTemplate``, we will show how to do it in TheMainTemplate_. 
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    49
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    50
First, to remove the login menu, we just need to comment out the display of the
81
f5886815126b punctuation stuff
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 74
diff changeset
    51
login component such as follows: ::
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    52
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    53
  class MyHTMLPageHeader(HTMLPageHeader):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    54
    
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    55
      def main_header(self, view):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    56
          """build the top menu with authentification info and the rql box"""
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    57
          self.w(u'<table id="header"><tr>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    58
          self.w(u'<td id="firstcolumn">')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    59
          self.vreg.select_component('logo', self.req, self.rset).dispatch(w=self.w)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    60
          self.w(u'</td>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    61
          # appliname and breadcrumbs
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    62
          self.w(u'<td id="headtext">')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    63
          comp = self.vreg.select_component('appliname', self.req, self.rset)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    64
          if comp and comp.propval('visible'):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    65
              comp.dispatch(w=self.w)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    66
          comp = self.vreg.select_component('breadcrumbs', self.req, self.rset, view=view)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    67
          if comp and comp.propval('visible'):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    68
              comp.dispatch(w=self.w, view=view)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    69
          self.w(u'</td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    70
          # logged user and help
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    71
          #self.w(u'<td>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    72
          #comp = self.vreg.select_component('loggeduserlink', self.req, self.rset)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    73
          #comp.dispatch(w=self.w)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    74
          #self.w(u'</td><td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    75
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    76
          self.w(u'<td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    77
          helpcomp = self.vreg.select_component('help', self.req, self.rset)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    78
          if helpcomp: # may not be available if Card is not defined in the schema
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    79
              helpcomp.dispatch(w=self.w)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    80
          self.w(u'</td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    81
          # lastcolumn
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    82
          self.w(u'<td id="lastcolumn">')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    83
          self.w(u'</td>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    84
          self.w(u'</tr></table>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    85
          self.template('logform', rset=self.rset, id='popupLoginBox', klass='hidden',
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    86
                        title=False, message=False)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    87
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    88
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    89
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    90
.. image:: images/lax-book.06-header-no-login.en.png
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    91
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    92
Let's now move the search box in the top-right header area. To do so, we will
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    93
first create a method to get the search box display and insert it in the header
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    94
table.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    95
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    96
::
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    97
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    98
 from ginco.web.views.basetemplates import HTMLPageHeader
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
    99
 class MyHTMLPageHeader(HTMLPageHeader):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   100
    def main_header(self, view):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   101
        """build the top menu with authentification info and the rql box"""
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   102
        self.w(u'<table id="header"><tr>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   103
        self.w(u'<td id="firstcolumn">')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   104
        self.vreg.select_component('logo', self.req, self.rset).dispatch(w=self.w)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   105
        self.w(u'</td>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   106
        # appliname and breadcrumbs
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   107
        self.w(u'<td id="headtext">')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   108
        comp = self.vreg.select_component('appliname', self.req, self.rset)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   109
        if comp and comp.propval('visible'):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   110
            comp.dispatch(w=self.w)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   111
        comp = self.vreg.select_component('breadcrumbs', self.req, self.rset, view=view)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   112
        if comp and comp.propval('visible'):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   113
            comp.dispatch(w=self.w, view=view)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   114
        self.w(u'</td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   115
        
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   116
        # logged user and help
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   117
        #self.w(u'<td>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   118
        #comp = self.vreg.select_component('loggeduserlink', self.req, self.rset)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   119
        #comp.dispatch(w=self.w)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   120
        #self.w(u'</td><td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   121
        
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   122
        # search box
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   123
        self.w(u'<td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   124
        self.get_searchbox(view, 'left')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   125
        self.w(u'</td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   126
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   127
        self.w(u'<td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   128
        helpcomp = self.vreg.select_component('help', self.req, self.rset)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   129
        if helpcomp: # may not be available if Card is not defined in the schema
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   130
            helpcomp.dispatch(w=self.w)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   131
        self.w(u'</td>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   132
        # lastcolumn
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   133
        self.w(u'<td id="lastcolumn">')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   134
        self.w(u'</td>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   135
        self.w(u'</tr></table>\n')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   136
        self.template('logform', rset=self.rset, id='popupLoginBox', klass='hidden',
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   137
                      title=False, message=False)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   138
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   139
    def get_searchbox(self, view, context):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   140
        boxes = list(self.vreg.possible_vobjects('boxes', self.req, self.rset,
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   141
                                                 view=view, context=context))
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   142
        if boxes:
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   143
            for box in boxes:
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   144
                if box.id == 'search_box':
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   145
                    box.dispatch(w=self.w, view=view)
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   146
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   147
 
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   148
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   149
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   150
HTMLPageFooter
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 115
diff changeset
   151
~~~~~~~~~~~~~~
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   152
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   153
If you want to change the footer for example, look
81
f5886815126b punctuation stuff
Katia Saurfelt <katia.saurfelt@logilab.fr>
parents: 74
diff changeset
   154
for HTMLPageFooter and override it in your views file as in: 
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   155
::
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   156
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   157
  form ginco.web.views.basetemplates import HTMLPageFooter
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   158
  class MyHTMLPageFooter(HTMLPageFooter):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   159
      def call(self, **kwargs):
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   160
          self.w(u'<div class="footer">')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   161
          self.w(u'This website has been created with <a href="http://lax.logilab.org">LAX</a>.')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   162
          self.w(u'</div>')
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   163
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   164
Updating a view does not require any restart of the server. By reloading
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   165
the page you can see your new page footer.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   166
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   167
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   168
TheMainTemplate
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 115
diff changeset
   169
~~~~~~~~~~~~~~~
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 115
diff changeset
   170
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   171
.. _TheMainTemplate:
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   172
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   173
The MainTemplate is a bit complex as it tries to accomodate many
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   174
different cases. We are now about to go through it and cutomize entirely
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   175
our application.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   176
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   177
TheMainTemplate is responsible for the general layout of the entire application. 
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   178
It defines the template of ``id = main`` that is used by the application. Is 
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   179
also defined in ``ginco/web/views/basetemplates.py`` another template that can
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   180
be used based on TheMainTemplate called SimpleMainTemplate which does not have 
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   181
a top section.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   182
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   183
.. image:: images/lax-book.06-simple-main-template.en.png
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   184
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   185
CSS changes
116
e2303f9b5bfa [doc] more merging and reorg
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents: 115
diff changeset
   186
~~~~~~~~~~~
74
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   187
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   188
We cannot modify the order in which the application is reading the CSS. In
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   189
the case we want to create new CSS style, the best is to define it a in a new
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   190
CSS located under ``myapp/data/``.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   191
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   192
If you want to modify an existing CSS styling property, you will have to use
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   193
``!important`` declaration to override the existing property. The application
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   194
apply a higher priority on the default CSS and you can not change that. 
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   195
Customized CSS will not be read first.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   196
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   197
[TODO]
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   198
Add login menu in left column
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   199
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   200
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   201
[WRITE ME]
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   202
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   203
* customize MainTemplate and show that everything in the user
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   204
  interface can be changed
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   205
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   206
[TODO]
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   207
Rajouter une section pour definir la terminologie utilisee.
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   208
Dans ginco-doc rajouter une section pour erudi-ctl shell ou
9a9fe515934d [doc] reuse the lax book
Nicolas Chauvat <nicolas.chauvat@logilab.fr>
parents:
diff changeset
   209
on liste les commandes dispos.