homeland-press 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3dd63a97785ef7985557ff8d64479b3bd2c697ee
4
- data.tar.gz: fcfdb253b853734d940b42e2f8bc4c178e778700
3
+ metadata.gz: e9cc3c455c07a0670af45ab7a72ff155d5447688
4
+ data.tar.gz: ec7204dbc3eceb92ea1c36a2ecb5f695e76c3a10
5
5
  SHA512:
6
- metadata.gz: 6e961f4e3b141921d4f0bfe510a0c0a4f12a14261d538d851c9057172e833bb4f105afbbf5376ade1748643b6501ebba67dbed544743929d77a02cef5aa601df
7
- data.tar.gz: 6b7d790e587e9e820dfb732d2ceec1399fb019cfcdd155ed0a7d151d226c169d358c54feb5cbe264a58f172d55537b75cad1e88f19f8c5e08ce6f797a66e2dd3
6
+ metadata.gz: b0f854ec0699c3e0567385da2d5cab44c4a198e17963b1664a5dfc978417db886b9064e2b982ed0af23b753f8dc5d0536222d51e11488ced7aa7028b828e0635
7
+ data.tar.gz: e97c740289298fe1f58ece76c606d7e46c6f5c8c7689c5e392c7cd90fa3e09365399e002a06e809ec4ac9a07dd36920f663c2d3c1dc86ab741987ab2e3b61efd
data/README.md CHANGED
@@ -19,18 +19,21 @@ gem 'homeland-press'
19
19
 
20
20
  修改 Homeland 的 `modules` 配置,增加 `press` 以启用。
21
21
 
22
- ```
22
+ ```yml
23
23
  defaults: &defaults
24
24
  # add "press" to modules
25
25
  modules: 'topic,...,press'
