Skip to content

Commit

Permalink
Merge branch 'master' of github.com:okfn/ckan into 3028-dashboard-act…
Browse files Browse the repository at this point in the history
…ivity-stream-filtering

Conflicts:
	ckan/public/base/css/main.css
  • Loading branch information
Sean Hammond committed Jan 26, 2013
2 parents 8235e06 + 556c218 commit 3bf744f
Show file tree
Hide file tree
Showing 14 changed files with 140 additions and 36 deletions.
2 changes: 1 addition & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Community
---------

* Developer mailing list: `ckan-dev@lists.okfn.org <http://lists.okfn.org/mailman/listinfo/ckan-dev>`_
* Developer IRC channel: #ckan on `irc.freenode.net <http://freenode.net/>`_
* Developer IRC channel: `#ckan on irc.freenode.net <http://webchat.freenode.net/?channels=ckan>`_
* Issue tracker: `trac.ckan.org <http://trac.ckan.org/>`_
* `CKAN tag on StackOverflow <http://stackoverflow.com/questions/tagged/ckan>`_

Expand Down
5 changes: 5 additions & 0 deletions ckan/controllers/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -722,6 +722,11 @@ def new_metadata(self, id, data=None, errors=None, error_summary=None):
error_summary = error_summary or {}
vars = {'data': data, 'errors': errors, 'error_summary': error_summary}
vars['pkg_name'] = id

package_type = self._get_package_type(id)
self._setup_template_variables(context, {},
package_type=package_type)

return render('package/new_package_metadata.html', extra_vars=vars)

def edit(self, id, data=None, errors=None, error_summary=None):
Expand Down
30 changes: 29 additions & 1 deletion ckan/lib/formatters.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def rnd(number, divisor):
return localised_number(float(number * 10 / divisor) / 10)

if number < 1024:
return _('{bytes} bytes').format(bytes=number)
return _('{bytes} bytes').format(bytes=localised_number(number))
elif number < 1024 ** 2:
return _('{kibibytes} KiB').format(kibibytes=rnd(number, 1024))
elif number < 1024 ** 3:
Expand All @@ -120,3 +120,31 @@ def rnd(number, divisor):
return _('{gibibytes} GiB').format(gibibytes=rnd(number, 1024 ** 3))
else:
return _('{tebibytes} TiB').format(tebibytes=rnd(number, 1024 ** 4))


def localised_SI_number(number):
''' Returns a localised unicode representation of a number in SI format
eg 14700 becomes 14.7k '''

def rnd(number, divisor):
# round to 1 decimal place
return localised_number(float(number * 10 / divisor) / 10)

if number < 1000:
return _('{n}').format(n=localised_number(number))
elif number < 1000 ** 2:
return _('{k}k').format(k=rnd(number, 1000))
elif number < 1000 ** 3:
return _('{m}M').format(m=rnd(number, 1000 ** 2))
elif number < 1000 ** 4:
return _('{g}G').format(g=rnd(number, 1000 ** 3))
elif number < 1000 ** 5:
return _('{t}T').format(t=rnd(number, 1000 ** 4))
elif number < 1000 ** 6:
return _('{p}P').format(p=rnd(number, 1000 ** 5))
elif number < 1000 ** 7:
return _('{e}E').format(e=rnd(number, 1000 ** 6))
elif number < 1000 ** 8:
return _('{z}Z').format(z=rnd(number, 1000 ** 7))
else:
return _('{y}Y').format(y=rnd(number, 1000 ** 8))
11 changes: 11 additions & 0 deletions ckan/lib/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1424,6 +1424,16 @@ def resource_preview(resource, pkg_id):
)


def SI_number_span(number):
''' outputs a span with the number in SI unit eg 14700 -> 14.7k '''
number = int(number)
if number < 1000:
output = literal('<span>')
else:
output = literal('<span title="' + formatters.localised_number(number) + '">')
return output + formatters.localised_SI_number(number) + literal('<span>')


