Merge Request #52

Merged
softwarepublico/colab!52
Created by Carlos Coêlho

Extract header and footer from base

Milestone: None

Merged by Sergio Oliveira

Source branch has been removed
Commits (3)
5 participants
colab/settings.py
@@ -222,14 +222,6 @@ AUTHENTICATION_BACKENDS = ( @@ -222,14 +222,6 @@ AUTHENTICATION_BACKENDS = (
222 'colab.accounts.auth.ColabBrowserIDBackend', 222 'colab.accounts.auth.ColabBrowserIDBackend',
223 ) 223 )
224 224
225 -STATICFILES_DIRS = (  
226 - os.path.join(BASE_DIR, 'static'),  
227 -)  
228 -  
229 -TEMPLATE_DIRS = (  
230 - os.path.join(BASE_DIR, 'templates'),  
231 -)  
232 -  
233 LOCALE_PATHS = ( 225 LOCALE_PATHS = (
234 os.path.join(BASE_DIR, 'locale'), 226 os.path.join(BASE_DIR, 'locale'),
235 ) 227 )
@@ -317,8 +309,16 @@ for app_name, app in COLAB_APPS.items(): @@ -317,8 +309,16 @@ for app_name, app in COLAB_APPS.items():
317 if context_processor not in TEMPLATE_CONTEXT_PROCESSORS: 309 if context_processor not in TEMPLATE_CONTEXT_PROCESSORS:
318 TEMPLATE_CONTEXT_PROCESSORS += (context_processor,) 310 TEMPLATE_CONTEXT_PROCESSORS += (context_processor,)
319 311
320 -colab_templates = locals().get('COLAB_TEMPLATES') or {}  
321 -colab_statics = locals().get('COLAB_STATICS') or {} 312 +colab_templates = locals().get('COLAB_TEMPLATES') or ()
  313 +colab_statics = locals().get('COLAB_STATICS') or []
322 314
323 -TEMPLATE_DIRS += tuple(colab_templates)  
324 -STATICFILES_DIRS += tuple(colab_statics) 315 +TEMPLATE_DIRS = tuple(colab_templates)
  316 +STATICFILES_DIRS = list(colab_statics)
  317 +
  318 +STATICFILES_DIRS += [
  319 + os.path.join(BASE_DIR, 'static'),
  320 +]
  321 +
  322 +TEMPLATE_DIRS += (
  323 + os.path.join(BASE_DIR, 'templates'),
  324 +)
