From 0e8f59c16fcb21301c736ecbc4424cb4c5388c42 Mon Sep 17 00:00:00 2001 From: Eugen Rochko Date: Mon, 29 Feb 2016 19:42:08 +0100 Subject: Refactoring Grape API methods into normal controllers & other things --- app/views/accounts/show.atom.ruby | 24 ++++++++++++++++++++++ app/views/accounts/show.html.haml | 14 +++++++++++++ app/views/atom/entry.xml.ruby | 9 --------- app/views/atom/user_stream.xml.ruby | 24 ---------------------- app/views/profile/_favourite.html.haml | 5 ----- app/views/profile/_follow.html.haml | 5 ----- app/views/profile/_status.html.haml | 23 --------------------- app/views/profile/_status_footer.html.haml | 2 -- app/views/profile/_status_header.html.haml | 7 ------- app/views/profile/entry.html.haml | 5 ----- app/views/profile/show.html.haml | 14 ------------- app/views/stream_entries/_favourite.html.haml | 5 +++++ app/views/stream_entries/_follow.html.haml | 5 +++++ app/views/stream_entries/_status.html.haml | 29 +++++++++++++++++++++++++++ app/views/stream_entries/show.atom.ruby | 9 +++++++++ app/views/stream_entries/show.html.haml | 5 +++++ app/views/xrd/webfinger.xml.ruby | 6 +++--- 17 files changed, 94 insertions(+), 97 deletions(-) create mode 100644 app/views/accounts/show.atom.ruby create mode 100644 app/views/accounts/show.html.haml delete mode 100644 app/views/atom/entry.xml.ruby delete mode 100644 app/views/atom/user_stream.xml.ruby delete mode 100644 app/views/profile/_favourite.html.haml delete mode 100644 app/views/profile/_follow.html.haml delete mode 100644 app/views/profile/_status.html.haml delete mode 100644 app/views/profile/_status_footer.html.haml delete mode 100644 app/views/profile/_status_header.html.haml delete mode 100644 app/views/profile/entry.html.haml delete mode 100644 app/views/profile/show.html.haml create mode 100644 app/views/stream_entries/_favourite.html.haml create mode 100644 app/views/stream_entries/_follow.html.haml create mode 100644 app/views/stream_entries/_status.html.haml create mode 100644 app/views/stream_entries/show.atom.ruby create mode 100644 app/views/stream_entries/show.html.haml (limited to 'app/views') diff --git a/app/views/accounts/show.atom.ruby b/app/views/accounts/show.atom.ruby new file mode 100644 index 000000000..12d2bb233 --- /dev/null +++ b/app/views/accounts/show.atom.ruby @@ -0,0 +1,24 @@ +Nokogiri::XML::Builder.new do |xml| + feed(xml) do + simple_id xml, account_url(@account, format: 'atom') + title xml, @account.display_name + subtitle xml, @account.note + updated_at xml, stream_updated_at + logo xml, asset_url(@account.avatar.url(:medium)) + + author(xml) do + include_author xml, @account + end + + link_alternate xml, url_for_target(@account) + link_self xml, account_url(@account, format: 'atom') + link_hub xml, HUB_URL + link_salmon xml, api_salmon_url(@account.id) + + @account.stream_entries.order('id desc').each do |stream_entry| + entry(xml, false) do + include_entry xml, stream_entry + end + end + end +end.to_xml diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml new file mode 100644 index 000000000..113db12f6 --- /dev/null +++ b/app/views/accounts/show.html.haml @@ -0,0 +1,14 @@ +- content_for :header_tags do + %link{ rel: 'salmon', href: api_salmon_url(@account.id) }/ + %link{ rel: 'alternate', type: 'application/atom+xml', href: account_url(@account, format: 'atom') }/ + +.card + .avatar= image_tag @account.avatar.url(:medium) + .bio + %h1.name + = @account.display_name.blank? ? @account.username : @account.display_name + %small= "@#{@account.username}" + +.activity-stream + - @account.statuses.order('id desc').each do |status| + = render partial: 'stream_entries/status', locals: { status: status, include_threads: false, is_successor: false, is_predecessor: false } diff --git a/app/views/atom/entry.xml.ruby b/app/views/atom/entry.xml.ruby deleted file mode 100644 index e0e089f46..000000000 --- a/app/views/atom/entry.xml.ruby +++ /dev/null @@ -1,9 +0,0 @@ -Nokogiri::XML::Builder.new do |xml| - entry(xml, true) do - author(xml) do - include_author xml, @entry.account - end - - include_entry xml, @entry - end -end.to_xml diff --git a/app/views/atom/user_stream.xml.ruby b/app/views/atom/user_stream.xml.ruby deleted file mode 100644 index 00b2cdc14..000000000 --- a/app/views/atom/user_stream.xml.ruby +++ /dev/null @@ -1,24 +0,0 @@ -Nokogiri::XML::Builder.new do |xml| - feed(xml) do - simple_id xml, atom_user_stream_url(id: @account.id) - title xml, @account.display_name - subtitle xml, @account.note - updated_at xml, stream_updated_at - logo xml, asset_url(@account.avatar.url(:medium)) - - author(xml) do - include_author xml, @account - end - - link_alternate xml, profile_url(@account) - link_self xml, atom_user_stream_url(id: @account.id) - link_hub xml, HUB_URL - link_salmon xml, salmon_url(@account) - - @account.stream_entries.order('id desc').each do |stream_entry| - entry(xml, false) do - include_entry xml, stream_entry - end - end - end -end.to_xml diff --git a/app/views/profile/_favourite.html.haml b/app/views/profile/_favourite.html.haml deleted file mode 100644 index 85e3a0824..000000000 --- a/app/views/profile/_favourite.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -.entry.entry-favourite - .content - %strong= favourite.account.acct - favourited a post by - %strong= favourite.status.account.acct diff --git a/app/views/profile/_follow.html.haml b/app/views/profile/_follow.html.haml deleted file mode 100644 index c1c081374..000000000 --- a/app/views/profile/_follow.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -.entry.entry-follow - .content - %strong= follow.account.acct - is now following - %strong= follow.target_account.acct diff --git a/app/views/profile/_status.html.haml b/app/views/profile/_status.html.haml deleted file mode 100644 index b089036b1..000000000 --- a/app/views/profile/_status.html.haml +++ /dev/null @@ -1,23 +0,0 @@ -- if status.reply? && include_threads - = render partial: 'status', locals: { status: status.thread, include_threads: false, is_predecessor: true, is_successor: false } - -.entry{ class: entry_classes(status, is_predecessor, is_successor, include_threads) } - - if status.reblog? - .pre-header - %i.fa.fa-retweet - Shared by - = link_to display_name(status.account), profile_url(status.account), class: 'name' - .entry__container - .avatar - = image_tag avatar_for_status_url(status) - .entry__container__container - .header - = render partial: 'status_header', locals: { status: status.reblog? ? status.reblog : status } - .content - = status.content.html_safe - .counters - = render partial: 'status_footer', locals: { status: status.reblog? ? status.reblog : status } - -- if include_threads - - status.replies.each do |status| - = render partial: 'status', locals: { status: status, include_threads: false, is_successor: true, is_predecessor: false } diff --git a/app/views/profile/_status_footer.html.haml b/app/views/profile/_status_footer.html.haml deleted file mode 100644 index a2333df15..000000000 --- a/app/views/profile/_status_footer.html.haml +++ /dev/null @@ -1,2 +0,0 @@ -- if status.reply? - = link_to "In response to #{status.thread.account.acct}", status_url(status.thread), class: 'conversation-link' diff --git a/app/views/profile/_status_header.html.haml b/app/views/profile/_status_header.html.haml deleted file mode 100644 index 225a89d71..000000000 --- a/app/views/profile/_status_header.html.haml +++ /dev/null @@ -1,7 +0,0 @@ -= link_to profile_url(status.account), class: 'name' do - %strong= display_name(status.account) - = "@#{status.account.acct}" - -= link_to status_url(status), class: 'time' do - %span{ title: status.created_at } - = relative_time(status.created_at) diff --git a/app/views/profile/entry.html.haml b/app/views/profile/entry.html.haml deleted file mode 100644 index e4d5db300..000000000 --- a/app/views/profile/entry.html.haml +++ /dev/null @@ -1,5 +0,0 @@ -- content_for :header_tags do - %link{ rel: 'alternate', type: 'application/atom+xml', href: atom_entry_url(id: @entry.id) }/ - -.activity-stream - = render partial: @type, locals: { @type.to_sym => @entry.activity, include_threads: true, is_predecessor: false, is_successor: false } diff --git a/app/views/profile/show.html.haml b/app/views/profile/show.html.haml deleted file mode 100644 index c02bdddcf..000000000 --- a/app/views/profile/show.html.haml +++ /dev/null @@ -1,14 +0,0 @@ -- content_for :header_tags do - %link{ rel: 'salmon', href: salmon_url(@account) }/ - %link{ rel: 'alternate', type: 'application/atom+xml', href: atom_user_stream_url(id: @account.id) }/ - -.card - .avatar= image_tag @account.avatar.url(:medium) - .bio - %h1.name - = @account.display_name.blank? ? @account.username : @account.display_name - %small= "@#{@account.username}" - -.activity-stream - - @account.statuses.order('id desc').each do |status| - = render partial: 'status', locals: { status: status, include_threads: false, is_successor: false, is_predecessor: false } diff --git a/app/views/stream_entries/_favourite.html.haml b/app/views/stream_entries/_favourite.html.haml new file mode 100644 index 000000000..85e3a0824 --- /dev/null +++ b/app/views/stream_entries/_favourite.html.haml @@ -0,0 +1,5 @@ +.entry.entry-favourite + .content + %strong= favourite.account.acct + favourited a post by + %strong= favourite.status.account.acct diff --git a/app/views/stream_entries/_follow.html.haml b/app/views/stream_entries/_follow.html.haml new file mode 100644 index 000000000..c1c081374 --- /dev/null +++ b/app/views/stream_entries/_follow.html.haml @@ -0,0 +1,5 @@ +.entry.entry-follow + .content + %strong= follow.account.acct + is now following + %strong= follow.target_account.acct diff --git a/app/views/stream_entries/_status.html.haml b/app/views/stream_entries/_status.html.haml new file mode 100644 index 000000000..89dd53613 --- /dev/null +++ b/app/views/stream_entries/_status.html.haml @@ -0,0 +1,29 @@ +- if status.reply? && include_threads + = render partial: 'status', locals: { status: status.thread, include_threads: false, is_predecessor: true, is_successor: false } + +.entry{ class: entry_classes(status, is_predecessor, is_successor, include_threads) } + - if status.reblog? + .pre-header + %i.fa.fa-retweet + Shared by + = link_to display_name(status.account), url_for_target(status.account), class: 'name' + + .entry__container + .avatar + = image_tag avatar_for_status_url(status) + + .entry__container__container + .header + = link_to url_for_target(status.reblog? ? status.reblog.account : status.account), class: 'name' do + %strong= display_name(status.reblog? ? status.reblog.account : status.account) + = "@#{status.reblog? ? status.reblog.account.acct : status.account.acct}" + = link_to url_for_target(status.reblog? ? status.reblog : status), class: 'time' do + %span{ title: status.reblog? ? status.reblog.created_at : status.created_at } + = relative_time(status.reblog? ? status.reblog.created_at : status.created_at) + + .content + = status.content.html_safe + +- if include_threads + - status.replies.each do |status| + = render partial: 'status', locals: { status: status, include_threads: false, is_successor: true, is_predecessor: false } diff --git a/app/views/stream_entries/show.atom.ruby b/app/views/stream_entries/show.atom.ruby new file mode 100644 index 000000000..e0e089f46 --- /dev/null +++ b/app/views/stream_entries/show.atom.ruby @@ -0,0 +1,9 @@ +Nokogiri::XML::Builder.new do |xml| + entry(xml, true) do + author(xml) do + include_author xml, @entry.account + end + + include_entry xml, @entry + end +end.to_xml diff --git a/app/views/stream_entries/show.html.haml b/app/views/stream_entries/show.html.haml new file mode 100644 index 000000000..6286daf53 --- /dev/null +++ b/app/views/stream_entries/show.html.haml @@ -0,0 +1,5 @@ +- content_for :header_tags do + %link{ rel: 'alternate', type: 'application/atom+xml', href: account_stream_entry_url(@account, @stream_entry, format: 'atom') }/ + +.activity-stream + = render partial: @type, locals: { @type.to_sym => @stream_entry.activity, include_threads: true, is_predecessor: false, is_successor: false } diff --git a/app/views/xrd/webfinger.xml.ruby b/app/views/xrd/webfinger.xml.ruby index 42adc6551..ac0fd3d0e 100644 --- a/app/views/xrd/webfinger.xml.ruby +++ b/app/views/xrd/webfinger.xml.ruby @@ -1,10 +1,10 @@ Nokogiri::XML::Builder.new do |xml| xml.XRD(xmlns: 'http://docs.oasis-open.org/ns/xri/xrd-1.0') do xml.Subject @canonical_account_uri - xml.Alias profile_url(@account) - xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: profile_url(@account)) + xml.Alias url_for_target(@account) + xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: url_for_target(@account)) xml.Link(rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: atom_user_stream_url(id: @account.id)) - xml.Link(rel: 'salmon', href: salmon_url(@account)) + xml.Link(rel: 'salmon', href: api_salmon_url(@account.id)) xml.Link(rel: 'magic-public-key', href: @magic_key) end end.to_xml -- cgit