From 0254ee9795822ec75ff64ace6ec2b91573bc9a52 Mon Sep 17 00:00:00 2001 From: Ben Roberts Date: Wed, 12 Apr 2017 14:04:33 -0400 Subject: 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 --- app/helpers/stream_entries_helper.rb | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'app/helpers/stream_entries_helper.rb') 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? -- cgit