diff --git a/mixins/TabLike.pixy b/mixins/TabLike.pixy new file mode 100644 index 00000000..8f9fd7f6 --- /dev/null +++ b/mixins/TabLike.pixy @@ -0,0 +1,14 @@ +component TabLike(label string, icon string, typeName string, likeable arn.Likeable, user *arn.User) + if user == nil + .tab.action(aria-label=label, title="Login to like this " + typeName) + Icon(icon) + span.tab-text= label + else + if likeable.LikedBy(user.ID) + .tab.action(data-api="/api" + likeable.Link(), data-action="unlike", data-trigger="click", aria-label=label, title="Click to unlike this " + typeName) + Icon(icon) + span.tab-text= label + else + .tab.action(data-api="/api" + likeable.Link(), data-action="like", data-trigger="click", aria-label=label, title="Click to like this " + typeName) + Icon(icon + "-o") + span.tab-text= label diff --git a/mixins/TabLikeQuote.pixy b/mixins/TabLikeQuote.pixy deleted file mode 100644 index aae32d10..00000000 --- a/mixins/TabLikeQuote.pixy +++ /dev/null @@ -1,14 +0,0 @@ -component TabLikeQuote(label string, icon string, quote *arn.Quote, user *arn.User) - if user == nil - .tab.action(aria-label=label, title="Login to like this quote") - Icon(icon) - span.tab-text= label - else - if quote.LikedBy(user.ID) - .tab.action(data-api="/api" + quote.Link(), data-action="unlike", data-trigger="click", aria-label=label, title="Click to unlike this quote") - Icon(icon) - span.tab-text= label - else - .tab.action(data-api="/api" + quote.Link(), data-action="like", data-trigger="click", aria-label=label, title="Click to like this quote") - Icon(icon + "-o") - span.tab-text= label diff --git a/mixins/TabLikeTrack.pixy b/mixins/TabLikeTrack.pixy deleted file mode 100644 index 58bc5f5c..00000000 --- a/mixins/TabLikeTrack.pixy +++ /dev/null @@ -1,14 +0,0 @@ -component TabLikeTrack(label string, icon string, track *arn.SoundTrack, user *arn.User) - if user == nil - .tab.action(aria-label=label, title="Login to like this track") - Icon(icon) - span.tab-text= label - else - if track.LikedBy(user.ID) - .tab.action(data-api="/api" + track.Link(), data-action="unlike", data-trigger="click", aria-label=label, title="Click to unlike this track") - Icon(icon) - span.tab-text= label - else - .tab.action(data-api="/api" + track.Link(), data-action="like", data-trigger="click", aria-label=label, title="Click to like this track") - Icon(icon + "-o") - span.tab-text= label diff --git a/pages/quote/quote.pixy b/pages/quote/quote.pixy index 5a456e90..66f893d1 100644 --- a/pages/quote/quote.pixy +++ b/pages/quote/quote.pixy @@ -50,7 +50,7 @@ component QuoteInformation(quote *arn.Quote, user *arn.User) component QuoteTabs(quote *arn.Quote, user *arn.User) .tabs - TabLikeQuote(strconv.Itoa(len(quote.Likes)), "heart", quote, user) + TabLike(strconv.Itoa(len(quote.Likes)), "heart", "quote", quote, user) Tab("Quote", "quote-left", quote.Link()) Tab("Edit", "pencil", quote.Link() + "/edit") diff --git a/pages/soundtrack/soundtrack.pixy b/pages/soundtrack/soundtrack.pixy index 33a7e379..0beb9b26 100644 --- a/pages/soundtrack/soundtrack.pixy +++ b/pages/soundtrack/soundtrack.pixy @@ -50,6 +50,6 @@ component Track(track *arn.SoundTrack, user *arn.User) component SoundTrackTabs(track *arn.SoundTrack, user *arn.User) .tabs - TabLikeTrack(strconv.Itoa(len(track.Likes)), "heart", track, user) + TabLike(strconv.Itoa(len(track.Likes)), "heart", "track", track, user) Tab("Soundtrack", "music", track.Link()) Tab("Edit", "pencil", track.Link() + "/edit")