Skip to content

Commit

Permalink
Merge branch 'feature-2375-demo-theme' of github.com:okfn/ckan into f…
Browse files Browse the repository at this point in the history
…eature-2375-demo-theme
  • Loading branch information
tobes committed May 24, 2012
2 parents d4bc4ac + 2be7b73 commit 4b0f242
Show file tree
Hide file tree
Showing 6 changed files with 146 additions and 5 deletions.
1 change: 1 addition & 0 deletions ckan/config/routing.py
Expand Up @@ -162,6 +162,7 @@ def make_map():
requirements=dict(action='|'.join([
'list',
'new',
'new_resource',
'autocomplete',
'search'
]))
Expand Down
4 changes: 4 additions & 0 deletions ckan/controllers/package.py
Expand Up @@ -471,6 +471,10 @@ def new(self, data=None, errors=None, error_summary=None):
c.form = render(self._package_form(package_type=package_type), extra_vars=vars)
return render( self._new_template(package_type))

def new_resource(self, data=None, errors=None, error_summary=None):
""" This is a temporary action to allow styling of the forms. """
package_type = self._guess_package_type(True)
return render('package/new_resource.html')

def edit(self, id, data=None, errors=None, error_summary=None):
package_type = self._get_package_type(id)
Expand Down
21 changes: 21 additions & 0 deletions ckan/public/base/less/forms.less
Expand Up @@ -4,6 +4,7 @@ label {
}

label {
cursor: pointer;
font-size: 14px;
line-height: 2;
}
Expand All @@ -12,6 +13,11 @@ label:after {
content: ":";
}

label.radio:after,
label.checkbox:after {
content: "";
}

input,
textarea,
select,
Expand All @@ -22,6 +28,7 @@ select,

select {
margin-top: 6px;
padding: 0;
}

textarea {
Expand Down Expand Up @@ -53,6 +60,15 @@ textarea {
text-align: right;
}

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

// Override the default form widths.
.form-horizontal .control-label {
width: 115px;
Expand Down Expand Up @@ -81,6 +97,11 @@ textarea {
top: 10px;
}

.form-horizontal .form-actions {
padding-left: @gutter-x;
padding-right: @gutter-x;
}

.editor textarea {
.border-radius(@inputBorderRadius @inputBorderRadius 0 0);
border-bottom: none;
Expand Down
7 changes: 2 additions & 5 deletions ckan/templates/package/new.html
Expand Up @@ -18,11 +18,8 @@
<div class="primary">
<section class="module">
<div class="content">
<ol class="stages">
<li class="active"><a href="">Create dataset</a></li>
<li>Add data</li>
<li>Additional data</li>
</ol>
${h.snippet('package/new_stages.html', stage=1)}

<form class="dataset-form form-horizontal" method="post" py:with="errors = {}; data = {};">
<div class="alert alert-error error-explanation" py:if="False and error_summary">
<h2>Errors in form</h2>
Expand Down
101 changes: 101 additions & 0 deletions ckan/templates/package/new_resource.html
@@ -0,0 +1,101 @@
<!DOCTYPE html>
<html
xmlns="http://www.w3.org/1999/xhtml"
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude">
<!--! Include matchers nearest first -->
<xi:include href="../page.html" />

<!--! Now include the current page -->
<head>
<title>Add data to the dataset</title>
</head>
<body>
<div class="toolbar">
${h.snippet('package/new_breadcrumb.html')}
</div>

<div class="primary">
<section class="module">
<div class="content">
${h.snippet('package/new_stages.html', stage=2)}

<form class="dataset-form form-horizontal" method="post" py:with="errors = {}; data = {};">
<div class="control-group dataset-form-resource-types">
<div class="controls">
<label class="radio inline" for="field-resource-type-file">
<input id="field-resource-type-file" type="radio" name="resources__0__url" checked="checked" value="file" />
Link to a file
</label>
<label class="radio inline" for="field-resource-type-api">
<input id="field-resource-type-api" type="radio" name="resources__0__url" value="api" />
Link to an API
</label>
</div>
</div>

<div class="control-group control-large control-full" py:with="error = errors.get('title', '')">
<label class="control-label" for="field-resource-url">Resource</label>
<div class="controls">
<input id="field-resource-url" name="resources__0__url" value="${data.get('title', '')}" placeholder="${_('eg. http://example.com/jan-2011.json')}" />
<span class="error-block" py:if="error">${error}</span>
</div>
</div>

<div class="control-group control-full" py:with="error = errors.get('name', '')">
<label class="control-label" for="field-resources-name">Name</label>
<div class="controls">
<input id="field-resource-name" name="resources__0__name" value="${data.get('name', '')}" placeholder="${_('eg. January 2011')}" />
<span class="error-block" py:if="error">${error}</span>
</div>
</div>

<div class="control-group control-full" py:with="error = errors.get('notes', '')">
<label class="control-label" for="field-resource-description">Description</label>
<div class="controls editor">
<textarea id="field-resource-description" name="resources__0__description" cols="20" rows="5" placeholder="Some useful notes about the data">${data.get('notes', '')}</textarea>
<span class="info-block">You can use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown</a> editing here</span>
<span class="error-block" py:if="error">${error}</span>
</div>
</div>

<div class="control-group control-full" py:with="error = errors.get('', '')">
<label class="control-label" for="field-resource-format">Format</label>
<div class="controls">
<input id="field-resource-name" name="resources__0__format" value="${data.get('', '')}" placeholder="${_('eg. application/json')}" />
<span class="error-block" py:if="error">${error}</span>
</div>
</div>

<div class="control-group">
<label for="field-resource-type" class="control-label">Resource Type</label>
<div class="controls">
<select id="field-resource-type" name="resources__0__type">
<option selected="selected" value="">Select a type&hellip;</option>
</select>
</div>
</div>

<div class="form-actions">
<p class="action-info">Important: By submitting content, you
agree to release your contributions under the Open Database
License.</p>
<a class="btn" href="">Save and close</a>
<button class="btn btn-primary" type="submit">Next: Add Info</button>
</div>
</form>
</div>
</section>
</div>

<div class="secondary">
<section class="module">
<h2 class="heading"><i class="ckan-icon ckan-icon-info"></i> What is data?</h2>
<div class="content">
<p>Data can be any file or link to a file containing useful data.</p>
</div>
</section>
</div>
</body>
</html>
17 changes: 17 additions & 0 deletions ckan/templates/package/new_stages.html
@@ -0,0 +1,17 @@
<py:choose test="stage" xmlns="http://www.w3.org/1999/xhtml" xmlns:py="http://genshi.edgewall.org/">
<ol class="stages" py:when="1">
<li class="active">${h.nav_link(_('Create Dataset'), controller='package', action='new')}</li>
<li>Add data</li>
<li>Additional data</li>
</ol>
<ol class="stages" py:when="2">
<li>${h.nav_link(_('Create Dataset'), controller='package', action='new')}</li>
<li class="active"><a href="">Add data</a></li>
<li>Additional data</li>
</ol>
<ol class="stages" py:when="3">
<li>${h.nav_link(_('Create Dataset'), controller='package', action='new')}</li>
<li><a href="">Add data</a></li>
<li class="active"><a href="">Additional data</a></li>
</ol>
</py:choose>

0 comments on commit 4b0f242

Please sign in to comment.