about summary refs log tree commit diff
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-03-06 12:34:39 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-03-06 12:34:39 +0100
commitaab330eb2d39711e19753e89ba7ff67521929cf0 (patch)
treea652e2dc7f3bbd67264f45bb9c7c010e149c03c8
parentab80ebdeecf9410c5b43dde333b2e036e1198e24 (diff)
Adjusting design of public pages, optimizing account page queries
-rw-r--r--app/assets/stylesheets/accounts.scss42
-rw-r--r--app/assets/stylesheets/application.scss1
-rw-r--r--app/assets/stylesheets/stream_entries.scss32
-rw-r--r--app/controllers/accounts_controller.rb2
-rw-r--r--app/models/status.rb8
-rw-r--r--app/views/accounts/show.html.haml22
-rw-r--r--app/views/stream_entries/_follow.html.haml4
-rw-r--r--app/views/stream_entries/show.html.haml2
8 files changed, 79 insertions, 34 deletions
diff --git a/app/assets/stylesheets/accounts.scss b/app/assets/stylesheets/accounts.scss
index 89fa8f5bc..b9633f074 100644
--- a/app/assets/stylesheets/accounts.scss
+++ b/app/assets/stylesheets/accounts.scss
@@ -1,14 +1,10 @@
 .card {
   background: $primary-color image-url('background-photo.jpeg');
   background-size: cover;
-  padding: 80px 0;
-  padding-bottom: 30px;
+  padding: 60px 0;
+  padding-bottom: 10px;
   border-radius: 4px 4px 0 0;
 
-  .bio {
-
-  }
-
   .name {
     display: block;
     font-size: 20px;
@@ -37,4 +33,38 @@
       border-radius: 120px;
     }
   }
+
+  .details {
+    display: flex;
+    margin-top: 30px;
+  }
+
+  .counter {
+    width: 80px;
+    color: #9baec8;
+    padding: 0 10px;
+    border-right: 1px solid #9baec8;
+    cursor: default;
+
+    .counter-label {
+      font-size: 12px;
+      text-transform: uppercase;
+      display: block;
+      margin-bottom: 5px;
+    }
+
+    .counter-number {
+      font-weight: 500;
+      font-size: 18px;
+      color: #fff;
+    }
+  }
+
+  .bio {
+    flex: 1;
+    font-size: 14px;
+    line-height: 18px;
+    padding: 5px 10px;
+    color: #d9e1e8;
+  }
 }
