def render_stars(stars, reason, last_updated): if stars==0: stars_html = 5 * icon('star-grey') else: stars_html = stars * icon('star') tooltip = literal('<div class="star-rating-reason"><b>Reason: </b>%s</div>' % reason) if reason else '' for i in range(5,0,-1): classname = 'fail' if (i > stars) else '' tooltip += literal('<div class="star-rating-entry %s">%s</div>' % (classname, mini_stars_and_caption(i))) datestamp = last_updated.strftime('%d/%m/%Y') tooltip += literal('<div class="star-rating-last-updated"><b>Score updated: </b>%s</div>' % datestamp) return literal('<span class="star-rating"><span class="tooltip">%s</span><a href="http://lab.linkeddata.deri.ie/2010/star-scheme-by-example/" target="_blank">%s</a></span>' % (tooltip, stars_html))
def get_star_html(stars, reason): if stars == 0: return literal('<span class="star-rating no-stars">[%s]</span>' % reason) captions = [ _('Available under an open license.'), _('Available as structured data (eg. Excel instead of a scanned table).' ), _('Uses non-proprietary formats (e.g., CSV instead of Excel).'), _('Uses URIs to identify things, so that people can link to it.'), _('Linked to other data to provide context.') ] caption = "" for i in range(5, 0, -1): fail = 'fail' if (i > stars) else '' text_stars = i * '★' caption += literal('<span class="%s">%s "%s"</span>' % (fail, text_stars, captions[i - 1])) star_icons = stars * icon('star') return literal( '<span class="star-rating hover-for-help"><span class="help-text">[%s] %s</span><a href="http://lab.linkeddata.deri.ie/2010/star-scheme-by-example/" target="_blank">%s</a></span>' % (reason, caption, star_icons))
def render_stars(stars, reason, last_updated): if stars == 0: stars_html = 5 * icon("star-grey") else: stars_html = stars * icon("star") tooltip = literal('<div class="star-rating-reason"><b>Reason: </b>%s</div>' % reason) if reason else "" for i in range(5, 0, -1): classname = "fail" if (i > stars) else "" tooltip += literal('<div class="star-rating-entry %s">%s</div>' % (classname, mini_stars_and_caption(i))) datestamp = last_updated.strftime("%d/%m/%Y") tooltip += literal('<div class="star-rating-last-updated"><b>Score updated: </b>%s</div>' % datestamp) return literal( '<span class="star-rating"><span class="tooltip">%s</span><a href="http://lab.linkeddata.deri.ie/2010/star-scheme-by-example/" target="_blank">%s</a></span>' % (tooltip, stars_html) )
def get_star_html(stars, reason): if stars == 0: return literal('<span class="star-rating no-stars">[%s]</span>' % reason) captions = [ _('Available under an open license.'), _('Available as structured data (eg. Excel instead of a scanned table).'), _('Uses non-proprietary formats (e.g., CSV instead of Excel).'), _('Uses URIs to identify things, so that people can link to it.'), _('Linked to other data to provide context.') ] caption = "" for i in range(5, 0, -1): fail = 'fail' if (i > stars) else '' text_stars = i * '★' caption += literal('<span class="%s">%s "%s"</span>' % (fail, text_stars, captions[i-1])) star_icons = stars * icon('star') return literal('<span class="star-rating hover-for-help"><span class="help-text">[%s] %s</span><a href="http://lab.linkeddata.deri.ie/2010/star-scheme-by-example/" target="_blank">%s</a></span>' % (reason, caption, star_icons))
def package_matrix(packages, core_fields): html = u'' html += u'<table class="table table-bordered table-condensed packages">' + u"\n" table_rows = [] table_heads = {} for pkg_dict in packages: dic = {} for key, value in pkg_dict.iteritems(): if key == 'tags': tags = [] for tag_dict in pkg_dict['tags']: tags += [tag_dict['name']] dic['tags'] = tags table_heads['tags'] = "" elif key == 'groups': groups = [] #for group_dict in pkg_dict['groups']: # groups += [group_dict['id']] #dic['groups'] = groups dic['groups'] = pkg_dict['groups'] table_heads['groups'] = "" elif key == 'extras': for extra_dict in pkg_dict['extras']: if not extra_dict['key'] in dic.keys(): dic[extra_dict['key']] = extra_dict['value'] table_heads[extra_dict['key']] = "" elif key in core_fields and key not in dic.keys(): dic[key] = value table_heads[key] = "" table_rows.append(dic) if 'title' in table_heads: del table_heads['title'] if 'id' in table_heads: del table_heads['id'] table_heads_sorted = sorted(table_heads.iterkeys()) html += u'<thead>' + u"\n" html += u'<tr>' + u"\n" html += u'<th class="edit narrowTh" style="width: 15px;"><input type="checkbox" name="checkall" value="checkall" class="checkall"/></th>' + u"\n" html += u'<th class="title wideTh" style="max-width: 250px;">Title</th>' + u"\n" for key in table_heads_sorted: html += u'<th class="' + unicode(key) + u' wideTh">' + unicode( _(key)) + u'</th>' + u"\n" html += u'<th class="single_edit narrowTh" style="width: 35px;">Edit</th>' + u"\n" html += u'</tr>' + u"\n" html += u'</thead>' + u"\n" html += u'<tbody>' for row in table_rows: html += u'<tr>' html += u'<td><input type="checkbox" name="package_select" class="package_select" value="' + unicode( row['id']) + u'" /></td>' html += u'<td class="title ' + row['id'] + '">' html += unicode( h.link_to( row['title'] or row['name'], h.url_for(controller='package', action='read', id=row['name']))) html += u'</td>' for key in table_heads_sorted: if key in row: import json try: row_key = json.loads(row[key]) except (ValueError, TypeError): row_key = row[key] if key == "notes": val = h.markdown_extract(row_key) if key == "groups": group_ids = [] group_names = [] for group_dict in row[key]: group_ids += [group_dict['id']] group_names += [ h.group_name_to_title(group_dict['name']) ] row_key = ", ".join(group_ids) val = ", ".join(group_names) elif isinstance(row_key, list): val = ", ".join(row_key) else: val = row_key full_val = row_key html += u'<td class="' + unicode(key) + u' ' + unicode( row['id'] ) + u'" title="' + unicode( full_val ) + u'" style="max-height: 100px; display: block; overflow-y: auto;">' html += unicode(val) html += u'</td>' else: html += u'<td class="' + unicode(key) + u' ' + unicode( row['id'] ) + u'" style="max-height: 100px; display: block; overflow-y: scroll;"></td>' html += u'<td class="single_edit">' + unicode( h.subnav_link(h.icon('package_edit'), controller='package', action='edit', id=row['name'])) + u'</td>' html += u'</tr>' html += u'</tbody>' html += u'</table>' return toolkit.literal(html)