sitemap_generator 0.2.3 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -9
- data/Rakefile +68 -17
- data/VERSION +1 -1
- data/lib/sitemap_generator.rb +10 -6
- data/lib/sitemap_generator/link_set.rb +167 -14
- data/rails/install.rb +1 -11
- data/rails/uninstall.rb +1 -3
- data/tasks/sitemap_generator_tasks.rake +9 -79
- metadata +17 -43
- data/test/mock_app/app/controllers/application_controller.rb +0 -10
- data/test/mock_app/app/controllers/contents_controller.rb +0 -85
- data/test/mock_app/app/models/content.rb +0 -2
- data/test/mock_app/config/boot.rb +0 -110
- data/test/mock_app/config/environment.rb +0 -41
- data/test/mock_app/config/environments/development.rb +0 -17
- data/test/mock_app/config/environments/production.rb +0 -28
- data/test/mock_app/config/environments/test.rb +0 -28
- data/test/mock_app/config/initializers/backtrace_silencers.rb +0 -7
- data/test/mock_app/config/initializers/inflections.rb +0 -10
- data/test/mock_app/config/initializers/mime_types.rb +0 -5
- data/test/mock_app/config/initializers/new_rails_defaults.rb +0 -19
- data/test/mock_app/config/initializers/session_store.rb +0 -15
- data/test/mock_app/config/routes.rb +0 -45
- data/test/mock_app/config/sitemap.rb +0 -13
- data/test/mock_app/db/migrate/20090826121911_create_contents.rb +0 -12
- data/test/mock_app/db/schema.rb +0 -20
- data/test/mock_app_gem/app/controllers/application_controller.rb +0 -10
- data/test/mock_app_gem/app/controllers/contents_controller.rb +0 -85
- data/test/mock_app_gem/app/models/content.rb +0 -2
- data/test/mock_app_gem/config/boot.rb +0 -110
- data/test/mock_app_gem/config/environment.rb +0 -42
- data/test/mock_app_gem/config/environments/development.rb +0 -17
- data/test/mock_app_gem/config/environments/production.rb +0 -28
- data/test/mock_app_gem/config/environments/test.rb +0 -28
- data/test/mock_app_gem/config/initializers/backtrace_silencers.rb +0 -7
- data/test/mock_app_gem/config/initializers/inflections.rb +0 -10
- data/test/mock_app_gem/config/initializers/mime_types.rb +0 -5
- data/test/mock_app_gem/config/initializers/new_rails_defaults.rb +0 -19
- data/test/mock_app_gem/config/initializers/session_store.rb +0 -15
- data/test/mock_app_gem/config/routes.rb +0 -45
- data/test/mock_app_gem/config/sitemap.rb +0 -13
- data/test/mock_app_gem/db/migrate/20090826121911_create_contents.rb +0 -12
- data/test/mock_app_gem/db/schema.rb +0 -20
- data/test/sitemap_generator_test.rb +0 -83
- data/test/test_helper.rb +0 -12
@@ -1,10 +0,0 @@
|
|
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
|
@@ -1,19 +0,0 @@
|
|
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
|
@@ -1,15 +0,0 @@
|
|
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
|
@@ -1,45 +0,0 @@
|
|
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
|
@@ -1,13 +0,0 @@
|
|
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
|
@@ -1,20 +0,0 @@
|
|
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
|
@@ -1,83 +0,0 @@
|
|
1
|
-
require File.dirname(__FILE__) + '/test_helper'
|
2
|
-
|
3
|
-
class SitemapGeneratorTest < Test::Unit::TestCase
|
4
|
-
context "SitemapGenerator Rake Tasks" do
|
5
|
-
|
6
|
-
context "when running the clean task" do
|
7
|
-
setup do
|
8
|
-
copy_sitemap_file_to_rails_app
|
9
|
-
FileUtils.touch(File.join(RAILS_ROOT, '/public/sitemap_index.xml.gz'))
|
10
|
-
Rake::Task['sitemap:clean'].invoke
|
11
|
-
end
|
12
|
-
|
13
|
-
should "the sitemap xml files be deleted" do
|
14
|
-
assert !File.exists?(File.join(RAILS_ROOT, '/public/sitemap_index.xml.gz'))
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
# For some reason I just couldn't get this to work! It seemed to delete the
|
19
|
-
# file before calling the second *should* assertion.
|
20
|
-
context "when installed to a clean Rails app" do
|
21
|
-
setup do
|
22
|
-
#delete_sitemap_file_from_rails_app
|
23
|
-
#Rake::Task['sitemap:install'].invoke
|
24
|
-
end
|
25
|
-
|
26
|
-
should "a sitemap.rb is created" do
|
27
|
-
#assert File.exists?(File.join(RAILS_ROOT, 'config/sitemap.rb'))
|
28
|
-
end
|
29
|
-
|
30
|
-
should "the sitemap.rb file matches the template" do
|
31
|
-
#assert identical_files?(File.join(RAILS_ROOT, 'config/sitemap.rb'), SitemapGenerator.templates[:sitemap_sample])
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
context "when installed multiple times" do
|
36
|
-
setup do
|
37
|
-
copy_sitemap_file_to_rails_app
|
38
|
-
Rake::Task['sitemap:install'].invoke
|
39
|
-
end
|
40
|
-
|
41
|
-
should "not overwrite existing sitemap.rb file" do
|
42
|
-
assert identical_files?(File.join(File.dirname(__FILE__), '/sitemap.file'), File.join(RAILS_ROOT, '/config/sitemap.rb'))
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context "when sitemap generated" do
|
47
|
-
setup do
|
48
|
-
copy_sitemap_file_to_rails_app
|
49
|
-
Rake::Task['sitemap:refresh'].invoke
|
50
|
-
end
|
51
|
-
|
52
|
-
should "not create sitemap xml files" do
|
53
|
-
assert File.exists?(File.join(RAILS_ROOT, '/public/sitemap_index.xml.gz'))
|
54
|
-
assert File.exists?(File.join(RAILS_ROOT, '/public/sitemap1.xml.gz'))
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "SitemapGenerator library" do
|
60
|
-
setup do
|
61
|
-
copy_sitemap_file_to_rails_app
|
62
|
-
end
|
63
|
-
|
64
|
-
should "be have x elements" do
|
65
|
-
assert_equal 14, SitemapGenerator::Sitemap.links.size
|
66
|
-
end
|
67
|
-
end
|
68
|
-
|
69
|
-
def copy_sitemap_file_to_rails_app
|
70
|
-
FileUtils.cp(File.join(File.dirname(__FILE__), '/sitemap.file'), File.join(RAILS_ROOT, '/config/sitemap.rb'))
|
71
|
-
end
|
72
|
-
|
73
|
-
def delete_sitemap_file_from_rails_app
|
74
|
-
FileUtils.remove(File.join(RAILS_ROOT, '/config/sitemap.rb')) rescue nil
|
75
|
-
end
|
76
|
-
|
77
|
-
def identical_files?(first, second)
|
78
|
-
first = open(first, 'r').read
|
79
|
-
second = open(second, 'r').read
|
80
|
-
first == second
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
data/test/test_helper.rb
DELETED
@@ -1,12 +0,0 @@
|
|
1
|
-
ENV['RAILS_ENV'] = 'test'
|
2
|
-
ENV['RAILS_ROOT'] ||= File.join(File.dirname(__FILE__), 'mock_app')
|
3
|
-
|
4
|
-
require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config', 'environment.rb'))
|
5
|
-
|
6
|
-
require 'fileutils'
|
7
|
-
require 'rake'
|
8
|
-
require 'shoulda'
|
9
|
-
|
10
|
-
require 'rake/testtask'
|
11
|
-
require 'rake/rdoctask'
|
12
|
-
require 'tasks/rails'
|