commit: 47d50b0e3967f1d396bdbe8ea3e8909ce2be599f
parent: f1654da7ad11920979d335798cfeef2e88118c1b
Author: Eugen Rochko <eugen@zeonfederated.com>
Date: Sun, 28 Feb 2016 15:46:29 +0100
A lot of fixes from a live test
Diffstat:
17 files changed, 59 insertions(+), 27 deletions(-)
diff --git a/app/assets/stylesheets/profile.scss b/app/assets/stylesheets/profile.scss
@@ -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 {
diff --git a/app/controllers/xrd_controller.rb b/app/controllers/xrd_controller.rb
@@ -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)
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
@@ -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
diff --git a/app/helpers/profile_helper.rb b/app/helpers/profile_helper.rb
@@ -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
diff --git a/app/helpers/routing_helper.rb b/app/helpers/routing_helper.rb
@@ -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
diff --git a/app/services/follow_service.rb b/app/services/follow_service.rb
@@ -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
diff --git a/app/services/post_status_service.rb b/app/services/post_status_service.rb
@@ -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
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
@@ -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
diff --git a/app/services/process_interaction_service.rb b/app/services/process_interaction_service.rb
@@ -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
diff --git a/app/services/reblog_service.rb b/app/services/reblog_service.rb
@@ -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
diff --git a/app/services/send_interaction_service.rb b/app/services/send_interaction_service.rb
@@ -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
diff --git a/app/views/profile/_favourite.html.haml b/app/views/profile/_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/profile/_follow.html.haml b/app/views/profile/_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/profile/_status.html.haml b/app/views/profile/_status.html.haml
@@ -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 }
diff --git a/app/views/xrd/webfinger.xml.ruby b/app/views/xrd/webfinger.xml.ruby
@@ -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)
diff --git a/spec/helpers/application_helper_spec.rb b/spec/helpers/application_helper_spec.rb
@@ -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
diff --git a/spec/helpers/profile_helper_spec.rb b/spec/helpers/profile_helper_spec.rb
@@ -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