First stab at About page
This commit is contained in:
parent
fdea828ed4
commit
c103398e9a
|
@ -0,0 +1,3 @@
|
|||
export default Ember.Component.extend({
|
||||
classNames: ['user-small']
|
||||
});
|
|
@ -0,0 +1,8 @@
|
|||
export default Ember.Route.extend({
|
||||
model: function() {
|
||||
return Discourse.ajax("/about.json").then(function(result) {
|
||||
return result.about;
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
@ -10,6 +10,8 @@ Discourse.Route.buildRoutes(function() {
|
|||
// Error page
|
||||
this.route('exception', { path: '/exception' });
|
||||
|
||||
this.resource('about', { path: '/about' });
|
||||
|
||||
// Topic routes
|
||||
this.resource('topic', { path: '/t/:slug/:id' }, function() {
|
||||
this.route('fromParams', { path: '/' });
|
||||
|
|
|
@ -0,0 +1,62 @@
|
|||
<div class='container'>
|
||||
<h2>{{i18n about.title}}</h2>
|
||||
|
||||
{{#if admins}}
|
||||
<section class='about admins'>
|
||||
<h3>Our Admins</h3>
|
||||
|
||||
{{#each admins}}
|
||||
{{user-small user=this}}
|
||||
{{/each}}
|
||||
<div class='clearfix'></div>
|
||||
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
{{#if moderators}}
|
||||
<section class='about admins'>
|
||||
<h3>Our Moderators</h3>
|
||||
|
||||
<div class='users'>
|
||||
{{#each moderators}}
|
||||
{{user-small user=this}}
|
||||
{{/each}}
|
||||
</div>
|
||||
<div class='clearfix'></div>
|
||||
</section>
|
||||
{{/if}}
|
||||
|
||||
<section class='about stats'>
|
||||
<h3>{{i18n about.stats}}</h3>
|
||||
|
||||
<table class='table'>
|
||||
<tr>
|
||||
<td class='title'>{{i18n about.topic_count}}</td>
|
||||
<td>{{stats.topic_count}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{i18n about.topics_7_days}}</td>
|
||||
<td>{{stats.topics_7_days}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{i18n about.post_count}}</td>
|
||||
<td>{{stats.post_count}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{i18n about.posts_7_days}}</td>
|
||||
<td>{{stats.posts_7_days}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{i18n about.user_count}}</td>
|
||||
<td>{{stats.user_count}}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>{{i18n about.users_7_days}}</td>
|
||||
<td>{{stats.users_7_days}}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</section>
|
||||
|
||||
|
||||
|
||||
</div>
|
|
@ -0,0 +1,4 @@
|
|||
{{#link-to 'user' user.username}}
|
||||
{{avatar user imageSize="tiny"}}
|
||||
{{user.username}}
|
||||
{{/link-to}}
|
|
@ -0,0 +1,34 @@
|
|||
section.about {
|
||||
margin-top: 20px;
|
||||
|
||||
h3 {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.user-small {
|
||||
padding: 5px;
|
||||
width: 200px;
|
||||
float: left;
|
||||
|
||||
img {
|
||||
padding-right: 4px;
|
||||
}
|
||||
}
|
||||
|
||||
padding-bottom: 10px;
|
||||
|
||||
table {
|
||||
margin-top: 20px;
|
||||
width: 100%;
|
||||
|
||||
td, th {
|
||||
padding: 10px 5px 5px 5px;
|
||||
border-bottom: 1px solid lighten($primary, 70%);
|
||||
}
|
||||
|
||||
td.title {
|
||||
width: 30%;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,8 @@
|
|||
class AboutController < ApplicationController
|
||||
skip_before_filter :check_xhr, only: [:show]
|
||||
|
||||
def index
|
||||
@about = About.new
|
||||
render_serialized(@about, AboutSerializer)
|
||||
end
|
||||
end
|
|
@ -0,0 +1,26 @@
|
|||
class About
|
||||
include ActiveModel::Serialization
|
||||
|
||||
attr_accessor :moderators,
|
||||
:admins
|
||||
|
||||
def moderators
|
||||
@moderators ||= User.where(moderator: true)
|
||||
end
|
||||
|
||||
def admins
|
||||
@admins ||= User.where(admin: true)
|
||||
end
|
||||
|
||||
def stats
|
||||
@stats ||= {
|
||||
topic_count: Topic.listable_topics.count,
|
||||
post_count: Post.count,
|
||||
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
|
||||
}
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
class AboutSerializer < ApplicationSerializer
|
||||
has_many :moderators, serializer: BasicUserSerializer, embed: :objects
|
||||
has_many :admins, serializer: BasicUserSerializer, embed: :objects
|
||||
|
||||
attributes :stats
|
||||
end
|
|
@ -144,6 +144,16 @@ en:
|
|||
suggested_topics:
|
||||
title: "Suggested Topics"
|
||||
|
||||
about:
|
||||
title: "About"
|
||||
stats: "Site Statistics"
|
||||
topic_count: "Topic Count"
|
||||
topics_7_days: "Topic Count (last 7 days)"
|
||||
post_count: "Post Count"
|
||||
posts_7_days: "Post Count (last 7 days)"
|
||||
user_count: "User Count"
|
||||
users_7_days: "User Count (last 7 days)"
|
||||
|
||||
bookmarks:
|
||||
not_logged_in: "sorry, you must be logged in to bookmark posts"
|
||||
created: "you've bookmarked this post"
|
||||
|
|
|
@ -22,6 +22,8 @@ Discourse::Application.routes.draw do
|
|||
mount Logster::Web => "/logs", constraints: AdminConstraint.new
|
||||
end
|
||||
|
||||
resources :about
|
||||
|
||||
get "site" => "site#index"
|
||||
|
||||
resources :forums
|
||||
|
|
Loading…
Reference in New Issue