homeland 0.0.5 → 0.0.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown
CHANGED
@@ -1,36 +1,58 @@
|
|
1
1
|
A new style forum for tiny community as Rails Engine. You can mount this in you apps.
|
2
2
|
|
3
|
-
##
|
3
|
+
## Requrements
|
4
|
+
|
5
|
+
* Rails 3.1
|
6
|
+
* Mongoid
|
7
|
+
* rails_autolink
|
4
8
|
|
5
|
-
|
9
|
+
## Install
|
6
10
|
|
7
11
|
1. in you Gemfile:
|
8
12
|
|
13
|
+
```ruby
|
9
14
|
gem "homeland"
|
15
|
+
```
|
10
16
|
|
11
17
|
2. Install thought this commands:
|
12
18
|
|
13
|
-
|
14
|
-
|
19
|
+
```bash
|
20
|
+
rails g homeland:install
|
21
|
+
```
|
22
|
+
|
15
23
|
3. change you application.html.erb
|
16
24
|
|
17
|
-
before:
|
25
|
+
before:
|
18
26
|
|
27
|
+
```erb
|
19
28
|
<%= link_to "Home", root_path %>
|
20
29
|
<%= link_to "Posts", posts_path %>
|
30
|
+
```
|
21
31
|
|
22
|
-
after:
|
32
|
+
after:
|
23
33
|
|
34
|
+
```erb
|
24
35
|
<%= link_to "Home", main_app.root_path %>
|
25
36
|
<%= link_to "Home", main_app.posts_path %>
|
37
|
+
```
|
38
|
+
|
26
39
|
|
27
40
|
4. Change you routes.rb to add this:
|
28
41
|
|
42
|
+
```ruby
|
29
43
|
mount Homeland::Engine, :at => "/bbs"
|
30
|
-
|
44
|
+
```
|
31
45
|
|
32
46
|
## Generate views to custom
|
33
47
|
|
48
|
+
```bash
|
34
49
|
rails g homeland:views
|
50
|
+
```
|
51
|
+
|
52
|
+
## Demo App
|
53
|
+
|
54
|
+
* [http://720p.so/bbs](http://720p.so/bbs)
|
55
|
+
|
56
|
+
----
|
35
57
|
|
36
|
-
Thanks [V2EX](http://v2ex.com) forum idea.
|
58
|
+
Thanks [V2EX](http://www.v2ex.com/?r=huacnlee) forum idea.
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# coding: utf-8
|
1
|
+
# coding: utf-8
|
2
2
|
module Homeland
|
3
3
|
class TopicsController < Homeland::ApplicationController
|
4
4
|
before_filter :homeland_require_user, :only => [:new,:edit,:create,:update,:destroy,:reply]
|
@@ -6,7 +6,7 @@ module Homeland
|
|
6
6
|
caches_page :feed, :expires_in => 1.hours
|
7
7
|
|
8
8
|
private
|
9
|
-
def init_list_sidebar
|
9
|
+
def init_list_sidebar
|
10
10
|
if !fragment_exist? "topic/init_list_sidebar/hot_nodes"
|
11
11
|
@hot_nodes = Node.hots.limit(20)
|
12
12
|
end
|
@@ -20,7 +20,7 @@ module Homeland
|
|
20
20
|
@sections = Section.all
|
21
21
|
|
22
22
|
end
|
23
|
-
|
23
|
+
|
24
24
|
def feed
|
25
25
|
@topics = Topic.recent.limit(20)
|
26
26
|
response.headers['Content-Type'] = 'application/rss+xml'
|
@@ -44,13 +44,12 @@ module Homeland
|
|
44
44
|
result = Redis::Search.query("Topic", params[:key], :limit => 500)
|
45
45
|
ids = result.collect { |r| r["id"] }
|
46
46
|
@topics = Topic.find(ids).paginate(:page => params[:page], :per_page => 20)
|
47
|
-
|
47
|
+
|
48
48
|
render :action => "index"
|
49
49
|
end
|
50
50
|
|
51
51
|
def show
|
52
52
|
@topic = Topic.find(params[:id])
|
53
|
-
@topic.hit!
|
54
53
|
@node = @topic.node
|
55
54
|
@replies = @topic.replies.all
|
56
55
|
|
@@ -72,7 +71,7 @@ module Homeland
|
|
72
71
|
|
73
72
|
def reply
|
74
73
|
@topic = Topic.find(params[:id])
|
75
|
-
@reply = @topic.replies.build(params[:reply])
|
74
|
+
@reply = @topic.replies.build(params[:reply])
|
76
75
|
@reply.user_id = current_user.id
|
77
76
|
if @reply.save
|
78
77
|
flash[:notice] = "回复成功。"
|
@@ -1,24 +1,23 @@
|
|
1
|
-
# coding: utf-8
|
1
|
+
# coding: utf-8
|
2
2
|
module Homeland
|
3
3
|
class Topic
|
4
4
|
include Mongoid::Document
|
5
5
|
include Mongoid::Timestamps
|
6
6
|
include Mongoid::Paranoia
|
7
|
-
|
7
|
+
|
8
8
|
field :title
|
9
|
-
field :body
|
9
|
+
field :body
|
10
10
|
field :replied_at , :type => DateTime
|
11
11
|
field :replies_count, :type => Integer, :default => 0
|
12
|
-
|
13
|
-
|
12
|
+
|
14
13
|
belongs_to :user, :inverse_of => :topics, :class_name => Homeland.user_class.to_s
|
15
14
|
belongs_to :node, :class_name => "Homeland::Node"
|
16
15
|
belongs_to :last_reply_user, :class_name => Homeland.user_class.to_s
|
17
16
|
has_many :replies, :class_name => "Homeland::Reply"
|
18
|
-
|
17
|
+
|
19
18
|
attr_protected :user_id
|
20
19
|
validates_presence_of :user_id, :title, :body, :node_id
|
21
|
-
|
20
|
+
|
22
21
|
index :replied_at
|
23
22
|
index :user_id
|
24
23
|
index :node_id
|
@@ -30,11 +29,7 @@ module Homeland
|
|
30
29
|
def set_replied_at
|
31
30
|
self.replied_at = Time.now
|
32
31
|
end
|
33
|
-
|
34
|
-
def hit!
|
35
|
-
self.update_attribute(:hit,{ :inc => 1 })
|
36
|
-
end
|
37
|
-
|
32
|
+
|
38
33
|
def node_name
|
39
34
|
return "" if self.node.blank?
|
40
35
|
self.node.name
|
@@ -5,10 +5,10 @@
|
|
5
5
|
<%= render 'sidebar' %>
|
6
6
|
<div class="content">
|
7
7
|
<div class="topics box">
|
8
|
-
<div class="topic">
|
8
|
+
<div class="topic">
|
9
9
|
<div class="pull-right avatar_large">
|
10
10
|
<%= user_avatar_tag(@topic.user) %>
|
11
|
-
</div>
|
11
|
+
</div>
|
12
12
|
<div class="infos">
|
13
13
|
<h1><%= truncate(@topic.title, :length => 100) %></h1>
|
14
14
|
<div class="info leader">
|
@@ -21,9 +21,8 @@
|
|
21
21
|
<% else %>
|
22
22
|
最后由 <%= user_name_tag(@topic.last_reply_user) %> 回复于 <%= timeago(@topic.replied_at) %>
|
23
23
|
<% end %>
|
24
|
-
, <%= @topic.hits %> 次阅读
|
25
24
|
</div>
|
26
|
-
</div>
|
25
|
+
</div>
|
27
26
|
</div>
|
28
27
|
<div class="body">
|
29
28
|
<%= format_topic_body(@topic.body) %>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: homeland
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-28 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>'
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: 3.1.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>'
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.1.0
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: jquery-atwho-rails
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 0.1.5
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.1.5
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: rails_autolink
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ! '>='
|
@@ -43,7 +53,12 @@ dependencies:
|
|
43
53
|
version: 1.0.0
|
44
54
|
type: :runtime
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ! '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 1.0.0
|
47
62
|
description: A new style forum for small communitys.
|
48
63
|
email:
|
49
64
|
- huacnlee@gmail.com
|
@@ -108,9 +123,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
123
|
version: 1.3.6
|
109
124
|
requirements: []
|
110
125
|
rubyforge_project:
|
111
|
-
rubygems_version: 1.8.
|
126
|
+
rubygems_version: 1.8.24
|
112
127
|
signing_key:
|
113
128
|
specification_version: 3
|
114
129
|
summary: A new style forum for small communitys.
|
115
130
|
test_files: []
|
116
|
-
has_rdoc:
|