blogit 0.3.2 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -20,15 +20,17 @@ module Blogit
20
20
  end
21
21
 
22
22
  # Turns on page caching for the given actions if
23
- # Blogit.configuration.include_admin_links is true
23
+ # Blogit.configuration.cache_pages is true
24
24
  def self.blogit_cacher(*args)
25
- if blogit_conf.include_admin_links
25
+ if blogit_conf.cache_pages
26
26
  caches_page *args
27
27
  end
28
28
  end
29
-
29
+
30
+ # Sets a cache sweeper to observe changes if
31
+ # Blogit.configuration.cache_pages is true
30
32
  def self.blogit_sweeper(*args)
31
- if blogit_conf.include_admin_links
33
+ if blogit_conf.cache_pages
32
34
  cache_sweeper Blogit::BlogitSweeper, only: args
33
35
  end
34
36
  end
@@ -1,6 +1,10 @@
1
1
  module Blogit
2
2
  class Comment < ActiveRecord::Base
3
3
 
4
+ # require custom validators
5
+ require "validators"
6
+ include Validators
7
+
4
8
  self.table_name = "blog_comments"
5
9
 
6
10
  # ================
@@ -8,7 +12,7 @@ module Blogit
8
12
  # ================
9
13
 
10
14
  belongs_to :post, class_name: "Blogit::Post",
11
- foreign_key: "post_id", counter_cache: true
15
+ foreign_key: "post_id", counter_cache: true, touch: true
12
16
 
13
17
  # TODO: Check if this is optimal