colab/templates/base.html
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 -{% load i18n browserid conversejs gravatar plugins %} 2 +{% load i18n browserid conversejs gravatar %}
3 {% load static from staticfiles %} 3 {% load static from staticfiles %}
4 4
5 <html> 5 <html>
@@ -54,7 +54,7 @@ @@ -54,7 +54,7 @@
54 </head> 54 </head>
55 55
56 <!-- data-no-turbolink will disable Rails TurboLinks for all pages under Colab --> 56 <!-- data-no-turbolink will disable Rails TurboLinks for all pages under Colab -->
57 - <body class="container" data-no-turbolink> 57 + <body data-no-turbolink>
58 {% if BROWSERID_ENABLED %} 58 {% if BROWSERID_ENABLED %}
59 {% browserid_info %} 59 {% browserid_info %}
60 {% endif %} 60 {% endif %}
@@ -70,94 +70,8 @@ @@ -70,94 +70,8 @@
70 {% endblock %} 70 {% endblock %}
71 71
72 {% block navbar %} 72 {% block navbar %}
73 - <nav class="navbar navbar-default navbar-fixed-top" role="navigation">  
74 - <div class="container">  
75 - <div class="navbar-header">  
76 -  
77 - <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main">  
78 - <span class="sr-only">Toggle navigation</span>  
79 - <span class="icon-bar"></span>  
80 - <span class="icon-bar"></span>  
81 - <span class="icon-bar"></span>  
82 - <span class="icon-bar"></span>  
83 - </button>  
84 - <a class="navbar-brand" href="/"><img alt="Colab" src="{% static 'img/logo.svg' %}"></a>  
85 - </div>  
86 - <div class="collapse navbar-collapse navbar-main">  
87 - <ul class="nav navbar-nav">  
88 -  
89 - <li>  
90 - <a href="{% url 'thread_list' %}">{% trans "Groups" %}</a>  
91 - </li>  
92 -  
93 - {% plugins_menu %}  
94 -  
95 - <li class="hidden-lg hidden-md">  
96 - <a href="{% url 'haystack_search' %}?q=">{% trans "Search" %}</a>  
97 - </li>  
98 - </ul>  
99 -  
100 - <ul class="nav navbar-nav navbar-right">  
101 - {% if not user.is_authenticated %}  
102 -  
103 - <li class="dropdown hidden-xs hidden-lg">  
104 - <a href="#" class="dropdown-toggle" data-toggle="dropdown">Acesso <b class="caret"></b></a>  
105 - <ul class="dropdown-menu">  
106 - {% trans 'Login' as login_text %}  
107 - {% if BROWSERID_ENABLED %}  
108 - <li>{% browserid_login text=login_text %}</li>  
109 - {% else %}  
110 - <li><a href="{% url 'signup' %}">{% trans "Register" %}</a></li>  
111 - <li><a href="{% url 'login' %}">{% trans "Login" %}</a></li>  
112 - {% endif %}  
113 - </ul>  
114 - </li>  
115 - {% trans 'Login' as login_text %}  
116 - {% if BROWSERID_ENABLED %}  
117 - <li class="visible-xs hidden-sm hidden-md">{% browserid_login text=login_text %}</li>  
118 - {% else %}  
119 - <li class="visible-xs hidden-sm hidden-md"><a href="{% url 'signup' %}">{% trans "Register" %}</a></li>  
120 - <li class="visible-xs hidden-sm hidden-md"><a href="{% url 'login' %}">{% trans "Login" %}</a></li>  
121 - {% endif %}  
122 - {% else %}  
123 - <li id="user-menu" class="dropdown">  
124 - <a href="#" class="dropdown-toggle user" data-toggle="dropdown">{% gravatar user.email 40 %} <b class="caret"></b>&nbsp;&nbsp;</a>  
125 - <ul class="dropdown-menu" role="menu">  
126 - <li>  
127 - <div class="wrapper">  
128 - <div class="thumbnail">{% gravatar user.email 100 %}</div>  
129 - <div class="user-info">  
130 - <span><b>{{ user.get_full_name }}</b></span>  
131 - <span class="quiet">{{ user.email }}</span>  
132 - </div>  
133 - <div>  
134 - <a class="btn btn-info pull-left" href="{% url 'user_profile' user.username %}">{% trans "My Profile" %}</a>  
135 - {% trans 'Logout' as logout_text %}  
136 - {% if BROWSERID_ENABLED %}  
137 - {% browserid_logout text=logout_text link_class='btn btn-default pull-right' %}  
138 - {% else %}  
139 - <a class="btn btn-default pull-right" href="{% url 'logout' %}"> {% trans "Logout" %}</a>  
140 - {% endif %}  
141 - </div>  
142 - </div>  
143 - </li>  
144 - </ul>  
145 - </li>  
146 - {% endif %}  
147 - </ul>  
148 -  
149 - <form action="{% url 'haystack_search' %}" method="GET" id="search-form" class="navbar-form navbar-right hidden-xs hidden-sm" role="search">  
150 - <div class="form-group">  
151 - <label class="sr-only" for="header-searchbox">{% trans 'Search here...' %}</label>  
152 - <input name="q" id="header-searchbox"  
153 - class="form-control" value="{{ request.GET.q }}"  
154 - type="search" placeholder="{% trans 'Search here...' %}" />  
155 - </div>  
156 - <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>  
157 - </form>  
158 - </div>  
159 - </div>  
160 - </nav> 73 +
  74 + {% include "header.html" %}
161 75
162 {% endblock %} 76 {% endblock %}
163 77
@@ -181,29 +95,16 @@ @@ -181,29 +95,16 @@
181 </div> 95 </div>
182 {% endblock %} 96 {% endblock %}
183 97
184 - <div id="main-content"> 98 + <div id="main-content" class="container">
185 {% block main-content %}{% endblock %} 99 {% block main-content %}{% endblock %}
186 </div> 100 </div>
187 101
188 <div class="row">&nbsp;</div> 102 <div class="row">&nbsp;</div>
189 103
190 {% block footer %} 104 {% block footer %}
191 - <div class="footer row">  
192 - {% if user.is_staff %}  
193 - <p class="col-lg-12 text-center">{% trans "Last email imported at" %} {{ last_imported_message.received_time|date:'DATETIME_FORMAT' }}</p>  
194 - {% endif %}  
195 - <p class="col-lg-12 text-center">  
196 - <a href="{% url 'opendata' %}"><img src="{% static 'img/opendata3.png' %}"/></a>  
197 - <a href="http://creativecommons.org/licenses/by-sa/4.0/deed.pt_BR"><img src="{% static 'img/cc_by_sa.png' %}"/></a>  
198 - </p>  
199 - <p class="col-lg-12 text-center">  
200 - {% trans "The contents of this site is published under license" %}:  
201 - <br>  
202 - <a href="http://creativecommons.org/licenses/by-sa/4.0/deed.pt_BR">  
203 - {% trans "Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual" %}.  
204 - </a>  
205 - </p>  
206 - </div> 105 +
  106 + {% include "footer.html" %}
  107 +
