Change RSS feeds (#18356)
* Change RSS feeds - Use date and time for titles instead of ellipsized text - Use full content in body, even when there is a content warning - Use media extensions * Change feed icons and add width and height attributes to custom emojis * Fix custom emoji animate on hover breaking * Fix tests
This commit is contained in:
parent
f17e73da09
commit
2b8dc58b7f
19 changed files with 311 additions and 307 deletions
|
@ -11,6 +11,7 @@ class EmojiFormatter
|
|||
# @param [Array<CustomEmoji>] custom_emojis
|
||||
# @param [Hash] options
|
||||
# @option options [Boolean] :animate
|
||||
# @option options [String] :style
|
||||
def initialize(html, custom_emojis, options = {})
|
||||
raise ArgumentError unless html.html_safe?
|
||||
|
||||
|
@ -85,14 +86,29 @@ class EmojiFormatter
|
|||
def image_for_emoji(shortcode, emoji)
|
||||
original_url, static_url = emoji
|
||||
|
||||
if animate?
|
||||
image_tag(original_url, draggable: false, class: 'emojione', alt: ":#{shortcode}:", title: ":#{shortcode}:")
|
||||
else
|
||||
image_tag(original_url, draggable: false, class: 'emojione custom-emoji', alt: ":#{shortcode}:", title: ":#{shortcode}:", data: { original: original_url, static: static_url })
|
||||
end
|
||||
image_tag(
|
||||
animate? ? original_url : static_url,
|
||||
image_attributes.merge(alt: ":#{shortcode}:", title: ":#{shortcode}:", data: image_data_attributes(original_url, static_url))
|
||||
)
|
||||
end
|
||||
|
||||
def image_attributes
|
||||
{ rel: 'emoji', draggable: false, width: 16, height: 16, class: image_class_names, style: image_style }
|
||||
end
|
||||
|
||||
def image_data_attributes(original_url, static_url)
|
||||
{ original: original_url, static: static_url } unless animate?
|
||||
end
|
||||
|
||||
def image_class_names
|
||||
animate? ? 'emojione' : 'emojione custom-emoji'
|
||||
end
|
||||
|
||||
def image_style
|
||||
@options[:style]
|
||||
end
|
||||
|
||||
def animate?
|
||||
@options[:animate]
|
||||
@options[:animate] || @options.key?(:style)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue