duck_map 0.8.4 → 0.8.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/lib/duck_map/array_helper.rb +0 -1
- data/lib/duck_map/attributes.rb +2 -3
- data/lib/duck_map/class_helpers.rb +0 -1
- data/lib/duck_map/engine.rb +5 -5
- data/lib/duck_map/filter_stack.rb +0 -1
- data/lib/duck_map/handlers/base.rb +2 -0
- data/lib/duck_map/handlers/edit.rb +19 -0
- data/lib/duck_map/handlers/index.rb +0 -10
- data/lib/duck_map/handlers/new.rb +19 -0
- data/lib/duck_map/last_mod.rb +1 -2
- data/lib/duck_map/logger.rb +0 -1
- data/lib/duck_map/mapper.rb +11 -4
- data/lib/duck_map/model.rb +0 -1
- data/lib/duck_map/route_filter.rb +2 -0
- data/lib/duck_map/route_set.rb +8 -12
- data/lib/duck_map/sitemap_object.rb +2 -3
- data/lib/duck_map/version.rb +1 -1
- data/lib/duck_map/view_helpers.rb +1 -3
- data/lib/duck_map.rb +2 -1
- data/lib/tasks/duck_map_tasks.rake +4 -0
- metadata +42 -16
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 305fb5ad0e27605cee8fc74c2a2e4503a1df9a83
|
4
|
+
data.tar.gz: 20c88d54a9cfb4ed011fe8cb260f2e1af0936f45
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 1f69066f412ac398337f4a8a3d2e3087a586303488eabe15a6bc442d76fe4ff02d7e684497ef3a54d89df361dc92e15c86c40c9e2ecc9b78101b990d098c7a64
|
7
|
+
data.tar.gz: 8505654b66ebe33decedb58ee7ee3be7ffdf0a31230acb74253ee1632aab9db0c491d1aeda80cde93b3bb750cef45f1b47a38dc13d88758237573c43a4573364
|
data/lib/duck_map/attributes.rb
CHANGED
@@ -1,12 +1,11 @@
|
|
1
|
-
# DONE
|
2
1
|
require 'active_support/concern'
|
3
2
|
|
4
3
|
module DuckMap
|
5
4
|
|
6
5
|
##################################################################################
|
7
6
|
# This module has a single purpose. To declare a class-level attribute using the Rails class_attribute method.
|
8
|
-
# Also, we are using
|
9
|
-
#
|
7
|
+
# Also, we are using ActiveSupport::Concern and the included block. This module is included in
|
8
|
+
# ActionController::Base, so, every controller object will have the attribute.
|
10
9
|
#
|
11
10
|
# See {DuckMap::Attributes::ClassMethods#sitemap_attributes} for an explanation.
|
12
11
|
module InheritableClassAttributes
|
data/lib/duck_map/engine.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
require 'journey'
|
2
|
-
|
3
1
|
module DuckMap
|
4
2
|
extend ActiveSupport::Autoload
|
5
3
|
|
@@ -33,7 +31,7 @@ module DuckMap
|
|
33
31
|
|
34
32
|
end
|
35
33
|
|
36
|
-
class
|
34
|
+
class Engine < Rails::Engine
|
37
35
|
|
38
36
|
# # this is so I can develop the gem
|
39
37
|
# # run dev.com, make changes to files in lib/duck_captcha, refresh browser.
|
@@ -49,7 +47,7 @@ module DuckMap
|
|
49
47
|
seo: "%a, %d %b %Y %H:%M:%S %Z")
|
50
48
|
end
|
51
49
|
|
52
|
-
Journey::Route.send :include, Route
|
50
|
+
ActionDispatch::Journey::Route.send :include, Route
|
53
51
|
|
54
52
|
ActionDispatch::Routing::RouteSet.send :include, RouteSet
|
55
53
|
ActionDispatch::Routing::RouteSet.send :include, RouteFilter
|
@@ -64,11 +62,13 @@ module DuckMap
|
|
64
62
|
ActiveRecord::Base.send :include, SitemapObject
|
65
63
|
end
|
66
64
|
|
67
|
-
ActiveSupport.on_load(:
|
65
|
+
ActiveSupport.on_load(:after_initialize) do
|
68
66
|
ActionController::Base.send :include, InheritableClassAttributes
|
69
67
|
ActionController::Base.send :include, Attributes
|
70
68
|
ActionController::Base.send :include, ControllerHelpers
|
71
69
|
ActionController::Base.send :include, Handlers::Base
|
70
|
+
ActionController::Base.send :include, Handlers::Edit
|
71
|
+
ActionController::Base.send :include, Handlers::New
|
72
72
|
ActionController::Base.send :include, Handlers::Index
|
73
73
|
ActionController::Base.send :include, Handlers::Show
|
74
74
|
ActionController::Base.send :include, Model
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module DuckMap
|
4
|
+
module Handlers
|
5
|
+
|
6
|
+
##################################################################################
|
7
|
+
module Edit
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
##################################################################################
|
11
|
+
# Not implemented yet.
|
12
|
+
def sitemap_edit(options = {})
|
13
|
+
return []
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -7,16 +7,6 @@ module DuckMap
|
|
7
7
|
module Index
|
8
8
|
extend ActiveSupport::Concern
|
9
9
|
|
10
|
-
##################################################################################
|
11
|
-
def sitemap_new(options = {})
|
12
|
-
return []
|
13
|
-
end
|
14
|
-
|
15
|
-
##################################################################################
|
16
|
-
def sitemap_edit(options = {})
|
17
|
-
return []
|
18
|
-
end
|
19
|
-
|
20
10
|
##################################################################################
|
21
11
|
# Default handler method for index actions.
|
22
12
|
#
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module DuckMap
|
4
|
+
module Handlers
|
5
|
+
|
6
|
+
##################################################################################
|
7
|
+
module New
|
8
|
+
extend ActiveSupport::Concern
|
9
|
+
|
10
|
+
##################################################################################
|
11
|
+
# Not implemented yet.
|
12
|
+
def sitemap_new(options = {})
|
13
|
+
return []
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
data/lib/duck_map/last_mod.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# DONE
|
2
1
|
module DuckMap
|
3
2
|
|
4
3
|
##################################################################################
|
@@ -9,7 +8,7 @@ module DuckMap
|
|
9
8
|
# Parses a DateTime represented as a String into a DateTime value. If value is String, then, it is parsed
|
10
9
|
# and returns a DateTime Object if valid. Otherwise, it returns nil. If the value passed is a Date, Time, or DateTime, then,
|
11
10
|
# it is returned as is.
|
12
|
-
# @param [String] A DateTime represented as a String to parse or can be a Date, Time, or DateTime value.
|
11
|
+
# @param [String] value A DateTime represented as a String to parse or can be a Date, Time, or DateTime value.
|
13
12
|
# @return [DateTime] DateTime value.
|
14
13
|
def self.to_date(value)
|
15
14
|
date_value = nil
|
data/lib/duck_map/logger.rb
CHANGED
data/lib/duck_map/mapper.rb
CHANGED
@@ -11,6 +11,12 @@ module DuckMap
|
|
11
11
|
|
12
12
|
##################################################################################
|
13
13
|
# Defines a sitemap for a Rails app.
|
14
|
+
#
|
15
|
+
#
|
16
|
+
# You can find a few examples and apps at:
|
17
|
+
# - (http://www.jeffduckett.com/blog/11/defining-rails-3-x-sitemaps-using-duckmap.html)
|
18
|
+
# - (http://www.jeffduckett.com/blog/12/multiple-sitemap-definitions.html)
|
19
|
+
#
|
14
20
|
# @return [Nil]
|
15
21
|
def sitemap(name = :sitemap, options = {}, &block)
|
16
22
|
options = name.kind_of?(Hash) ? name : options
|
@@ -20,14 +26,15 @@ module DuckMap
|
|
20
26
|
sitemap_raw_route_name = "#{name}_sitemap"
|
21
27
|
|
22
28
|
# create a route for the sitemap using the name that was passed to the sitemap method inside config/routes.
|
23
|
-
match %(/#{name}.:format), controller: config[:controller], action: name, as: sitemap_raw_route_name
|
29
|
+
match %(/#{name}.:format), controller: config[:controller], action: name, via: [:get], as: sitemap_raw_route_name
|
24
30
|
|
25
31
|
# the current Rails implementation keeps the routes in an array. Also, it does nothing to prevent duplicate routes from being added.
|
26
32
|
# at the time of development, the route is always at the end of the list, so, it is pretty safe to assume
|
27
33
|
# the last route in the list is the sitemap route we just added.
|
28
|
-
|
34
|
+
|
29
35
|
# last_route_name is used after we check to see if we just added a duplicate route.
|
30
|
-
last_route_name = @set.routes.last.route_name
|
36
|
+
#last_route_name = @set.routes.last.route_name
|
37
|
+
last_route_name = @set.routes.last.name
|
31
38
|
|
32
39
|
# identify the route as a "sitemap" route and build it's full name.
|
33
40
|
@set.routes.last.is_sitemap = true
|
@@ -145,7 +152,7 @@ module DuckMap
|
|
145
152
|
extend ActiveSupport::Concern
|
146
153
|
|
147
154
|
##################################################################################
|
148
|
-
# See {DuckMap::
|
155
|
+
# See {DuckMap::RouteFilter#blank_route_name blank_route_name}
|
149
156
|
def allow_blank_route_name(value)
|
150
157
|
@set.blank_route_name = value
|
151
158
|
end
|
data/lib/duck_map/model.rb
CHANGED
@@ -20,6 +20,8 @@ module DuckMap
|
|
20
20
|
##################################################################################
|
21
21
|
# Mixin module for ActionDispatch::Routing::RouteSet. This module is responsible for evaluating each route
|
22
22
|
# for consideration to be included in a sitemap.
|
23
|
+
#
|
24
|
+
# You can find a few examples and apps at: (http://www.jeffduckett.com/blog/15/route-filters.html)
|
23
25
|
module RouteFilter
|
24
26
|
extend ActiveSupport::Concern
|
25
27
|
|
data/lib/duck_map/route_set.rb
CHANGED
@@ -10,8 +10,8 @@ module DuckMap
|
|
10
10
|
|
11
11
|
##################################################################################
|
12
12
|
# Builds a list of routes associated with a sitemap. The actual list of routes returned is based
|
13
|
-
# on {DuckMap::
|
14
|
-
# @note See {DuckMap::
|
13
|
+
# on {DuckMap::Route#sitemap_route_name sitemap_route_name}, which is the named route of the sitemap.
|
14
|
+
# @note See {DuckMap::Mapper#sitemap} for a full explanation of how to define a sitemap and how those rules affect this method.
|
15
15
|
# @param [String] name_or_path The request.path of the current sitemap url or the name assigned to the sitemap via config/routes.rb.
|
16
16
|
# @return [Array]
|
17
17
|
def find_sitemap_route(name_or_path)
|
@@ -35,9 +35,9 @@ module DuckMap
|
|
35
35
|
|
36
36
|
##################################################################################
|
37
37
|
# Builds a list of routes associated with a sitemap route. The actual list of routes returned is based
|
38
|
-
# on {DuckMap::
|
38
|
+
# on {DuckMap::Route#sitemap_route_name sitemap_route_name}, which is the named
|
39
39
|
# route of the sitemap.
|
40
|
-
# @note See {DuckMap::
|
40
|
+
# @note See {DuckMap::Mapper#sitemap} for a full explanation of how to define a sitemap and how those rules affect this method.
|
41
41
|
# @param [String] sitemap_route A sitemap route.
|
42
42
|
# @return [Array]
|
43
43
|
def sitemap_routes(sitemap_route)
|
@@ -58,7 +58,6 @@ module DuckMap
|
|
58
58
|
else
|
59
59
|
|
60
60
|
candidates = self.routes.find_all {|route| !route.is_sitemap?}
|
61
|
-
|
62
61
|
potential_owners = self.routes.find_all {|route| route.is_sitemap?}
|
63
62
|
potential_owners.sort! { |a,b| b.namespace_prefix_underscores <=> a.namespace_prefix_underscores}
|
64
63
|
|
@@ -106,6 +105,7 @@ module DuckMap
|
|
106
105
|
end
|
107
106
|
|
108
107
|
list.reject! {|route| route.path.spec =~ %r{/rails/info/properties|^/assets}}
|
108
|
+
list.reject! {|route| route.name.eql?("rails_info")}
|
109
109
|
list.reject! {|route| !route.is_available?}
|
110
110
|
|
111
111
|
return list
|
@@ -155,7 +155,7 @@ module DuckMap
|
|
155
155
|
##################################################################################
|
156
156
|
def find_route_via_path(path, environment = {})
|
157
157
|
method = (environment[:method] || "GET").to_s.upcase
|
158
|
-
path = Journey::Router::Utils.normalize_path(path) unless path =~ %r{://}
|
158
|
+
path = ActionDispatch::Journey::Router::Utils.normalize_path(path) unless path =~ %r{://}
|
159
159
|
|
160
160
|
begin
|
161
161
|
env = Rack::MockRequest.env_for(path, {:method => method})
|
@@ -167,13 +167,13 @@ module DuckMap
|
|
167
167
|
@router.recognize(req) do |route, matches, params|
|
168
168
|
params.each do |key, value|
|
169
169
|
if value.is_a?(String)
|
170
|
-
value = value.dup.force_encoding(Encoding::BINARY) if value.encoding_aware?
|
170
|
+
value = value.dup.force_encoding(Encoding::BINARY)# if value.encoding_aware?
|
171
171
|
params[key] = URI.parser.unescape(value)
|
172
172
|
end
|
173
173
|
end
|
174
174
|
|
175
175
|
dispatcher = route.app
|
176
|
-
|
176
|
+
|
177
177
|
while dispatcher.is_a?(ActionDispatch::Routing::Mapper::Constraints) && dispatcher.matches?(env) do
|
178
178
|
dispatcher = dispatcher.app
|
179
179
|
end
|
@@ -187,10 +187,6 @@ module DuckMap
|
|
187
187
|
raise ActionController::RoutingError, "No route matches #{path.inspect}"
|
188
188
|
end
|
189
189
|
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
190
|
end
|
195
191
|
|
196
192
|
end
|
@@ -1,4 +1,3 @@
|
|
1
|
-
# DONE i think. need to proof read and re-verify
|
2
1
|
require 'active_support/concern'
|
3
2
|
|
4
3
|
module DuckMap
|
@@ -131,7 +130,7 @@ module DuckMap
|
|
131
130
|
# @option options [Symbol] :keywords Default value: :keywords
|
132
131
|
# @option options [Symbol] :lastmod Default value: :updated_at
|
133
132
|
# @option options [Symbol] :priority Valid static values range from 0.0 to 1.0
|
134
|
-
# @option options [Symbol] :segments Sub-hash containing attributes for the segments. See {#
|
133
|
+
# @option options [Symbol] :segments Sub-hash containing attributes for the segments. See {#sitemap_segments sitemap_segments}
|
135
134
|
# @option options [Symbol] :title Default value: :title
|
136
135
|
# @option options [Symbol] :url_format Default value: "html"
|
137
136
|
# @option options [Symbol] :url_limit Default value: 50000
|
@@ -329,7 +328,7 @@ module DuckMap
|
|
329
328
|
# - :my_title is a Symbol, however, a matching attribute/method does NOT exist on the target object, so,
|
330
329
|
# it is ignored and not included in the returning Hash.
|
331
330
|
#
|
332
|
-
# @param [Hash]
|
331
|
+
# @param [Hash] attributes Options hash. Can be any combination of key/value pairs (one-dimensional).
|
333
332
|
# return [Hash]
|
334
333
|
def sitemap_capture_attributes(attributes = {})
|
335
334
|
values = {}
|
data/lib/duck_map/version.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
# DONE
|
2
1
|
require 'active_support/concern'
|
3
2
|
|
4
3
|
module DuckMap
|
@@ -11,13 +10,12 @@ module DuckMap
|
|
11
10
|
##################################################################################
|
12
11
|
# View helper method to generate the content of a sitemap. Loops through all of the current
|
13
12
|
# Hashes contained in {DuckMap::Model#sitemap_model}.
|
14
|
-
# @param [Block] A block to execute for each row contained in {DuckMap::Model#sitemap_model}.
|
15
|
-
#
|
16
13
|
#
|
17
14
|
# To see it in action, have a look at the file.
|
18
15
|
#
|
19
16
|
# /app/views/sitemap/default_template.xml.erb
|
20
17
|
#
|
18
|
+
# @param [Block] block A block to execute for each row contained in {DuckMap::Model#sitemap_model}.
|
21
19
|
# @return [NilClass]
|
22
20
|
def sitemap_content(&block)
|
23
21
|
|
data/lib/duck_map.rb
CHANGED
metadata
CHANGED
@@ -1,33 +1,58 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: duck_map
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
5
|
-
prerelease:
|
4
|
+
version: 0.8.6
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Jeff Duckett
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date: 2013-
|
11
|
+
date: 2013-11-26 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ~>
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.1
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ~>
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.1
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: sqlite3
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - '>='
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
14
41
|
- !ruby/object:Gem::Dependency
|
15
42
|
name: highline
|
16
43
|
requirement: !ruby/object:Gem::Requirement
|
17
|
-
none: false
|
18
44
|
requirements:
|
19
|
-
- -
|
45
|
+
- - '>='
|
20
46
|
- !ruby/object:Gem::Version
|
21
47
|
version: '0'
|
22
48
|
type: :runtime
|
23
49
|
prerelease: false
|
24
50
|
version_requirements: !ruby/object:Gem::Requirement
|
25
|
-
none: false
|
26
51
|
requirements:
|
27
|
-
- -
|
52
|
+
- - '>='
|
28
53
|
- !ruby/object:Gem::Version
|
29
54
|
version: '0'
|
30
|
-
description: Duck Map is a Rails
|
55
|
+
description: Duck Map is a Rails 4.x compliant gem providing support for dynamically
|
31
56
|
generating sitemaps and meta tags in HTML page headers.
|
32
57
|
email:
|
33
58
|
- jeff.duckett@gmail.com
|
@@ -41,6 +66,7 @@ files:
|
|
41
66
|
- lib/generators/duckmap/sync/USAGE
|
42
67
|
- lib/generators/duckmap/sitemaps/sitemaps_generator.rb
|
43
68
|
- lib/generators/duckmap/sitemaps/USAGE
|
69
|
+
- lib/tasks/duck_map_tasks.rake
|
44
70
|
- lib/duck_map/sync.rb
|
45
71
|
- lib/duck_map/mapper.rb
|
46
72
|
- lib/duck_map/sitemap_object.rb
|
@@ -57,6 +83,8 @@ files:
|
|
57
83
|
- lib/duck_map/model.rb
|
58
84
|
- lib/duck_map/route.rb
|
59
85
|
- lib/duck_map/handlers/base.rb
|
86
|
+
- lib/duck_map/handlers/edit.rb
|
87
|
+
- lib/duck_map/handlers/new.rb
|
60
88
|
- lib/duck_map/handlers/index.rb
|
61
89
|
- lib/duck_map/handlers/show.rb
|
62
90
|
- lib/duck_map/static.rb
|
@@ -71,28 +99,26 @@ files:
|
|
71
99
|
- config/routes.rb
|
72
100
|
homepage: http://www.jeffduckett.com/
|
73
101
|
licenses: []
|
102
|
+
metadata: {}
|
74
103
|
post_install_message:
|
75
104
|
rdoc_options: []
|
76
105
|
require_paths:
|
77
106
|
- lib
|
78
107
|
required_ruby_version: !ruby/object:Gem::Requirement
|
79
|
-
none: false
|
80
108
|
requirements:
|
81
|
-
- -
|
109
|
+
- - '>='
|
82
110
|
- !ruby/object:Gem::Version
|
83
111
|
version: '0'
|
84
112
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
85
|
-
none: false
|
86
113
|
requirements:
|
87
|
-
- -
|
114
|
+
- - '>='
|
88
115
|
- !ruby/object:Gem::Version
|
89
116
|
version: '0'
|
90
117
|
requirements: []
|
91
118
|
rubyforge_project: duck_map
|
92
|
-
rubygems_version: 1.
|
119
|
+
rubygems_version: 2.1.11
|
93
120
|
signing_key:
|
94
|
-
specification_version:
|
95
|
-
summary: Duck Map is a Rails
|
121
|
+
specification_version: 4
|
122
|
+
summary: Duck Map is a Rails 4.x compliant gem providing support for dynamically generating
|
96
123
|
sitemaps and meta tags in HTML page headers.
|
97
124
|
test_files: []
|
98
|
-
has_rdoc:
|