about summary refs log tree commit diff
path: root/app/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers')
-rw-r--r--app/helpers/accounts_helper.rb3
-rw-r--r--app/helpers/api/salmon_helper.rb2
-rw-r--r--app/helpers/api/subscriptions_helper.rb2
-rw-r--r--app/helpers/application_helper.rb22
-rw-r--r--app/helpers/atom_builder_helper.rb (renamed from app/helpers/atom_helper.rb)32
-rw-r--r--app/helpers/stream_entries_helper.rb (renamed from app/helpers/profile_helper.rb)2
6 files changed, 24 insertions, 39 deletions
diff --git a/app/helpers/accounts_helper.rb b/app/helpers/accounts_helper.rb
new file mode 100644
index 000000000..51fe6bc4e
--- /dev/null
+++ b/app/helpers/accounts_helper.rb
@@ -0,0 +1,3 @@
+module AccountsHelper
+
+end
diff --git a/app/helpers/api/salmon_helper.rb b/app/helpers/api/salmon_helper.rb
new file mode 100644
index 000000000..513c6fb7d
--- /dev/null
+++ b/app/helpers/api/salmon_helper.rb
@@ -0,0 +1,2 @@
+module Api::SalmonHelper
+end
diff --git a/app/helpers/api/subscriptions_helper.rb b/app/helpers/api/subscriptions_helper.rb
new file mode 100644
index 000000000..3796aee42
--- /dev/null
+++ b/app/helpers/api/subscriptions_helper.rb
@@ -0,0 +1,2 @@
+module Api::SubscriptionsHelper
+end
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb
index 90b45a025..5d696316d 100644
--- a/app/helpers/application_helper.rb
+++ b/app/helpers/application_helper.rb
@@ -1,6 +1,4 @@
 module ApplicationHelper
-  include RoutingHelper
-
   def unique_tag(date, id, type)
     "tag:#{LOCAL_DOMAIN},#{date.strftime('%Y-%m-%d')}:objectId=#{id}:objectType=#{type}"
   end
@@ -13,24 +11,4 @@ module ApplicationHelper
   def local_id?(id)
     id.start_with?("tag:#{LOCAL_DOMAIN}")
   end
-
-  def subscription_url(account)
-    add_base_url_prefix subscriptions_path(id: account.id, format: '')
-  end
-
-  def salmon_url(account)
-    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
 end
diff --git a/app/helpers/atom_helper.rb b/app/helpers/atom_builder_helper.rb
index bd7aee9a0..8e3652c70 100644
--- a/app/helpers/atom_helper.rb
+++ b/app/helpers/atom_builder_helper.rb
@@ -1,4 +1,4 @@
-module AtomHelper
+module AtomBuilderHelper
   def stream_updated_at
     @account.stream_entries.last ? (@account.updated_at > @account.stream_entries.last.created_at ? @account.updated_at : @account.stream_entries.last.created_at) : @account.updated_at
   end
@@ -97,10 +97,10 @@ module AtomHelper
     xml['thr'].send('in-reply-to', { ref: uri, href: url, type: 'text/html' })
   end
 
-  def disambiguate_uri(target)
+  def uri_for_target(target)
     if target.local?
       if target.object_type == :person
-        profile_url(target)
+        account_url(target)
       else
         unique_tag(target.stream_entry.created_at, target.stream_entry.activity_id, target.stream_entry.activity_type)
       end
@@ -109,12 +109,12 @@ module AtomHelper
     end
   end
 
-  def disambiguate_url(target)
+  def url_for_target(target)
     if target.local?
       if target.object_type == :person
-        profile_url(target)
+        account_url(target)
       else
-        status_url(target)
+        account_stream_entry_url(target.account, target.stream_entry)
       end
     else
       target.url
@@ -122,13 +122,13 @@ module AtomHelper
   end
 
   def link_mention(xml, account)
-    xml.link(rel: 'mentioned', href: disambiguate_uri(account))
+    xml.link(rel: 'mentioned', href: uri_for_target(account))
   end
 
   def link_avatar(xml, account)
-    xml.link('rel' => 'avatar', 'type' => account.avatar_content_type, 'media:width' => '300', 'media:height' =>'300', 'href' => asset_url(account.avatar.url(:large)))
-    xml.link('rel' => 'avatar', 'type' => account.avatar_content_type, 'media:width' => '96', 'media:height' =>'96', 'href' => asset_url(account.avatar.url(:medium)))
-    xml.link('rel' => 'avatar', 'type' => account.avatar_content_type, 'media:width' => '48', 'media:height' =>'48', 'href' => asset_url(account.avatar.url(:small)))
+    xml.link('rel' => 'avatar', 'type' => account.avatar_content_type, 'media:width' => '300', 'media:height' =>'300', 'href' => asset_url(account.avatar.url(:large, false)))
+    xml.link('rel' => 'avatar', 'type' => account.avatar_content_type, 'media:width' => '96', 'media:height' =>'96', 'href' => asset_url(account.avatar.url(:medium, false)))
+    xml.link('rel' => 'avatar', 'type' => account.avatar_content_type, 'media:width' => '48', 'media:height' =>'48', 'href' => asset_url(account.avatar.url(:small, false)))
   end
 
   def logo(xml, url)
@@ -137,10 +137,10 @@ module AtomHelper
 
   def include_author(xml, account)
     object_type      xml, :person
-    uri              xml, profile_url(account)
+    uri              xml, url_for_target(account)
     name             xml, account.username
     summary          xml, account.note
-    link_alternate   xml, profile_url(account)
+    link_alternate   xml, url_for_target(account)
     link_avatar      xml, account
     portable_contact xml, account
   end
@@ -152,20 +152,20 @@ module AtomHelper
     title        xml, stream_entry.title
     content      xml, stream_entry.content
     verb         xml, stream_entry.verb
-    link_self    xml, atom_entry_url(id: stream_entry.id)
+    link_self    xml, account_stream_entry_url(stream_entry.account, stream_entry, format: 'atom')
     object_type  xml, stream_entry.object_type
 
     # Comments need thread element
     if stream_entry.threaded?
-      in_reply_to xml, disambiguate_uri(stream_entry.thread), disambiguate_url(stream_entry.thread)
+      in_reply_to xml, uri_for_target(stream_entry.thread), url_for_target(stream_entry.thread)
     end
 
     if stream_entry.targeted?
       target(xml) do
         object_type    xml, stream_entry.target.object_type
-        simple_id      xml, disambiguate_uri(stream_entry.target)
+        simple_id      xml, uri_for_target(stream_entry.target)
         title          xml, stream_entry.target.title
-        link_alternate xml, disambiguate_url(stream_entry.target)
+        link_alternate xml, url_for_target(stream_entry.target)
 
         # People have summary and portable contacts information
         if stream_entry.target.object_type == :person
diff --git a/app/helpers/profile_helper.rb b/app/helpers/stream_entries_helper.rb
index 3a34dfbd8..c588f5ce7 100644
--- a/app/helpers/profile_helper.rb
+++ b/app/helpers/stream_entries_helper.rb
@@ -1,4 +1,4 @@
-module ProfileHelper
+module StreamEntriesHelper
   def display_name(account)
     account.display_name.blank? ? account.username : account.display_name
   end