diff --git a/app/helpers/admin/citations_helper.rb b/app/helpers/admin/citations_helper.rb new file mode 100644 index 0000000000..a383aa7d67 --- /dev/null +++ b/app/helpers/admin/citations_helper.rb @@ -0,0 +1,18 @@ +# Helpers for displaying Citations in the admin interface +module Admin::CitationsHelper + ICONS = { + journalism: '🗞️', + campaigning: '📣', + academic: '🎓', + other: '🌐' + }.with_indifferent_access.freeze + + def citation_icon(citation) + html_attrs = { + title: citation.type.humanize, + class: "citation-icon citation-icon--#{citation.type}" + } + + tag.span(ICONS.fetch(citation.type), **html_attrs) + end +end diff --git a/app/helpers/admin_helper.rb b/app/helpers/admin_helper.rb index b8fe71a8a3..27069eec66 100644 --- a/app/helpers/admin_helper.rb +++ b/app/helpers/admin_helper.rb @@ -1,6 +1,7 @@ module AdminHelper include Admin::BootstrapHelper include Admin::CensorRulesHelper + include Admin::CitationsHelper include Admin::LinkHelper include Admin::ProminenceHelper diff --git a/app/models/citation.rb b/app/models/citation.rb index 8758f522fb..460eb357ef 100644 --- a/app/models/citation.rb +++ b/app/models/citation.rb @@ -29,7 +29,7 @@ class Citation < ApplicationRecord message: _('Source URL is too long') }, format: { with: /\Ahttps?:\/\/.*\z/, message: _('Please enter a Source URL') } - validates :type, inclusion: { in: %w(news_story academic_paper other), + validates :type, inclusion: { in: %w(journalism academic campaigning other), message: _('Please select a type') } scope :newest, ->(limit = 1) do diff --git a/app/views/admin/citations/_list.html.erb b/app/views/admin/citations/_list.html.erb index c594b4ad65..d620a9b7f7 100644 --- a/app/views/admin/citations/_list.html.erb +++ b/app/views/admin/citations/_list.html.erb @@ -3,6 +3,7 @@ <% citations.each do |citation| %>
+ <%= citation_icon(citation) %> <%= link_to citation.source_url, citation.source_url %> diff --git a/app/views/citations/new.html.erb b/app/views/citations/new.html.erb index e5dd283201..bc8d604b28 100644 --- a/app/views/citations/new.html.erb +++ b/app/views/citations/new.html.erb @@ -23,14 +23,19 @@ <%= _('What type of article is it?') %> -