0
0
Fork 0

Adding Turbolinks, adding status posting form on homepage

This commit is contained in:
Eugen Rochko 2016-03-21 18:26:47 +01:00
parent c28971c70c
commit f14f462eaf
14 changed files with 104 additions and 2 deletions

View file

@ -12,4 +12,5 @@
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

View file

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/

View file

@ -200,6 +200,15 @@
box-shadow: 0 0 15px rgba(0, 0, 0, 0.2);
}
}
hr {
clear: both;
border: 0;
padding: 0;
width: 100%;
height: 0;
margin: 30px 0;
}
}
.dashboard__top-bar {

View file

@ -0,0 +1,3 @@
// Place all the styles related to the statuses controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

View file

@ -0,0 +1,18 @@
class StatusesController < ApplicationController
layout 'dashboard'
before_action :authenticate_user!
def create
status = PostStatusService.new.(current_user.account, status_params[:text])
redirect_to root_path
rescue ActiveRecord::RecordInvalid
redirect_to root_path
end
private
def status_params
params.require(:status).permit(:text)
end
end

View file

@ -0,0 +1,2 @@
module StatusesHelper
end

View file

@ -13,6 +13,7 @@ class Status < ActiveRecord::Base
validates :account, presence: true
validates :uri, uniqueness: true, unless: 'local?'
validates :text, presence: true, if: Proc.new { |s| s.local? && !s.reblog? }
scope :with_counters, -> { select('statuses.*, (select count(r.id) from statuses as r where r.reblog_of_id = statuses.id) as reblogs_count, (select count(f.id) from favourites as f where f.status_id = statuses.id) as favourites_count') }
scope :with_includes, -> { includes(:account, reblog: :account, thread: :account) }

View file

@ -7,7 +7,10 @@ class FollowRemoteAccountService < BaseService
# @return [Account]
def call(uri, subscribe = true)
username, domain = uri.split('@')
account = Account.where(username: username, domain: domain).first
return Account.find_local(username) if domain == Rails.configuration.x.local_domain
account = Account.find_by(username: username, domain: domain)
if account.nil?
account = Account.new(username: username, domain: domain)

View file

@ -1,3 +1,11 @@
= simple_form_for Status.new, url: statuses_path, method: :post do |f|
= f.input :text, required: true, autofocus: true, label: false, placeholder: 'What are you up to?'
.form-actions
= f.button :submit, 'Post update'
%hr/
%h3 OAuth2
%p All API methods require a valid access token.
@ -83,6 +91,15 @@
%samp /api/accounts/:id/unfollow
.description
Unfollows target account from the user's account. Returns the target account.
%li
.address
%samp.method GET
%samp /api/accounts/lookup
.options
Options:
%samp usernames
.description
Returns accounts for a comma-separated list of usernames
%h3 Follows
%ul.api-descriptions