forked from treehouse/mastodon
A lot of fixes from a live test
parent
f1654da7ad
commit
47d50b0e39
|
@ -56,6 +56,13 @@
|
||||||
background: darken($background-color, 5%);
|
background: darken($background-color, 5%);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&.entry-follow, &.entry-favourite {
|
||||||
|
.content {
|
||||||
|
padding-top: 10px;
|
||||||
|
padding-bottom: 10px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
&:last-child {
|
&:last-child {
|
||||||
border-bottom: 0;
|
border-bottom: 0;
|
||||||
}
|
}
|
||||||
|
@ -127,6 +134,15 @@
|
||||||
font-size: 16px;
|
font-size: 16px;
|
||||||
padding: 0 10px;
|
padding: 0 10px;
|
||||||
padding-left: 8px;
|
padding-left: 8px;
|
||||||
|
|
||||||
|
a {
|
||||||
|
color: $primary-color;
|
||||||
|
text-decoration: none;
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.time {
|
.time {
|
||||||
|
|
|
@ -19,7 +19,12 @@ class XrdController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def username_from_resource
|
def username_from_resource
|
||||||
params[:resource].split('@').first.gsub('acct:', '')
|
if params[:resource].start_with?('acct:')
|
||||||
|
params[:resource].split('@').first.gsub('acct:', '')
|
||||||
|
else
|
||||||
|
url = Addressable::URI.parse(params[:resource])
|
||||||
|
url.path.gsub('/users/', '')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def pem_to_magic_key(public_key)
|
def pem_to_magic_key(public_key)
|
||||||
|
|
|
@ -22,6 +22,14 @@ module ApplicationHelper
|
||||||
add_base_url_prefix salmon_path(id: account.id, format: '')
|
add_base_url_prefix salmon_path(id: account.id, format: '')
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def profile_url(account)
|
||||||
|
account.local? ? super(name: account.username) : account.url
|
||||||
|
end
|
||||||
|
|
||||||
|
def status_url(status)
|
||||||
|
status.local? ? super(name: status.account.username, id: status.stream_entry.id) : status.url
|
||||||
|
end
|
||||||
|
|
||||||
def add_base_url_prefix(suffix)
|
def add_base_url_prefix(suffix)
|
||||||
File.join(root_url, "api", suffix)
|
File.join(root_url, "api", suffix)
|
||||||
end
|
end
|
||||||
|
|
|
@ -3,14 +3,6 @@ module ProfileHelper
|
||||||
account.display_name.blank? ? account.username : account.display_name
|
account.display_name.blank? ? account.username : account.display_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def profile_url(account)
|
|
||||||
account.local? ? super(name: account.username) : account.url
|
|
||||||
end
|
|
||||||
|
|
||||||
def status_url(status)
|
|
||||||
status.local? ? super(name: status.account.username, id: status.stream_entry.id) : status.url
|
|
||||||
end
|
|
||||||
|
|
||||||
def avatar_for_status_url(status)
|
def avatar_for_status_url(status)
|
||||||
status.reblog? ? status.reblog.account.avatar.url(:small) : status.account.avatar.url(:small)
|
status.reblog? ? status.reblog.account.avatar.url(:small) : status.account.avatar.url(:small)
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,6 +2,7 @@ module RoutingHelper
|
||||||
extend ActiveSupport::Concern
|
extend ActiveSupport::Concern
|
||||||
include Rails.application.routes.url_helpers
|
include Rails.application.routes.url_helpers
|
||||||
include GrapeRouteHelpers::NamedRouteMatcher
|
include GrapeRouteHelpers::NamedRouteMatcher
|
||||||
|
include ActionView::Helpers::AssetUrlHelper
|
||||||
|
|
||||||
included do
|
included do
|
||||||
def default_url_options
|
def default_url_options
|
||||||
|
|
|
@ -9,7 +9,7 @@ class FollowService < BaseService
|
||||||
|
|
||||||
follow = source_account.follow!(target_account)
|
follow = source_account.follow!(target_account)
|
||||||
send_interaction_service.(follow.stream_entry, target_account)
|
send_interaction_service.(follow.stream_entry, target_account)
|
||||||
source_account.ping!(atom_user_stream_url(id: source_account.id), HUB_URL)
|
source_account.ping!(atom_user_stream_url(id: source_account.id), [HUB_URL])
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
|
@ -7,7 +7,7 @@ class PostStatusService < BaseService
|
||||||
def call(account, text, in_reply_to = nil)
|
def call(account, text, in_reply_to = nil)
|
||||||
status = account.statuses.create!(text: text, thread: in_reply_to)
|
status = account.statuses.create!(text: text, thread: in_reply_to)
|
||||||
process_mentions_service.(status)
|
process_mentions_service.(status)
|
||||||
account.ping!(atom_user_stream_url(id: account.id), HUB_URL)
|
account.ping!(atom_user_stream_url(id: account.id), [HUB_URL])
|
||||||
status
|
status
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class ProcessFeedService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
xml.xpath('//xmlns:entry').each do |entry|
|
xml.xpath('//xmlns:entry').each do |entry|
|
||||||
next unless [:note, :comment, :activity].includes? object_type(entry)
|
next unless [:note, :comment, :activity].include? object_type(entry)
|
||||||
|
|
||||||
status = Status.find_by(uri: activity_id(entry))
|
status = Status.find_by(uri: activity_id(entry))
|
||||||
|
|
||||||
|
@ -88,7 +88,7 @@ class ProcessFeedService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def thread_id(xml)
|
def thread_id(xml)
|
||||||
xml.at_xpath('./thr:in-reply-to-id').attribute('ref').value
|
xml.at_xpath('./thr:in-reply-to').attribute('ref').value
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
end
|
||||||
|
|
|
@ -43,7 +43,7 @@ class ProcessInteractionService < BaseService
|
||||||
end
|
end
|
||||||
|
|
||||||
def mentions_account?(xml, account)
|
def mentions_account?(xml, account)
|
||||||
xml.xpath('/xmlns:entry/xmlns:link[@rel="mentioned"]').each { |mention_link| return true if mention_link.attribute('ref') == profile_url(name: account.username) }
|
xml.xpath('/xmlns:entry/xmlns:link[@rel="mentioned"]').each { |mention_link| return true if mention_link.attribute('href').value == profile_url(account) }
|
||||||
false
|
false
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -5,7 +5,7 @@ class ReblogService < BaseService
|
||||||
# @return [Status]
|
# @return [Status]
|
||||||
def call(account, reblogged_status)
|
def call(account, reblogged_status)
|
||||||
reblog = account.statuses.create!(reblog: reblogged_status, text: '')
|
reblog = account.statuses.create!(reblog: reblogged_status, text: '')
|
||||||
account.ping!(atom_user_stream_url(id: account.id), HUB_URL)
|
account.ping!(atom_user_stream_url(id: account.id), [HUB_URL])
|
||||||
return reblog if reblogged_status.local?
|
return reblog if reblogged_status.local?
|
||||||
send_interaction_service.(reblog.stream_entry, reblogged_status.account)
|
send_interaction_service.(reblog.stream_entry, reblogged_status.account)
|
||||||
reblog
|
reblog
|
||||||
|
|
|
@ -5,7 +5,7 @@ class SendInteractionService < BaseService
|
||||||
# @param [StreamEntry] stream_entry
|
# @param [StreamEntry] stream_entry
|
||||||
# @param [Account] target_account
|
# @param [Account] target_account
|
||||||
def call(stream_entry, target_account)
|
def call(stream_entry, target_account)
|
||||||
envelope = salmon.pack(entry_xml(stream_entry), target_account.keypair)
|
envelope = salmon.pack(entry_xml(stream_entry), stream_entry.account.keypair)
|
||||||
salmon.post(target_account.salmon_url, envelope)
|
salmon.post(target_account.salmon_url, envelope)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
.entry.entry-favourite
|
||||||
|
.content
|
||||||
|
%strong= favourite.account.acct
|
||||||
|
favourited a post by
|
||||||
|
%strong= favourite.status.account.acct
|
|
@ -0,0 +1,5 @@
|
||||||
|
.entry.entry-follow
|
||||||
|
.content
|
||||||
|
%strong= follow.account.acct
|
||||||
|
is now following
|
||||||
|
%strong= follow.target_account.acct
|
|
@ -14,7 +14,7 @@
|
||||||
.header
|
.header
|
||||||
= render partial: 'status_header', locals: { status: status.reblog? ? status.reblog : status }
|
= render partial: 'status_header', locals: { status: status.reblog? ? status.reblog : status }
|
||||||
.content
|
.content
|
||||||
= status.content
|
= status.content.html_safe
|
||||||
.counters
|
.counters
|
||||||
= render partial: 'status_footer', locals: { status: status.reblog? ? status.reblog : status }
|
= render partial: 'status_footer', locals: { status: status.reblog? ? status.reblog : status }
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
Nokogiri::XML::Builder.new do |xml|
|
Nokogiri::XML::Builder.new do |xml|
|
||||||
xml.XRD(xmlns: 'http://docs.oasis-open.org/ns/xri/xrd-1.0') do
|
xml.XRD(xmlns: 'http://docs.oasis-open.org/ns/xri/xrd-1.0') do
|
||||||
xml.Subject @canonical_account_uri
|
xml.Subject @canonical_account_uri
|
||||||
xml.Alias profile_url(name: @account.username)
|
xml.Alias profile_url(@account)
|
||||||
xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: profile_url(name: @account.username))
|
xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: profile_url(@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: '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: salmon_url(@account))
|
||||||
xml.Link(rel: 'magic-public-key', href: @magic_key)
|
xml.Link(rel: 'magic-public-key', href: @magic_key)
|
||||||
|
|
|
@ -34,4 +34,12 @@ RSpec.describe ApplicationHelper, type: :helper do
|
||||||
expect(helper.add_base_url_prefix('test')).to eql "#{root_url}api/test"
|
expect(helper.add_base_url_prefix('test')).to eql "#{root_url}api/test"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '#profile_url' do
|
||||||
|
pending
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '#status_url' do
|
||||||
|
pending
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -5,14 +5,6 @@ RSpec.describe ProfileHelper, type: :helper do
|
||||||
pending
|
pending
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#profile_url' do
|
|
||||||
pending
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#status_url' do
|
|
||||||
pending
|
|
||||||
end
|
|
||||||
|
|
||||||
describe '#avatar_for_status_url' do
|
describe '#avatar_for_status_url' do
|
||||||
pending
|
pending
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue