about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/components/components/status_content.jsx4
-rw-r--r--app/assets/javascripts/components/features/ui/components/column.jsx2
-rw-r--r--app/assets/javascripts/components/features/ui/components/columns_area.jsx1
-rw-r--r--app/assets/javascripts/components/features/ui/components/drawer.jsx2
-rw-r--r--app/assets/stylesheets/application.scss4
-rw-r--r--app/assets/stylesheets/components.scss5
-rw-r--r--app/controllers/api/salmon_controller.rb10
-rw-r--r--app/controllers/auth/registrations_controller.rb2
-rw-r--r--app/lib/formatter.rb4
-rw-r--r--app/services/fetch_remote_account_service.rb2
-rw-r--r--app/services/follow_remote_account_service.rb49
-rw-r--r--app/services/process_feed_service.rb13
-rw-r--r--app/views/about/index.html.haml6
-rw-r--r--app/views/auth/confirmations/new.html.haml3
-rw-r--r--app/views/auth/passwords/edit.html.haml3
-rw-r--r--app/views/auth/passwords/new.html.haml3
-rw-r--r--app/views/auth/registrations/edit.html.haml3
-rw-r--r--app/views/auth/registrations/new.html.haml3
-rw-r--r--app/views/auth/sessions/new.html.haml3
-rw-r--r--app/views/xrd/webfinger.xml.ruby2
20 files changed, 83 insertions, 41 deletions
diff --git a/app/assets/javascripts/components/components/status_content.jsx b/app/assets/javascripts/components/components/status_content.jsx
index bf1ba54fc..357465248 100644
--- a/app/assets/javascripts/components/components/status_content.jsx
+++ b/app/assets/javascripts/components/components/status_content.jsx
@@ -22,11 +22,11 @@ const StatusContent = React.createClass({
       let mention = this.props.status.get('mentions').find(item => link.href === item.get('url'));
 
       if (mention) {
-        link.addEventListener('click', this.onMentionClick.bind(this, mention));
+        link.addEventListener('click', this.onMentionClick.bind(this, mention), false);
       } else {
         link.setAttribute('target', '_blank');
         link.setAttribute('rel', 'noopener');
-        link.addEventListener('click', this.onNormalClick);
+        link.addEventListener('click', this.onNormalClick, false);
       }
     }
   },
