about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-09-26 23:55:21 +0200
committerEugen Rochko <eugen@zeonfederated.com>2016-09-26 23:56:53 +0200
commit7e14eefc819ce27f45406452a4f8e2039d0f0886 (patch)
treea58bb240cff3a247b154362a0106369789a04ad1 /app
parent210362e66578dae32cbf169884d3c2905fe32cb7 (diff)
Replace logo, fix #57 - delete/unreblog/unfavourite API, fix #45 - app
registration API
Diffstat (limited to 'app')
-rw-r--r--app/assets/images/logo.pngbin0 -> 24218 bytes
-rw-r--r--app/assets/javascripts/components/actions/interactions.jsx20
-rw-r--r--app/assets/stylesheets/application.scss82
-rw-r--r--app/controllers/api/apps_controller.rb13
-rw-r--r--app/controllers/api/statuses_controller.rb17
-rw-r--r--app/controllers/api_controller.rb4
-rw-r--r--app/controllers/auth/sessions_controller.rb6
-rw-r--r--app/controllers/home_controller.rb2
-rw-r--r--app/controllers/oauth/applications_controller.rb18
-rw-r--r--app/helpers/api/apps_helper.rb2
-rw-r--r--app/helpers/oauth/applications_helper.rb2
-rw-r--r--app/services/unfavourite_service.rb12
-rw-r--r--app/views/api/apps/create.rabl4
-rw-r--r--app/views/application/_logo.html.erb11
-rw-r--r--app/views/layouts/auth.html.haml2
15 files changed, 100 insertions, 95 deletions
diff --git a/app/assets/images/logo.png b/app/assets/images/logo.png
new file mode 100644
index 000000000..3a5a743c0
--- /dev/null
+++ b/app/assets/images/logo.png
Binary files differdiff --git a/app/assets/javascripts/components/actions/interactions.jsx b/app/assets/javascripts/components/actions/interactions.jsx
index f2c615b00..3b3e2a6b6 100644
--- a/app/assets/javascripts/components/actions/interactions.jsx
+++ b/app/assets/javascripts/components/actions/interactions.jsx
@@ -22,6 +22,16 @@ export function reblog(status) {
   };
 };
 
