spud_blog 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/spud/blog/sitemaps.js +2 -0
- data/app/assets/stylesheets/spud/blog/sitemaps.css +4 -0
- data/app/controllers/spud/blog/sitemaps_controller.rb +8 -0
- data/app/helpers/spud/blog/sitemaps_helper.rb +2 -0
- data/app/models/spud_post.rb +3 -4
- data/app/views/spud/blog/sitemaps/show.xml.builder +16 -0
- data/config/routes.rb +3 -0
- data/lib/spud_blog/configuration.rb +2 -1
- data/lib/spud_blog/engine.rb +4 -0
- metadata +11 -6
data/app/models/spud_post.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
class SpudPost < ActiveRecord::Base
|
2
|
-
|
3
2
|
searchable
|
4
3
|
has_and_belongs_to_many :categories,
|
5
4
|
:class_name => 'SpudPostCategory',
|
@@ -7,13 +6,13 @@ class SpudPost < ActiveRecord::Base
|
|
7
6
|
:foreign_key => 'spud_post_id'
|
8
7
|
belongs_to :author, :class_name => 'SpudUser', :foreign_key => 'spud_user_id'
|
9
8
|
has_many :comments, :class_name => 'SpudPostComment'
|
10
|
-
|
9
|
+
scope :publicly, where('visible = 1 AND published_at <= ?', Time.now.utc).order('published_at desc')
|
11
10
|
validates_presence_of :title, :content, :published_at, :spud_user_id, :url_name
|
12
11
|
validates_uniqueness_of :url_name
|
13
12
|
before_validation :set_url_name
|
14
13
|
|
15
14
|
def self.public_posts(page, per_page)
|
16
|
-
return where('visible = 1 AND published_at <= ?',
|
15
|
+
return where('visible = 1 AND published_at <= ?', Time.now.utc).order('published_at desc').includes(:comments, :categories).paginate(:page => page, :per_page => per_page)
|
17
16
|
end
|
18
17
|
|
19
18
|
def self.public_blog_posts(page, per_page)
|
@@ -25,7 +24,7 @@ class SpudPost < ActiveRecord::Base
|
|
25
24
|
end
|
26
25
|
|
27
26
|
def self.recent_posts(limit=5)
|
28
|
-
return where('visible = 1 AND published_at <= ?',
|
27
|
+
return where('visible = 1 AND published_at <= ?', Time.now.utc).order('published_at desc').limit(limit)
|
29
28
|
end
|
30
29
|
|
31
30
|
def self.recent_blog_posts(limit=5)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
xml.instruct! :xml, :version => '1.0', :encoding => 'UTF-8'
|
3
|
+
|
4
|
+
# create the urlset
|
5
|
+
xml.urlset :xmlns => 'http://www.sitemaps.org/schemas/sitemap/0.9' do
|
6
|
+
@posts.each do |post|
|
7
|
+
xml.url do
|
8
|
+
if post.is_news
|
9
|
+
xml.loc news_post_path(post)
|
10
|
+
else
|
11
|
+
xml.loc blog_post_path(post)
|
12
|
+
end
|
13
|
+
xml.lastmod post.published_at.strftime('%Y-%m-%d')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module Spud
|
2
2
|
module Blog
|
3
3
|
include ActiveSupport::Configurable
|
4
|
-
config_accessor :base_layout, :blog_enabled, :news_enabled, :posts_per_page, :blog_path, :news_path
|
4
|
+
config_accessor :base_layout, :blog_enabled, :news_enabled, :posts_per_page, :blog_path, :news_path,:enable_sitemap
|
5
5
|
self.base_layout = 'application'
|
6
6
|
self.news_enabled = false
|
7
7
|
self.blog_enabled = true
|
8
8
|
self.posts_per_page = 5
|
9
9
|
self.blog_path = 'blog'
|
10
10
|
self.news_path = 'news'
|
11
|
+
self.enable_sitemap = true
|
11
12
|
end
|
12
13
|
end
|
data/lib/spud_blog/engine.rb
CHANGED
@@ -10,6 +10,9 @@ module Spud
|
|
10
10
|
:url => '/spud/admin/post_categories',
|
11
11
|
:order => 3
|
12
12
|
}]
|
13
|
+
if Spud::Blog.enable_sitemap == true
|
14
|
+
Spud::Core.config.sitemap_urls += [:spud_cms_sitemap_url]
|
15
|
+
end
|
13
16
|
if Spud::Blog.config.blog_enabled
|
14
17
|
Spud::Core.config.admin_applications += [{
|
15
18
|
:name => 'Blog Posts',
|
@@ -26,6 +29,7 @@ module Spud
|
|
26
29
|
:order => 2
|
27
30
|
}]
|
28
31
|
end
|
32
|
+
|
29
33
|
end
|
30
34
|
initializer :assets do
|
31
35
|
Rails.application.config.assets.precompile += ['spud/admin/posts.css']
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spud_blog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
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-02-
|
12
|
+
date: 2012-02-17 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spud_core
|
16
|
-
requirement: &
|
16
|
+
requirement: &70355129523080 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.5.2
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70355129523080
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: will_paginate
|
27
|
-
requirement: &
|
27
|
+
requirement: &70355129522600 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ! '>='
|
@@ -32,7 +32,7 @@ dependencies:
|
|
32
32
|
version: '0'
|
33
33
|
type: :runtime
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70355129522600
|
36
36
|
description:
|
37
37
|
email: greg@westlakedesign.com
|
38
38
|
executables: []
|
@@ -44,23 +44,27 @@ files:
|
|
44
44
|
- app/assets/javascripts/spud/admin/post_categories.js
|
45
45
|
- app/assets/javascripts/spud/admin/post_comments.js
|
46
46
|
- app/assets/javascripts/spud/admin/posts.js
|
47
|
+
- app/assets/javascripts/spud/blog/sitemaps.js
|
47
48
|
- app/assets/stylesheets/news.css
|
48
49
|
- app/assets/stylesheets/spud/admin/news_posts.css
|
49
50
|
- app/assets/stylesheets/spud/admin/post_categories.css
|
50
51
|
- app/assets/stylesheets/spud/admin/post_comments.css
|
51
52
|
- app/assets/stylesheets/spud/admin/posts.css
|
53
|
+
- app/assets/stylesheets/spud/blog/sitemaps.css
|
52
54
|
- app/controllers/blog_controller.rb
|
53
55
|
- app/controllers/news_controller.rb
|
54
56
|
- app/controllers/spud/admin/news_posts_controller.rb
|
55
57
|
- app/controllers/spud/admin/post_categories_controller.rb
|
56
58
|
- app/controllers/spud/admin/post_comments_controller.rb
|
57
59
|
- app/controllers/spud/admin/posts_controller.rb
|
60
|
+
- app/controllers/spud/blog/sitemaps_controller.rb
|
58
61
|
- app/helpers/blog_helper.rb
|
59
62
|
- app/helpers/news_helper.rb
|
60
63
|
- app/helpers/spud/admin/news_posts_helper.rb
|
61
64
|
- app/helpers/spud/admin/post_categories_helper.rb
|
62
65
|
- app/helpers/spud/admin/post_comments_helper.rb
|
63
66
|
- app/helpers/spud/admin/posts_helper.rb
|
67
|
+
- app/helpers/spud/blog/sitemaps_helper.rb
|
64
68
|
- app/models/spud_post.rb
|
65
69
|
- app/models/spud_post_category.rb
|
66
70
|
- app/models/spud_post_comment.rb
|
@@ -84,6 +88,7 @@ files:
|
|
84
88
|
- app/views/spud/admin/posts/edit.html.erb
|
85
89
|
- app/views/spud/admin/posts/index.html.erb
|
86
90
|
- app/views/spud/admin/posts/new.html.erb
|
91
|
+
- app/views/spud/blog/sitemaps/show.xml.builder
|
87
92
|
- config/application.rb
|
88
93
|
- config/boot.rb
|
89
94
|
- config/routes.rb
|