about summary refs log tree commit diff
path: root/app/helpers/stream_entries_helper.rb
diff options
context:
space:
mode:
authorBen Roberts <ben@thatmustbe.me>2017-04-12 14:04:33 -0400
committerEugen <eugen@zeonfederated.com>2017-04-12 20:04:33 +0200
commit0254ee9795822ec75ff64ace6ec2b91573bc9a52 (patch)
tree2e06fe9639cbfb568eedcddbc9515939158ef3cc /app/helpers/stream_entries_helper.rb
parente32edd247f04916270d5b2477c1ff1777e75cf51 (diff)
significant improvement in microformats markup (#1063)
* significant improvement in microformats markup

This is a huge improvement and I believe will close #965.

Had these microformats reviewed by others in the community to help
ensure they are at least correct, if not complete.

I did not want to change the structure of the page, and so there it does
not fully mark up the entire ancestry chain, or reply chain, only the
direct decendants and direct ancestors are correctly associated, but
this is likely fine as the most important bit is to have access to the
urls for those toots which are now correctly fetchable.

* improve code climate

* trying to pass code climate tests

* code climate

* fix p-summary for content warning posts

* fix error introduced when merging via github
Diffstat (limited to 'app/helpers/stream_entries_helper.rb')
-rw-r--r--app/helpers/stream_entries_helper.rb24
1 files changed, 19 insertions, 5 deletions
diff --git a/app/helpers/stream_entries_helper.rb b/app/helpers/stream_entries_helper.rb
index 18ef8b909..00a01df44 100644
--- a/app/helpers/stream_entries_helper.rb
+++ b/app/helpers/stream_entries_helper.rb
@@ -13,15 +13,29 @@ module StreamEntriesHelper
     "@#{account.acct}#{embedded_view? && account.local? ? "@#{Rails.configuration.x.local_domain}" : ''}"
   end
 
-  def entry_classes(status, is_predecessor, is_successor, include_threads)
+  def style_classes(status, is_predecessor, is_successor, include_threads)
     classes = ['entry']
-    classes << 'entry-reblog u-repost-of h-cite' if status.reblog?
-    classes << 'entry-predecessor u-in-reply-to h-cite' if is_predecessor
-    classes << 'entry-successor u-comment h-cite' if is_successor
-    classes << 'entry-center h-entry' if include_threads
+    classes << 'entry-predecessor' if is_predecessor
+    classes << 'entry-reblog' if status.reblog?
+    classes << 'entry-successor' if is_successor
+    classes << 'entry-center' if include_threads
     classes.join(' ')
   end
 
+  def microformats_classes(status, is_direct_parent, is_direct_child)
+    classes = []
+    classes << 'p-in-reply-to' if is_direct_parent
+    classes << 'p-repost-of' if status.reblog? && is_direct_parent
+    classes << 'p-comment' if is_direct_child
+    classes.join(' ')
+  end
+
+  def microformats_h_class(status, is_predecessor, is_successor, include_threads)
+    return 'h-cite' if is_predecessor || status.reblog || is_successor
+    return 'h-entry' unless include_threads
+    ''
+  end
+
   def rtl?(text)
     return false if text.empty?