From c8767dc505f98d76e8197fdca68a7ffe30b21c1c Mon Sep 17 00:00:00 2001
From: Robin Ward <robin.ward@gmail.com>
Date: Mon, 11 Aug 2014 18:15:35 -0400
Subject: [PATCH] UX: Tweak about page

---
 .../discourse/templates/about.js.handlebars   | 25 ++++++++++++-------
 .../templates/site_map.js.handlebars          |  3 +++
 app/assets/stylesheets/common/base/about.scss |  4 +++
 app/models/about.rb                           | 24 +++++++++++++++++-
 app/serializers/about_serializer.rb           |  6 ++++-
 config/locales/client.en.yml                  |  4 ++-
 6 files changed, 54 insertions(+), 12 deletions(-)

diff --git a/app/assets/javascripts/discourse/templates/about.js.handlebars b/app/assets/javascripts/discourse/templates/about.js.handlebars
index 2b6149b2a1c..7e0fa71b64b 100644
--- a/app/assets/javascripts/discourse/templates/about.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/about.js.handlebars
@@ -1,5 +1,8 @@
 <div class='container'>
-  <h2>{{i18n about.title}}</h2>
+  <section class='about'>
+    <h2>{{i18n about.title title=title}}</h2>
+    <p>{{description}}</p>
+  </section>
 
   {{#if admins}}
     <section class='about admins'>
@@ -36,22 +39,26 @@
         <th>{{i18n about.stat.last_7_days}}</th>
       <tr>
         <td class='title'>{{i18n about.topic_count}}</td>
-        <td>{{stats.topic_count}}</td>
-        <td>{{stats.topics_7_days}}</td>
+        <td>{{number stats.topic_count}}</td>
+        <td>{{number stats.topics_7_days}}</td>
       </tr>
       <tr>
         <td>{{i18n about.post_count}}</td>
-        <td>{{stats.post_count}}</td>
-        <td>{{stats.posts_7_days}}</td>
+        <td>{{number stats.post_count}}</td>
+        <td>{{number stats.posts_7_days}}</td>
       </tr>
       <tr>
         <td>{{i18n about.user_count}}</td>
-        <td>{{stats.user_count}}</td>
-        <td>{{stats.users_7_days}}</td>
+        <td>{{number stats.user_count}}</td>
+        <td>{{number stats.users_7_days}}</td>
       </tr>
+      <tr>
+        <td>{{i18n about.like_count}}</td>
+        <td>{{number stats.like_count}}</td>
+        <td>{{number stats.likes_7_days}}</td>
+      </tr>
+    </table>
     </table>
   </section>
 
-
-
 </div>
diff --git a/app/assets/javascripts/discourse/templates/site_map.js.handlebars b/app/assets/javascripts/discourse/templates/site_map.js.handlebars
index 94490e6026d..d0f7f69071c 100644
--- a/app/assets/javascripts/discourse/templates/site_map.js.handlebars
+++ b/app/assets/javascripts/discourse/templates/site_map.js.handlebars
@@ -27,6 +27,9 @@
     <li>
       <a href="{{unbound faqUrl}}" class="faq-link">{{i18n faq}}</a>
     </li>
+    <li>
+      {{#link-to 'about'}}{{i18n about.simple_title}}{{/link-to}}
+    </li>
     {{#if showMobileToggle}}
       <li><a href="#" class="mobile-toggle-link" {{action toggleMobileView}}>{{boundI18n mobileViewLinkTextKey}}</a></li>
     {{/if}}
diff --git a/app/assets/stylesheets/common/base/about.scss b/app/assets/stylesheets/common/base/about.scss
index e3ef8ecc398..85c283ea36c 100644
--- a/app/assets/stylesheets/common/base/about.scss
+++ b/app/assets/stylesheets/common/base/about.scss
@@ -17,6 +17,10 @@ section.about {
 
   padding-bottom: 10px;
 
+  p {
+    margin: 10px 0;
+  }
+
   table {
     margin-top: 20px;
     width: 100%;
diff --git a/app/models/about.rb b/app/models/about.rb
index 4bc4b187835..73978b7bb0b 100644
--- a/app/models/about.rb
+++ b/app/models/about.rb
@@ -4,12 +4,30 @@ class About
   attr_accessor :moderators,
                 :admins
 
+  def version
+    Discourse::VERSION::STRING
+  end
+
+  def title
+    SiteSetting.title
+  end
+
+  def locale
+    SiteSetting.default_locale
+  end
+
+  def description
+    SiteSetting.site_description
+  end
+
   def moderators
     @moderators ||= User.where(moderator: true)
+                        .where.not(id: Discourse::SYSTEM_USER_ID)
   end
 
   def admins
     @admins ||= User.where(admin: true)
+                    .where.not(id: Discourse::SYSTEM_USER_ID)
   end
 
   def stats
@@ -19,7 +37,11 @@ class About
        user_count: User.count,
        topics_7_days: Topic.listable_topics.where('created_at > ?', 7.days.ago).count,
        posts_7_days: Post.where('created_at > ?', 7.days.ago).count,
-       users_7_days: User.where('created_at > ?', 7.days.ago).count
+       users_7_days: User.where('created_at > ?', 7.days.ago).count,
+       like_count: UserAction.where(action_type: UserAction::LIKE).count,
+       likes_7_days: UserAction.where(action_type: UserAction::LIKE)
+                               .where("created_at > ?", 7.days.ago)
+                               .count
     }
   end
 
diff --git a/app/serializers/about_serializer.rb b/app/serializers/about_serializer.rb
index 67a04e9879d..b56a1658807 100644
--- a/app/serializers/about_serializer.rb
+++ b/app/serializers/about_serializer.rb
@@ -2,5 +2,9 @@ class AboutSerializer < ApplicationSerializer
   has_many :moderators, serializer: BasicUserSerializer, embed: :objects
   has_many :admins, serializer: BasicUserSerializer, embed: :objects
 
-  attributes :stats
+  attributes :stats,
+             :description,
+             :title,
+             :locale,
+             :version
 end
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 65caea5f38e..58bb6bfb493 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -145,11 +145,13 @@ en:
       title: "Suggested Topics"
 
     about:
-      title: "About"
+      simple_title: "About"
+      title: "About %{title}"
       stats: "Site Statistics"
       stat:
         all_time: "All Time"
         last_7_days: "Last 7 Days"
+      like_count: "Like Count"
       topic_count: "Topic Count"
       post_count: "Post Count"
       user_count: "User Count"