Skip to content

Commit

Permalink
Merge branch 'feature-2454-demo-login' into feature-2375-demo-theme
Browse files Browse the repository at this point in the history
  • Loading branch information
aron committed Jun 6, 2012
2 parents d0a6195 + 92cb94f commit 6d7ce58
Show file tree
Hide file tree
Showing 6 changed files with 112 additions and 11 deletions.
11 changes: 8 additions & 3 deletions ckan/public/base/less/forms.less
Expand Up @@ -67,19 +67,24 @@ textarea {
background: none;
margin-left: -@gutter-x;
margin-right: -@gutter-x;
padding-bottom: 0; // Prevents reduces the padding when included in a module.
margin-bottom: 0; // Prevents reduces the padding when included in a module.
padding-bottom: 0;
text-align: right;
}

.form-actions .action-info {
float: left;
width: 50%;
font-size: 11px;
line-height: 1.2;
line-height: 2;
text-align: left;
color: #707070;
}

.form-actions .action-info.small {
font-size: 11px;
line-height: 1.2;
}

// Override the default form widths.
.form-horizontal .control-label {
width: 115px;
Expand Down
42 changes: 35 additions & 7 deletions ckan/templates/macros/form.html
Expand Up @@ -13,7 +13,7 @@

Examples:

{% import form from 'macros/form.html' %}
{% import 'macros/form.html' as form %}
{{ form.input('title', label=_('Title'), value=data.title, error=errors.title) }}

#}
Expand All @@ -23,6 +23,34 @@
{% endcall %}
{% endmacro %}

{#
Builds a single checkbox input.

name - The name of the form parameter.
id - The id to use on the input and label. Convention is to prefix with 'field-'.
label - The human readable label.
value - The value of the input.
checked - If true the checkbox will be checked
error - An error string for the field.
classes - An array of classes to apply to the control-group.

Example:

{% import 'macros/form.html' as form %}
{{ form.checbox('remember', checked=true) }}

#}
{% macro checkbox(name, id='', label='', value='', checked=false, placeholder='', error="", classes=[]) %}
<div class="control-group{{ " " ~ classes | join(" ") }}">
<div class="controls">
<label class="checkbox" for="{{ id or name }}">
<input id="{{ id or name }}" type="checkbox" name="{{ name }}" value="{{ value | e }}" {{ "checked " if checked }}/>
{{ label or name }}
</label>
</div>
</div>
{% endmacro %}

{#
Creates all the markup required for an select element. Handles matching labels to
inputs and error messages.
Expand All @@ -37,7 +65,7 @@

Examples:

{% import form from 'macros/form.html' %}
{% import 'macros/form.html' as form %}
{{ form.select('year', label=_('Year'), options={2010: 2010, 2011: 2011}, selected=2011, error=errors.year) }}

#}
Expand Down Expand Up @@ -65,7 +93,7 @@

Examples:

{% import form from 'macros/form.html' %}
{% import 'macros/form.html' as form %}
{{ form.markdown('desc', id='field-description', label=_('Description'), value=data.desc, error=errors.desc) }}

#}
Expand Down Expand Up @@ -95,7 +123,7 @@

Examples:

{% import form from 'macros/form.html' %}
{% import 'macros/form.html' as form %}
{{ form.prepend('slug', id='field-slug', prepend='/dataset/', label=_('Slug'), value=data.slug, error=errors.slug) }}

#}
Expand Down Expand Up @@ -130,7 +158,7 @@

Examples:

{% import form from 'macros/form.html' %}
{% import 'macros/form.html' as form %}
{{ form.custom(
names=('custom_key', 'custom_value', 'custom_deleted'),
id='field-custom',
Expand Down Expand Up @@ -167,7 +195,7 @@

Example:

{% import form from 'macros/form.html' %}
{% import 'macros/form.html' as form %}
{% call form.block("field", "My Field") %}
<input id="field" type="text" name="{{ name }}" value="{{ value | e }}" />
{% endcall %}
Expand All @@ -192,7 +220,7 @@

Example:

{% import form from 'macros/form.html' %}
{% import 'macros/form.html' as form %}
{{ form.errors(error_summary, type="warning") }}

#}
Expand Down
2 changes: 1 addition & 1 deletion ckan/templates/package/new_resource.html
Expand Up @@ -82,7 +82,7 @@
</div>

<div class="form-actions">
<p class="action-info">Important: By submitting content, you
<p class="action-info small">Important: By submitting content, you
agree to release your contributions under the Open Database
License.</p>
<a class="btn" href="">Save and close</a>
Expand Down
12 changes: 12 additions & 0 deletions ckan/templates/page.jinja.html
Expand Up @@ -15,6 +15,18 @@
{%- block content %}
<div role="main">
<div class="container">

{% block flash %}
{% set flash_messages = h.flash.pop_messages() | list %}
{% for message in flash_messages %}
<div class="flash-messages">
<div class="alert {{ message.category }}">
{{ h.literal(message) }}
</div>
</div>
{% endfor %}
{% endblock %}

{% block toolbar %}
<div class="toolbar">
{% block breadcrumb %}{% endblock %}
Expand Down
46 changes: 46 additions & 0 deletions ckan/templates/user/login.html
@@ -0,0 +1,46 @@
{% extends "page.jinja.html" %}

{% block title %}{{ _('Login') }} - {{ super() }}{% endblock %}

{% block breadcrumb %}
<ol class="breadcrumb">
<li class="current">{{ h.nav_link(_('Login'), controller='user', action='login') }}</li>
</ol>
{% endblock %}

{% block actions %}
<ul class="actions">
<li>{{ h.nav_link(_('Register'), controller='user', action='register', class_="btn", icon="head") }}</li>
</ul>
{% endblock %}

{% block primary_content %}
<section class="module">
<div class="content">
<h1 class="page-heading">{{ _('Login') }}</h1>
{% include "user/partials/login_form.html" %}
</div>
</section>
{% endblock %}

{% block secondary_content %}
<section class="module info">
<h2 class="heading">{{ _('Need an Account?') }}</h2>
<div class="content">
<p>{% trans %}Then sign right up, it only takes a minute.{% endtrans %}</p>
<p class="action">
<a class="btn" href="{{ h.url_for(controller='user', action='register') }}">{{ _('Create an Account') }}</a>
</p>
</div>
</section>

<section class="module info">
<h2 class="heading">{{ _('Forgotten your details?') }}</h2>
<div class="content">
<p>{% trans %}No problem, use our password recovery form to reset it.{% endtrans %}</p>
<p class="action">
<a class="btn" href="{{ h.url_for(controller='user', action='request_reset') }}">{{ _('Forgot your password?') }}</a>
</p>
</div>
</section>
{% endblock %}
10 changes: 10 additions & 0 deletions ckan/templates/user/partials/login_form.html
@@ -0,0 +1,10 @@
{% import 'macros/form.html' as form %}

<form action="{{ c.login_handler }}" method="post" class="form-horizontal">
{{ form.input('login', label="Username", id='field-login', value="", error="", classes=["control-full"]) }}
{{ form.input('password', label="Password", id='field-password', type="password", value="", error="", classes=["control-full"]) }}
{{ form.checkbox('remember', label="Remember me", id='field-remember', checked=true, value="63072000") }}
<div class="form-actions">
<button class="btn btn-primary" type="submit">{{ _('Log in') }}</button>
</div>
</form>

0 comments on commit 6d7ce58

Please sign in to comment.