2019-05-03 06:17:27 +08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2014-03-21 01:25:17 +08:00
|
|
|
module EmbedHelper
|
|
|
|
|
|
|
|
def embed_post_date(dt)
|
|
|
|
current = Time.now
|
|
|
|
|
|
|
|
if dt >= 1.day.ago
|
|
|
|
distance_of_time_in_words(dt, current)
|
|
|
|
else
|
|
|
|
if dt.year == current.year
|
|
|
|
dt.strftime("%e %b")
|
|
|
|
else
|
2014-03-24 03:22:02 +08:00
|
|
|
dt.strftime("%b '%y")
|
2014-03-21 01:25:17 +08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2018-05-10 01:24:44 +08:00
|
|
|
def get_html(post)
|
2020-03-26 20:07:41 +08:00
|
|
|
key = "js.action_codes.#{post.action_code}"
|
|
|
|
cooked = post.cooked.blank? ? I18n.t(key, when: nil).humanize : post.cooked
|
|
|
|
|
|
|
|
raw PrettyText.format_for_email(cooked, post)
|
2015-05-01 21:04:45 +08:00
|
|
|
end
|
2014-03-21 01:25:17 +08:00
|
|
|
end
|