mirror of
https://github.com/mastodon/mastodon.git
synced 2024-12-23 13:22:00 +01:00
Merge branch 'feature/toot-app-source' of https://github.com/ineffyble/mastodon into ineffyble-feature/toot-app-source
This commit is contained in:
commit
ab165547fd
13 changed files with 39 additions and 6 deletions
|
@ -54,7 +54,7 @@ const DetailedStatus = React.createClass({
|
||||||
{media}
|
{media}
|
||||||
|
|
||||||
<div style={{ marginTop: '15px', color: '#616b86', fontSize: '14px', lineHeight: '18px' }}>
|
<div style={{ marginTop: '15px', color: '#616b86', fontSize: '14px', lineHeight: '18px' }}>
|
||||||
<a className='detailed-status__datetime' style={{ color: 'inherit' }} href={status.get('url')} target='_blank' rel='noopener'><FormattedDate value={new Date(status.get('created_at'))} hour12={false} year='numeric' month='short' day='2-digit' hour='2-digit' minute='2-digit' /></a> · <Link to={`/statuses/${status.get('id')}/reblogs`} style={{ color: 'inherit', textDecoration: 'none' }}><i className='fa fa-retweet' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}><FormattedNumber value={status.get('reblogs_count')} /></span></Link> · <Link to={`/statuses/${status.get('id')}/favourites`} style={{ color: 'inherit', textDecoration: 'none' }}><i className='fa fa-star' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}><FormattedNumber value={status.get('favourites_count')} /></span></Link>
|
<a className='detailed-status__datetime' style={{ color: 'inherit' }} href={status.get('url')} target='_blank' rel='noopener'><FormattedDate value={new Date(status.get('created_at'))} hour12={false} year='numeric' month='short' day='2-digit' hour='2-digit' minute='2-digit' /></a> · <a className='detailed-status__application' style={{ color: 'inherit' }} href={status.getIn(['application', 'website'])} target='_blank' rel='nooopener'>{status.getIn(['application', 'name'])}</a> · <Link to={`/statuses/${status.get('id')}/reblogs`} style={{ color: 'inherit', textDecoration: 'none' }}><i className='fa fa-retweet' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}><FormattedNumber value={status.get('reblogs_count')} /></span></Link> · <Link to={`/statuses/${status.get('id')}/favourites`} style={{ color: 'inherit', textDecoration: 'none' }}><i className='fa fa-star' /><span style={{ fontWeight: '500', fontSize: '12px', marginLeft: '6px', display: 'inline-block' }}><FormattedNumber value={status.get('favourites_count')} /></span></Link>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -183,7 +183,7 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.status__display-name, .status__relative-time, .detailed-status__display-name, .detailed-status__datetime, .account__display-name {
|
.status__display-name, .status__relative-time, .detailed-status__display-name, .detailed-status__datetime, .detailed-status__application, .account__display-name {
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,6 +4,6 @@ class Api::V1::AppsController < ApiController
|
||||||
respond_to :json
|
respond_to :json
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@app = Doorkeeper::Application.create!(name: params[:client_name], redirect_uri: params[:redirect_uris], scopes: (params[:scopes] || Doorkeeper.configuration.default_scopes))
|
@app = Doorkeeper::Application.create!(name: params[:client_name], redirect_uri: params[:redirect_uris], scopes: (params[:scopes] || Doorkeeper.configuration.default_scopes), website: params[:website])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -52,7 +52,7 @@ class Api::V1::StatusesController < ApiController
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
@status = PostStatusService.new.call(current_user.account, params[:status], params[:in_reply_to_id].blank? ? nil : Status.find(params[:in_reply_to_id]), media_ids: params[:media_ids], sensitive: params[:sensitive], visibility: params[:visibility])
|
@status = PostStatusService.new.call(current_user.account, params[:status], params[:in_reply_to_id].blank? ? nil : Status.find(params[:in_reply_to_id]), media_ids: params[:media_ids], sensitive: params[:sensitive], visibility: params[:visibility], application: doorkeeper_token.application)
|
||||||
render action: :show
|
render action: :show
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
8
app/models/concerns/application.rb
Normal file
8
app/models/concerns/application.rb
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
module ApplicationExtension
|
||||||
|
extend ActiveSupport::Concern
|
||||||
|
included do
|
||||||
|
validates :website
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
Doorkeeper::Application.send :include, ApplicationExtension
|
|
@ -7,6 +7,8 @@ class Status < ApplicationRecord
|
||||||
|
|
||||||
enum visibility: [:public, :unlisted, :private], _suffix: :visibility
|
enum visibility: [:public, :unlisted, :private], _suffix: :visibility
|
||||||
|
|
||||||
|
belongs_to :application, class_name: 'Doorkeeper::Application'
|
||||||
|
|
||||||
belongs_to :account, inverse_of: :statuses
|
belongs_to :account, inverse_of: :statuses
|
||||||
belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account'
|
belongs_to :in_reply_to_account, foreign_key: 'in_reply_to_account_id', class_name: 'Account'
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,7 @@ class PostStatusService < BaseService
|
||||||
# @option [Enumerable] :media_ids Optional array of media IDs to attach
|
# @option [Enumerable] :media_ids Optional array of media IDs to attach
|
||||||
# @return [Status]
|
# @return [Status]
|
||||||
def call(account, text, in_reply_to = nil, options = {})
|
def call(account, text, in_reply_to = nil, options = {})
|
||||||
status = account.statuses.create!(text: text, thread: in_reply_to, sensitive: options[:sensitive], visibility: options[:visibility])
|
status = account.statuses.create!(text: text, thread: in_reply_to, sensitive: options[:sensitive], visibility: options[:visibility], application: options[:application])
|
||||||
attach_media(status, options[:media_ids])
|
attach_media(status, options[:media_ids])
|
||||||
process_mentions_service.call(status)
|
process_mentions_service.call(status)
|
||||||
process_hashtags_service.call(status)
|
process_hashtags_service.call(status)
|
||||||
|
|
3
app/views/api/v1/apps/show.rabl
Normal file
3
app/views/api/v1/apps/show.rabl
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
object @application
|
||||||
|
|
||||||
|
attributes :id, :name, :website
|
|
@ -6,6 +6,10 @@ node(:url) { |status| TagManager.instance.url_for(status) }
|
||||||
node(:reblogs_count) { |status| defined?(@reblogs_counts_map) ? (@reblogs_counts_map[status.id] || 0) : status.reblogs.count }
|
node(:reblogs_count) { |status| defined?(@reblogs_counts_map) ? (@reblogs_counts_map[status.id] || 0) : status.reblogs.count }
|
||||||
node(:favourites_count) { |status| defined?(@favourites_counts_map) ? (@favourites_counts_map[status.id] || 0) : status.favourites.count }
|
node(:favourites_count) { |status| defined?(@favourites_counts_map) ? (@favourites_counts_map[status.id] || 0) : status.favourites.count }
|
||||||
|
|
||||||
|
child :application do
|
||||||
|
extends 'api/v1/apps/show'
|
||||||
|
end
|
||||||
|
|
||||||
child :account do
|
child :account do
|
||||||
extends 'api/v1/accounts/show'
|
extends 'api/v1/accounts/show'
|
||||||
end
|
end
|
||||||
|
|
|
@ -28,6 +28,10 @@
|
||||||
= link_to TagManager.instance.url_for(status), class: 'detailed-status__datetime u-url u-uid', target: @external_links ? '_blank' : nil, rel: 'noopener' do
|
= link_to TagManager.instance.url_for(status), class: 'detailed-status__datetime u-url u-uid', target: @external_links ? '_blank' : nil, rel: 'noopener' do
|
||||||
%span= l(status.created_at)
|
%span= l(status.created_at)
|
||||||
·
|
·
|
||||||
|
- if status.application
|
||||||
|
= link_to status.application.website, class: 'detailed-status__application', target: @external_links ? '_blank' : nil, rel: 'noopener' do
|
||||||
|
%span= status.application.name
|
||||||
|
·
|
||||||
%span
|
%span
|
||||||
= fa_icon('retweet')
|
= fa_icon('retweet')
|
||||||
%span= status.reblogs.count
|
%span= status.reblogs.count
|
||||||
|
|
5
db/migrate/20170114194937_add_application_to_statuses.rb
Normal file
5
db/migrate/20170114194937_add_application_to_statuses.rb
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
class AddApplicationToStatuses < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
add_column :statuses, :application_id, :int
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,5 @@
|
||||||
|
class AddWebsiteToOauthApplication < ActiveRecord::Migration[5.0]
|
||||||
|
def change
|
||||||
|
add_column :oauth_applications, :website, :string
|
||||||
|
end
|
||||||
|
end
|
|
@ -10,7 +10,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 20170112154826) do
|
ActiveRecord::Schema.define(version: 20170114203041) do
|
||||||
|
|
||||||
# These are extensions that must be enabled in order to support this database
|
# These are extensions that must be enabled in order to support this database
|
||||||
enable_extension "plpgsql"
|
enable_extension "plpgsql"
|
||||||
|
@ -153,6 +153,7 @@ ActiveRecord::Schema.define(version: 20170112154826) do
|
||||||
t.datetime "created_at"
|
t.datetime "created_at"
|
||||||
t.datetime "updated_at"
|
t.datetime "updated_at"
|
||||||
t.boolean "superapp", default: false, null: false
|
t.boolean "superapp", default: false, null: false
|
||||||
|
t.string "website"
|
||||||
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree
|
t.index ["uid"], name: "index_oauth_applications_on_uid", unique: true, using: :btree
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -259,6 +260,7 @@ ActiveRecord::Schema.define(version: 20170112154826) do
|
||||||
t.boolean "sensitive", default: false
|
t.boolean "sensitive", default: false
|
||||||
t.integer "visibility", default: 0, null: false
|
t.integer "visibility", default: 0, null: false
|
||||||
t.integer "in_reply_to_account_id"
|
t.integer "in_reply_to_account_id"
|
||||||
|
t.integer "application_id"
|
||||||
t.index ["account_id"], name: "index_statuses_on_account_id", using: :btree
|
t.index ["account_id"], name: "index_statuses_on_account_id", using: :btree
|
||||||
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id", using: :btree
|
t.index ["in_reply_to_id"], name: "index_statuses_on_in_reply_to_id", using: :btree
|
||||||
t.index ["reblog_of_id"], name: "index_statuses_on_reblog_of_id", using: :btree
|
t.index ["reblog_of_id"], name: "index_statuses_on_reblog_of_id", using: :btree
|
||||||
|
|
Loading…
Reference in a new issue