diff --git a/app/assets/stylesheets/application.scss b/app/assets/stylesheets/application.scss
index 42fae02e1..3a35ab997 100644
--- a/app/assets/stylesheets/application.scss
+++ b/app/assets/stylesheets/application.scss
@@ -181,7 +181,6 @@ body {
     margin-top: 30px;
     text-align: center;
 
-
     a {
       color: #9baec8;
       text-decoration: none;
diff --git a/app/assets/stylesheets/stream_entries.scss b/app/assets/stylesheets/stream_entries.scss
index 5fc6e66cd..ce5c7f4ba 100644
--- a/app/assets/stylesheets/stream_entries.scss
+++ b/app/assets/stylesheets/stream_entries.scss
@@ -9,34 +9,38 @@
     border-left: 2px solid #fff;
 
     &.entry-reblog {
-      border-left: 2px solid $tertiary-color;
-
-      .content {
-        a {
-          color: $tertiary-color;
-        }
-      }
+      border-left-color: #2b90d9;
     }
 
     &.entry-predecessor, &.entry-successor {
-
-      .content {
-        a {
-
-        }
-      }
+      background: #d9e1e8;
+      border-left-color: #d9e1e8;
     }
 
     &.entry-follow, &.entry-favourite {
       .content {
         padding-top: 10px;
         padding-bottom: 10px;
+
+        strong {
+          font-weight: 500;
+        }
       }
     }
 
     &:last-child {
       border-bottom: 0;
-      border-radius: 0 0 4px 0;
+      border-radius: 0 0 4px 4px;
+    }
+  }
+
+  &.activity-stream-headless {
+    .entry:first-child {
+      border-radius: 4px 4px 0 0;
+
+      &:last-child {
+        border-radius: 4px;
+      }
     }
   }
 
diff --git a/app/controllers/accounts_controller.rb b/app/controllers/accounts_controller.rb
index 6fbbf97e3..156926927 100644
--- a/app/controllers/accounts_controller.rb
+++ b/app/controllers/accounts_controller.rb
@@ -5,6 +5,8 @@ class AccountsController < ApplicationController
   before_action :set_webfinger_header
 
   def show
+    @statuses = @account.statuses.order('id desc').includes(thread: [:account], reblog: [:account], stream_entry: [])
+
     respond_to do |format|
       format.html
       format.atom
diff --git a/app/models/status.rb b/app/models/status.rb
index 3ba58cc91..a346ac9b0 100644
--- a/app/models/status.rb
+++ b/app/models/status.rb
@@ -1,14 +1,14 @@
 class Status < ActiveRecord::Base
   belongs_to :account, inverse_of: :statuses
 
-  belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status'
-  belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status'
+  belongs_to :thread, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :replies
+  belongs_to :reblog, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblogs
 
   has_one :stream_entry, as: :activity, dependent: :destroy
 
   has_many :favourites, inverse_of: :status, dependent: :destroy
-  has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status'
-  has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status'
+  has_many :reblogs, foreign_key: 'reblog_of_id', class_name: 'Status', inverse_of: :reblog
+  has_many :replies, foreign_key: 'in_reply_to_id', class_name: 'Status', inverse_of: :thread
   has_many :mentioned_accounts, class_name: 'Mention', dependent: :destroy
 
   validates :account, presence: true
diff --git a/app/views/accounts/show.html.haml b/app/views/accounts/show.html.haml
index ea55b655b..9f665e8c3 100644
--- a/app/views/accounts/show.html.haml
+++ b/app/views/accounts/show.html.haml
@@ -4,11 +4,21 @@
 
 .card
   .avatar= image_tag @account.avatar.url(:large)
-  .bio
-    %h1.name
-      = @account.display_name.blank? ? @account.username : @account.display_name
-      %small= "@#{@account.username}"
-
+  %h1.name
+    = @account.display_name.blank? ? @account.username : @account.display_name
+    %small= "@#{@account.username}"
+  .details
+    .counter
+      %span.counter-label Posts
+      %span.counter-number= @account.statuses.count
+    .counter
+      %span.counter-label Following
+      %span.counter-number= @account.following.count
+    .counter
+      %span.counter-label Followers
+      %span.counter-number= @account.followers.count
+    .bio
+      %p= @account.note
 .activity-stream
-  - @account.statuses.order('id desc').each do |status|
+  - @statuses.each do |status|
     = render partial: 'stream_entries/status', locals: { status: status, include_threads: false, is_successor: false, is_predecessor: false }
diff --git a/app/views/stream_entries/_follow.html.haml b/app/views/stream_entries/_follow.html.haml
index c1c081374..f19e8783d 100644
--- a/app/views/stream_entries/_follow.html.haml
+++ b/app/views/stream_entries/_follow.html.haml
@@ -1,5 +1,5 @@
 .entry.entry-follow
   .content
-    %strong= follow.account.acct
+    %strong= link_to follow.account.acct, account_path(follow.account)
     is now following
-    %strong= follow.target_account.acct
+    %strong= link_to follow.target_account.acct, url_for_target(follow.target_account)
diff --git a/app/views/stream_entries/show.html.haml b/app/views/stream_entries/show.html.haml
index 6286daf53..a951120ac 100644
--- a/app/views/stream_entries/show.html.haml
+++ b/app/views/stream_entries/show.html.haml
@@ -1,5 +1,5 @@
 - content_for :header_tags do
   %link{ rel: 'alternate', type: 'application/atom+xml', href: account_stream_entry_url(@account, @stream_entry, format: 'atom') }/
 
-.activity-stream
+.activity-stream.activity-stream-headless
   = render partial: @type, locals: { @type.to_sym => @stream_entry.activity, include_threads: true, is_predecessor: false, is_successor: false }