Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

133 lines (119 sloc) 7.065 kb
{% extends "bookmarks/base.html" %}
{% load i18n %}
{% load account_tags %}
{% load avatar_tags %}
{% load voting_tags %}
{% load pagination_tags %}
{% load extra_voting_tags %}
{% load in_filter %}
{% load extra_tagging_tags %}
{% load sorting_tags %}
{% block head_title %}{% blocktrans %}All Bookmarks{% endblocktrans %}{% endblock %}
{% block extra_head %}
<link rel="alternate" type="application/atom+xml" title="Bookmarks Feed" href="/feeds/bookmarks/" />
{% endblock %}
{% block body %}
<h1>{% trans "All Bookmarks" %}</h1>
{% if bookmarks %}
{# ## FIXME this should probably be done in djanog-sorting #}
{% with request.field|cut:"-" as sort_order %}
<p>{% trans "These are bookmarks from everyone:" %}</p>
<p>{% trans "Sort by:" %}
{% ifequal sort_order "points" %}
{% anchor "hotness" "reddit-like hotness" %}
{% trans "or" %}
<b>{% trans "total points" %}</b>
{% trans "or" %}
{% anchor "date" "date added" %}
{% order_by_votes bookmarks request.direction %}
{% else %}
{% ifequal sort_order "hotness" %}
<b>{% trans "reddit-like hotness" %}</b>
{% trans "or" %}
{% anchor "points" "total points" %}
{% trans "or" %}
{% anchor "date" "date added" %}
{% order_by_reddit bookmarks added request.direction %}
{% else %}
{% anchor "hotness" "reddit-like hotness" %}
{% trans "or" %}
{% anchor "points" "total points" %}
{% trans "or" %}
<b>{% trans "date added" %}</b>
{% endifequal %}
{% endifequal %}
</p>
{% autopaginate bookmarks %}
{% votes_by_user user on bookmarks as vote_dict %}
{% scores_for_objects bookmarks as score_dict %}
<table class="bookmarks">
{% for bookmark in bookmarks %}
<tr class="{% cycle odd,even %}">
<td class="meta">
<div class="avatar">{% avatar bookmark.adder 40 %}</div>
<div class="details"><a href="{% url profile_detail bookmark.adder.username %}">{% user_display bookmark.adder %}</a></div>
{{ bookmark.added|date }}
</td>
<td class="vote">
{% dict_entry_for_item bookmark from vote_dict as vote %}
{% dict_entry_for_item bookmark from score_dict as score %}
{% if user.is_authenticated %}
<a id="up_{{ bookmark.id }}" href="#" onclick="vote({{ bookmark.id }}, '{% if vote and vote.is_downvote %}clear{% else %}up{% endif %}'); return false;"><img src="{{ STATIC_URL }}bookmarks/img/up_{% if vote and vote.is_upvote %}mod{% else %}grey{% endif %}.png"/></a><br />
{% endif %}
<span id="bookmark_{{ bookmark.id }}_score">
{{ score.score|default:0 }} point{{ score.score|default:0|pluralize }}
</span><br />
{% if user.is_authenticated %}
<a id="down_{{ bookmark.id }}" href="#" onclick="vote({{ bookmark.id }}, '{% if vote and vote.is_upvote %}clear{% else %}down{% endif %}'); return false;"><img id="img_{{ bookmark.id }}_down" src="{{ STATIC_URL }}bookmarks/img/down_{% if vote and vote.is_downvote %}mod{% else %}grey{% endif %}.png"/></a>
{% endif %}
</td>
<td>
<h2><a href="{{ bookmark.url }}">{{ bookmark.description }}</a></h2>
<div class="url">{% if bookmark.get_favicon_url %}<img src="{{ bookmark.get_favicon_url }}" width="16" height="16" /> {% endif %}{{ bookmark.url }}</div>
<div class="body">{{ bookmark.note|linebreaks }}</div>
<div class="save">
{% blocktrans count bookmark.saved_instances.count as count %}
Saved once
{% plural %}
Saved {{ count }} times
{% endblocktrans %}
{% if bookmark in user_bookmarks %}
{% blocktrans %}(including you){% endblocktrans %}
{% else %}
(<a href="{% url add_bookmark %}?url={{ bookmark.url }};description={{ bookmark.description }}">{% blocktrans %}save{% endblocktrans %}</a>)
{% endif %}
</div>
<div class="tags">{% show_tag_counts bookmark.all_tags_with_counts %}</div>
</td>
</tr>
{% endfor %}
</table>
{% paginate %}
{% endwith %}
{% else %}
<p>{% trans "No bookmarks yet." %}</p>
{% endif %}
{% endblock %}
{% block extra_body %}
<script>
function vote(bookmark_id, direction) {
$.post(bookmark_id + '/' + direction + 'vote/', function(data) {
var jsonResult = eval('(' + data + ')');
var new_score = jsonResult.score.score;
$('#bookmark_' + bookmark_id + '_score').text(new_score + ' point' + (new_score == 1 ? '': 's'));
});
if (direction == 'up') {
$('#up_' + bookmark_id).replaceWith('<a id="up_' + bookmark_id + '" href="#" onclick="return false;"><img src="{{ STATIC_URL }}bookmarks/img/up_mod.png"/>');
$('#down_' + bookmark_id).replaceWith('<a id="down_' + bookmark_id + '" href="#" onclick="vote(' + bookmark_id + ', \'clear\'); return false;"><img src="{{ STATIC_URL }}bookmarks/img/down_grey.png"/>');
}
else if (direction == 'down') {
$('#up_' + bookmark_id).replaceWith('<a id="up_' + bookmark_id + '" href="#" onclick="vote(' + bookmark_id + ', \'clear\'); return false;"><img src="{{ STATIC_URL }}bookmarks/img/up_grey.png"/>');
$('#down_' + bookmark_id).replaceWith('<a id="down_' + bookmark_id + '" href="#" onclick="return false;"><img src="{{ STATIC_URL }}bookmarks/img/down_mod.png"/>');
}
else { // clear
$('#up_' + bookmark_id).replaceWith('<a id="up_' + bookmark_id + '" href="#" onclick="vote(' + bookmark_id + ', \'up\'); return false;"><img src="{{ STATIC_URL }}bookmarks/img/up_grey.png"/>');
$('#down_' + bookmark_id).replaceWith('<a id="down_' + bookmark_id + '" href="#" onclick="vote(' + bookmark_id + ', \'down\'); return false;"><img src="{{ STATIC_URL }}bookmarks/img/down_grey.png"/>');
}
}
</script>
{% endblock %}
Jump to Line
Something went wrong with that request. Please try again.