+export function unreblog(status) {
+  return (dispatch, getState) => {
+    api(getState).post(`/api/statuses/${status.get('id')}/unreblog`).then(response => {
+      //
+    }).catch(error => {
+      //
+    });
+  };
+};
+
 export function reblogRequest(status) {
   return {
     type: REBLOG_REQUEST,
@@ -57,6 +67,16 @@ export function favourite(status) {
   };
 };
 
+export function unfavourite(status) {
+  return (dispatch, getState) => {
+    api(getState).post(`/api/statuses/${status.get('id')}/unfavourite`).then(response => {
+      //
+    }).catch(error => {
+      //
+    });
+  };
+};
+
 export function favouriteRequest(status) {
   return {
     type: FAVOURITE_REQUEST,
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index fd0e257a7..84f15eaca 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -59,7 +59,7 @@ table {
 
 body {
   font-family: 'Roboto', sans-serif;
-  background: #282c37 image-url('background-photo.jpeg');
+  background: #282c37 image-url('background-photo.jpg');
   background-size: cover;
   background-attachment: fixed;
   font-size: 13px;
@@ -104,10 +104,29 @@ body {
     font-size: 48px;
     font-weight: 500;
 
+    img {
+      display: block;
+      margin: 20px auto;
+      width: 180px;
+      height: 180px;
+    }
+
     a {
       color: inherit;
       text-decoration: none;
       outline: 0;
+
+      img {
+        opacity: 0.8;
+        transition: all 0.8s ease;
+      }
+
+      &:hover {
+        img {
+          opacity: 1;
+          transition-duration: 0.2s;
+        }
+      }
     }
 
     small {
@@ -313,67 +332,6 @@ body {
   }
 }
 
-.turbolinks-progress-bar {
-  background-color: #2b90d9;
-}
-
-.mastodon {
-  $head: #282c37;
-  $tusk: #d9e1e8;
-  $backdrop: #2b90d9;
-  $highlight: 18%;
-
-  .mastodon-backdrop {
-    fill: $backdrop;
-  }
-
-  #mastodon-ear {
-    fill: lighten($head, 5%);
-
-    &:hover, &.highlight {
-      fill: lighten($head, $highlight);
-    }
-  }
-
-  #mastodon-head-backdrop {
-    fill: darken($head, 5%);
-
-    &:hover, &.highlight {
-      fill: darken($head, 5%);
-    }
-  }
-
-  #mastodon-nose, #mastodon-cheek, #mastodon-forehead, #mastodon-backhead {
-    fill: $head;
-
-    &:hover, &.highlight {
-      fill: lighten($head, $highlight);
-    }
-  }
-
-  #mastodon-tusk-front {
-    fill: lighten($tusk, 5%);
-  }
-
-  #mastodon-tusk-back {
-    fill: $tusk;
-
-    &:hover, &.highlight {
-      fill: lighten($tusk, $highlight);
-    }
-  }
-
-  .mastodon-shape {
-    transition: all 0.8s ease;
-    stroke: transparent;
-    stroke-width: 0px;
-
-    &:hover, &.highlight {
-      transition-duration: 0.2s;
-    }
-  }
-}
-
 @import 'accounts';
 @import 'stream_entries';
 @import 'components'
diff --git a/app/controllers/api/apps_controller.rb b/app/controllers/api/apps_controller.rb
new file mode 100644
index 000000000..629cb2416
--- /dev/null
+++ b/app/controllers/api/apps_controller.rb
@@ -0,0 +1,13 @@
+class Api::AppsController < ApplicationController
+  respond_to :json
+
+  def create
+    @app = Doorkeeper::Application.create!(app_params)
+  end
+
+  private
+
+  def app_params
+    params.permit(:name, :redirect_uri)
+  end
+end
diff --git a/app/controllers/api/statuses_controller.rb b/app/controllers/api/statuses_controller.rb
index f68f298d8..44fb40bae 100644
--- a/app/controllers/api/statuses_controller.rb
+++ b/app/controllers/api/statuses_controller.rb
@@ -17,16 +17,33 @@ class Api::StatusesController < ApiController
     render action: :show
   end
 
+  def destroy
+    @status = Status.where(account_id: current_user.account).find(params[:id])
+    RemoveStatusService.new.(@status)
+    render_empty
+  end
+
   def reblog
     @status = ReblogService.new.(current_user.account, Status.find(params[:id])).reload
     render action: :show
   end
 
+  def unreblog
+    RemoveStatusService.new.(Status.where(account_id: current_user.account, reblog_of_id: params[:id]).first!)
+    @status = Status.find(params[:id])
+    render action: :show
+  end
+
   def favourite
     @status = FavouriteService.new.(current_user.account, Status.find(params[:id])).status.reload
     render action: :show
   end
 
+  def unfavourite
+    @status = UnfavouriteService.new.(current_user.account, Status.find(params[:id])).status.reload
+    render action: :show
+  end
+
   def home
     @statuses = Feed.new(:home, current_user.account).get(20, params[:max_id]).to_a
   end
diff --git a/app/controllers/api_controller.rb b/app/controllers/api_controller.rb
index cbe7141b9..e3ac9fc67 100644
--- a/app/controllers/api_controller.rb
+++ b/app/controllers/api_controller.rb
@@ -27,4 +27,8 @@ class ApiController < ApplicationController
   def current_user
     super || current_resource_owner
   end
+
+  def render_empty
+    render json: {}, status: 200
+  end
 end
diff --git a/app/controllers/auth/sessions_controller.rb b/app/controllers/auth/sessions_controller.rb
index fe0adc9bb..1418ab2ca 100644
--- a/app/controllers/auth/sessions_controller.rb
+++ b/app/controllers/auth/sessions_controller.rb
@@ -8,4 +8,10 @@ class Auth::SessionsController < Devise::SessionsController
       remember_me(resource)
     end
   end
+
+  protected
+
+  def after_sign_in_path_for(_resource)
+    root_path
+  end
 end
diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb
index f159c3df8..6b52b704d 100644
--- a/app/controllers/home_controller.rb
+++ b/app/controllers/home_controller.rb
@@ -7,7 +7,7 @@ class HomeController < ApplicationController
     @mentions     = Feed.new(:mentions, current_user.account).get(20)
     @token        = find_or_create_access_token.token
   end
-
+  
   private
 
   def find_or_create_access_token
diff --git a/app/controllers/oauth/applications_controller.rb b/app/controllers/oauth/applications_controller.rb
deleted file mode 100644
index 47935bf7c..000000000
--- a/app/controllers/oauth/applications_controller.rb
+++ /dev/null
@@ -1,18 +0,0 @@
-class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
-  before_action :authenticate_user!
-
-  def index
-    @applications = current_user.oauth_applications
-  end
-
-  def create
-    @application = Doorkeeper::Application.new(application_params)
-    @application.owner = current_user
-
-    if @application.save
-      redirect_to oauth_application_url(@application)
-    else
-      render :new
-    end
-  end
-end
diff --git a/app/helpers/api/apps_helper.rb b/app/helpers/api/apps_helper.rb
new file mode 100644
index 000000000..f6b0c6635
--- /dev/null
+++ b/app/helpers/api/apps_helper.rb
@@ -0,0 +1,2 @@
+module Api::AppsHelper
+end
diff --git a/app/helpers/oauth/applications_helper.rb b/app/helpers/oauth/applications_helper.rb
deleted file mode 100644
index 2c1818055..000000000
--- a/app/helpers/oauth/applications_helper.rb
+++ /dev/null
@@ -1,2 +0,0 @@
-module Oauth::ApplicationsHelper
-end
diff --git a/app/services/unfavourite_service.rb b/app/services/unfavourite_service.rb
new file mode 100644
index 000000000..2491c194f
--- /dev/null
+++ b/app/services/unfavourite_service.rb
@@ -0,0 +1,12 @@
+class UnfavouriteService < BaseService
+  def call(account, status)
+    favourite = Favourite.find_by!(account: account, status: status)
+    favourite.destroy!
+
+    unless status.local?
+      NotificationWorker.perform_async(favourite.stream_entry.id, status.account_id)
+    end
+
+    favourite
+  end
+end
diff --git a/app/views/api/apps/create.rabl b/app/views/api/apps/create.rabl
new file mode 100644
index 000000000..1ff6469a4
--- /dev/null
+++ b/app/views/api/apps/create.rabl
@@ -0,0 +1,4 @@
+object @app
+attributes :id, :redirect_uri
+node(:client_id) { |app| app.uid }
+node(:client_secret) { |app| app.secret }
diff --git a/app/views/application/_logo.html.erb b/app/views/application/_logo.html.erb
deleted file mode 100644
index 21fa4f657..000000000
--- a/app/views/application/_logo.html.erb
+++ /dev/null
@@ -1,11 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="<%= dim %>" height="<%= dim %>" class="mastodon" viewBox="-100 0 1390 750">
-  <circle cx="600" cy="380" r="500" fill="#9baec8" class="mastodon-backdrop"/>
-  <path fill="#282c37" d="M500 200l130-60h140l160 130-90 160-250 45-150-24-26 56 16 83h60l10 40-50 50-80-40-60-160 90-180" class="mastodon-shape" id="mastodon-head-backdrop"/>
-  <path fill="#282c37" d="M442.1204 451.3337l-42.08-151.3737-.0425.0424-89.993 180.007 60.002 159.9848 80.003 40.0015 49.9913-49.9913-10.011-40.0015h-59.981l-16.0134-82.994 26.003-56.015 2.121.3393z" class="mastodon-shape" id="mastodon-nose"/>
-  <path fill="#282c37" d="M498.2625 201.7378L400.0403 299.96l42.08 151.3737 147.8742 23.67.5515-.106-92.2835-273.16z" class="mastodon-shape" id="mastodon-cheek"/>
-  <path fill="#282c37" d="M498.2625 201.7378l92.2835 273.16.7635-.1273L770.0862 140.06l-.0848-.0637H629.996l-129.9943 60.0023-1.7392 1.7392z" class="mastodon-shape" id="mastodon-forehead"/>
-  <path fill="#282c37" d="M770.0862 140.06L591.3095 474.7705l248.684-44.7737 90.014-160.006L770.0862 140.06z" class="mastodon-shape" id="mastodon-backhead"/>
-  <path fill="#fff" d="M440 450l-40 80-170-20L70 390-80 230 0 390l100 100 120 100 120 20h130l90-140" class="mastodon-shape" id="mastodon-tusk-front"/>
-  <path fill="#d9e1e8" d="M268 516L120 360 80 260l70 90 110 90 59 22-8 18 15 41" class="mastodon-shape" id="mastodon-tusk-back"/>
-  <path fill="#282c37" d="M780 190l110 80-80 140-40-80" class="mastodon-shape" id="mastodon-ear"/>
- </svg>
diff --git a/app/views/layouts/auth.html.haml b/app/views/layouts/auth.html.haml
index bddba570a..54aa07e2c 100644
--- a/app/views/layouts/auth.html.haml
+++ b/app/views/layouts/auth.html.haml
@@ -3,7 +3,7 @@
     .logo-container
       %h1
         = link_to root_path do
-          = render partial: 'application/logo', locals: { dim: 200 }
+          = image_tag 'logo.png'
           %small= Rails.configuration.x.local_domain
 
     .form-container