14
18
  URL_REGEX = /^(http|https):\/\/[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(([0-9]{1,5})?\/.*)?$/ix
@@ -1,8 +1,31 @@
1
1
  module Blogit
2
2
 
3
+ # This is a universal cache sweeper. If a comment is added or a
4
+ # blog post is updated, we should remove all the cached pages.
5
+ # This will reduce the risk of dead links from tags clouds etc.
6
+ #
7
+ # To activate page caching, set <tt>config.cache_pages = true</tt>
8
+ # in your blogit.rb file
3
9
  class BlogitSweeper < ActionController::Caching::Sweeper
4
10
 
5
11
  observe Blogit::Post, Blogit::Comment
12
+
13
+ def after_save(record)
14
+ clear_cached_pages
15
+ end
16
+
17
+ private
18
+
19
+ def clear_cached_pages
20
+ # remove each blog page (tags may require updating etc.)
21
+ Blogit::Post.all.each do |post|
22
+ expire_page post_path(post)
23
+ end
24
+ # remove the index blog pages
25
+ expire_page "/blog"
26
+ expire_page "/"
27
+ expire_page "/blog/sitemap.xml"
28
+ end
6
29
 
7
30
  end
8
31
 
@@ -1,10 +1,10 @@
1
1
  xml.instruct!
2
2
  xml.urlset :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9' do
3
3
 
4
- for post in posts
4
+ for post in @posts
5
5
  xml.url do
6
- xml.loc post_url(story)
7
- xml.lastmod story.updated_at.xmlschema
6
+ xml.loc post_url(post)
7
+ xml.lastmod post.updated_at.xmlschema
8
8
  end
9
9
  end
10
10
 
@@ -3,8 +3,11 @@ Blogit::Engine.routes.draw do
3
3
  resources :posts, except: [:index] do
4
4
  resources :comments, only: [:create, :destroy]
5
5
  end
6
-
6
+
7
+ match "sitemap.xml" => 'posts#index', format: :xml
8
+
7
9
  match "page/:page" => "posts#index"
10
+
8
11
  match "posts/tagged/:tag" => 'posts#tagged', as: :tagged_blog_posts
9
12
 
10
13
  root to: "posts#index"
@@ -1,3 +1,3 @@
1
1
  module Blogit
2
- VERSION = "0.3.2"
2
+ VERSION = "0.4.0"
3
3
  end
@@ -1,3 +1,3 @@
1
- require "validators/absence_validator"
2
1
  module Validators
2
+ require "validators/absence_validator"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: blogit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.4.0
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: 2011-12-28 00:00:00.000000000Z
12
+ date: 2011-12-29 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: RedCloth
16
- requirement: &70095292390220 !ruby/object:Gem::Requirement
16
+ requirement: &70218719380620 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: 4.2.9
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70095292390220
24
+ version_requirements: *70218719380620
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: redcarpet
27
- requirement: &70095292389420 !ruby/object:Gem::Requirement
27
+ requirement: &70218719379280 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: 2.0.1
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70095292389420
35
+ version_requirements: *70218719379280
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: nokogiri
38
- requirement: &70095292388420 !ruby/object:Gem::Requirement
38
+ requirement: &70218719378380 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: 1.5.0
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70095292388420
46
+ version_requirements: *70218719378380
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: albino
49
- requirement: &70095292382440 !ruby/object:Gem::Requirement
49
+ requirement: &70218719373420 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.3.3
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70095292382440
57
+ version_requirements: *70218719373420
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: acts-as-taggable-on
60
- requirement: &70095292381500 !ruby/object:Gem::Requirement
60
+ requirement: &70218719372160 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 2.2.1
66
66
  type: :runtime
67
67
  prerelease: false
68
- version_requirements: *70095292381500
68
+ version_requirements: *70218719372160
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: kaminari
71
- requirement: &70095292380640 !ruby/object:Gem::Requirement
71
+ requirement: &70218719370640 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: 0.13.0
77
77
  type: :runtime
78
78
  prerelease: false
79
- version_requirements: *70095292380640
79
+ version_requirements: *70218719370640
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: jquery-rails
82
- requirement: &70095292380040 !ruby/object:Gem::Requirement
82
+ requirement: &70218719369320 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ! '>='
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: '0'
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70095292380040
90
+ version_requirements: *70218719369320
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: sqlite3
93
- requirement: &70095292379340 !ruby/object:Gem::Requirement
93
+ requirement: &70218719367880 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70095292379340
101
+ version_requirements: *70218719367880
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: guard
104
- requirement: &70095292378680 !ruby/object:Gem::Requirement
104
+ requirement: &70218719367220 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,10 +109,10 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70095292378680
112
+ version_requirements: *70218719367220
113
113
  - !ruby/object:Gem::Dependency
114
114
  name: guard-rspec
115
- requirement: &70095292377980 !ruby/object:Gem::Requirement
115
+ requirement: &70218719366180 !ruby/object:Gem::Requirement
116
116
  none: false
117
117
  requirements:
118
118
  - - ! '>='
@@ -120,10 +120,10 @@ dependencies:
120
120
  version: '0'
121
121
  type: :development
122
122
  prerelease: false
123
- version_requirements: *70095292377980
123
+ version_requirements: *70218719366180
124
124
  - !ruby/object:Gem::Dependency
125
125
  name: growl
126
- requirement: &70095292377480 !ruby/object:Gem::Requirement
126
+ requirement: &70218719363080 !ruby/object:Gem::Requirement
127
127
  none: false
128
128
  requirements:
129
129
  - - ! '>='
@@ -131,10 +131,10 @@ dependencies:
131
131
  version: '0'
132
132
  type: :development
133
133
  prerelease: false
134
- version_requirements: *70095292377480
134
+ version_requirements: *70218719363080
135
135
  - !ruby/object:Gem::Dependency
136
136
  name: factory_girl
137
- requirement: &70095292376720 !ruby/object:Gem::Requirement
137
+ requirement: &70218719360100 !ruby/object:Gem::Requirement
138
138
  none: false
139
139
  requirements:
140
140
  - - ! '>='
@@ -142,10 +142,10 @@ dependencies:
142
142
  version: 2.3.2
143
143
  type: :development
144
144
  prerelease: false
145
- version_requirements: *70095292376720
145
+ version_requirements: *70218719360100
146
146
  - !ruby/object:Gem::Dependency
147
147
  name: mocha
148
- requirement: &70095292375640 !ruby/object:Gem::Requirement
148
+ requirement: &70218719358300 !ruby/object:Gem::Requirement
149
149
  none: false
150
150
  requirements:
151
151
  - - ! '>='
@@ -153,10 +153,10 @@ dependencies:
153
153
  version: '0'
154
154
  type: :development
155
155
  prerelease: false
156
- version_requirements: *70095292375640
156
+ version_requirements: *70218719358300
157
157
  - !ruby/object:Gem::Dependency
158
158
  name: rspec-rails
159
- requirement: &70095292375120 !ruby/object:Gem::Requirement
159
+ requirement: &70218719342700 !ruby/object:Gem::Requirement
160
160
  none: false
161
161
  requirements:
162
162
  - - ! '>='
@@ -164,10 +164,10 @@ dependencies:
164
164
  version: '0'
165
165
  type: :development
166
166
  prerelease: false
167
- version_requirements: *70095292375120
167
+ version_requirements: *70218719342700
168
168
  - !ruby/object:Gem::Dependency
169
169
  name: sqlite3
170
- requirement: &70095292374620 !ruby/object:Gem::Requirement
170
+ requirement: &70218719332720 !ruby/object:Gem::Requirement
171
171
  none: false
172
172
  requirements:
173
173
  - - ! '>='
@@ -175,7 +175,7 @@ dependencies:
175
175
  version: '0'
176
176
  type: :development
177
177
  prerelease: false
178
- version_requirements: *70095292374620
178
+ version_requirements: *70218719332720
179
179
  description: Add a blog to your Rails application in minutes with this mountable Rails
180
180
  Engine
181
181
  email:
@@ -358,7 +358,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
358
358
  version: '0'
359
359
  segments:
360
360
  - 0
361
- hash: 3723702619972481732
361
+ hash: 3694567605765797249
362
362
  required_rubygems_version: !ruby/object:Gem::Requirement
363
363
  none: false
364
364
  requirements:
@@ -367,7 +367,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
367
367
  version: '0'
368
368
  segments:
369
369
  - 0
370
- hash: 3723702619972481732
370
+ hash: 3694567605765797249
371
371
  requirements: []
372
372
  rubyforge_project:
373
373
  rubygems_version: 1.8.11