26
26
  ```
27
27
 
28
+ ## Screenshot
29
+
30
+ ![2017-02-28 10 52 08](https://cloud.githubusercontent.com/assets/5518/23389601/f72025f2-fda3-11e6-8340-7845c21e3a06.png)
28
31
 
29
32
  ## Contributing
30
33
 
31
34
  如果你需要开发此插件,你需要同时准备好 Homeland 项目的开发环境,并修改 Homeland 项目 Gemfile:
32
35
 
33
- ```
36
+ ```rb
34
37
  gem 'homeland-press', path: '../homeland-press'
35
38
  ````
36
39
 
@@ -1,12 +1,6 @@
1
1
  /*
2
2
  *= require_self
3
3
  */
4
-
5
- .sub-navbar .container,
6
- .main-container {
7
- max-width: 960px;
8
- }
9
-
10
4
  #homeland-press {
11
5
 
12
6
 
@@ -27,9 +21,10 @@
27
21
  }
28
22
 
29
23
  .post {
24
+ margin: 0 -15px;
25
+ padding: 0 15px 15px 15px;
30
26
  margin-bottom: 15px;
31
27
  border-bottom: 1px solid #eee;
32
- padding-bottom: 15px;
33
28
 
34
29
  &:last-child {
35
30
  border-bottom: 0;
@@ -37,6 +32,23 @@
37
32
  }
38
33
  }
39
34
 
35
+ .post-likes {
36
+ width: 60px;
37
+ text-align: center;
38
+ padding-top: 0px;
39
+ color: #666;
40
+
41
+ &.active {
42
+ .icon { color: #EB5424; }
43
+ }
44
+
45
+ .icon {
46
+ font-size: 22px; margin-bottom: 0px;
47
+
48
+ }
49
+ .counter { font-size: 14px; }
50
+ }
51
+
40
52
  .post-title { font-size: 18px; line-height: 22px; margin-bottom: 0px; }
41
53
  .post-summary {
42
54
  padding: 10px 0;
@@ -44,6 +56,7 @@
44
56
  }
45
57
  .post-info {
46
58
  color: #aaa;
59
+ font-size: 12px;
47
60
  a { color: #aaa; }
48
61
  }
49
62
 
@@ -55,7 +68,7 @@
55
68
 
56
69
  #post-detail {
57
70
  .panel-body {
58
- padding: 60px;
71
+ padding: 30px 50px;
59
72
  }
60
73
 
61
74
  h1 {
@@ -74,16 +87,21 @@
74
87
  .media-object { display: inline; }
75
88
  a { color: #777;}
76
89
  a.user-name { color: #0069D6; font-weight: bold; }
90
+ margin-bottom: 20px;
77
91
  }
78
92
 
79
93
  .post-actions {
80
94
  margin-top: 15px;
81
- .likeable {
82
- padding: 10px 20px;
95
+ .btn {
96
+ padding: 8px 20px 6px 20px;
83
97
  border-radius: 6px;
98
+ font-size: 16px;
99
+ margin: 0 5px;
100
+ }
84
101
 
102
+ .likeable {
85
103
  &.active {
86
- color: #D83227;
104
+ color: #EB5424;
87
105
  background: #fff !important;
88
106
  box-shadow: 0 0 0;
89
107
  }
@@ -91,3 +109,15 @@
91
109
  }
92
110
  }
93
111
  }
112
+
113
+ .post-upcoming {
114
+ .post {
115
+ .title {
116
+ font-size: 16px;
117
+ a { color: #2e3ebd; }
118
+ a:visited { color: #777; }
119
+ }
120
+ .author,
121
+ .time { width: 120px; }
122
+ }
123
+ }
@@ -0,0 +1,15 @@
1
+ module Homeland::Press::Admin
2
+ class PostsController < ::Admin::ApplicationController
3
+ layout '/layouts/admin'
4
+
5
+ def index
6
+ @posts = Post.includes(:user).order("id desc").page(params[:page])
7
+ end
8
+
9
+ def destroy
10
+ @post = Post.find_by_slug!(params[:id])
11
+ @post.destroy
12
+ redirect_to admin_posts_path
13
+ end
14
+ end
15
+ end
@@ -5,12 +5,11 @@ module Homeland::Press
5
5
 
6
6
  # GET /posts
7
7
  def index
8
- @posts = Post.published.order('published_at desc, id desc').page(params[:page]).per(10)
8
+ @posts = Post.includes(:user).published.order('published_at desc, id desc').page(params[:page]).per(10)
9
9
  end
10
10
 
11
11
  def upcoming
12
- @posts = Post.upcoming.order('id desc').page(params[:page]).per(10)
13
- render 'index'
12
+ @posts = Post.includes(:user).upcoming.order('id desc').page(params[:page]).per(10)
14
13
  end
15
14
 
16
15
  # GET /posts/1
@@ -0,0 +1,26 @@
1
+ <% content_for :sitemap do %>
2
+ <span class="current">头条</span>
3
+ <% end %>
4
+
5
+ <table class="table table-bordered table-striped table-condensed">
6
+ <tr>
7
+ <th>#</th>
8
+ <th>状态</th>
9
+ <th>标题</th>
10
+ <th>提交人</th>
11
+ <th>更新时间</th>
12
+ <th style="width:100px"></th>
13
+ </tr>
14
+ <% @posts.each do |post| %>
15
+ <tr class="post">
16
+ <td><%= post.id %></td>
17
+ <td><%= post.status %></td>
18
+ <td class="title"><%= link_to post.title, post %></td>
19
+ <td class="author"><%= user_name_tag(post.user) %></td>
20
+ <td class="time"><%= l post.updated_at, format: :long %></td>
21
+ <td><%= link_to "", admin_post_path(post), 'data-confirm' => 'Are you sure?', method: :delete, class: "fa fa-trash" %></td>
22
+ </tr>
23
+ <% end %>
24
+ </table>
25
+
26
+ <%= paginate @posts %>
@@ -1,14 +1,21 @@
1
- <div class="post" id="post-<= post.id %>">
2
- <div class="post-title"><%= link_to post.title, post %></div>
3
- <% if post.published? %>
4
- <div class="post-summary markdown">
5
- <%= simple_format post.summary %>
1
+ <div class="post media" id="post-<= post.id %>">
2
+ <div class="media-left">
3
+ <div class="post-likes<%= ' active' if post.likes_count >= 1 %>">
4
+ <div class="icon"><i class="fa fa-heart"></i></div>
5
+ <div class="counter"><%= post.likes_count %></div>
6
+ </div>
6
7
  </div>
7
- <div class="post-info">
8
- <%= user_name_tag(post.user) %> ·
9
- <%= timeago(post.created_at) %> ·
10
- <%= link_to "#{post.likes_count} 个赞", post %> ·
11
- <%= link_to "#{post.comments_count} 条评论", post_path(post, anchor: 'comments') %>
8
+ <div class="media-body">
9
+ <div class="post-title"><%= link_to post.title, post %></div>
10
+ <% if post.published? %>
11
+ <div class="post-summary markdown">
12
+ <%= simple_format post.summary %>
13
+ </div>
14
+ <div class="post-info">
15
+ <%= user_name_tag(post.user) %> ·
16
+ <span class="time" title="发布时间"><i class="fa fa-clock-o"></i> <%= timeago(post.created_at) %></span> ·
17
+ <%= link_to "#{post.comments_count} 条评论", post_path(post, anchor: 'comments') %>
18
+ </div>
19
+ <% end %>
12
20
  </div>
13
- <% end %>
14
21
  </div>
@@ -0,0 +1,17 @@
1
+ <div class="sidebar col-md-3 hide-ios">
2
+ <div class="panel panel-default">
3
+ <div class="panel-body">
4
+ <% if can? :create, Post %>
5
+ <%= link_to "提交新文章", new_post_path, class: 'btn btn-block btn-primary' %>
6
+ <% end %>
7
+
8
+ <% if can? :publish, Post %>
9
+ <hr />
10
+ <a href="<%= upcoming_posts_path %>" data-turbolinks-action="replace">
11
+ <i class="fa fa-newspaper-o"></i> 待审核列表...
12
+ </a>
13
+ <% end %>
14
+ </div>
15
+ </div>
16
+ <%= raw Setting.topic_index_sidebar_html %>
17
+ </div>
@@ -1,36 +1,18 @@
1
1
  <% title_tag "头条" %>
2
2
 
3
- <% content_for :sub_navbar do %>
4
- <div class="sub-navbar node-header hide-ios">
5
- <div class="container">
6
- <div class="pull-right">
7
- <% if can? :create, Post %>
8
- <%= link_to "提交新文章", new_post_path, class: 'btn btn-sm btn-primary' %>
3
+ <div class="row">
4
+ <div class="col-md-9">
5
+ <div id="post-list" class="panel panel-default post-<%= action_name %>">
6
+ <div class="panel-body">
7
+ <% if @posts.blank? %>
8
+ <div class="no-result">暂无任何文章</div>
9
+ <% else %>
10
+ <%= render partial: 'post', collection: @posts %>
9
11
  <% end %>
10
- </div>
11
12
 
12
- <ul class="filter nav nav-pills">
13
- <li class="<%= ' active' if action_name == 'index' %>">
14
- <a href="<%= posts_path %>" data-turbolinks-action="replace">最近发布</a>
15
- </li>
16
- <% if can? :publish, Post %>
17
- <li class="<%= ' active' if action_name == 'upcoming' %>">
18
- <a href="<%= upcoming_posts_path %>" data-turbolinks-action="replace">待审核</a>
19
- </li>
20
- <% end %>
21
- </ul>
13
+ <%= paginate @posts %>
14
+ </div>
22
15
  </div>
23
16
  </div>
24
- <% end %>
25
-
26
- <div id="post-list" class="panel panel-default post-<%= action_name %>">
27
- <div class="panel-body">
28
- <% if @posts.blank? %>
29
- <div class="no-result">暂无任何文章</div>
30
- <% else %>
31
- <%= render partial: 'post', collection: @posts %>
32
- <% end %>
33
-
34
- <%= paginate @posts %>
35
- </div>
17
+ <%= render 'sidebar' %>
36
18
  </div>
@@ -2,31 +2,39 @@
2
2
 
3
3
  <div id="post-detail" class="panel panel-default">
4
4
  <div class="panel-body">
5
- <div class="post-opts">
6
- <% if can?(:update, @post) %>
7
- <%= link_to '编辑', edit_post_path, class: 'btn btn-sm btn-default' %>
8
- <% end %>
5
+ <div class="post-opts clearfix">
6
+ <div class="pull-left">
7
+ <a href="<%= posts_path %>" class="btn btn-default"><i class="fa fa-chevron-left"></i> 返回文章列表</a>
8
+ </div>
9
9
 
10
- <% if can?(:publish, @post) && @post.upcoming? %>
11
- <%= link_to '审核通过', publish_post_path, method: 'put', class: 'btn btn-sm btn-success' %>
12
- <% end %>
10
+ <div class="pull-right">
11
+ <% if can?(:update, @post) %>
12
+ <%= link_to '编辑', edit_post_path, class: 'btn btn-sm btn-default' %>
13
+ <% end %>
13
14
 
14
- <% if can?(:destroy, @post) && @post.upcoming? %>
15
- <%= link_to '删除', @post, method: 'delete', class: 'btn btn-sm btn-danger', data: { confirm: "确定要删除么?" } %>
16
- <% end %>
15
+ <% if can?(:publish, @post) && @post.upcoming? %>
16
+ <%= link_to '审核通过', publish_post_path, method: 'put', class: 'btn btn-sm btn-success' %>
17
+ <% end %>
18
+
19
+ <% if can?(:destroy, @post) && @post.upcoming? %>
20
+ <%= link_to '删除', @post, method: 'delete', class: 'btn btn-sm btn-danger', data: { confirm: "确定要删除么?" } %>
21
+ <% end %>
22
+ </div>
17
23
  </div>
18
24
  <h1><%= @post.title %></h1>
19
25
  <div class="post-info">
20
26
  <%= user_name_tag(@post.user) %> ·
21
- <%= timeago @post.created_at %> ·
27
+ <span class="time" title="发布时间"><i class="fa fa-clock-o"></i> <%= timeago @post.created_at %></span> ·
22
28
  <%= @post.hits %> 次阅读 ·
23
- <a href="#comments"><%= @post.comments_count %> 条评论</a>
29
+ <a href="#comments"><i class="fa fa-comments-o"></i> <%= @post.comments_count %> 条评论</a>
24
30
  </div>
25
31
  <div class="post-body markdown">
26
32
  <%= markdown @post.body %>
27
33
  </div>
28
34
  <div class="post-actions">
29
35
  <%= likeable_tag(@post, class: 'btn btn-lg btn-default') %>
36
+
37
+ <%= reward_user_tag(@post.user, class: 'btn btn-lg btn-default') %>
30
38
  </div>
31
39
  </div>
32
40
  </div>
@@ -0,0 +1,34 @@
1
+ <% title_tag "头条" %>
2
+
3
+ <div class="row">
4
+ <div class="col-md-9">
5
+ <div id="post-upcoming" class="panel panel-default post-<%= action_name %>">
6
+ <div class="panel-heading">待审核列表</div>
7
+ <div class="panel-body">
8
+ <% if @posts.blank? %>
9
+ <div class="no-result">暂无任何文章</div>
10
+ <% else %>
11
+ <table class="table table-bordered table-striped table-condensed">
12
+ <tr>
13
+ <th>#</th>
14
+ <th>标题</th>
15
+ <th>提交人</th>
16
+ <th>更新时间</th>
17
+ </tr>
18
+ <% @posts.each do |post| %>
19
+ <tr class="post">
20
+ <td><%= post.id %></td>
21
+ <td class="title"><%= link_to post.title, post %></td>
22
+ <td class="author"><%= user_name_tag(post.user) %></td>
23
+ <td class="time"><%= timeago post.updated_at %></td>
24
+ </tr>
25
+ <% end %>
26
+ </table>
27
+ <% end %>
28
+
29
+ <%= paginate @posts %>
30
+ </div>
31
+ </div>
32
+ </div>
33
+ <%= render 'sidebar' %>
34
+ </div>
data/config/routes.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  Homeland::Press::Engine.routes.draw do
2
- resources :posts, path: '' do
2
+ resources :posts do
3
3
  collection do
4
4
  get :upcoming
5
5
  post :preview
@@ -8,4 +8,7 @@ Homeland::Press::Engine.routes.draw do
8
8
  put :publish
9
9
  end
10
10
  end
11
+ namespace :admin do
12
+ resources :posts
13
+ end
11
14
  end
@@ -10,15 +10,17 @@ module Homeland
10
10
  plugin.display_name = '头条'
11
11
  plugin.description = 'A Press plugin for Homeland.'
12
12
  plugin.navbar_link = true
13
+ plugin.admin_navbar_link = true
13
14
  plugin.user_menu_link = true
14
15
  plugin.root_path = "/posts"
16
+ plugin.admin_path = "/admin/posts"
15
17
  plugin.spec_path = config.root.join('spec')
16
18
  end
17
19
 
18
20
  User.send :include, Homeland::Press::UserMixin
19
21
 
20
22
  app.routes.prepend do
21
- mount Homeland::Press::Engine, at: '/posts'
23
+ mount Homeland::Press::Engine => '/'
22
24
  end
23
25
 
24
26
  app.config.paths["db/migrate"].concat(config.paths["db/migrate"].expanded)
@@ -1,6 +1,6 @@
1
1
  module Homeland
2
2
  module Press
3
3
  NAME = 'press'
4
- VERSION = '0.1.1'
4
+ VERSION = '0.2.0'
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: homeland-press
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Lee
@@ -38,17 +38,21 @@ files:
38
38
  - app/assets/config/homeland_press_manifest.js
39
39
  - app/assets/javascripts/homeland/press/application.coffee
40
40
  - app/assets/stylesheets/homeland/press/application.scss
41
+ - app/controllers/homeland/press/admin/posts_controller.rb
41
42
  - app/controllers/homeland/press/application_controller.rb
42
43
  - app/controllers/homeland/press/posts_controller.rb
43
44
  - app/helpers/homeland/press/application_helper.rb
44
45
  - app/models/homeland/press/ability.rb
45
46
  - app/models/post.rb
47
+ - app/views/homeland/press/admin/posts/index.html.erb
46
48
  - app/views/homeland/press/posts/_form.html.erb
47
49
  - app/views/homeland/press/posts/_post.html.erb
50
+ - app/views/homeland/press/posts/_sidebar.html.erb
48
51
  - app/views/homeland/press/posts/edit.html.erb
49
52
  - app/views/homeland/press/posts/index.html.erb
50
53
  - app/views/homeland/press/posts/new.html.erb
51
54
  - app/views/homeland/press/posts/show.html.erb
55
+ - app/views/homeland/press/posts/upcoming.html.erb
52
56
  - app/views/layouts/homeland/press/application.html.erb
53
57
  - app/views/notifications/_press_published.html.erb
54
58
  - config/locales/homeland.press.zh-CN.yml