radiant 0.6.3 → 0.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of radiant might be problematic. Click here for more details.
- data/CHANGELOG +61 -7
- data/CONTRIBUTORS +15 -0
- data/app/controllers/admin/export_controller.rb +1 -1
- data/app/controllers/admin/page_controller.rb +1 -0
- data/app/controllers/admin/user_controller.rb +2 -1
- data/app/controllers/application.rb +7 -8
- data/app/helpers/admin/node_helper.rb +84 -0
- data/app/helpers/admin/page_helper.rb +1 -19
- data/app/helpers/application_helper.rb +15 -9
- data/app/models/file_not_found_page.rb +2 -2
- data/app/models/page.rb +22 -18
- data/app/models/page_context.rb +9 -0
- data/app/models/radiant/config.rb +4 -2
- data/app/models/response_cache.rb +18 -12
- data/app/models/standard_tags.rb +111 -50
- data/app/views/admin/extension/index.rhtml +2 -2
- data/app/views/admin/layout/edit.rhtml +2 -2
- data/app/views/admin/layout/remove.rhtml +2 -2
- data/app/views/admin/page/_node.rhtml +4 -26
- data/app/views/admin/page/_part.rhtml +9 -14
- data/app/views/admin/page/edit.rhtml +38 -121
- data/app/views/admin/page/index.rhtml +2 -6
- data/app/views/admin/page/remove.rhtml +2 -2
- data/app/views/admin/snippet/edit.rhtml +3 -3
- data/app/views/admin/snippet/index.rhtml +2 -2
- data/app/views/admin/snippet/remove.rhtml +2 -2
- data/app/views/admin/user/edit.rhtml +4 -4
- data/app/views/admin/user/preferences.rhtml +2 -2
- data/app/views/admin/welcome/login.rhtml +1 -1
- data/config/environment.rb +79 -78
- data/db/schema.rb +2 -0
- data/lib/local_time.rb +12 -0
- data/lib/plugins/extension_patches/lib/fixture_loading_extension.rb +1 -1
- data/lib/plugins/extension_patches/lib/mailer_view_paths_extension.rb +3 -3
- data/lib/radiant.rb +1 -1
- data/lib/radiant/extension.rb +9 -3
- data/lib/radiant/extension_loader.rb +2 -2
- data/lib/tasks/extensions.rake +23 -8
- data/public/javascripts/admin.js +89 -0
- data/public/javascripts/controls.js +486 -354
- data/public/javascripts/dragdrop.js +90 -58
- data/public/javascripts/effects.js +398 -364
- data/public/javascripts/pngfix.js +37 -37
- data/public/javascripts/prototype.js +2764 -1095
- data/public/javascripts/ruledtable.js +10 -25
- data/public/javascripts/sitemap.js +74 -112
- data/public/javascripts/string.js +1 -7
- data/public/javascripts/tabcontrol.js +71 -86
- data/public/javascripts/tag_reference_search.js +19 -26
- data/public/stylesheets/admin/main.css +11 -5
- data/test/fixtures/extensions/01_basic/lib/new_module.rb +2 -0
- data/test/fixtures/page_parts.yml +16 -1
- data/test/fixtures/pages.yml +47 -84
- data/test/functional/extension_initialization_test.rb +11 -0
- data/test/helpers/login_test_helper.rb +12 -1
- data/test/helpers/page_test_helper.rb +6 -0
- data/test/helpers/render_test_helper.rb +11 -8
- data/test/test_helper.rb +1 -12
- data/test/unit/file_not_found_page_test.rb +5 -1
- data/test/unit/local_time_test.rb +45 -0
- data/test/unit/page_context_test.rb +32 -1
- data/test/unit/page_test.rb +45 -11
- data/test/unit/radiant/config_test.rb +1 -1
- data/test/unit/response_cache_test.rb +27 -2
- data/test/unit/standard_tags_test.rb +60 -15
- data/vendor/extensions/archive/README +29 -0
- data/vendor/extensions/archive/Rakefile +25 -0
- data/{app → vendor/extensions/archive/app}/models/archive_day_index_page.rb +0 -0
- data/{app → vendor/extensions/archive/app}/models/archive_finder.rb +8 -6
- data/{app → vendor/extensions/archive/app}/models/archive_month_index_page.rb +0 -0
- data/{app → vendor/extensions/archive/app}/models/archive_page.rb +0 -0
- data/{app → vendor/extensions/archive/app}/models/archive_year_index_page.rb +0 -0
- data/vendor/extensions/archive/archive_extension.rb +19 -0
- data/{lib → vendor/extensions/archive/lib}/archive_index_tags_and_methods.rb +0 -0
- data/vendor/extensions/archive/lib/tasks/archive_extension_tasks.rake +28 -0
- data/vendor/extensions/archive/test/fixtures/pages.yml +397 -0
- data/vendor/extensions/archive/test/functional/archive_extension_test.rb +16 -0
- data/{test → vendor/extensions/archive/test}/helpers/archive_index_test_helper.rb +0 -0
- data/vendor/extensions/archive/test/test_helper.rb +19 -0
- data/{test → vendor/extensions/archive/test}/unit/archive_day_index_page_test.rb +0 -0
- data/{test → vendor/extensions/archive/test}/unit/archive_month_index_page_test.rb +0 -0
- data/{test → vendor/extensions/archive/test}/unit/archive_page_test.rb +7 -1
- data/{test → vendor/extensions/archive/test}/unit/archive_year_index_page_test.rb +0 -0
- data/vendor/rails/actionmailer/CHANGELOG +10 -0
- data/vendor/rails/actionmailer/Rakefile +1 -1
- data/vendor/rails/actionmailer/lib/action_mailer/version.rb +1 -1
- data/vendor/rails/actionpack/CHANGELOG +51 -2
- data/vendor/rails/actionpack/Rakefile +1 -1
- data/vendor/rails/actionpack/lib/action_controller/assertions/dom_assertions.rb +2 -2
- data/vendor/rails/actionpack/lib/action_controller/assertions/model_assertions.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/assertions/response_assertions.rb +3 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/routing_assertions.rb +1 -0
- data/vendor/rails/actionpack/lib/action_controller/assertions/selector_assertions.rb +2 -0
- data/vendor/rails/actionpack/lib/action_controller/base.rb +7 -1
- data/vendor/rails/actionpack/lib/action_controller/caching.rb +39 -38
- data/vendor/rails/actionpack/lib/action_controller/cgi_ext/pstore_performance_fix.rb +30 -0
- data/vendor/rails/actionpack/lib/action_controller/cgi_ext/raw_post_data_fix.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/cgi_process.rb +13 -4
- data/vendor/rails/actionpack/lib/action_controller/cookies.rb +5 -3
- data/vendor/rails/actionpack/lib/action_controller/filters.rb +176 -77
- data/vendor/rails/actionpack/lib/action_controller/integration.rb +31 -21
- data/vendor/rails/actionpack/lib/action_controller/macros/in_place_editing.rb +1 -1
- data/vendor/rails/actionpack/lib/action_controller/pagination.rb +7 -1
- data/vendor/rails/actionpack/lib/action_controller/resources.rb +117 -32
- data/vendor/rails/actionpack/lib/action_controller/routing.rb +56 -23
- data/vendor/rails/actionpack/lib/action_controller/test_process.rb +5 -2
- data/vendor/rails/actionpack/lib/action_controller/url_rewriter.rb +4 -1
- data/vendor/rails/actionpack/lib/action_controller/verification.rb +1 -0
- data/vendor/rails/actionpack/lib/action_pack/version.rb +1 -1
- data/vendor/rails/actionpack/lib/action_view/base.rb +25 -19
- data/vendor/rails/actionpack/lib/action_view/compiled_templates.rb +2 -2
- data/vendor/rails/actionpack/lib/action_view/helpers/active_record_helper.rb +18 -18
- data/vendor/rails/actionpack/lib/action_view/helpers/debug_helper.rb +10 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/deprecated_helper.rb +3 -0
- data/vendor/rails/actionpack/lib/action_view/helpers/prototype_helper.rb +33 -17
- data/vendor/rails/actionpack/test/activerecord/pagination_test.rb +9 -0
- data/vendor/rails/actionpack/test/controller/action_pack_assertions_test.rb +13 -0
- data/vendor/rails/actionpack/test/controller/addresses_render_test.rb +4 -1
- data/vendor/rails/actionpack/test/controller/base_test.rb +1 -1
- data/vendor/rails/actionpack/test/controller/caching_test.rb +3 -2
- data/vendor/rails/actionpack/test/controller/cookie_test.rb +11 -0
- data/vendor/rails/actionpack/test/controller/deprecation/deprecated_base_methods_test.rb +18 -0
- data/vendor/rails/actionpack/test/controller/filter_params_test.rb +1 -0
- data/vendor/rails/actionpack/test/controller/filters_test.rb +149 -26
- data/vendor/rails/actionpack/test/controller/integration_test.rb +93 -8
- data/vendor/rails/actionpack/test/controller/resources_test.rb +215 -36
- data/vendor/rails/actionpack/test/controller/routing_test.rb +2 -2
- data/vendor/rails/actionpack/test/controller/test_test.rb +16 -0
- data/vendor/rails/actionpack/test/controller/url_rewriter_test.rb +66 -10
- data/vendor/rails/actionpack/test/controller/verification_test.rb +15 -0
- data/vendor/rails/actionpack/test/fixtures/test/hello_world.rxml +2 -1
- data/vendor/rails/actionpack/test/template/asset_tag_helper_test.rb +5 -0
- data/vendor/rails/actionpack/test/template/compiled_templates_test.rb +29 -17
- data/vendor/rails/actionpack/test/template/javascript_helper_test.rb +4 -4
- data/vendor/rails/actionpack/test/template/number_helper_test.rb +1 -1
- data/vendor/rails/actionpack/test/template/prototype_helper_test.rb +13 -13
- data/vendor/rails/actionwebservice/CHANGELOG +14 -0
- data/vendor/rails/actionwebservice/Rakefile +2 -2
- data/vendor/rails/actionwebservice/lib/action_web_service/version.rb +1 -1
- data/vendor/rails/activerecord/CHANGELOG +34 -0
- data/vendor/rails/activerecord/Rakefile +1 -1
- data/vendor/rails/activerecord/lib/active_record/acts/list.rb +14 -2
- data/vendor/rails/activerecord/lib/active_record/acts/tree.rb +7 -0
- data/vendor/rails/activerecord/lib/active_record/associations.rb +29 -14
- data/vendor/rails/activerecord/lib/active_record/associations/association_collection.rb +5 -1
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_association.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/associations/has_many_through_association.rb +10 -0
- data/vendor/rails/activerecord/lib/active_record/base.rb +12 -3
- data/vendor/rails/activerecord/lib/active_record/calculations.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/abstract/quoting.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/oracle_adapter.rb +1 -0
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlite_adapter.rb +2 -2
- data/vendor/rails/activerecord/lib/active_record/connection_adapters/sqlserver_adapter.rb +54 -38
- data/vendor/rails/activerecord/lib/active_record/deprecated_finders.rb +3 -3
- data/vendor/rails/activerecord/lib/active_record/fixtures.rb +1 -1
- data/vendor/rails/activerecord/lib/active_record/timestamp.rb +0 -9
- data/vendor/rails/activerecord/lib/active_record/version.rb +1 -1
- data/vendor/rails/activerecord/test/associations/eager_test.rb +13 -0
- data/vendor/rails/activerecord/test/associations/join_model_test.rb +10 -1
- data/vendor/rails/activerecord/test/associations_test.rb +36 -3
- data/vendor/rails/activerecord/test/base_test.rb +17 -4
- data/vendor/rails/activerecord/test/defaults_test.rb +15 -0
- data/vendor/rails/activerecord/test/fixtures/author.rb +1 -0
- data/vendor/rails/activerecord/test/fixtures/binaries.yml +437 -0
- data/vendor/rails/activerecord/test/fixtures/db_definitions/schema.rb +13 -0
- data/vendor/rails/activerecord/test/fixtures/developer.rb +10 -0
- data/vendor/rails/activerecord/test/fixtures_test.rb +9 -5
- data/vendor/rails/activerecord/test/migration_test.rb +9 -10
- data/vendor/rails/activerecord/test/mixin_test.rb +47 -0
- data/vendor/rails/activerecord/test/validations_test.rb +2 -2
- data/vendor/rails/activesupport/CHANGELOG +16 -0
- data/vendor/rails/activesupport/lib/active_support/core_ext/blank.rb +9 -3
- data/vendor/rails/activesupport/lib/active_support/core_ext/hash/conversions.rb +48 -3
- data/vendor/rails/activesupport/lib/active_support/core_ext/module/introspection.rb +14 -0
- data/vendor/rails/activesupport/lib/active_support/dependencies.rb +3 -3
- data/vendor/rails/activesupport/lib/active_support/json/encoders/core.rb +5 -3
- data/vendor/rails/activesupport/lib/active_support/multibyte/chars.rb +6 -6
- data/vendor/rails/activesupport/lib/active_support/version.rb +1 -1
- data/vendor/rails/activesupport/test/core_ext/hash_ext_test.rb +37 -0
- data/vendor/rails/activesupport/test/core_ext/module_test.rb +8 -0
- data/vendor/rails/activesupport/test/dependencies_test.rb +11 -0
- data/vendor/rails/activesupport/test/{json.rb → json_test.rb} +15 -5
- data/vendor/rails/railties/CHANGELOG +25 -1
- data/vendor/rails/railties/README +32 -3
- data/vendor/rails/railties/Rakefile +5 -5
- data/vendor/rails/railties/environments/boot.rb +12 -18
- data/vendor/rails/railties/environments/environment.rb +15 -15
- data/vendor/rails/railties/lib/dispatcher.rb +1 -2
- data/vendor/rails/railties/lib/initializer.rb +33 -9
- data/vendor/rails/railties/lib/rails/version.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold/scaffold_generator.rb +1 -1
- data/vendor/rails/railties/lib/rails_generator/generators/components/scaffold_resource/scaffold_resource_generator.rb +1 -0
- data/vendor/rails/railties/lib/railties_path.rb +1 -1
- data/vendor/rails/railties/lib/tasks/framework.rake +4 -4
- data/vendor/rails/railties/lib/tasks/routes.rake +17 -0
- data/vendor/rails/release.rb +2 -2
- metadata +1877 -1848
data/app/models/page_context.rb
CHANGED
@@ -14,9 +14,13 @@ class PageContext < Radius::Context
|
|
14
14
|
end
|
15
15
|
|
16
16
|
def render_tag(name, attributes = {}, &block)
|
17
|
+
binding = @tag_binding_stack.last
|
18
|
+
locals = binding ? binding.locals : globals
|
19
|
+
set_process_variables(locals.page)
|
17
20
|
super
|
18
21
|
rescue Exception => e
|
19
22
|
raise e if testing?
|
23
|
+
@tag_binding_stack.pop unless @tag_binding_stack.last == binding
|
20
24
|
render_error_message(e.message)
|
21
25
|
end
|
22
26
|
|
@@ -32,6 +36,11 @@ class PageContext < Radius::Context
|
|
32
36
|
"<div><strong>#{message}</strong></div>"
|
33
37
|
end
|
34
38
|
|
39
|
+
def set_process_variables(page)
|
40
|
+
page.request ||= @page.request
|
41
|
+
page.response ||= @page.response
|
42
|
+
end
|
43
|
+
|
35
44
|
def testing?
|
36
45
|
RAILS_ENV == 'test'
|
37
46
|
end
|
@@ -23,7 +23,9 @@ module Radiant
|
|
23
23
|
# defaults.page.parts :: a comma separated list of default page parts
|
24
24
|
# defaults.page.status :: a string representation of the default page status
|
25
25
|
# dev.host :: the hostname where draft pages are viewable
|
26
|
-
#
|
26
|
+
# local.timezone :: the timezone offset (using a String or integer
|
27
|
+
# from http://api.rubyonrails.org/classes/TimeZone.html)
|
28
|
+
# used to correct displayed times
|
27
29
|
class Config < ActiveRecord::Base
|
28
30
|
set_table_name "config"
|
29
31
|
|
@@ -48,7 +50,7 @@ module Radiant
|
|
48
50
|
|
49
51
|
def to_hash
|
50
52
|
Hash[ *find(:all).map { |pair| [pair.key, pair.value] }.flatten ]
|
51
|
-
end
|
53
|
+
end
|
52
54
|
end
|
53
55
|
|
54
56
|
def value=(param)
|
@@ -148,29 +148,35 @@ class ResponseCache
|
|
148
148
|
cache_page(metadata, response.body, path)
|
149
149
|
end
|
150
150
|
|
151
|
-
def page_cache_path(path)
|
152
|
-
|
151
|
+
def page_cache_path(path)
|
152
|
+
root_dir = File.expand_path(page_cache_directory)
|
153
|
+
cache_path = File.expand_path(File.join(root_dir,path), root_dir)
|
154
|
+
if(cache_path.index(root_dir) == 0)
|
155
|
+
cache_path
|
156
|
+
end
|
153
157
|
end
|
154
158
|
|
155
159
|
def expire_page(path)
|
156
160
|
return unless perform_caching
|
157
161
|
|
158
|
-
path = page_cache_path(path)
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
+
if path = page_cache_path(path)
|
163
|
+
benchmark "Expired page: #{path}" do
|
164
|
+
File.delete("#{path}.yml") if File.exists?("#{path}.yml")
|
165
|
+
File.delete("#{path}.data") if File.exists?("#{path}.data")
|
166
|
+
end
|
162
167
|
end
|
163
168
|
end
|
164
169
|
|
165
170
|
def cache_page(metadata, content, path)
|
166
171
|
return unless perform_caching
|
167
172
|
|
168
|
-
path = page_cache_path(path)
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
173
|
+
if path = page_cache_path(path)
|
174
|
+
benchmark "Cached page: #{path}" do
|
175
|
+
FileUtils.makedirs(File.dirname(path))
|
176
|
+
#dont want yml without data
|
177
|
+
File.open("#{path}.data", "wb+") { |f| f.write(content) }
|
178
|
+
File.open("#{path}.yml", "wb+") { |f| f.write(metadata) }
|
179
|
+
end
|
174
180
|
end
|
175
181
|
end
|
176
182
|
end
|
data/app/models/standard_tags.rb
CHANGED
@@ -1,33 +1,34 @@
|
|
1
1
|
module StandardTags
|
2
2
|
|
3
3
|
include Radiant::Taggable
|
4
|
-
|
4
|
+
include LocalTime
|
5
|
+
|
5
6
|
class TagError < StandardError; end
|
6
7
|
|
7
8
|
desc %{
|
8
9
|
Causes the tags referring to a page's attributes to refer to the current page.
|
9
|
-
|
10
|
+
|
10
11
|
*Usage:*
|
11
12
|
<pre><code><r:page>...</r:page></code></pre>
|
12
13
|
}
|
13
14
|
tag 'page' do |tag|
|
14
|
-
tag.locals.page = tag.globals.
|
15
|
+
tag.locals.page = tag.globals.page
|
15
16
|
tag.expand
|
16
17
|
end
|
17
18
|
|
18
19
|
[:breadcrumb, :slug, :title, :url].each do |method|
|
19
|
-
desc %{
|
20
|
+
desc %{
|
20
21
|
Renders the @#{method}@ attribute of the current page.
|
21
|
-
}
|
22
|
+
}
|
22
23
|
tag(method.to_s) do |tag|
|
23
24
|
tag.locals.page.send(method)
|
24
25
|
end
|
25
|
-
end
|
26
|
-
|
27
|
-
desc %{
|
26
|
+
end
|
27
|
+
|
28
|
+
desc %{
|
28
29
|
Gives access to a page's children.
|
29
30
|
|
30
|
-
*Usage:*
|
31
|
+
*Usage:*
|
31
32
|
<pre><code><r:children>...</r:children></code></pre>
|
32
33
|
}
|
33
34
|
tag 'children' do |tag|
|
@@ -42,7 +43,7 @@ module StandardTags
|
|
42
43
|
tag.locals.children.count
|
43
44
|
end
|
44
45
|
|
45
|
-
desc %{
|
46
|
+
desc %{
|
46
47
|
Returns the first child. Inside this tag all page attribute tags are mapped to
|
47
48
|
the first child. Takes the same ordering options as @<r:children:each>@.
|
48
49
|
|
@@ -74,10 +75,10 @@ module StandardTags
|
|
74
75
|
end
|
75
76
|
end
|
76
77
|
|
77
|
-
desc %{
|
78
|
+
desc %{
|
78
79
|
Cycles through each of the children. Inside this tag all page attribute tags
|
79
80
|
are mapped to the current child page.
|
80
|
-
|
81
|
+
|
81
82
|
*Usage:*
|
82
83
|
<pre><code><r:children:each [offset="number"] [limit="number"] [by="attribute"] [order="asc|desc"]
|
83
84
|
[status="draft|reviewed|published|hidden|all"]>
|
@@ -112,19 +113,19 @@ module StandardTags
|
|
112
113
|
tag.locals.page = tag.locals.child
|
113
114
|
tag.expand
|
114
115
|
end
|
115
|
-
|
116
|
-
desc %{
|
116
|
+
|
117
|
+
desc %{
|
117
118
|
Renders the tag contents only if the contents do not match the previous header. This
|
118
119
|
is extremely useful for rendering date headers for a list of child pages.
|
119
|
-
|
120
|
+
|
120
121
|
If you would like to use several header blocks you may use the @name@ attribute to
|
121
122
|
name the header. When a header is named it will not restart until another header of
|
122
123
|
the same name is different.
|
123
|
-
|
124
|
+
|
124
125
|
Using the @restart@ attribute you can cause other named headers to restart when the
|
125
126
|
present header changes. Simply specify the names of the other headers in a semicolon
|
126
127
|
separated list.
|
127
|
-
|
128
|
+
|
128
129
|
*Usage:*
|
129
130
|
<pre><code><r:children:each>
|
130
131
|
<r:header [name="header_name"] [restart="name1[;name2;...]"]>
|
@@ -148,8 +149,7 @@ module StandardTags
|
|
148
149
|
header
|
149
150
|
end
|
150
151
|
end
|
151
|
-
|
152
|
-
|
152
|
+
|
153
153
|
desc %{
|
154
154
|
Page attribute tags inside this tag refer to the parent of the current page.
|
155
155
|
|
@@ -162,7 +162,7 @@ module StandardTags
|
|
162
162
|
tag.expand if parent
|
163
163
|
end
|
164
164
|
|
165
|
-
desc %{
|
165
|
+
desc %{
|
166
166
|
Renders the contained elements only if the current contextual page has a parent, i.e.
|
167
167
|
is not the root page.
|
168
168
|
|
@@ -174,10 +174,10 @@ module StandardTags
|
|
174
174
|
tag.expand if parent
|
175
175
|
end
|
176
176
|
|
177
|
-
desc %{
|
177
|
+
desc %{
|
178
178
|
Renders the contained elements only if the current contextual page has no parent, i.e.
|
179
179
|
is the root page.
|
180
|
-
|
180
|
+
|
181
181
|
*Usage:*
|
182
182
|
<pre><code><r:unless_parent>...</r:unless_parent></code></pre>
|
183
183
|
}
|
@@ -186,11 +186,39 @@ module StandardTags
|
|
186
186
|
tag.expand unless parent
|
187
187
|
end
|
188
188
|
|
189
|
-
desc %{
|
189
|
+
desc %{
|
190
|
+
Renders the contained elements only if the current contextual page has one or
|
191
|
+
more child pages. The @status@ attribute limits the status of found child pages
|
192
|
+
to the given status, the default is @"published"@. @status="all"@ includes all
|
193
|
+
non-virtual pages regardless of status.
|
194
|
+
|
195
|
+
*Usage:*
|
196
|
+
<pre><code><r:if_children [status="published"]>...</r:if_children></code></pre>
|
197
|
+
}
|
198
|
+
tag "if_children" do |tag|
|
199
|
+
children = tag.locals.page.children.count(:conditions => children_find_options(tag)[:conditions])
|
200
|
+
tag.expand if children > 0
|
201
|
+
end
|
202
|
+
|
203
|
+
desc %{
|
204
|
+
Renders the contained elements only if the current contextual page has no children.
|
205
|
+
The @status@ attribute limits the status of found child pages to the given status,
|
206
|
+
the default is @"published"@. @status="all"@ includes all non-virtual pages
|
207
|
+
regardless of status.
|
208
|
+
|
209
|
+
*Usage:*
|
210
|
+
<pre><code><r:unless_children [status="published"]>...</r:unless_children></code></pre>
|
211
|
+
}
|
212
|
+
tag "unless_children" do |tag|
|
213
|
+
children = tag.locals.page.children.count(:conditions => children_find_options(tag)[:conditions])
|
214
|
+
tag.expand unless children > 0
|
215
|
+
end
|
216
|
+
|
217
|
+
desc %{
|
190
218
|
Renders one of the passed values based on a global cycle counter. Use the @reset@
|
191
219
|
attribute to reset the cycle to the beginning. Use the @name@ attribute to track
|
192
220
|
multiple cycles; the default is @cycle@.
|
193
|
-
|
221
|
+
|
194
222
|
*Usage:*
|
195
223
|
<pre><code><r:cycle values="first, second, third" [reset="true|false"] [name="cycle"] /></code></pre>
|
196
224
|
}
|
@@ -213,7 +241,7 @@ module StandardTags
|
|
213
241
|
@false@. Use the @contextual@ attribute to force a part inherited from a parent
|
214
242
|
part to be evaluated in the context of the child page. By default 'contextual'
|
215
243
|
is set to true.
|
216
|
-
|
244
|
+
|
217
245
|
*Usage:*
|
218
246
|
<pre><code><r:content [part="part_name"] [inherit="true|false"] [contextual="true|false"] /></code></pre>
|
219
247
|
}
|
@@ -243,7 +271,7 @@ module StandardTags
|
|
243
271
|
|
244
272
|
desc %{
|
245
273
|
Renders the containing elements only if the part exists on a page. By default the
|
246
|
-
@part@ attribute is set @body@.
|
274
|
+
@part@ attribute is set to @body@.
|
247
275
|
|
248
276
|
*Usage:*
|
249
277
|
<pre><code><r:if_content [part="part_name"]>...</r:if_content></code></pre>
|
@@ -258,7 +286,7 @@ module StandardTags
|
|
258
286
|
|
259
287
|
desc %{
|
260
288
|
The opposite of the @if_content@ tag.
|
261
|
-
|
289
|
+
|
262
290
|
*Usage:*
|
263
291
|
<pre><code><r:unless_content [part="part_name"]>...</r:unless_content></code></pre>
|
264
292
|
}
|
@@ -274,7 +302,7 @@ module StandardTags
|
|
274
302
|
Renders the containing elements only if the page's url matches the regular expression
|
275
303
|
given in the @matches@ attribute. If the @ignore_case@ attribute is set to false, the
|
276
304
|
match is case sensitive. By default, @ignore_case@ is set to true.
|
277
|
-
|
305
|
+
|
278
306
|
*Usage:*
|
279
307
|
<pre><code><r:if_url matches="regexp" [ignore_case="true|false"]>...</if_url></code></pre>
|
280
308
|
}
|
@@ -288,7 +316,7 @@ module StandardTags
|
|
288
316
|
|
289
317
|
desc %{
|
290
318
|
The opposite of the @if_url@ tag.
|
291
|
-
|
319
|
+
|
292
320
|
*Usage:*
|
293
321
|
<pre><code><r:unless_url matches="regexp" [ignore_case="true|false"]>...</unless_url></code></pre>
|
294
322
|
}
|
@@ -299,8 +327,8 @@ module StandardTags
|
|
299
327
|
tag.expand
|
300
328
|
end
|
301
329
|
end
|
302
|
-
|
303
|
-
desc %{
|
330
|
+
|
331
|
+
desc %{
|
304
332
|
Renders the name of the author of the current page.
|
305
333
|
}
|
306
334
|
tag 'author' do |tag|
|
@@ -310,14 +338,14 @@ module StandardTags
|
|
310
338
|
end
|
311
339
|
end
|
312
340
|
|
313
|
-
desc %{
|
341
|
+
desc %{
|
314
342
|
Renders the date based on the current page (by default when it was published or created).
|
315
343
|
The format attribute uses the same formating codes used by the Ruby @strftime@ function. By
|
316
344
|
default it's set to @%A, %B %d, %Y@. The @for@ attribute selects which date to render. Valid
|
317
345
|
options are @published_at@, @created_at@, @updated_at@, and @now@. @now@ will render the
|
318
346
|
current date/time, regardless of the page.
|
319
|
-
|
320
|
-
*Usage:*
|
347
|
+
|
348
|
+
*Usage:*
|
321
349
|
<pre><code><r:date [format="%A, %B %d, %Y"] [for="published_at"]/></code></pre>
|
322
350
|
}
|
323
351
|
tag 'date' do |tag|
|
@@ -336,7 +364,7 @@ module StandardTags
|
|
336
364
|
else
|
337
365
|
page.published_at || page.created_at
|
338
366
|
end
|
339
|
-
date.strftime(format)
|
367
|
+
adjust_time(date).strftime(format)
|
340
368
|
end
|
341
369
|
|
342
370
|
desc %{
|
@@ -347,7 +375,7 @@ module StandardTags
|
|
347
375
|
or @id@ attribute. If the @anchor@ attribute is passed to the tag it will
|
348
376
|
append a pound sign (<code>#</code>) followed by the value of the attribute to
|
349
377
|
the @href@ attribute of the HTML @a@ tag--effectively making an HTML anchor.
|
350
|
-
|
378
|
+
|
351
379
|
*Usage:*
|
352
380
|
<pre><code><r:link [anchor="name"] [other attributes...] /></code></pre>
|
353
381
|
or
|
@@ -361,7 +389,7 @@ module StandardTags
|
|
361
389
|
text = tag.double? ? tag.expand : tag.render('title')
|
362
390
|
%{<a href="#{tag.render('url')}#{anchor}"#{attributes}>#{text}</a>}
|
363
391
|
end
|
364
|
-
|
392
|
+
|
365
393
|
desc %{
|
366
394
|
Renders a trail of breadcrumbs to the current page. The separator attribute
|
367
395
|
specifies the HTML fragment that is inserted between each of the breadcrumbs. By
|
@@ -379,8 +407,8 @@ module StandardTags
|
|
379
407
|
separator = tag.attr['separator'] || ' > '
|
380
408
|
breadcrumbs.join(separator)
|
381
409
|
end
|
382
|
-
|
383
|
-
desc %{
|
410
|
+
|
411
|
+
desc %{
|
384
412
|
Renders the snippet specified in the @name@ attribute within the context of a page.
|
385
413
|
|
386
414
|
*Usage:*
|
@@ -389,9 +417,7 @@ module StandardTags
|
|
389
417
|
tag 'snippet' do |tag|
|
390
418
|
if name = tag.attr['name']
|
391
419
|
if snippet = Snippet.find_by_name(name.strip)
|
392
|
-
|
393
|
-
global_page = tag.globals.actual_page || tag.globals.page
|
394
|
-
page.render_snippet(snippet, global_page)
|
420
|
+
tag.globals.page.render_snippet(snippet)
|
395
421
|
else
|
396
422
|
raise TagError.new('snippet not found')
|
397
423
|
end
|
@@ -412,23 +438,23 @@ module StandardTags
|
|
412
438
|
unless FileNotFoundPage === found
|
413
439
|
tag.locals.page = found
|
414
440
|
tag.expand
|
415
|
-
|
441
|
+
end
|
416
442
|
end
|
417
443
|
else
|
418
444
|
raise TagError.new("`find' tag must contain `url' attribute")
|
419
445
|
end
|
420
446
|
end
|
421
447
|
|
422
|
-
desc %{
|
448
|
+
desc %{
|
423
449
|
Randomly renders one of the options specified by the @option@ tags.
|
424
|
-
|
450
|
+
|
425
451
|
*Usage:*
|
426
452
|
<pre><code><r:random>
|
427
453
|
<r:option>...</r:option>
|
428
454
|
<r:option>...</r:option>
|
429
455
|
...
|
430
456
|
<r:random>
|
431
|
-
</code></pre>
|
457
|
+
</code></pre>
|
432
458
|
}
|
433
459
|
tag 'random' do |tag|
|
434
460
|
tag.locals.random = []
|
@@ -536,11 +562,47 @@ module StandardTags
|
|
536
562
|
end
|
537
563
|
end
|
538
564
|
|
565
|
+
desc %{
|
566
|
+
Renders the containing elements only if Radiant in is development mode.
|
567
|
+
|
568
|
+
*Usage:*
|
569
|
+
<pre><code><r:if_dev>...</r:if_dev></code></pre>
|
570
|
+
}
|
571
|
+
tag 'if_dev' do |tag|
|
572
|
+
config = Radiant::Config
|
573
|
+
request = tag.globals.page.request
|
574
|
+
unless request.nil?
|
575
|
+
if dev_host = config['dev.host']
|
576
|
+
tag.expand if request.host == dev_host
|
577
|
+
else
|
578
|
+
tag.expand if request.host =~ /^dev\./
|
579
|
+
end
|
580
|
+
end
|
581
|
+
end
|
582
|
+
|
583
|
+
desc %{
|
584
|
+
The opposite of the @if_dev@ tag.
|
585
|
+
|
586
|
+
*Usage:*
|
587
|
+
<pre><code><r:unless_dev>...</r:unless_dev></code></pre>
|
588
|
+
}
|
589
|
+
tag 'unless_dev' do |tag|
|
590
|
+
config = Radiant::Config
|
591
|
+
request = tag.globals.page.request
|
592
|
+
unless request.nil?
|
593
|
+
if dev_host = config['dev.host']
|
594
|
+
tag.expand unless request.host == dev_host
|
595
|
+
else
|
596
|
+
tag.expand unless request.host =~ /^dev\./
|
597
|
+
end
|
598
|
+
end
|
599
|
+
end
|
600
|
+
|
539
601
|
private
|
540
602
|
|
541
603
|
def children_find_options(tag)
|
542
604
|
attr = tag.attr.symbolize_keys
|
543
|
-
|
605
|
+
|
544
606
|
options = {}
|
545
607
|
|
546
608
|
[:limit, :offset].each do |symbol|
|
@@ -597,7 +659,6 @@ module StandardTags
|
|
597
659
|
rescue RegexpError => e
|
598
660
|
raise TagError.new("Malformed regular expression in `#{attribute_name}' argument of `#{tag.name}' tag: #{e.message}")
|
599
661
|
end
|
600
|
-
|
601
|
-
end
|
602
|
-
|
662
|
+
regexp
|
663
|
+
end
|
603
664
|
end
|