207 {% endblock %} 108 {% endblock %}
208 109
209 {% if not is_mobile %} 110 {% if not is_mobile %}
colab/templates/footer.html 0 → 100644
@@ -0,0 +1,19 @@ @@ -0,0 +1,19 @@
  1 +{% load i18n browserid conversejs gravatar %}
  2 +{% load static from staticfiles %}
  3 +
  4 +<div class="footer row">
  5 + {% if user.is_staff %}
  6 + <p class="col-lg-12 text-center">{% trans "Last email imported at" %} {{ last_imported_message.received_time|date:'DATETIME_FORMAT' }}</p>
  7 + {% endif %}
  8 + <p class="col-lg-12 text-center">
  9 + <a href="{% url 'opendata' %}"><img src="{% static 'img/opendata3.png' %}"/></a>
  10 + <a href="http://creativecommons.org/licenses/by-sa/4.0/deed.pt_BR"><img src="{% static 'img/cc_by_sa.png' %}"/></a>
  11 + </p>
  12 + <p class="col-lg-12 text-center">
  13 + {% trans "The contents of this site is published under license" %}:
  14 + <br>
  15 + <a href="http://creativecommons.org/licenses/by-sa/4.0/deed.pt_BR">
  16 + {% trans "Creative Commons 4.0 Brasil - Atribuir Fonte - Compartilhar Igual" %}.
  17 + </a>
  18 + </p>
  19 +</div>
