diff --git a/media/css/style.scss b/media/css/style.scss index 694b68e..4910594 100644 --- a/media/css/style.scss +++ b/media/css/style.scss @@ -682,10 +682,9 @@ article.snipt { } &.copy { background-image: url('/static/images/copy-icon.png'); - - span.done { - display: none; - } + } + &.favorite { + background-image: url('/static/images/favorite-icon.png'); } } } @@ -791,6 +790,14 @@ article.snipt { } } } + div.modal { + textarea { + font: normal 12px/16px $Consolas; + height: 200px; + margin: 0; + width: 520px; + } + } &.selected { div.container { -webkit-box-shadow: 0 0 20px #85D2DD; @@ -802,12 +809,17 @@ article.snipt { } } } - div.modal { - textarea { - font: normal 12px/16px $Consolas; - height: 200px; - margin: 0; - width: 520px; + &.favorited { + div.container { + header { + @include vertical-gradient-with-image(url('/static/images/favorited-icon.png') top right no-repeat, #FFF, #FFFAF2); + + h1 { + a { + padding-right: 25px; + } + } + } } } } diff --git a/media/images/favorite-icon.png b/media/images/favorite-icon.png new file mode 100644 index 0000000..f79434a Binary files /dev/null and b/media/images/favorite-icon.png differ diff --git a/media/images/favorited-icon.png b/media/images/favorited-icon.png new file mode 100644 index 0000000..1a80594 Binary files /dev/null and b/media/images/favorited-icon.png differ diff --git a/media/js/src/modules/snipt.js b/media/js/src/modules/snipt.js index 45be1e6..d92b0a2 100644 --- a/media/js/src/modules/snipt.js +++ b/media/js/src/modules/snipt.js @@ -174,6 +174,14 @@ }); return false; }, + favorite: function() { + + }, + initFavorite: function() { + this.$favorite.click(function() { + return false; + }); + }, initLocalVars: function() { this.$aside = $('aside', this.$el); this.$container = $('div.container', this.$el); @@ -182,6 +190,7 @@ this.$copyModalBody = $('div.modal-body', this.$copyModal); this.$embedModal = $('div.embed-modal', this.$el); this.$embedModalBody = $('div.modal-body', this.$embedModal); + this.$favorite = $('a.favorite', this.$el); this.$h1 = $('header h1 a', this.$el); this.$tags = $('section.tags ul', this.$aside); @@ -196,6 +205,10 @@ window.ui_halted = false; window.from_modal = true; }); + + if (this.$favorite.length) { + this.initFavorite(); + } }, next: function() { if (!window.ui_halted) { @@ -283,6 +296,9 @@ selectFromClick: function(e) { this.select(true); e.stopPropagation(); + }, + unFavorite: function() { + } }); Snipt.SniptListView = Backbone.View.extend({ diff --git a/snipts/templates/snipts/snipt-js-template.html b/snipts/templates/snipts/snipt-js-template.html index 70a6236..5d244db 100644 --- a/snipts/templates/snipts/snipt-js-template.html +++ b/snipts/templates/snipts/snipt-js-template.html @@ -34,7 +34,7 @@ Embed
  • - Copy + Copy
  • diff --git a/snipts/templates/snipts/snipt-list.html b/snipts/templates/snipts/snipt-list.html index c944619..f95bc79 100644 --- a/snipts/templates/snipts/snipt-list.html +++ b/snipts/templates/snipts/snipt-list.html @@ -1,6 +1,6 @@ -{% load humanize %} +{% load humanize snipt_tags %} -
    +
    #{{ snipt.pk }}
    @@ -33,8 +33,17 @@ Embed
  • - Copy + Copy
  • + {% if snipt.user != request.user and request.user.is_authenticated %} +
  • + {% if snipt|is_favorited_by:request.user %} + Favorited + {% else %} + Favorite + {% endif %} +
  • + {% endif %}

    {{ snipt.tags.all|length }} tag{{ snipt.tags.all|pluralize }}

    diff --git a/snipts/templatetags/__init__.py b/snipts/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/snipts/templatetags/snipt_tags.py b/snipts/templatetags/snipt_tags.py new file mode 100644 index 0000000..69fe2c8 --- /dev/null +++ b/snipts/templatetags/snipt_tags.py @@ -0,0 +1,14 @@ +from django import template + +from snipts.models import Favorite + +register = template.Library() + + +@register.filter +def is_favorited_by(snipt, user): + try: + Favorite.objects.get(snipt=snipt, user=user) + return True + except Favorite.DoesNotExist: + return False