Browse Source

Use Zurb Foundation as base front-end framework

pull/6/head
Marcio Mazza 10 years ago
parent
commit
cf834f1d96
  1. 2
      requirements/requirements.txt
  2. 30
      sapl/layout.py
  3. 9
      sapl/settings.py
  4. 71
      templates/base.html

2
requirements/requirements.txt

@ -1,8 +1,10 @@
crispy-forms-foundation
Django
django-admin-bootstrapped
django-bootstrap3
django-braces
django-crispy-forms
django-zurb-foundation
psycopg2
pytz
PyYAML

30
sapl/layout.py

@ -1,5 +1,5 @@
from crispy_forms.bootstrap import FormActions
from crispy_forms.layout import Submit, Reset, Layout, Div, Fieldset
from crispy_forms_foundation.layout import (
Layout, Fieldset, Row, Column, ButtonGroup, Button, Submit)
from django.utils.translation import ugettext as _
@ -9,11 +9,11 @@ def to_column(name_span):
except:
return name_span
else:
return Div(fieldname, css_class='col-xs-%d' % span)
return Column(fieldname, css_class='large-%d' % span)
def to_row(names_spans):
return Div(*list(map(to_column, names_spans)), css_class='row-fluid')
return Row(*list(map(to_column, names_spans)))
def to_fieldsets(fields):
@ -29,9 +29,21 @@ def to_fieldsets(fields):
class SaplFormLayout(Layout):
def __init__(self, *fields):
_fields = list(to_fieldsets(fields)) + [
FormActions(
Submit('save', _('Save'), css_class='btn btn-primary '),
Reset('reset', _('Cancel'), css_class='btn'))
]
_fields = list(to_fieldsets(fields)) + buttons_crispies()
super(SaplFormLayout, self).__init__(*_fields)
def buttons_crispies():
return [
Row(
Column(
ButtonGroup(
Submit('submit', _('Submit'), css_class='success'),
Button('cancel', _('Cancel')),
Button('dummy', _('Delete'), css_class='alert'),
css_class='radius right'
),
css_class='clearfix'
),
),
]

9
sapl/settings.py

@ -54,6 +54,10 @@ INSTALLED_APPS = (
'django_extensions',
'bootstrap3',
'crispy_forms',
# zurb foundation
'foundation',
'crispy_forms_foundation',
)
MIDDLEWARE_CLASSES = (
@ -118,9 +122,12 @@ LOCALE_PATHS = (
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, "static"),
)
DAB_FIELD_RENDERER = \
'django_admin_bootstrapped.renderers.BootstrapFieldRenderer'
CRISPY_TEMPLATE_PACK = 'bootstrap3'
CRISPY_TEMPLATE_PACK = 'foundation-5'
CRISPY_FAIL_SILENTLY = not DEBUG

71
templates/base.html

@ -1,67 +1,48 @@
{% load bootstrap3 %}
{% load i18n %}
{% load static from staticfiles %}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="{{ LANGUAGE_CODE|default:"en-us" }}" {% if LANGUAGE_BIDI %}dir="rtl"{% endif %}>
{% load staticfiles %}
<!DOCTYPE html>
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<title>{% block title %}{% trans 'SAPL - Sistema de Apoio ao Processo Legislativo' %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<meta http-equiv="Content-Type" content="text/xhtml; charset=UTF-8" />
<link href="{% static "bootstrap/css/bootstrap.min.css" %}" rel="stylesheet"/>
<style type="text/css">
body {
padding: 10px 20px 40px;
}
</style>
<link href="{% static "bootstrap/css/bootstrap-theme.min.css" %}" rel="stylesheet"/>
{# TODO review these js dependencies #}
<script src="{% static "admin/js/jquery-1.9.1.min.js" %}"></script>
<script src="{% static "admin/js/jquery-migrate-1.2.1.min.js" %}"></script>
<script src="{% static "bootstrap/js/bootstrap.min.js" %}"></script>
<script type="text/javascript">
//<![CDATA[
(function($) {
$(document).ready(function() {
$('input[type="submit"]').addClass('btn');
$('[title]').tooltip();
});
}(jQuery));
//]]>
</script>
{% block extrahead %}{% endblock %}
<meta charset="utf-8">
<title>{% block head_title %}{% trans 'SAPL - Sistema de Apoio ao Processo Legislativo' %}{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
{% block header_content %}
<link rel="stylesheet" href="{% static 'foundation/css/foundation.min.css' %}">
<script type="text/javascript" src="{% static 'foundation/js/vendor/modernizr.js' %}"></script>
<script type="text/javascript" src="{% static 'foundation/js/vendor/jquery.js' %}"></script>
<script type="text/javascript" src="{% static 'foundation/js/vendor/fastclick.js' %}"></script>
<script type="text/javascript" src="{% static 'foundation/js/foundation.min.js' %}"></script>
{% endblock %}
</head>
<body>
<!-- Container -->
<div class="container-fluid">
<header>
... header ...
<hr/>
</header>
<!-- Content -->
<div id="content" class="{% block coltype %}colM{% endblock %}">
{% block content_title %}{% if title %}<h1>{{ title }}</h1>{% endif %}{% endblock %}
{% bootstrap_messages %}
{% block content_container %}
{# FIXME: row class is not for that: replace it keeping the layout (notice width) #}
<div id="body_content" class="row">
{% block content %}{% endblock %}
</div>
{% endblock %}
<!-- END Content -->
<footer id="footer">
<hr/>
... footer...
</footer>
</div>
<!-- END Container -->
{% block foot_more_js %}{% endblock %}
{# Init Foundation #}
{% block foundation_js_init %}
<script>
$(document).foundation();
</script>
{% endblock foundation_js_init %}
</body>
</html>

Loading…
Cancel
Save