Skip to content

Commit

Permalink
[#1583][m]: Integrated star ratings into frontend. Needs hooking up t…
Browse files Browse the repository at this point in the history
…o backend.
  • Loading branch information
teajaymars committed Jan 24, 2012
1 parent 2337424 commit 69f0bd1
Show file tree
Hide file tree
Showing 5 changed files with 67 additions and 5 deletions.
13 changes: 12 additions & 1 deletion ckan/lib/helpers.py
Expand Up @@ -20,7 +20,7 @@
from routes import url_for, redirect_to
from alphabet_paginate import AlphaPage
from lxml.html import fromstring
from i18n import get_available_locales
from i18n import get_available_locales, _



Expand Down Expand Up @@ -338,6 +338,17 @@ def resource_display_name(resource_dict):
else:
return '[no name] %s ' % resource_dict['id']

def resource_star_rating(resource_dict):
stars = 0 if ('index' in resource_dict.get('url')) else 3
out = ""
if stars==0:
message = _('When we last checked, this resource was not available.');
out = literal('<a href="#" class="mouseover-help-link error-hint" data="%s">404?</a>' % message)
else:
for n in range(stars):
out += icon('star')
return out

def resource_link(resource_dict, package_id):
text = resource_display_name(resource_dict)
url = url_for(controller='package',
Expand Down
39 changes: 36 additions & 3 deletions ckan/public/css/style.css
Expand Up @@ -207,7 +207,29 @@ tbody tr.table-empty td {
font-size: 2.2em;
font-weight: normal;
}

.mouseover-help-link {
border-bottom: 1px dashed #bb2222;
position: relative;
}
.mouseover-help-link:hover {
border-bottom: 1px dashed #183661;
}
.mouseover-help-link .inner {
position: absolute;
top: 18px;
left: -30px;
display: none;
padding: 4px 8px;
font-size: 11px;
background: #333;
text-align: left;
width: 150px;
z-index: 3;
color: #fff;
}
.mouseover-help-link:hover .inner {
display: block;
}

/* =============== */
/* MinorNavigation */
Expand Down Expand Up @@ -1129,16 +1151,27 @@ body.package.read h3 {
.search-result .main-link {
font-size: 125%;
}
.search-result .view-more-link {
.search-result .extra-links {
float: right;
}
.search-result .view-more-link {
color: #000;
text-align: middle;
display: block;
text-align: right;
margin-top: 4px;
padding: 3px 22px 3px 10px;
background: url('/images/icons/arrow-right-16-black.png') no-repeat right;
opacity:0.4;
filter:alpha(opacity=40); /* For IE8 and earlier */
}
.search-result .star-rating {
display: block;
padding-top: 5px;
text-align: right;
}
.search-result .error-hint {
font-size: 11px;
}
.search-result .view-more-link:hover {
opacity:1.0;
filter:alpha(opacity=100); /* For IE8 and earlier */
Expand Down
Binary file added ckan/public/images/icons/star.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 13 additions & 0 deletions ckan/public/scripts/application.js
Expand Up @@ -8,6 +8,8 @@
CKAN.Utils.setupFormatAutocomplete($(this));
});
CKAN.Utils.setupMarkdownEditor($('.markdown-editor'));
CKAN.Utils.setupMouseoverHelpLinks($('.mouseover-help-link'));

// set up ckan js
var config = {
endpoint: CKAN.SITE_URL + '/'
Expand Down Expand Up @@ -427,6 +429,17 @@ CKAN.Utils = function($, my) {
});
};

my.setupMouseoverHelpLinks = function(links) {
$.each(links, function(n,link) {
link = $(link);
link.click(function() { return false; });
var div = $('<div />');
div.html(link.attr('data'));
div.addClass('inner');
link.append(div);
});
}

// If notes field is more than 1 paragraph, just show the
// first paragraph with a 'Read more' link that will expand
// the div if clicked
Expand Down
7 changes: 6 additions & 1 deletion ckan/templates/package/read_core.html
Expand Up @@ -19,7 +19,12 @@
<h3>Resources</h3>
<py:for each="res in c.pkg_dict.get('resources', [])">
<div class="search-result">
<a class="view-more-link" href="${h.url_for(controller='package', action='resource_read', id=c.pkg_dict['name'], resource_id=res['id'])}">View</a>
<p class="extra-links">
<a class="view-more-link" href="${h.url_for(controller='package', action='resource_read', id=c.pkg_dict['name'], resource_id=res['id'])}">View</a>
<span class="star-rating">
${h.resource_star_rating(res)}
</span>
</p>
<a class="main-link" href="${h.url_for(controller='package', action='resource_read', id=c.pkg_dict['name'], resource_id=res['id'])}">${h.resource_display_name(res)}</a>
&nbsp;&nbsp;
<span py:if="res.get('format')" class="format-box" property="dc:format">${res.get('format')}</span>
Expand Down

0 comments on commit 69f0bd1

Please sign in to comment.