summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-02-28 15:46:29 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-02-28 15:46:29 +0100
commit47d50b0e3967f1d396bdbe8ea3e8909ce2be599f (patch)
tree07b076154cbe66f2d1a31dbb9662892fb24c8156
parentf1654da7ad11920979d335798cfeef2e88118c1b (diff)
A lot of fixes from a live test
-rw-r--r--app/assets/stylesheets/profile.scss16
-rw-r--r--app/controllers/xrd_controller.rb7
-rw-r--r--app/helpers/application_helper.rb8
-rw-r--r--app/helpers/profile_helper.rb8
-rw-r--r--app/helpers/routing_helper.rb1
-rw-r--r--app/services/follow_service.rb2
-rw-r--r--app/services/post_status_service.rb2
-rw-r--r--app/services/process_feed_service.rb4
-rw-r--r--app/services/process_interaction_service.rb2
-rw-r--r--app/services/reblog_service.rb2
-rw-r--r--app/services/send_interaction_service.rb2
-rw-r--r--app/views/profile/_favourite.html.haml5
-rw-r--r--app/views/profile/_follow.html.haml5
-rw-r--r--app/views/profile/_status.html.haml2
-rw-r--r--app/views/xrd/webfinger.xml.ruby4
-rw-r--r--spec/helpers/application_helper_spec.rb8
-rw-r--r--spec/helpers/profile_helper_spec.rb8
17 files changed, 59 insertions, 27 deletions
diff --git a/app/assets/stylesheets/profile.scss b/app/assets/stylesheets/profile.scss
index 71466527ed0..49ce98d025d 100644
--- 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
index 6fda75a03e4..417d4f4fa45 100644
--- 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
index 4c65a78bbf2..90b45a02520 100644
--- 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
index cb19638d381..3a34dfbd863 100644
--- 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
index 655e6bc264b..39060262388 100644
--- 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
index bcf7f5f97ba..55cb9bdcacc 100644
--- 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
index 64519a4003d..e19c0584e19 100644
--- 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
index 1c85942f39e..146869552d8 100644
--- 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
index b5ceaac06c0..2ebaa5296e3 100644
--- 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
index 66b7634fb08..4c76e503809 100644
--- 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
index 42b273ed672..5385831edf8 100644
--- 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
new file mode 100644
index 00000000000..85e3a082492
--- /dev/null
+++ 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
new file mode 100644
index 00000000000..c1c0813746b
--- /dev/null
+++ 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
index 1edd8df7795..b089036b17d 100644
--- 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
index ce21f148abd..42adc6551e6 100644
--- 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
index ad4284768d9..0599c46e65a 100644
--- 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
index cd5952717cb..77712105c6b 100644
--- 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