Refactoring Grape API methods into normal controllers & other things

This commit is contained in:
Eugen Rochko
2016-02-29 19:42:08 +01:00
parent 11ff92c9d7
commit 0e8f59c16f
63 changed files with 336 additions and 406 deletions

View File

@ -1,6 +1,6 @@
Nokogiri::XML::Builder.new do |xml|
feed(xml) do
simple_id xml, atom_user_stream_url(id: @account.id)
simple_id xml, account_url(@account, format: 'atom')
title xml, @account.display_name
subtitle xml, @account.note
updated_at xml, stream_updated_at
@ -10,10 +10,10 @@ Nokogiri::XML::Builder.new do |xml|
include_author xml, @account
end
link_alternate xml, profile_url(@account)
link_self xml, atom_user_stream_url(id: @account.id)
link_alternate xml, url_for_target(@account)
link_self xml, account_url(@account, format: 'atom')
link_hub xml, HUB_URL
link_salmon xml, salmon_url(@account)
link_salmon xml, api_salmon_url(@account.id)
@account.stream_entries.order('id desc').each do |stream_entry|
entry(xml, false) do

View File

@ -1,6 +1,6 @@
- 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) }/
%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)
@ -11,4 +11,4 @@
.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 }
= render partial: 'stream_entries/status', locals: { status: status, include_threads: false, is_successor: false, is_predecessor: false }

View File

@ -1,2 +0,0 @@
- if status.reply?
= link_to "In response to #{status.thread.account.acct}", status_url(status.thread), class: 'conversation-link'

View File

@ -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)

View File

@ -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 }

View File

@ -6,17 +6,23 @@
.pre-header
%i.fa.fa-retweet
Shared by
= link_to display_name(status.account), profile_url(status.account), class: 'name'
= 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
= render partial: 'status_header', locals: { status: status.reblog? ? status.reblog : status }
= 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
.counters
= render partial: 'status_footer', locals: { status: status.reblog? ? status.reblog : status }
- if include_threads
- status.replies.each do |status|

View File

@ -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 }

View File

@ -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