Skip to content

Commit

Permalink
[refactor,templates][xs]: split some of dataset related templates int…
Browse files Browse the repository at this point in the history
…o their own template files.
  • Loading branch information
rgrp committed Jul 28, 2011
1 parent 82ee4d2 commit 2f65ab6
Show file tree
Hide file tree
Showing 5 changed files with 191 additions and 187 deletions.
2 changes: 2 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@
<script src="../vendor/backbone/0.5.1/backbone.js"></script>

<script src="../lib/templates.js"></script>
<script src="../lib/template/dataset-view.js"></script>
<script src="../lib/template/dataset-form.js"></script>
<script src="../lib/client.js"></script>
<script src="../lib/model.js"></script>
<script src="../lib/view.js"></script>
Expand Down
90 changes: 90 additions & 0 deletions lib/template/dataset-form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
CKAN.Templates.datasetForm = ' \
<form class="dataset" action="" method="POST"> \
<fieldset> \
<legend> \
<h3>Basics</h3> \
</legend> \
<dl> \
<dt> \
<label class="field_opt" for="dataset--title"> \
Title * \
</label> \
</dt> \
<dd> \
<input id="Dataset--title" name="Dataset--title" type="text" value="${title}" placeholder="A title (not a description) ..."/> \
</dd> \
\
<dt> \
<label class="field_req" for="Dataset--name"> \
Slug * \
</label> \
</dt> \
<dd> \
<input id="Dataset--name" maxlength="100" name="Dataset--name" type="text" value="${name}" placeholder="A shortish name usable in urls ..." /> \
<img src="img/help.png" \
class="help" \
title="A unique lowercase name for the dataset for use in urls and therefore only containing alphanumeric characters plus - and _" \
> \
</dd> \
\
<dt> \
<label class="field_opt" for="Dataset--url"> \
Home Page \
</label> \
</dt> \
<dd> \
<input id="Dataset--url" name="Dataset--url" type="text" value="${url}" placeholder="http://mydataset.com/about/" /> \
</dd> \
\
<dt> \
<label class="field_opt" for="Dataset--license_id"> \
Licence \
</label> \
</dt> \
<dd> \
<select id="Dataset--license_id" name="Dataset--license_id"> \
<option selected="selected" value=""></option> \
<option value="notspecified">Other::License Not Specified</option> \
</select> \
</dd> \
\
<dt> \
<label class="field_opt" for="Dataset--notes"> \
Description and Notes \
</label> \
You can use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown formatting</a> \
</dt> \
<dd> \
<div class="previewable-textarea"> \
<ul class="tabs"> \
<li><a href="#" action="write" class="selected">Write</a></li> \
<li><a href="#" action="preview">Preview</a></li> \
</ul> \
<textarea id="Dataset--notes" name="Dataset--notes" placeholder="Start with a summary sentence ...">${notes}</textarea> \
<div id="Dataset--notes-preview" class="preview" style="display: none;"> \
<div> \
</div> \
</dd> \
\
<dt> \
<label class="field_opt" for="Dataset--tags"> \
Tags \
</label> \
</dt> \
<dd> \
<input class="tagComplete" data-tagcomplete-queryparam="incomplete" data-tagcomplete-url="/api/2/util/tag/autocomplete" id="Dataset--tags" name="Dataset--tags" type="text" value="${tags}" placeholder="e.g. pollution rivers water-quality" /> \
</dd> \
</dl> \
</fieldset> \
\
<div class="submit"> \
<input id="save" name="save" type="submit" value="Save" /> \
</div> \
<p class="hints"> \
<strong>Important:</strong> By submitting content, you agree to release your contributions \
under the open license specified on the <a href="http://ckan.net/license">license page</a>. Please <strong>refrain</strong> from editing if you are <strong>not</strong> happy to do this. \
</p> \
</form> \
';


96 changes: 96 additions & 0 deletions lib/template/dataset-view.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
CKAN.Templates.datasetFull = ' \
<div class="dataset view" dataset-id="${dataset.id}"> \
<div class="extract"> \
{{html dataset.snippet}} \
<a href="#anchor-notes">Read more</a> \
</div> \
<div class="tags"> \
{{if dataset.tags.length}} \
<ul class="dataset-tags"> \
{{each dataset.tags}} \
<li>${$value}</li> \
{{/each}} \
</ul> \
{{/if}} \
</div> \
<div class="resources subsection"> \
{{if dataset.resources.length }} \
<h3>Resources</h3> \
<table> \
<tr> \
<th>Description</th> \
<th>Format</th> \
</tr> \
{{each dataset.resources}} \
<tr> \
<td> \
{{if $value.description}} \
<a href="${$value.url}" target="_blank">${$value.description}</a> \
{{else}} \
<a href="${$value.url}" target="_blank">Download (no description)</a> \
{{/if}} \
</td> \
<td>${$value.format}</td> \
</tr> \
{{/each}} \
</table> \
{{/if}} \
<div class="add-resource"> \
<a href="#" class="action-add-resource">Add a resource</a> \
<div class="add-resource-form"></div> \
</div> \
</div> \
<div class="notes subsection"> \
<h3 id="anchor-notes">Notes</h3> \
{{html dataset.notesHtml}} \
</div> \
<div class="details subsection"> \
<h3>Additional Information</h3> \
<table> \
<thead> \
<tr> \
<th>Field</th> \
<th>Value</th> \
</tr> \
</thead> \
<tbody> \
<tr> \
<td>Creator</td> \
<td>${dataset.author}</td> \
</tr> \
<tr> \
<td>Maintainer</td> \
<td>${dataset.maintainer}</td> \
</tr> \
{{each dataset.extras}} \
<tr> \
<td class="package-label" property="rdfs:label">${$index}</td> \
<td class="package-details" property="rdf:value">${$value}</td> \
</tr> \
{{/each}} \
</tbody> \
</table> \
</div> \
</div> \
';

