From 6f0d55b22a130aa7bb2a90a730080a62bd001314 Mon Sep 17 00:00:00 2001 From: Marcin Kulik Date: Fri, 15 May 2015 17:36:12 +0000 Subject: [PATCH] Mark private and featured asciicasts --- app/assets/stylesheets/asciicasts.sass | 10 ++++++++++ app/presenters/asciicast_page_presenter.rb | 8 ++++++++ app/views/asciicasts/_featured_label.html.erb | 1 + app/views/asciicasts/_preview.html.slim | 4 ++++ app/views/asciicasts/_private_label.html.erb | 1 + app/views/asciicasts/show.html.slim | 7 ++++++- 6 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 app/views/asciicasts/_featured_label.html.erb create mode 100644 app/views/asciicasts/_private_label.html.erb diff --git a/app/assets/stylesheets/asciicasts.sass b/app/assets/stylesheets/asciicasts.sass index 7446a08..2260418 100644 --- a/app/assets/stylesheets/asciicasts.sass +++ b/app/assets/stylesheets/asciicasts.sass @@ -105,3 +105,13 @@ font-size: 12px margin-bottom: 5px padding: 6px + +.special-label + font-size: 12px + background-color: rgb(255, 239, 198) + color: rgb(161, 136, 43) + margin-left: 6px + padding: 2px 5px + border-radius: 4px + vertical-align: middle + cursor: help diff --git a/app/presenters/asciicast_page_presenter.rb b/app/presenters/asciicast_page_presenter.rb index d105967..5831b37 100644 --- a/app/presenters/asciicast_page_presenter.rb +++ b/app/presenters/asciicast_page_presenter.rb @@ -126,6 +126,14 @@ class AsciicastPagePresenter routes.oembed_url(url: routes.asciicast_url(asciicast), format: format) end + def show_private_label? + asciicast.private? + end + + def show_featured_label? + asciicast.featured? + end + private def author diff --git a/app/views/asciicasts/_featured_label.html.erb b/app/views/asciicasts/_featured_label.html.erb new file mode 100644 index 0000000..625df0e --- /dev/null +++ b/app/views/asciicasts/_featured_label.html.erb @@ -0,0 +1 @@ +featured diff --git a/app/views/asciicasts/_preview.html.slim b/app/views/asciicasts/_preview.html.slim index be43a53..d024b64 100644 --- a/app/views/asciicasts/_preview.html.slim +++ b/app/views/asciicasts/_preview.html.slim @@ -10,6 +10,10 @@ .info.clearfix h2 = link_to asciicast.title, asciicast + - if asciicast.private? + = render 'asciicasts/private_label' + - if asciicast.featured? + = render 'asciicasts/featured_label' span.duration = asciicast.formatted_duration span.author-avatar = asciicast.author_img_link small by #{asciicast.author_link} #{time_ago_tag asciicast.created_at} diff --git a/app/views/asciicasts/_private_label.html.erb b/app/views/asciicasts/_private_label.html.erb new file mode 100644 index 0000000..e7dca60 --- /dev/null +++ b/app/views/asciicasts/_private_label.html.erb @@ -0,0 +1 @@ +private diff --git a/app/views/asciicasts/show.html.slim b/app/views/asciicasts/show.html.slim index 9e29aba..23e8e5e 100644 --- a/app/views/asciicasts/show.html.slim +++ b/app/views/asciicasts/show.html.slim @@ -14,7 +14,12 @@ .row .col-md-8.col-xs-8 span.author-avatar = page.author_img_link - h2 = page.asciicast_title + h2 + = page.asciicast_title + - if page.show_private_label? + = render 'private_label' + - if page.show_featured_label? + = render 'featured_label' small by #{page.author_link} #{time_ago_tag page.asciicast_created_at} .col-md-4.col-xs-4.text-right