A lot of fixes from a live test

pull/6/head
Eugen Rochko 2016-02-28 15:46:29 +01:00
parent f1654da7ad
commit 47d50b0e39
17 changed files with 59 additions and 27 deletions

View File

@ -56,6 +56,13 @@
background: darken($background-color, 5%);
}
&.entry-follow, &.entry-favourite {
.content {
padding-top: 10px;
padding-bottom: 10px;
}
}
&:last-child {
border-bottom: 0;
}
@ -127,6 +134,15 @@
font-size: 16px;
padding: 0 10px;
padding-left: 8px;
a {
color: $primary-color;
text-decoration: none;
&:hover {
text-decoration: underline;
}
}
}
.time {

View File

@ -19,7 +19,12 @@ class XrdController < ApplicationController
end
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
def pem_to_magic_key(public_key)

View File

@ -22,6 +22,14 @@ module ApplicationHelper
add_base_url_prefix salmon_path(id: account.id, format: '')
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)
File.join(root_url, "api", suffix)
end

View File

@ -3,14 +3,6 @@ module ProfileHelper
account.display_name.blank? ? account.username : account.display_name
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)
status.reblog? ? status.reblog.account.avatar.url(:small) : status.account.avatar.url(:small)
end

View File

@ -2,6 +2,7 @@ module RoutingHelper
extend ActiveSupport::Concern
include Rails.application.routes.url_helpers
include GrapeRouteHelpers::NamedRouteMatcher
include ActionView::Helpers::AssetUrlHelper
included do
def default_url_options

View File

@ -9,7 +9,7 @@ class FollowService < BaseService
follow = source_account.follow!(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
private

View File

@ -7,7 +7,7 @@ class PostStatusService < BaseService
def call(account, text, in_reply_to = nil)
status = account.statuses.create!(text: text, thread: in_reply_to)
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
end

View File

@ -10,7 +10,7 @@ class ProcessFeedService < BaseService
end
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))
@ -88,7 +88,7 @@ class ProcessFeedService < BaseService
end
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
nil
end

View File

@ -43,7 +43,7 @@ class ProcessInteractionService < BaseService
end
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
end

View File

@ -5,7 +5,7 @@ class ReblogService < BaseService
# @return [Status]
def call(account, reblogged_status)
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?
send_interaction_service.(reblog.stream_entry, reblogged_status.account)
reblog

View File

@ -5,7 +5,7 @@ class SendInteractionService < BaseService
# @param [StreamEntry] stream_entry
# @param [Account] 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)
end

View File

@ -0,0 +1,5 @@
.entry.entry-favourite
.content
%strong= favourite.account.acct
favourited a post by
%strong= favourite.status.account.acct

View File

@ -0,0 +1,5 @@
.entry.entry-follow
.content
%strong= follow.account.acct
is now following
%strong= follow.target_account.acct

View File

@ -14,7 +14,7 @@
.header
= render partial: 'status_header', locals: { status: status.reblog? ? status.reblog : status }
.content
= status.content
= status.content.html_safe
.counters
= render partial: 'status_footer', locals: { status: status.reblog? ? status.reblog : status }

View File

@ -1,8 +1,8 @@
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(name: @account.username)
xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: 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(@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: 'magic-public-key', href: @magic_key)

View File

@ -34,4 +34,12 @@ RSpec.describe ApplicationHelper, type: :helper do
expect(helper.add_base_url_prefix('test')).to eql "#{root_url}api/test"
end
end
describe '#profile_url' do
pending
end
describe '#status_url' do
pending
end
end

View File

@ -5,14 +5,6 @@ RSpec.describe ProfileHelper, type: :helper do
pending
end
describe '#profile_url' do
pending
end
describe '#status_url' do
pending
end
describe '#avatar_for_status_url' do
pending
end