CKAN.Templates.sidebarDatasetView = ' \
<li class="widget-container widget_text"> \
<h3>Connections</h3> \
<ul> \
{{each dataset.relationships}} \
<li> \
<a href="...">${$value.package}</a> \
{{if $value.comment}} \
<span class="relationship_comment"> \
(${$value.comment}) \
</span> \
{{/if}} \
</li> \
{{/each}} \
</ul> \
{{if dataset.relationships.length == 0}} \
No connections to other datasets. \
{{/if}} \
</li> \
';
188 changes: 1 addition & 187 deletions lib/templates.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,171 +41,6 @@ CKAN.Templates = {
</li> \
',

datasetFull: ' \
<div class="dataset view" dataset-id="${dataset.id}"> \
<div class="extract"> \
{{html dataset.snippet}} \
<a href="#anchor-notes">Read more</a> \
</div> \
<div class="tags"> \
{{if dataset.tags.length}} \
<ul class="dataset-tags"> \
{{each dataset.tags}} \
<li>${$value}</li> \
{{/each}} \
</ul> \
{{/if}} \
</div> \
<div class="resources subsection"> \
{{if dataset.resources.length }} \
<h3>Resources</h3> \
<table> \
<tr> \
<th>Description</th> \
<th>Format</th> \
</tr> \
{{each dataset.resources}} \
<tr> \
<td> \
{{if $value.description}} \
<a href="${$value.url}" target="_blank">${$value.description}</a> \
{{else}} \
<a href="${$value.url}" target="_blank">Download (no description)</a> \
{{/if}} \
</td> \
<td>${$value.format}</td> \
</tr> \
{{/each}} \
</table> \
{{/if}} \
<div class="add-resource"> \
<a href="#" class="action-add-resource">Add a resource</a> \
<div class="add-resource-form"></div> \
</div> \
</div> \
<div class="notes subsection"> \
<h3 id="anchor-notes">Notes</h3> \
{{html dataset.notesHtml}} \
</div> \
<div class="details subsection"> \
<h3>Additional Information</h3> \
<table> \
<thead> \
<tr> \
<th>Field</th> \
<th>Value</th> \
</tr> \
</thead> \
<tbody> \
<tr> \
<td>Creator</td> \
<td>${dataset.author}</td> \
</tr> \
<tr> \
<td>Maintainer</td> \
<td>${dataset.maintainer}</td> \
</tr> \
{{each dataset.extras}} \
<tr> \
<td class="package-label" property="rdfs:label">${$index}</td> \
<td class="package-details" property="rdf:value">${$value}</td> \
</tr> \
{{/each}} \
</tbody> \
</table> \
</div> \
</div> \
',

datasetForm: ' \
<form class="dataset" action="" method="POST"> \
<fieldset> \
<legend> \
<h3>Basics</h3> \
</legend> \
<dl> \
<dt> \
<label class="field_opt" for="dataset--title"> \
Title * \
</label> \
</dt> \
<dd> \
<input id="Dataset--title" name="Dataset--title" type="text" value="${title}" placeholder="A title (not a description) ..."/> \
</dd> \
\
<dt> \
<label class="field_req" for="Dataset--name"> \
Slug * \
</label> \
</dt> \
<dd> \
<input id="Dataset--name" maxlength="100" name="Dataset--name" type="text" value="${name}" placeholder="A shortish name usable in urls ..." /> \
<img src="img/help.png" \
class="help" \
title="A unique lowercase name for the dataset for use in urls and therefore only containing alphanumeric characters plus - and _" \
> \
</dd> \
\
<dt> \
<label class="field_opt" for="Dataset--url"> \
Home Page \
</label> \
</dt> \
<dd> \
<input id="Dataset--url" name="Dataset--url" type="text" value="${url}" placeholder="http://mydataset.com/about/" /> \
</dd> \
\
<dt> \
<label class="field_opt" for="Dataset--license_id"> \
Licence \
</label> \
</dt> \
<dd> \
<select id="Dataset--license_id" name="Dataset--license_id"> \
<option selected="selected" value=""></option> \
<option value="notspecified">Other::License Not Specified</option> \
</select> \
</dd> \
\
<dt> \
<label class="field_opt" for="Dataset--notes"> \
Description and Notes \
</label> \
You can use <a href="http://daringfireball.net/projects/markdown/syntax">Markdown formatting</a> \
</dt> \
<dd> \
<div class="previewable-textarea"> \
<ul class="tabs"> \
<li><a href="#" action="write" class="selected">Write</a></li> \
<li><a href="#" action="preview">Preview</a></li> \
</ul> \
<textarea id="Dataset--notes" name="Dataset--notes" placeholder="Start with a summary sentence ...">${notes}</textarea> \
<div id="Dataset--notes-preview" class="preview" style="display: none;"> \
<div> \
</div> \
</dd> \
\
<dt> \
<label class="field_opt" for="Dataset--tags"> \
Tags \
</label> \
</dt> \
<dd> \
<input class="tagComplete" data-tagcomplete-queryparam="incomplete" data-tagcomplete-url="/api/2/util/tag/autocomplete" id="Dataset--tags" name="Dataset--tags" type="text" value="${tags}" placeholder="e.g. pollution rivers water-quality" /> \
</dd> \
</dl> \
</fieldset> \
\
<div class="submit"> \
<input id="save" name="save" type="submit" value="Save" /> \
</div> \
<p class="hints"> \
<strong>Important:</strong> By submitting content, you agree to release your contributions \
under the open license specified on the <a href="http://ckan.net/license">license page</a>. Please <strong>refrain</strong> from editing if you are <strong>not</strong> happy to do this. \
</p> \
</form> \
',

resourceForm: ' \
<h2>Add a Resource (File, API, ...)</h2> \
<form class="resource" action="" method="POST"> \
Expand Down Expand Up @@ -287,26 +122,5 @@ CKAN.Templates = {
<li><a href="#history">History</a></li> \
<li><a href="#subscribe">Subscribe</a></li> \
</ul> \
',

sidebarDatasetView: ' \
<li class="widget-container widget_text"> \
<h3>Connections</h3> \
<ul> \
{{each dataset.relationships}} \
<li> \
<a href="...">${$value.package}</a> \
{{if $value.comment}} \
<span class="relationship_comment"> \
(${$value.comment}) \
</span> \
{{/if}} \
</li> \
{{/each}} \
</ul> \
{{if dataset.relationships.length == 0}} \
No connections to other datasets. \
{{/if}} \
</li> \
'
'
};

0 comments on commit 2f65ab6

Please sign in to comment.