# these are the functions that will end up in `h` template helpers
__allowed_functions__ = [
# functions defined in ckan.lib.helpers
Expand Down Expand Up @@ -1501,6 +1511,7 @@ def resource_preview(resource, pkg_id):
'render_markdown',
'format_resource_items',
'resource_preview',
'SI_number_span',
# imported into ckan.lib.helpers
'literal',
'link_to',
Expand Down
53 changes: 41 additions & 12 deletions ckan/public/base/css/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -4506,13 +4506,13 @@ ul.icons li .icon-large:before {
.simple-list:after {
clear: both;
}
.simple-list > li {
.simple-list > li {
font-size: 12px;
line-height: 1.1666666666666667em;
padding: 7px 25px;
border-bottom: 1px dotted #cccccc;
}
.simple-list > li:last-of-type {
.simple-list > li:last-of-type {
border-bottom: 0;
}
.simple-list .ckan-icon {
Expand Down Expand Up @@ -4669,6 +4669,8 @@ ul.icons li .icon-large:before {
padding-right: 15px;
}
.module-grid {
margin: 0;
list-style: none;
margin: 0;
list-style: none;
*zoom: 1;
Expand All @@ -4692,6 +4694,7 @@ ul.icons li .icon-large:before {
padding-left: 20px;
padding-bottom: 25px;
float: left;
float: left;
margin-left: 20px;
width: 460px;
padding-top: 10px;
Expand All @@ -4717,10 +4720,10 @@ ul.icons li .icon-large:before {
.ckanext-datapreview {
position: relative;
}
.ckanext-datapreview > iframe {
.ckanext-datapreview > iframe {
min-height: 400px;
}
.ckanext-datapreview > img {
.ckanext-datapreview > img {
max-height: 500px;
max-width: 100%;
overflow: hidden;
Expand Down Expand Up @@ -4884,13 +4887,13 @@ ol.media-grid:after {
.nav-simple:after {
clear: both;
}
.nav-simple > li {
.nav-simple > li {
font-size: 12px;
line-height: 1.1666666666666667em;
padding: 7px 25px;
border-bottom: 1px dotted #cccccc;
}
.nav-simple > li:last-of-type {
.nav-simple > li:last-of-type {
border-bottom: 0;
}
.nav-simple .ckan-icon {
Expand All @@ -4912,10 +4915,12 @@ ol.media-grid:after {
}
.nav-item.active > a {
background: url("../../../base/images/background-tag.png") no-repeat -13px center;
position: relative;
display: block;
font-size: 11px;
line-height: 27px;
color: #187794;
padding-left: 10px;
padding-right: 5px;
margin-right: 11px;
-webkit-box-sizing: border-box;
Expand Down Expand Up @@ -5221,6 +5226,8 @@ textarea {
background-image: url("../../../base/images/sprite-ckan-icons.png");
background-repeat: no-repeat;
background-position: 16px 16px;
width: 17px;
height: 17px;
background-position: -51px -16px;
position: absolute;
display: block;
Expand Down Expand Up @@ -5762,11 +5769,11 @@ textarea {
}
.resource-item {
position: relative;
padding: 10px 110px 10px 60px;
padding: 10px 10px 10px 60px;
margin-bottom: 0px;
-webkit-border-radius: 2px;
-moz-border-radius: 2px;
border-radius: 2px;
-webkit-border-radius: 3px;
-moz-border-radius: 3px;
border-radius: 3px;
}
.resource-item:hover {
background-color: #efefef;
Expand All @@ -5787,7 +5794,7 @@ textarea {
}
.resource-item .btn-group {
position: absolute;
top: 13px;
top: 14px;
right: 10px;
}
.dataset-resource-form .dataset-form-resource-types {
Expand All @@ -5814,6 +5821,8 @@ textarea {
vertical-align: text-bottom;
position: relative;
top: 2px;
width: 16px;
height: 16px;
background-image: url("../../../base/images/sprite-ckan-icons.png");
background-repeat: no-repeat;
background-position: 16px 16px;
Expand Down Expand Up @@ -6673,6 +6682,7 @@ li .icon-large:before {
float: right;
}
[role=main] .secondary {
float: left;
margin-left: 20px;
width: 220px;
margin-left: 0;
Expand Down Expand Up @@ -7232,9 +7242,18 @@ header.masthead .debug {
display: block;
font-size: 30px;
font-weight: 700;
line-height: 1.2;
line-height: 36px;
margin-left: 0;
}
.profile-info .nums dl dd .smallest {
font-size: 13px;
}
.profile-info .nums dl dd .smaller {
font-size: 16px;
}
.profile-info .nums dl dd .small {
font-size: 21px;
}
.profile-info.editing .module-content {
margin-top: 0;
}
Expand Down Expand Up @@ -7592,6 +7611,16 @@ header.masthead .debug {
.ie8 .dashboard-aside {
width: 218px;
}
.dropdown:hover .dropdown-menu {
display: block;
}
.js .dropdown .dropdown-menu,
.js .dropdown:hover .dropdown-menu {
display: none;
}
.js .dropdown.open .dropdown-menu {
display: block;
}
body {
background-color: #00536b;
}
Expand Down
6 changes: 3 additions & 3 deletions ckan/public/base/less/dataset.less
Original file line number Diff line number Diff line change
Expand Up @@ -137,9 +137,9 @@

.resource-item {
position: relative;
padding: 10px 110px 10px 60px;
padding: 10px 10px 10px 60px;
margin-bottom: 0px;
.border-radius(2px);
.border-radius(3px);
&:hover {
background-color: @layoutBackgroundColor;
}
Expand All @@ -164,7 +164,7 @@

.resource-item .btn-group {
position: absolute;
top: 13px;
top: 14px;
right: 10px;
}

Expand Down
11 changes: 10 additions & 1 deletion ckan/public/base/less/profile.less
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,17 @@
display: block;
font-size: 30px;
font-weight: 700;
line-height: 1.2;
line-height: 36px;
margin-left: 0;
.smallest {
font-size: 13px;
}
.smaller {
font-size: 16px;
}
.small {
font-size: 21px;
}
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions ckan/templates/ajax_snippets/popover_context_dataset.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<div class="nums">
<dl>
<dt>{{ _('Resources') }}</dt>
<dd>{{ num_resources }}</dd>
<dd>{{ h.SI_number_span(num_resources) }}</dd>
</dl>
<dl>
<dt>{{ _('Tags') }}</dt>
<dd>{{ num_tags }}</dd>
<dd>{{ h.SI_number_span(num_tags) }}</dd>
</dl>
</div>
</div>
4 changes: 2 additions & 2 deletions ckan/templates/ajax_snippets/popover_context_group.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@
<div class="nums">
<dl>
<dt>{{ _('Followers') }}</dt>
<dd>{{ num_followers }}</dd>
<dd>{{ h.SI_number_span(num_followers) }}</dd>
</dl>
<dl>
<dt>{{ _('Datasets') }}</dt>
<dd>{{ num_datasets }}</dd>
<dd>{{ h.SI_number_span(num_datasets) }}</dd>
</dl>
</div>
</div>
6 changes: 3 additions & 3 deletions ckan/templates/ajax_snippets/popover_context_user.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
<div class="nums">
<dl>
<dt>{{ _('Followers') }}</dt>
<dd>{{ num_followers }}</dd>
<dd>{{ h.SI_number_span(num_followers) }}</dd>
</dl>
<dl>
<dt>{{ _('Datasets') }}</dt>
<dd>{{ number_administered_packages }}</dd>
<dd>{{ h.SI_number_span(number_administered_packages) }}</dd>
</dl>
<dl>
<dt>{{ _('Edits') }}</dt>
<dd>{{ number_of_edits }}</dd>
<dd>{{ h.SI_number_span(number_of_edits) }}</dd>
</dl>
</div>
</div>
4 changes: 2 additions & 2 deletions ckan/templates/group/read_base.html
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,11 @@ <h1 class="heading">{{ c.group_dict.display_name }}</h1>
<div class="nums">
<dl>
<dt>{{ _('Followers') }}</dt>
<dd>{{ c.group_dict.num_followers }}</dd>
<dd>{{ h.SI_number_span(c.group_dict.num_followers) }}</dd>
</dl>
<dl>
<dt>{{ _('Datasets') }}</dt>
<dd>{{ c.group_dict.packages|length }}</dd>
<dd>{{ h.SI_number_span(c.group_dict.packages|length) }}</dd>
</dl>
</div>
</section>
Expand Down
29 changes: 25 additions & 4 deletions ckan/templates/package/snippets/resource_item.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,29 @@
<span class="empty">{{ _('No description for this resource') }}</span>
{% endif %}
</p>
<p class="btn-group">
<a class="btn btn-primary" href="{{ url }}">{{ _('Explore Data') }}</a>
<a class="btn resource-url-analytics" href="{{ res.url }}" target="_blank">{{ _('Raw Data') }}</a>
</p>
{% block resource_item_explore %}
<div class="dropdown btn-group">
<a href="#" class="btn btn-primary dropdown-toggle" data-toggle="dropdown">
<i class="icon-share-alt"></i>
{{ _('Explore') }}
<span class="caret"></span>
</a>
<ul class="dropdown-menu">
{% block resource_item_explore_links %}
<li>
<a href="{{ url }}">
<i class="icon-bar-chart"></i>
{{ _('Preview') }}
</a>
</li>
<li>
<a href="{{ res.url }}" class="resource-url-analytics" target="_blank">
<i class="icon-download"></i>
{{ _('Download') }}
</a>
</li>
{% endblock %}
</ul>
</div>
{% endblock %}
</li>

0 comments on commit 3bf744f

Please sign in to comment.