diff --git a/app/assets/javascripts/components/features/ui/components/column.jsx b/app/assets/javascripts/components/features/ui/components/column.jsx
index be4fa8908..c2060749a 100644
--- a/app/assets/javascripts/components/features/ui/components/column.jsx
+++ b/app/assets/javascripts/components/features/ui/components/column.jsx
@@ -30,9 +30,7 @@ const scrollTop = (node) => {
 };
 
 const style = {
-  height: '100%',
   boxSizing: 'border-box',
-  flex: '0 0 auto',
   background: '#282c37',
   display: 'flex',
   flexDirection: 'column'
diff --git a/app/assets/javascripts/components/features/ui/components/columns_area.jsx b/app/assets/javascripts/components/features/ui/components/columns_area.jsx
index 3f88b1ea3..8d316e26b 100644
--- a/app/assets/javascripts/components/features/ui/components/columns_area.jsx
+++ b/app/assets/javascripts/components/features/ui/components/columns_area.jsx
@@ -3,7 +3,6 @@ import PureRenderMixin from 'react-addons-pure-render-mixin';
 const style = {
   display: 'flex',
   flex: '1 1 auto',
-  flexDirection: 'row',
   justifyContent: 'flex-start',
   overflowX: 'auto'
 };
diff --git a/app/assets/javascripts/components/features/ui/components/drawer.jsx b/app/assets/javascripts/components/features/ui/components/drawer.jsx
index 1fbb9333e..8966602e2 100644
--- a/app/assets/javascripts/components/features/ui/components/drawer.jsx
+++ b/app/assets/javascripts/components/features/ui/components/drawer.jsx
@@ -1,8 +1,6 @@
 import PureRenderMixin from 'react-addons-pure-render-mixin';
 
 const style = {
-  height: '100%',
-  flex: '0 0 auto',
   boxSizing: 'border-box',
   background: '#454b5e',
   padding: '0',
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index ddaece8d8..60875a3b3 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -77,9 +77,9 @@ table {
 }
 
 ::-webkit-scrollbar-track {
-  -webkit-box-shadow: inset 0 0 6px rgba(0,0,0,0.3);
   border: 0px none #ffffff;
-  border-radius: 50px;
+  border-radius: 0;
+  background: rgba(0, 0, 0, 0.1);
 }
 
 ::-webkit-scrollbar-track:hover {
diff --git a/app/assets/stylesheets/components.scss b/app/assets/stylesheets/components.scss
index ef39a87ed..0fd026fee 100644
--- a/app/assets/stylesheets/components.scss
+++ b/app/assets/stylesheets/components.scss
@@ -231,6 +231,7 @@
 .columns-area {
   margin: 10px;
   margin-left: 0;
+  flex-direction: row;
 }
 
 .column {
@@ -243,15 +244,19 @@
 
 .column, .drawer {
   margin-left: 10px;
+  flex: 0 0 auto;
+  overflow: hidden;
 }
 
 @media screen and (max-width: 1024px) {
   .column, .drawer {
     width: 100%;
     margin: 0;
+    flex: 1 1 100%;
   }
 
   .columns-area {
     margin: 10px;
+    flex-direction: column;
   }
 }
diff --git a/app/controllers/api/salmon_controller.rb b/app/controllers/api/salmon_controller.rb
index 8bd653d7d..c0ba32ff2 100644
--- a/app/controllers/api/salmon_controller.rb
+++ b/app/controllers/api/salmon_controller.rb
@@ -3,8 +3,14 @@ class Api::SalmonController < ApiController
   respond_to :txt
 
   def update
-    ProcessInteractionService.new.call(request.body.read, @account)
-    head 201
+    body = request.body.read
+
+    if body.nil?
+      head 200
+    else
+      ProcessInteractionService.new.call(body, @account)
+      head 201
+    end
   end
 
   private
diff --git a/app/controllers/auth/registrations_controller.rb b/app/controllers/auth/registrations_controller.rb
index 71eb0905e..7b7f6b52d 100644
--- a/app/controllers/auth/registrations_controller.rb
+++ b/app/controllers/auth/registrations_controller.rb
@@ -17,6 +17,6 @@ class Auth::RegistrationsController < Devise::RegistrationsController
   end
 
   def after_sign_up_path_for(_resource)
-    root_path
+    new_user_session_path
   end
 end
diff --git a/app/lib/formatter.rb b/app/lib/formatter.rb
index 17d2dfc58..60bc3733e 100644
--- a/app/lib/formatter.rb
+++ b/app/lib/formatter.rb
@@ -29,7 +29,9 @@ class Formatter
   end
 
   def link_urls(html)
-    auto_link(html, link: :urls, html: { rel: 'nofollow noopener' })
+    auto_link(html, link: :urls, html: { rel: 'nofollow noopener' }) do |text|
+      truncate(text.gsub(/\Ahttps?:\/\/(www\.)?/, ''), length: 30)
+    end
   end
 
   def link_mentions(html, mentions)
diff --git a/app/services/fetch_remote_account_service.rb b/app/services/fetch_remote_account_service.rb
index 83a81a61b..8a6b1e1b4 100644
--- a/app/services/fetch_remote_account_service.rb
+++ b/app/services/fetch_remote_account_service.rb
@@ -19,6 +19,8 @@ class FetchRemoteAccountService < BaseService
     Rails.logger.debug "Going to webfinger #{username}@#{domain}"
 
     return FollowRemoteAccountService.new.call("#{username}@#{domain}")
+  rescue TypeError => e
+    Rails.logger.debug "Unparseable URL given: #{url}"
   rescue Nokogiri::XML::XPath::SyntaxError
     Rails.logger.debug "Invalid XML or missing namespace"
   end
diff --git a/app/services/follow_remote_account_service.rb b/app/services/follow_remote_account_service.rb
index 43a598635..0a95badb2 100644
--- a/app/services/follow_remote_account_service.rb
+++ b/app/services/follow_remote_account_service.rb
@@ -1,4 +1,8 @@
 class FollowRemoteAccountService < BaseService
+  include OStatus2::MagicKey
+
+  DFRN_NS = 'http://purl.org/macgirvin/dfrn/1.0'.freeze
+
   # Find or create a local account for a remote user.
   # When creating, look up the user's webfinger and fetch all
   # important information from their feed
@@ -19,27 +23,21 @@ class FollowRemoteAccountService < BaseService
 
     data = Goldfinger.finger("acct:#{uri}")
 
+    raise Goldfinger::Error, 'Missing resource links' if data.link('http://schemas.google.com/g/2010#updates-from').nil? || data.link('salmon').nil? || data.link('http://webfinger.net/rel/profile-page').nil? || data.link('magic-public-key').nil?
+
     account.remote_url  = data.link('http://schemas.google.com/g/2010#updates-from').href
     account.salmon_url  = data.link('salmon').href
     account.url         = data.link('http://webfinger.net/rel/profile-page').href
     account.public_key  = magic_key_to_pem(data.link('magic-public-key').href)
     account.private_key = nil
 
-    feed = get_feed(account.remote_url)
-    hubs = feed.xpath('//xmlns:link[@rel="hub"]')
-
-    if hubs.empty? || hubs.first.attribute('href').nil?
-      raise Goldfinger::Error, 'No PubSubHubbub hubs found'
-    end
-
-    if feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').nil?
-      raise Goldfinger::Error, 'No author URI found'
-    end
+    xml  = get_feed(account.remote_url)
+    hubs = get_hubs(xml)
 
-    account.uri     = feed.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri').content
+    account.uri     = get_account_uri(xml)
     account.hub_url = hubs.first.attribute('href').value
 
-    get_profile(feed, account)
+    get_profile(xml, account)
     account.save!
 
     return account
@@ -52,20 +50,27 @@ class FollowRemoteAccountService < BaseService
     Nokogiri::XML(response)
   end
 
-  def get_profile(xml, account)
-    author = xml.at_xpath('/xmlns:feed/xmlns:author')
-    update_remote_profile_service.call(author, account)
+  def get_hubs(xml)
+    hubs = xml.xpath('//xmlns:link[@rel="hub"]')
+    raise Goldfinger::Error, 'No PubSubHubbub hubs found' if hubs.empty? || hubs.first.attribute('href').nil?
+    hubs
   end
 
-  def magic_key_to_pem(magic_key)
-    _, modulus, exponent = magic_key.split('.')
-    modulus, exponent = [modulus, exponent].map { |n| Base64.urlsafe_decode64(n).bytes.inject(0) { |a, e| (a << 8) | e } }
+  def get_account_uri(xml)
+    author_uri = xml.at_xpath('/xmlns:feed/xmlns:author/xmlns:uri')
 
-    key   = OpenSSL::PKey::RSA.new
-    key.n = modulus
-    key.e = exponent
+    if author_uri.nil?
+      owner = xml.at_xpath('/xmlns:feed').at_xpath('./dfrn:owner', dfrn: DFRN_NS)
+      author_uri = owner.at_xpath('./xmlns:uri') unless owner.nil?
+    end
 
-    key.to_pem
+    raise Goldfinger::Error, 'Author URI could not be found' if author_uri.nil?
+    author_uri.content
+  end
+
+  def get_profile(xml, account)
+    author = xml.at_xpath('/xmlns:feed/xmlns:author') || xml.at_xpath('/xmlns:feed').at_xpath('./dfrn:owner', dfrn: DFRN_NS)
+    update_remote_profile_service.call(author, account)
   end
 
   def update_remote_profile_service
diff --git a/app/services/process_feed_service.rb b/app/services/process_feed_service.rb
index cd9bd8e93..1efa0e15a 100644
--- a/app/services/process_feed_service.rb
+++ b/app/services/process_feed_service.rb
@@ -100,9 +100,14 @@ class ProcessFeedService < BaseService
 
       next unless media.nil?
 
-      media = MediaAttachment.new(account: status.account, status: status, remote_url: enclosure_link.attribute('href').value)
-      media.file_remote_url = enclosure_link.attribute('href').value
-      media.save
+      begin
+        media = MediaAttachment.new(account: status.account, status: status, remote_url: enclosure_link.attribute('href').value)
+        media.file_remote_url = enclosure_link.attribute('href').value
+        media.save
+      rescue Paperclip::Errors::NotIdentifiedByImageMagickError
+        Rails.logger.debug "Error saving attachment from #{enclosure_link.attribute('href').value}"
+        next
+      end
     end
   end
 
@@ -213,7 +218,7 @@ class ProcessFeedService < BaseService
   end
 
   def target_url(xml)
-    xml.at_xpath('.//activity:object').at_xpath('./xmlns:link[@rel="alternate"]', activity: ACTIVITY_NS).attribute('href').value
+    xml.at_xpath('.//activity:object', activity: ACTIVITY_NS).at_xpath('./xmlns:link[@rel="alternate"]').attribute('href').value
   end
 
   def object_type(xml)
diff --git a/app/views/about/index.html.haml b/app/views/about/index.html.haml
index 8e014760e..831e7f854 100644
--- a/app/views/about/index.html.haml
+++ b/app/views/about/index.html.haml
@@ -1,3 +1,6 @@
+- content_for :page_title do
+  = Rails.configuration.x.local_domain
+
 .wrapper
   %h1
     = image_tag 'logo.png'
@@ -16,4 +19,5 @@
     is a Mastodon instance.
 
   .actions
-    = link_to 'Get started', new_user_session_path, class: 'button'
+    = link_to 'Get started', new_user_registration_path, class: 'button'
+    = link_to 'Log in', new_user_session_path, class: 'button'
diff --git a/app/views/auth/confirmations/new.html.haml b/app/views/auth/confirmations/new.html.haml
index 5c1cf5734..e287f1528 100644
--- a/app/views/auth/confirmations/new.html.haml
+++ b/app/views/auth/confirmations/new.html.haml
@@ -1,3 +1,6 @@
+- content_for :page_title do
+  Confirmation instructions
+
 = form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f|
   = devise_error_messages!
 
diff --git a/app/views/auth/passwords/edit.html.haml b/app/views/auth/passwords/edit.html.haml
index 0d5f0fe10..79a044acf 100644
--- a/app/views/auth/passwords/edit.html.haml
+++ b/app/views/auth/passwords/edit.html.haml
@@ -1,3 +1,6 @@
+- content_for :page_title do
+  Set new password
+
 = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f|
   = devise_error_messages!
   = f.hidden_field :reset_password_token
diff --git a/app/views/auth/passwords/new.html.haml b/app/views/auth/passwords/new.html.haml
index 2677feea0..416870de8 100644
--- a/app/views/auth/passwords/new.html.haml
+++ b/app/views/auth/passwords/new.html.haml
@@ -1,3 +1,6 @@
+- content_for :page_title do
+  Reset password
+
 = form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f|
   = devise_error_messages!
 
diff --git a/app/views/auth/registrations/edit.html.haml b/app/views/auth/registrations/edit.html.haml
index 943230b34..9a52af35c 100644
--- a/app/views/auth/registrations/edit.html.haml
+++ b/app/views/auth/registrations/edit.html.haml
@@ -1,3 +1,6 @@
+- content_for :page_title do
+  Change password
+
 = form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f|
   = devise_error_messages!
 
diff --git a/app/views/auth/registrations/new.html.haml b/app/views/auth/registrations/new.html.haml
index c8532ec38..97ab5498e 100644
--- a/app/views/auth/registrations/new.html.haml
+++ b/app/views/auth/registrations/new.html.haml
@@ -1,3 +1,6 @@
+- content_for :page_title do
+  Sign up
+
 = form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f|
   = devise_error_messages!
 
diff --git a/app/views/auth/sessions/new.html.haml b/app/views/auth/sessions/new.html.haml
index 220d0ec79..7cfd1cb68 100644
--- a/app/views/auth/sessions/new.html.haml
+++ b/app/views/auth/sessions/new.html.haml
@@ -1,3 +1,6 @@
+- content_for :page_title do
+  Log in
+
 = form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
   .field
     = f.email_field :email, autofocus: true, placeholder: 'E-mail address', required: true
diff --git a/app/views/xrd/webfinger.xml.ruby b/app/views/xrd/webfinger.xml.ruby
index d633e3477..ee5b5fc9d 100644
--- a/app/views/xrd/webfinger.xml.ruby
+++ b/app/views/xrd/webfinger.xml.ruby
@@ -5,6 +5,6 @@ Nokogiri::XML::Builder.new do |xml|
     xml.Link(rel: 'http://webfinger.net/rel/profile-page', type: 'text/html', href: TagManager.instance.url_for(@account))
     xml.Link(rel: 'http://schemas.google.com/g/2010#updates-from', type: 'application/atom+xml', href: account_url(@account, format: 'atom'))
     xml.Link(rel: 'salmon', href: api_salmon_url(@account.id))
-    xml.Link(rel: 'magic-public-key', href: @magic_key)
+    xml.Link(rel: 'magic-public-key', href: "data:application/magic-public-key,#{@magic_key}")
   end
 end.to_xml