sitemap_generator 0.2.2 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +27 -1
- data/Rakefile +3 -3
- data/VERSION +1 -1
- data/lib/sitemap_generator/helper.rb +13 -14
- data/tasks/sitemap_generator_tasks.rake +51 -26
- data/templates/sitemap.rb +12 -0
- data/test/mock_app_gem/app/controllers/application_controller.rb +10 -0
- data/test/mock_app_gem/app/controllers/contents_controller.rb +85 -0
- data/test/mock_app_gem/app/models/content.rb +2 -0
- data/test/mock_app_gem/config/boot.rb +110 -0
- data/test/mock_app_gem/config/environment.rb +42 -0
- data/test/mock_app_gem/config/environments/development.rb +17 -0
- data/test/mock_app_gem/config/environments/production.rb +28 -0
- data/test/mock_app_gem/config/environments/test.rb +28 -0
- data/test/mock_app_gem/config/initializers/backtrace_silencers.rb +7 -0
- data/test/mock_app_gem/config/initializers/inflections.rb +10 -0
- data/test/mock_app_gem/config/initializers/mime_types.rb +5 -0
- data/test/mock_app_gem/config/initializers/new_rails_defaults.rb +19 -0
- data/test/mock_app_gem/config/initializers/session_store.rb +15 -0
- data/test/mock_app_gem/config/routes.rb +45 -0
- data/test/mock_app_gem/config/sitemap.rb +13 -0
- data/test/mock_app_gem/db/migrate/20090826121911_create_contents.rb +12 -0
- data/test/mock_app_gem/db/schema.rb +20 -0
- metadata +22 -4
data/README.md
CHANGED
@@ -3,6 +3,13 @@ SitemapGenerator
|
|
3
3
|
|
4
4
|
This plugin enables ['enterprise-class'][enterprise_class] Google Sitemaps to be easily generated for a Rails site as a rake task, using a simple 'Rails Routes'-like DSL.
|
5
5
|
|
6
|
+
Foreword
|
7
|
+
-------
|
8
|
+
|
9
|
+
Unfortunately, Adam Salter passed away recently. Those who knew him know what an amazing guy he was, and what an excellent Rails programmer he was. His passing is a great loss to the Rails community.
|
10
|
+
|
11
|
+
I will be taking over maintaining this gem from him. -- Karl
|
12
|
+
|
6
13
|
Raison d'être
|
7
14
|
-------
|
8
15
|
|
@@ -60,7 +67,7 @@ Installation
|
|
60
67
|
|
61
68
|
1. Install plugin as normal
|
62
69
|
|
63
|
-
<code>$ ./script/plugin install git://github.com/
|
70
|
+
<code>$ ./script/plugin install git://github.com/kjvarga/sitemap_generator.git</code>
|
64
71
|
|
65
72
|
----
|
66
73
|
|
@@ -111,6 +118,18 @@ Example 'config/sitemap.rb'
|
|
111
118
|
|
112
119
|
end
|
113
120
|
|
121
|
+
# Including Sitemaps from Rails Engines.
|
122
|
+
#
|
123
|
+
# These Sitemaps should be almost identical to a regular Sitemap file except
|
124
|
+
# they needn't define their own SitemapGenerator::Sitemap.default_host since
|
125
|
+
# they will undoubtedly share the host name of the application they belong to.
|
126
|
+
#
|
127
|
+
# As an example, say we have a Rails Engine in vendor/plugins/cadability_client
|
128
|
+
# We can include its Sitemap here as follows:
|
129
|
+
#
|
130
|
+
file = File.join(Rails.root, 'vendor/plugins/cadability_client/config/sitemap.rb')
|
131
|
+
eval(open(file).read, binding, file)
|
132
|
+
|
114
133
|
Notes
|
115
134
|
=======
|
116
135
|
|
@@ -135,6 +154,8 @@ Notes
|
|
135
154
|
end
|
136
155
|
end
|
137
156
|
|
157
|
+
4) If generation of your sitemap fails for some reason, the old sitemap will remain in public/. This ensures that robots will always find a valid sitemap. Running silently (`rake -s sitemap:refresh`) and with email forwarding setup you'll only get an email if your sitemap fails to build, and no notification when everything is fine - which will be most of the time.
|
158
|
+
|
138
159
|
Known Bugs
|
139
160
|
========
|
140
161
|
|
@@ -142,6 +163,11 @@ Known Bugs
|
|
142
163
|
- There's no check on the size of a URL which [isn't supposed to exceed 2,048 bytes][sitemaps_xml].
|
143
164
|
- Currently only supports one Sitemap Index file, which can contain 50,000 Sitemap files which can each contain 50,000 urls, so it _only_ supports up to 2,500,000,000 (2.5 billion) urls. I personally have no need of support for more urls, but plugin could be improved to support this.
|
144
165
|
|
166
|
+
Wishlist
|
167
|
+
========
|
168
|
+
|
169
|
+
- Auto coverage testing. Generate a report of broken URLs by checking the status codes of each page in the sitemap.
|
170
|
+
|
145
171
|
Thanks (in no particular order)
|
146
172
|
========
|
147
173
|
|
data/Rakefile
CHANGED
@@ -7,9 +7,9 @@ begin
|
|
7
7
|
s.name = "sitemap_generator"
|
8
8
|
s.summary = %Q{Generate 'enterprise-class' Sitemaps for your Rails site using a simple 'Rails Routes'-like DSL and a single Rake task}
|
9
9
|
s.description = %Q{Install as a plugin or Gem to easily generate ['enterprise-class'][enterprise_class] Google Sitemaps for your Rails site, using a simple 'Rails Routes'-like DSL and a single rake task.}
|
10
|
-
s.email = "
|
11
|
-
s.homepage = "http://github.com/
|
12
|
-
s.authors = ["Adam Salter"]
|
10
|
+
s.email = "kjvarga@gmail.com"
|
11
|
+
s.homepage = "http://github.com/kjvarga/sitemap_generator"
|
12
|
+
s.authors = ["Adam Salter", "Karl Varga"]
|
13
13
|
s.files = FileList["[A-Z]*", "{bin,lib,rails,templates,tasks}/**/*"]
|
14
14
|
# s is a Gem::Specification... see http://www.rubygems.org/read/chapter/20 for additional settings
|
15
15
|
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.2.
|
1
|
+
0.2.3
|
@@ -1,26 +1,25 @@
|
|
1
|
+
require 'sitemap_generator'
|
1
2
|
require 'action_controller'
|
2
|
-
require 'action_controller/test_process'
|
3
|
-
begin
|
4
|
-
require 'application_controller'
|
5
|
-
rescue LoadError
|
6
|
-
# Rails < 2.3
|
7
|
-
require 'application'
|
8
|
-
end
|
9
3
|
|
10
4
|
module SitemapGenerator
|
11
5
|
module Helper
|
6
|
+
include ActionController::UrlWriter
|
7
|
+
|
8
|
+
def self.included(base)
|
9
|
+
base.class_eval do
|
10
|
+
def self.default_url_options(options = nil)
|
11
|
+
{ :host => SitemapGenerator::Sitemap.default_host }
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
12
16
|
def load_sitemap_rb
|
13
|
-
controller = ApplicationController.new
|
14
|
-
controller.request = ActionController::TestRequest.new
|
15
|
-
controller.params = {}
|
16
|
-
controller.send(:initialize_current_url)
|
17
|
-
b = controller.instance_eval{binding}
|
18
17
|
sitemap_mapper_file = File.join(RAILS_ROOT, 'config/sitemap.rb')
|
19
|
-
eval(open(sitemap_mapper_file).read
|
18
|
+
eval(open(sitemap_mapper_file).read)
|
20
19
|
end
|
21
20
|
|
22
21
|
def url_with_hostname(path)
|
23
|
-
URI.join(Sitemap.default_host, path).to_s
|
22
|
+
URI.join(SitemapGenerator::Sitemap.default_host, path).to_s
|
24
23
|
end
|
25
24
|
|
26
25
|
def w3c_date(date)
|
@@ -1,32 +1,26 @@
|
|
1
1
|
require 'zlib'
|
2
|
+
require 'sitemap_generator/helper'
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
desc "Install a default config/sitemap.rb file"
|
6
|
-
task :install do
|
7
|
-
load File.expand_path(File.join(File.dirname(__FILE__), "../rails/install.rb"))
|
8
|
-
end
|
9
|
-
|
10
|
-
desc "Delete all Sitemap files in public/ directory"
|
11
|
-
task :clean do
|
12
|
-
sitemap_files = Dir[File.join(RAILS_ROOT, 'public/sitemap*.xml.gz')]
|
13
|
-
FileUtils.rm sitemap_files
|
14
|
-
end
|
4
|
+
class SiteMapRefreshTask < Rake::Task
|
5
|
+
include SitemapGenerator::Helper
|
15
6
|
|
16
|
-
|
17
|
-
|
18
|
-
task :refresh => ['sitemap:create'] do
|
7
|
+
def execute(*)
|
8
|
+
super
|
19
9
|
ping_search_engines("sitemap_index.xml.gz")
|
20
10
|
end
|
11
|
+
end
|
21
12
|
|
22
|
-
|
23
|
-
|
24
|
-
|
13
|
+
class SiteMapCreateTask < Rake::Task
|
14
|
+
include SitemapGenerator::Helper
|
15
|
+
include ActionView::Helpers::NumberHelper
|
25
16
|
|
26
|
-
|
27
|
-
|
28
|
-
|
17
|
+
def execute(*)
|
18
|
+
super
|
19
|
+
build_files
|
20
|
+
end
|
29
21
|
|
22
|
+
private
|
23
|
+
def build_files
|
30
24
|
start_time = Time.now
|
31
25
|
|
32
26
|
# update links from config/sitemap.rb
|
@@ -34,12 +28,22 @@ namespace :sitemap do
|
|
34
28
|
|
35
29
|
raise(ArgumentError, "Default hostname not defined") if SitemapGenerator::Sitemap.default_host.blank?
|
36
30
|
|
37
|
-
links_grps = SitemapGenerator::Sitemap.links.in_groups_of(
|
31
|
+
links_grps = SitemapGenerator::Sitemap.links.in_groups_of(50_000, false)
|
38
32
|
raise(ArgumentError, "TOO MANY LINKS!! I really thought 2,500,000,000 links would be enough for anybody!") if links_grps.length > 50000
|
39
33
|
|
40
34
|
Rake::Task['sitemap:clean'].invoke
|
41
35
|
|
42
36
|
# render individual sitemaps
|
37
|
+
sitemap_files = render_sitemap(links_grps)
|
38
|
+
|
39
|
+
# render index
|
40
|
+
render_index(sitemap_files)
|
41
|
+
|
42
|
+
stop_time = Time.now
|
43
|
+
puts "Sitemap stats: #{number_with_delimiter(SitemapGenerator::Sitemap.links.length)} links, " + ("%dm%02ds" % (stop_time - start_time).divmod(60)) if verbose
|
44
|
+
end
|
45
|
+
|
46
|
+
def render_sitemap(links_grps)
|
43
47
|
sitemap_files = []
|
44
48
|
links_grps.each_with_index do |links, index|
|
45
49
|
buffer = ''
|
@@ -49,12 +53,14 @@ namespace :sitemap do
|
|
49
53
|
Zlib::GzipWriter.open(filename) do |gz|
|
50
54
|
gz.write buffer
|
51
55
|
end
|
56
|
+
sitemap_files << filename
|
52
57
|
puts "+ #{filename}" if verbose
|
53
58
|
puts "** Sitemap too big! The uncompressed size exceeds 10Mb" if (buffer.size > 10 * 1024 * 1024) && verbose
|
54
|
-
sitemap_files << filename
|
55
59
|
end
|
60
|
+
sitemap_files
|
61
|
+
end
|
56
62
|
|
57
|
-
|
63
|
+
def render_index(sitemap_files)
|
58
64
|
buffer = ''
|
59
65
|
xml = Builder::XmlMarkup.new(:target=>buffer)
|
60
66
|
eval(open(SitemapGenerator.templates[:sitemap_index]).read, binding)
|
@@ -62,10 +68,29 @@ namespace :sitemap do
|
|
62
68
|
Zlib::GzipWriter.open(filename) do |gz|
|
63
69
|
gz.write buffer
|
64
70
|
end
|
71
|
+
|
65
72
|
puts "+ #{filename}" if verbose
|
66
73
|
puts "** Sitemap Index too big! The uncompressed size exceeds 10Mb" if (buffer.size > 10 * 1024 * 1024) && verbose
|
74
|
+
end
|
75
|
+
end
|
67
76
|
|
68
|
-
|
69
|
-
|
77
|
+
namespace :sitemap do
|
78
|
+
desc "Install a default config/sitemap.rb file"
|
79
|
+
task :install do
|
80
|
+
load File.expand_path(File.join(File.dirname(__FILE__), "../rails/install.rb"))
|
70
81
|
end
|
82
|
+
|
83
|
+
desc "Delete all Sitemap files in public/ directory"
|
84
|
+
task :clean do
|
85
|
+
sitemap_files = Dir[File.join(RAILS_ROOT, 'public/sitemap*.xml.gz')]
|
86
|
+
FileUtils.rm sitemap_files
|
87
|
+
end
|
88
|
+
|
89
|
+
desc "Create Sitemap XML files in public/ directory (rake -s for no output)"
|
90
|
+
SiteMapRefreshTask.define_task :refresh => ['sitemap:create']
|
91
|
+
|
92
|
+
desc "Create Sitemap XML files (don't ping search engines)"
|
93
|
+
task 'refresh:no_ping' => ['sitemap:create']
|
94
|
+
|
95
|
+
SiteMapCreateTask.define_task :create => [:environment]
|
71
96
|
end
|
data/templates/sitemap.rb
CHANGED
@@ -28,3 +28,15 @@ SitemapGenerator::Sitemap.add_links do |sitemap|
|
|
28
28
|
sitemap.add '/purchase', :priority => 0.7, :host => "https://www.example.com"
|
29
29
|
|
30
30
|
end
|
31
|
+
|
32
|
+
# Including Sitemaps from Rails Engines.
|
33
|
+
#
|
34
|
+
# These Sitemaps should be almost identical to a regular Sitemap file except
|
35
|
+
# they needn't define their own SitemapGenerator::Sitemap.default_host since
|
36
|
+
# they will undoubtedly share the host name of the application they belong to.
|
37
|
+
#
|
38
|
+
# As an example, say we have a Rails Engine in vendor/plugins/cadability_client
|
39
|
+
# We can include its Sitemap here as follows:
|
40
|
+
#
|
41
|
+
# file = File.join(Rails.root, 'vendor/plugins/cadability_client/config/sitemap.rb')
|
42
|
+
# eval(open(file).read, binding, file)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
|
4
|
+
class ApplicationController < ActionController::Base
|
5
|
+
helper :all # include all helpers, all the time
|
6
|
+
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
7
|
+
|
8
|
+
# Scrub sensitive parameters from your log
|
9
|
+
# filter_parameter_logging :password
|
10
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
class ContentsController < ApplicationController
|
2
|
+
# GET /contents
|
3
|
+
# GET /contents.xml
|
4
|
+
def index
|
5
|
+
@contents = Content.all
|
6
|
+
|
7
|
+
respond_to do |format|
|
8
|
+
format.html # index.html.erb
|
9
|
+
format.xml { render :xml => @contents }
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
# GET /contents/1
|
14
|
+
# GET /contents/1.xml
|
15
|
+
def show
|
16
|
+
@content = Content.find(params[:id])
|
17
|
+
|
18
|
+
respond_to do |format|
|
19
|
+
format.html # show.html.erb
|
20
|
+
format.xml { render :xml => @content }
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# GET /contents/new
|
25
|
+
# GET /contents/new.xml
|
26
|
+
def new
|
27
|
+
@content = Content.new
|
28
|
+
|
29
|
+
respond_to do |format|
|
30
|
+
format.html # new.html.erb
|
31
|
+
format.xml { render :xml => @content }
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET /contents/1/edit
|
36
|
+
def edit
|
37
|
+
@content = Content.find(params[:id])
|
38
|
+
end
|
39
|
+
|
40
|
+
# POST /contents
|
41
|
+
# POST /contents.xml
|
42
|
+
def create
|
43
|
+
@content = Content.new(params[:content])
|
44
|
+
|
45
|
+
respond_to do |format|
|
46
|
+
if @content.save
|
47
|
+
flash[:notice] = 'Content was successfully created.'
|
48
|
+
format.html { redirect_to(@content) }
|
49
|
+
format.xml { render :xml => @content, :status => :created, :location => @content }
|
50
|
+
else
|
51
|
+
format.html { render :action => "new" }
|
52
|
+
format.xml { render :xml => @content.errors, :status => :unprocessable_entity }
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# PUT /contents/1
|
58
|
+
# PUT /contents/1.xml
|
59
|
+
def update
|
60
|
+
@content = Content.find(params[:id])
|
61
|
+
|
62
|
+
respond_to do |format|
|
63
|
+
if @content.update_attributes(params[:content])
|
64
|
+
flash[:notice] = 'Content was successfully updated.'
|
65
|
+
format.html { redirect_to(@content) }
|
66
|
+
format.xml { head :ok }
|
67
|
+
else
|
68
|
+
format.html { render :action => "edit" }
|
69
|
+
format.xml { render :xml => @content.errors, :status => :unprocessable_entity }
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
# DELETE /contents/1
|
75
|
+
# DELETE /contents/1.xml
|
76
|
+
def destroy
|
77
|
+
@content = Content.find(params[:id])
|
78
|
+
@content.destroy
|
79
|
+
|
80
|
+
respond_to do |format|
|
81
|
+
format.html { redirect_to(contents_url) }
|
82
|
+
format.xml { head :ok }
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,110 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
def preinitialize
|
28
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def preinitializer_path
|
32
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Boot
|
37
|
+
def run
|
38
|
+
load_initializer
|
39
|
+
Rails::Initializer.run(:set_load_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class VendorBoot < Boot
|
44
|
+
def load_initializer
|
45
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
+
Rails::GemDependency.add_frozen_gem_path
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
class GemBoot < Boot
|
52
|
+
def load_initializer
|
53
|
+
self.class.load_rubygems
|
54
|
+
load_rails_gem
|
55
|
+
require 'initializer'
|
56
|
+
end
|
57
|
+
|
58
|
+
def load_rails_gem
|
59
|
+
if version = self.class.gem_version
|
60
|
+
gem 'rails', version
|
61
|
+
else
|
62
|
+
gem 'rails'
|
63
|
+
end
|
64
|
+
rescue Gem::LoadError => load_error
|
65
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
66
|
+
exit 1
|
67
|
+
end
|
68
|
+
|
69
|
+
class << self
|
70
|
+
def rubygems_version
|
71
|
+
Gem::RubyGemsVersion rescue nil
|
72
|
+
end
|
73
|
+
|
74
|
+
def gem_version
|
75
|
+
if defined? RAILS_GEM_VERSION
|
76
|
+
RAILS_GEM_VERSION
|
77
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
78
|
+
ENV['RAILS_GEM_VERSION']
|
79
|
+
else
|
80
|
+
parse_gem_version(read_environment_rb)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
def load_rubygems
|
85
|
+
require 'rubygems'
|
86
|
+
min_version = '1.3.1'
|
87
|
+
unless rubygems_version >= min_version
|
88
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
89
|
+
exit 1
|
90
|
+
end
|
91
|
+
|
92
|
+
rescue LoadError
|
93
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
94
|
+
exit 1
|
95
|
+
end
|
96
|
+
|
97
|
+
def parse_gem_version(text)
|
98
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
def read_environment_rb
|
103
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
# All that for this:
|
110
|
+
Rails.boot!
|
@@ -0,0 +1,42 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file
|
2
|
+
|
3
|
+
# Specifies gem version of Rails to use when vendor/rails is not present
|
4
|
+
RAILS_GEM_VERSION = '2.3.4' unless defined? RAILS_GEM_VERSION
|
5
|
+
|
6
|
+
# Bootstrap the Rails environment, frameworks, and default configuration
|
7
|
+
require File.join(File.dirname(__FILE__), 'boot')
|
8
|
+
|
9
|
+
Rails::Initializer.run do |config|
|
10
|
+
# Settings in config/environments/* take precedence over those specified here.
|
11
|
+
# Application configuration should go into files in config/initializers
|
12
|
+
# -- all .rb files in that directory are automatically loaded.
|
13
|
+
|
14
|
+
# Add additional load paths for your own custom dirs
|
15
|
+
# config.load_paths += %W( #{RAILS_ROOT}/extras )
|
16
|
+
|
17
|
+
# Specify gems that this application depends on and have them installed with rake gems:install
|
18
|
+
# config.gem "bj"
|
19
|
+
# config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net"
|
20
|
+
# config.gem "sqlite3-ruby", :lib => "sqlite3"
|
21
|
+
# config.gem "aws-s3", :lib => "aws/s3"
|
22
|
+
config.gem 'sitemap_generator', :lib => false
|
23
|
+
|
24
|
+
# Only load the plugins named here, in the order given (default is alphabetical).
|
25
|
+
# :all can be used as a placeholder for all plugins not explicitly named
|
26
|
+
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
|
27
|
+
|
28
|
+
# Skip frameworks you're not going to use. To use Rails without a database,
|
29
|
+
# you must remove the Active Record framework.
|
30
|
+
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
|
31
|
+
|
32
|
+
# Activate observers that should always be running
|
33
|
+
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
|
34
|
+
|
35
|
+
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
|
36
|
+
# Run "rake -D time" for a list of tasks for finding time zone names.
|
37
|
+
config.time_zone = 'UTC'
|
38
|
+
|
39
|
+
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
40
|
+
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
|
41
|
+
# config.i18n.default_locale = :de
|
42
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# In the development environment your application's code is reloaded on
|
4
|
+
# every request. This slows down response time but is perfect for development
|
5
|
+
# since you don't have to restart the webserver when you make code changes.
|
6
|
+
config.cache_classes = false
|
7
|
+
|
8
|
+
# Log error messages when you accidentally call methods on nil.
|
9
|
+
config.whiny_nils = true
|
10
|
+
|
11
|
+
# Show full error reports and disable caching
|
12
|
+
config.action_controller.consider_all_requests_local = true
|
13
|
+
config.action_view.debug_rjs = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
|
16
|
+
# Don't care if the mailer can't send
|
17
|
+
config.action_mailer.raise_delivery_errors = false
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# The production environment is meant for finished, "live" apps.
|
4
|
+
# Code is not reloaded between requests
|
5
|
+
config.cache_classes = true
|
6
|
+
|
7
|
+
# Full error reports are disabled and caching is turned on
|
8
|
+
config.action_controller.consider_all_requests_local = false
|
9
|
+
config.action_controller.perform_caching = true
|
10
|
+
config.action_view.cache_template_loading = true
|
11
|
+
|
12
|
+
# See everything in the log (default is :info)
|
13
|
+
# config.log_level = :debug
|
14
|
+
|
15
|
+
# Use a different logger for distributed setups
|
16
|
+
# config.logger = SyslogLogger.new
|
17
|
+
|
18
|
+
# Use a different cache store in production
|
19
|
+
# config.cache_store = :mem_cache_store
|
20
|
+
|
21
|
+
# Enable serving of images, stylesheets, and javascripts from an asset server
|
22
|
+
# config.action_controller.asset_host = "http://assets.example.com"
|
23
|
+
|
24
|
+
# Disable delivery errors, bad email addresses will be ignored
|
25
|
+
# config.action_mailer.raise_delivery_errors = false
|
26
|
+
|
27
|
+
# Enable threaded mode
|
28
|
+
# config.threadsafe!
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# Settings specified here will take precedence over those in config/environment.rb
|
2
|
+
|
3
|
+
# The test environment is used exclusively to run your application's
|
4
|
+
# test suite. You never need to work with it otherwise. Remember that
|
5
|
+
# your test database is "scratch space" for the test suite and is wiped
|
6
|
+
# and recreated between test runs. Don't rely on the data there!
|
7
|
+
config.cache_classes = true
|
8
|
+
|
9
|
+
# Log error messages when you accidentally call methods on nil.
|
10
|
+
config.whiny_nils = true
|
11
|
+
|
12
|
+
# Show full error reports and disable caching
|
13
|
+
config.action_controller.consider_all_requests_local = true
|
14
|
+
config.action_controller.perform_caching = false
|
15
|
+
config.action_view.cache_template_loading = true
|
16
|
+
|
17
|
+
# Disable request forgery protection in test environment
|
18
|
+
config.action_controller.allow_forgery_protection = false
|
19
|
+
|
20
|
+
# Tell Action Mailer not to deliver emails to the real world.
|
21
|
+
# The :test delivery method accumulates sent emails in the
|
22
|
+
# ActionMailer::Base.deliveries array.
|
23
|
+
config.action_mailer.delivery_method = :test
|
24
|
+
|
25
|
+
# Use SQL instead of Active Record's schema dumper when creating the test database.
|
26
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
27
|
+
# like if you have constraints or database-specific column types
|
28
|
+
# config.active_record.schema_format = :sql
|
@@ -0,0 +1,7 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
|
4
|
+
# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
|
5
|
+
|
6
|
+
# You can also remove all the silencers if you're trying do debug a problem that might steem from framework code.
|
7
|
+
# Rails.backtrace_cleaner.remove_silencers!
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Add new inflection rules using the following format
|
4
|
+
# (all these examples are active by default):
|
5
|
+
# ActiveSupport::Inflector.inflections do |inflect|
|
6
|
+
# inflect.plural /^(ox)$/i, '\1en'
|
7
|
+
# inflect.singular /^(ox)en/i, '\1'
|
8
|
+
# inflect.irregular 'person', 'people'
|
9
|
+
# inflect.uncountable %w( fish sheep )
|
10
|
+
# end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# These settings change the behavior of Rails 2 apps and will be defaults
|
4
|
+
# for Rails 3. You can remove this initializer when Rails 3 is released.
|
5
|
+
|
6
|
+
if defined?(ActiveRecord)
|
7
|
+
# Include Active Record class name as root for JSON serialized output.
|
8
|
+
ActiveRecord::Base.include_root_in_json = true
|
9
|
+
|
10
|
+
# Store the full class name (including module namespace) in STI type column.
|
11
|
+
ActiveRecord::Base.store_full_sti_class = true
|
12
|
+
end
|
13
|
+
|
14
|
+
# Use ISO 8601 format for JSON serialized times and dates.
|
15
|
+
ActiveSupport.use_standard_json_time_format = true
|
16
|
+
|
17
|
+
# Don't escape HTML entities in JSON, leave that for the #json_escape helper.
|
18
|
+
# if you're including raw json in an HTML page.
|
19
|
+
ActiveSupport.escape_html_entities_in_json = false
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Be sure to restart your server when you modify this file.
|
2
|
+
|
3
|
+
# Your secret key for verifying cookie session data integrity.
|
4
|
+
# If you change this key, all old sessions will become invalid!
|
5
|
+
# Make sure the secret is at least 30 characters and all random,
|
6
|
+
# no regular words or you'll be exposed to dictionary attacks.
|
7
|
+
ActionController::Base.session = {
|
8
|
+
:key => '_mock_app_session',
|
9
|
+
:secret => '4211cebf6f8890d6f058b632c6f31efd04cff62520622a3949630345c11cd37d5b0ee83ad0e21d52898cd0a3f0758205b374ddfd1f1a9a397024d81555e39511'
|
10
|
+
}
|
11
|
+
|
12
|
+
# Use the database for sessions instead of the cookie-based default,
|
13
|
+
# which shouldn't be used to store highly confidential information
|
14
|
+
# (create the session table with "rake db:sessions:create")
|
15
|
+
# ActionController::Base.session_store = :active_record_store
|
@@ -0,0 +1,45 @@
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
2
|
+
map.resources :contents
|
3
|
+
|
4
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
5
|
+
|
6
|
+
# Sample of regular route:
|
7
|
+
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
8
|
+
# Keep in mind you can assign values other than :controller and :action
|
9
|
+
|
10
|
+
# Sample of named route:
|
11
|
+
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
|
12
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
13
|
+
|
14
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
15
|
+
# map.resources :products
|
16
|
+
|
17
|
+
# Sample resource route with options:
|
18
|
+
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
|
19
|
+
|
20
|
+
# Sample resource route with sub-resources:
|
21
|
+
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
|
22
|
+
|
23
|
+
# Sample resource route with more complex sub-resources
|
24
|
+
# map.resources :products do |products|
|
25
|
+
# products.resources :comments
|
26
|
+
# products.resources :sales, :collection => { :recent => :get }
|
27
|
+
# end
|
28
|
+
|
29
|
+
# Sample resource route within a namespace:
|
30
|
+
# map.namespace :admin do |admin|
|
31
|
+
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
|
32
|
+
# admin.resources :products
|
33
|
+
# end
|
34
|
+
|
35
|
+
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
|
36
|
+
# map.root :controller => "welcome"
|
37
|
+
|
38
|
+
# See how all your routes lay out with "rake routes"
|
39
|
+
|
40
|
+
# Install the default routes as the lowest priority.
|
41
|
+
# Note: These default routes make all actions in every controller accessible via GET requests. You should
|
42
|
+
# consider removing or commenting them out if you're using named routes and resources.
|
43
|
+
map.connect ':controller/:action/:id'
|
44
|
+
map.connect ':controller/:action/:id.:format'
|
45
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
SitemapGenerator::Sitemap.default_host = "http://www.example.com"
|
2
|
+
SitemapGenerator::Sitemap.yahoo_app_id = false
|
3
|
+
|
4
|
+
SitemapGenerator::Sitemap.add_links do |sitemap|
|
5
|
+
sitemap.add contents_path, :priority => 0.7, :changefreq => 'daily'
|
6
|
+
|
7
|
+
# add all individual articles
|
8
|
+
Content.find(:all).each do |c|
|
9
|
+
sitemap.add content_path(c), :lastmod => c.updated_at
|
10
|
+
end
|
11
|
+
|
12
|
+
sitemap.add "/merchant_path", :host => "https://www.example.com"
|
13
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file is auto-generated from the current state of the database. Instead of editing this file,
|
2
|
+
# please use the migrations feature of Active Record to incrementally modify your database, and
|
3
|
+
# then regenerate this schema definition.
|
4
|
+
#
|
5
|
+
# Note that this schema.rb definition is the authoritative source for your database schema. If you need
|
6
|
+
# to create the application database on another system, you should be using db:schema:load, not running
|
7
|
+
# all the migrations from scratch. The latter is a flawed and unsustainable approach (the more migrations
|
8
|
+
# you'll amass, the slower it'll run and the greater likelihood for issues).
|
9
|
+
#
|
10
|
+
# It's strongly recommended to check this file into your version control system.
|
11
|
+
|
12
|
+
ActiveRecord::Schema.define(:version => 20090826121911) do
|
13
|
+
|
14
|
+
create_table "contents", :force => true do |t|
|
15
|
+
t.string "title"
|
16
|
+
t.datetime "created_at"
|
17
|
+
t.datetime "updated_at"
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
metadata
CHANGED
@@ -1,20 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sitemap_generator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Salter
|
8
|
+
- Karl Varga
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
12
|
|
12
|
-
date: 2009-11
|
13
|
+
date: 2009-12-11 00:00:00 +08:00
|
13
14
|
default_executable:
|
14
15
|
dependencies: []
|
15
16
|
|
16
17
|
description: Install as a plugin or Gem to easily generate ['enterprise-class'][enterprise_class] Google Sitemaps for your Rails site, using a simple 'Rails Routes'-like DSL and a single rake task.
|
17
|
-
email:
|
18
|
+
email: kjvarga@gmail.com
|
18
19
|
executables: []
|
19
20
|
|
20
21
|
extensions: []
|
@@ -39,7 +40,7 @@ files:
|
|
39
40
|
- templates/sitemap_index.builder
|
40
41
|
- templates/xml_sitemap.builder
|
41
42
|
has_rdoc: true
|
42
|
-
homepage: http://github.com/
|
43
|
+
homepage: http://github.com/kjvarga/sitemap_generator
|
43
44
|
licenses: []
|
44
45
|
|
45
46
|
post_install_message:
|
@@ -84,5 +85,22 @@ test_files:
|
|
84
85
|
- test/mock_app/config/sitemap.rb
|
85
86
|
- test/mock_app/db/migrate/20090826121911_create_contents.rb
|
86
87
|
- test/mock_app/db/schema.rb
|
88
|
+
- test/mock_app_gem/app/controllers/application_controller.rb
|
89
|
+
- test/mock_app_gem/app/controllers/contents_controller.rb
|
90
|
+
- test/mock_app_gem/app/models/content.rb
|
91
|
+
- test/mock_app_gem/config/boot.rb
|
92
|
+
- test/mock_app_gem/config/environment.rb
|
93
|
+
- test/mock_app_gem/config/environments/development.rb
|
94
|
+
- test/mock_app_gem/config/environments/production.rb
|
95
|
+
- test/mock_app_gem/config/environments/test.rb
|
96
|
+
- test/mock_app_gem/config/initializers/backtrace_silencers.rb
|
97
|
+
- test/mock_app_gem/config/initializers/inflections.rb
|
98
|
+
- test/mock_app_gem/config/initializers/mime_types.rb
|
99
|
+
- test/mock_app_gem/config/initializers/new_rails_defaults.rb
|
100
|
+
- test/mock_app_gem/config/initializers/session_store.rb
|
101
|
+
- test/mock_app_gem/config/routes.rb
|
102
|
+
- test/mock_app_gem/config/sitemap.rb
|
103
|
+
- test/mock_app_gem/db/migrate/20090826121911_create_contents.rb
|
104
|
+
- test/mock_app_gem/db/schema.rb
|
87
105
|
- test/sitemap_generator_test.rb
|
88
106
|
- test/test_helper.rb
|