about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authorFire Demon <firedemon@creature.cafe>2020-08-16 04:26:16 -0500
committerFire Demon <firedemon@creature.cafe>2020-08-30 05:45:18 -0500
commit49535c6a1a6dc63daa1158dddac6155e999a4919 (patch)
tree76666f10ccc949ac8b8de30db4fdf8e14d7a4e55 /app/lib
parent6e28a99c8e46295dd049f7af45565d4bea97c725 (diff)
[Articles] Add permalink to article summaries
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/formatter.rb6
-rw-r--r--app/lib/sanitize_config.rb2
2 files changed, 7 insertions, 1 deletions
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index bf99701b7..dec60a3ea 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -76,6 +76,7 @@ class Formatter
     end
 
     html = format_article_content(summary, html) if options[:article_content] && summary.present?
+    html = format_article_summary(html, status) if !options[:article_content] && summary.present?
     html.html_safe # rubocop:disable Rails/OutputSafety
   end
 
@@ -89,6 +90,11 @@ class Formatter
     text.html_safe # rubocop:disable Rails/OutputSafety
   end
 
+  def format_article_summary(html, status)
+    status_url = ActivityPub::TagManager.instance.url_for(status)
+    "#{html}\n<p data-name=\"permalink\"><span>📄&nbsp;</span>#{link_url(status_url)}</p>"
+  end
+
   def format_article_content(summary, html)
     "<blockquote data-name=\"summary\">#{format_summary(summary, html)}</blockquote>#{html}"
   end
diff --git a/app/lib/sanitize_config.rb b/app/lib/sanitize_config.rb
index 102dce2d2..93260c7dc 100644
--- a/app/lib/sanitize_config.rb
+++ b/app/lib/sanitize_config.rb
@@ -43,7 +43,7 @@ class Sanitize
       return unless name_list
 
       name_list.keep_if do |name|
-        next true if %w(summary abstract).include?(name)
+        next true if %w(summary abstract permalink).include?(name)
       end
 
       node['data-name'] = name_list.join(' ')