colab/templates/header.html 0 → 100644
@@ -0,0 +1,100 @@ @@ -0,0 +1,100 @@
  1 +{% load i18n browserid conversejs gravatar plugins %}
  2 +{% load static from staticfiles %}
  3 +
  4 +<nav class="navbar navbar-default navbar-fixed-top" role="navigation">
  5 + <div class="container">
  6 + <div class="navbar-header">
  7 +
  8 + <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-main">
  9 + <span class="sr-only">Toggle navigation</span>
  10 + <span class="icon-bar"></span>
  11 + <span class="icon-bar"></span>
  12 + <span class="icon-bar"></span>
  13 + <span class="icon-bar"></span>
  14 + </button>
  15 + <a class="navbar-brand" href="/"><img alt="Colab" src="{% static 'img/logo.svg' %}"></a>
  16 + </div>
  17 + <div class="collapse navbar-collapse navbar-main">
  18 + <ul class="nav navbar-nav">
  19 +
  20 + <li>
  21 + <a href="{% url 'thread_list' %}">{% trans "Groups" %}</a>
  22 + </li>
  23 +
  24 + {% if feedzilla %}
  25 + <li>
  26 + <a href="{% url "feedzilla_index" %}">{% trans "Blogs" %}</a>
  27 + </li>
  28 + {% endif %}
  29 +
  30 + {% plugins_menu %}
  31 +
  32 + <li><a href="/paste">{% trans "Paste" %}</a></li>
  33 +
  34 + <li class="hidden-lg hidden-md">
  35 + <a href="{% url 'haystack_search' %}?q=">{% trans "Search" %}</a>
  36 + </li>
  37 + </ul>
  38 +
  39 + <ul class="nav navbar-nav navbar-right">
  40 + {% if not user.is_authenticated %}
  41 +
  42 + <li class="dropdown hidden-xs hidden-lg">
  43 + <a href="#" class="dropdown-toggle" data-toggle="dropdown">Acesso <b class="caret"></b></a>
  44 + <ul class="dropdown-menu">
  45 + {% trans 'Login' as login_text %}
  46 + {% if BROWSERID_ENABLED %}
  47 + <li>{% browserid_login text=login_text %}</li>
  48 + {% else %}
  49 + <li><a href="{% url 'signup' %}">{% trans "Register" %}</a></li>
  50 + <li><a href="{% url 'login' %}">{% trans "Login" %}</a></li>
  51 + {% endif %}
  52 + </ul>
  53 + </li>
  54 + {% trans 'Login' as login_text %}
  55 + {% if BROWSERID_ENABLED %}
  56 + <li class="visible-xs hidden-sm hidden-md">{% browserid_login text=login_text %}</li>
  57 + {% else %}
  58 + <li class="visible-xs hidden-sm hidden-md"><a href="{% url 'signup' %}">{% trans "Register" %}</a></li>
  59 + <li class="visible-xs hidden-sm hidden-md"><a href="{% url 'login' %}">{% trans "Login" %}</a></li>
  60 + {% endif %}
  61 + {% else %}
  62 + <li id="user-menu" class="dropdown">
  63 + <a href="#" class="dropdown-toggle user" data-toggle="dropdown">{% gravatar user.email 40 %} <b class="caret"></b>&nbsp;&nbsp;</a>
  64 + <ul class="dropdown-menu" role="menu">
  65 + <li>
  66 + <div class="wrapper">
  67 + <div class="thumbnail">{% gravatar user.email 100 %}</div>
  68 + <div class="user-info">
  69 + <span><b>{{ user.get_full_name }}</b></span>
  70 + <span class="quiet">{{ user.email }}</span>
  71 + </div>
  72 + <div>
  73 + <a class="btn btn-info pull-left" href="{% url 'user_profile' user.username %}">{% trans "My Profile" %}</a>
  74 + {% trans 'Logout' as logout_text %}
  75 + {% if BROWSERID_ENABLED %}
  76 + {% browserid_logout text=logout_text link_class='btn btn-default pull-right' %}
  77 + {% else %}
  78 + <a class="btn btn-default pull-right" href="{% url 'logout' %}"> {% trans "Logout" %}</a>
  79 + {% endif %}
  80 + </div>
  81 + </div>
  82 + </li>
  83 + </ul>
  84 + </li>
  85 + {% endif %}
  86 + </ul>
  87 +
  88 + <form action="{% url 'haystack_search' %}" method="GET" id="search-form" class="navbar-form navbar-right hidden-xs hidden-sm" role="search">
  89 + <div class="form-group">
  90 + <label class="sr-only" for="header-searchbox">{% trans 'Search here...' %}</label>
  91 + <input name="q" id="header-searchbox"
  92 + class="form-control" value="{{ request.GET.q }}"
  93 + type="search" placeholder="{% trans 'Search here...' %}" />
  94 + </div>
  95 + <button type="submit" class="btn btn-default"><span class="glyphicon glyphicon-search"></span></button>
  96 + </form>
  97 + </div>
  98 + </div>
  99 +</nav>
  100 +
docs/source/user.rst
@@ -90,19 +90,26 @@ Extra Template Folders @@ -90,19 +90,26 @@ Extra Template Folders
90 90
91 .. attribute:: COLAB_TEMPLATES 91 .. attribute:: COLAB_TEMPLATES
92 92
93 - :default: None  
94 -  
95 - Colab's extra template folders. Use it to add plugins template files. 93 + :default: () (Empty tuple)
96 94
  95 + Colab's extra template folders. Use it to add plugins template files, and
  96 + remember to use the app hierarchy, e.g if your app name is example, then
  97 + you should put your templates inside ``COLAB_TEMPLATES/example``.
  98 + You can also use it to overwrite the default templates, e.g. if you want
  99 + to overwrite the default footer, you simply need to add a file named
  100 + ``footer.html`` to the folder where ``COLAB_TEMPLATES`` points to.
97 101
98 Extra Static Folders 102 Extra Static Folders
99 ++++++++++++++++++++ 103 ++++++++++++++++++++
100 104
101 .. attribute:: COLAB_STATIC 105 .. attribute:: COLAB_STATIC
102 106
103 - :default: None 107 + :default: [] (Empty list)
  108 +
  109 + Colab's extra static folders. Use it to add plugins static files. It's used
  110 + the same way COLAB_TEMPLATES is. Use it to overwrite or add your own static
  111 + files, such as CSS/JS files and/or images.
104 112
105 - Colab's extra static folders. Use it to add plugins static files.  
106 113
107 Settings 114 Settings
108 -------- 115 --------