radiant-layouts-extension 0.9.1 → 1.0.0
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.
- data/MIT-LICENSE +75 -4
- data/README.md +48 -1
- data/Rakefile +56 -15
- data/VERSION +1 -1
- data/app/models/haml_filter.rb +5 -0
- data/app/views/layouts/radiant.html.haml +1 -1
- data/config/routes.rb +5 -0
- data/layouts_extension.rb +13 -5
- data/lib/haml_layouts/models/layout.rb +34 -0
- data/lib/haml_layouts/models/page.rb +31 -0
- data/lib/nested_layouts/tags/core.rb +141 -0
- data/lib/share_layouts/controllers/action_controller.rb +25 -0
- data/lib/share_layouts/helpers/action_view.rb +50 -0
- data/lib/tasks/layouts_extension_tasks.rake +27 -6
- data/radiant-layouts-extension.gemspec +37 -26
- data/spec/controllers/{share_layouts_spec.rb → share_controller_spec.rb} +0 -0
- data/spec/datasets/layouts_layouts.rb +36 -0
- data/spec/datasets/layouts_pages.rb +43 -0
- data/spec/lib/haml_layouts/haml_layouts_extension_spec.rb +22 -0
- data/spec/lib/haml_layouts/models/layout_spec.rb +36 -0
- data/spec/lib/haml_layouts/models/page_spec.rb +40 -0
- data/spec/lib/nested_layouts/nested_layouts_extension_spec.rb +16 -0
- data/spec/lib/nested_layouts/{tags_spec.rb → tags/core_spec.rb} +41 -17
- data/spec/{controllers/nested_layouts_spec.rb → lib/share_layouts/controllers/action_controller_spec.rb} +0 -1
- data/spec/{helpers/share_layouts_helper_spec.rb → lib/share_layouts/helpers/action_view_spec.rb} +32 -29
- data/spec/lib/share_layouts/share_layouts_extension_spec.rb +22 -0
- data/spec/models/haml_filter_spec.rb +0 -0
- data/spec/models/rails_page_spec.rb +9 -9
- data/spec/spec.opts +2 -3
- metadata +43 -28
- data/lib/nested_layouts.rb +0 -2
- data/lib/nested_layouts/tags.rb +0 -127
- data/lib/share_layouts.rb +0 -2
- data/lib/share_layouts/helper.rb +0 -39
- data/lib/share_layouts/radiant_layouts.rb +0 -21
- data/spec/datasets/nested_layouts_dataset.rb +0 -38
- data/spec/datasets/share_layouts_dataset.rb +0 -38
- data/spec/lib/share_layouts_extension_spec.rb +0 -25
- data/spec/rcov.opts +0 -2
data/lib/share_layouts.rb
DELETED
data/lib/share_layouts/helper.rb
DELETED
@@ -1,39 +0,0 @@
|
|
1
|
-
module ShareLayouts::Helper
|
2
|
-
|
3
|
-
def radiant_layout(name = @radiant_layout)
|
4
|
-
page = find_page
|
5
|
-
assign_attributes!(page, name)
|
6
|
-
page.build_parts_from_hash!(extract_captures)
|
7
|
-
page.render
|
8
|
-
end
|
9
|
-
|
10
|
-
def assign_attributes!(page, name = @radiant_layout)
|
11
|
-
page.layout = Layout.find_by_name(name) || page.layout
|
12
|
-
page.title = @title || @content_for_title || page.title || ''
|
13
|
-
page.breadcrumb = @breadcrumb || @content_for_breadcrumb || page.breadcrumb || page.title
|
14
|
-
page.breadcrumbs = @breadcrumbs || @content_for_breadcrumbs || nil
|
15
|
-
page.url = request.path
|
16
|
-
page.slug = page.url.split("/").last
|
17
|
-
page.published_at ||= Time.now
|
18
|
-
page.request = request
|
19
|
-
page.response = response
|
20
|
-
end
|
21
|
-
|
22
|
-
def extract_captures
|
23
|
-
variables = instance_variables.grep(/@content_for_/)
|
24
|
-
variables.inject({}) do |h, var|
|
25
|
-
var =~ /^@content_for_(.*)$/
|
26
|
-
key = $1.intern
|
27
|
-
key = :body if key == :layout
|
28
|
-
unless key == :title || key == :breadcrumbs
|
29
|
-
h[key] = instance_variable_get(var)
|
30
|
-
end
|
31
|
-
h
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def find_page
|
36
|
-
page = Page.find_by_url(request.path) rescue nil
|
37
|
-
page.is_a?(RailsPage) ? page : RailsPage.new(:class_name => "RailsPage")
|
38
|
-
end
|
39
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
module ShareLayouts::RadiantLayouts
|
2
|
-
|
3
|
-
def self.included(base)
|
4
|
-
base.extend ClassMethods
|
5
|
-
end
|
6
|
-
|
7
|
-
module ClassMethods
|
8
|
-
def radiant_layout(name=nil, options={}, &block)
|
9
|
-
raise ArgumentError, "A layout name or block is required!" unless name || block
|
10
|
-
write_inheritable_attribute 'radiant_layout', name || block
|
11
|
-
before_filter :set_radiant_layout
|
12
|
-
layout 'radiant', options
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
def set_radiant_layout
|
17
|
-
@radiant_layout = self.class.read_inheritable_attribute 'radiant_layout'
|
18
|
-
@radiant_layout = @radiant_layout.call(self) if @radiant_layout.is_a? Proc
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
class NestedLayoutsDataset < Dataset::Base
|
2
|
-
def load
|
3
|
-
create_record :layout, :parent,
|
4
|
-
:name => 'parent',
|
5
|
-
:content => <<-CONTENT
|
6
|
-
<html>
|
7
|
-
<body class="<r:layout />">
|
8
|
-
<r:content_for_layout />
|
9
|
-
</body>
|
10
|
-
</html>
|
11
|
-
CONTENT
|
12
|
-
|
13
|
-
create_record :layout, :child,
|
14
|
-
:name => 'child',
|
15
|
-
:content => <<-CONTENT
|
16
|
-
<r:inside_layout name='parent'>
|
17
|
-
<h1>child</h1>
|
18
|
-
</r:inside_layout>
|
19
|
-
CONTENT
|
20
|
-
|
21
|
-
create_record :page, :parent_layout,
|
22
|
-
:title => 'child layout',
|
23
|
-
:layout_id => layouts(:parent).id,
|
24
|
-
:breadcrumb => 'Homepage',
|
25
|
-
:slug => '/',
|
26
|
-
:status_id => 100,
|
27
|
-
:published_at => '2008-01-01 08:00:00'
|
28
|
-
|
29
|
-
create_record :page, :child_layout,
|
30
|
-
:title => 'child layout',
|
31
|
-
:layout_id => layouts(:child).id,
|
32
|
-
:breadcrumb => 'Homepage',
|
33
|
-
:slug => '/',
|
34
|
-
:status_id => 100,
|
35
|
-
:published_at => '2008-01-01 08:00:00'
|
36
|
-
|
37
|
-
end
|
38
|
-
end
|
@@ -1,38 +0,0 @@
|
|
1
|
-
class ShareLayoutsDataset < Dataset::Base
|
2
|
-
def load
|
3
|
-
create_record :page, :homepage, :id => 1,
|
4
|
-
:title => 'Homepage',
|
5
|
-
:breadcrumb => 'Homepage',
|
6
|
-
:slug => '/',
|
7
|
-
:status_id => 100,
|
8
|
-
:published_at => '2008-01-01 08:00:00'
|
9
|
-
|
10
|
-
create_record :page, :rails_page,
|
11
|
-
:id => 2,
|
12
|
-
:title => 'App page',
|
13
|
-
:breadcrumb => 'App page',
|
14
|
-
:slug => 'app',
|
15
|
-
:class_name => 'RailsPage',
|
16
|
-
:status_id => 100,
|
17
|
-
:parent_id => 1,
|
18
|
-
:published_at => '2008-01-01 08:00:00'
|
19
|
-
|
20
|
-
create_record :page, :rails_page_child,
|
21
|
-
:id => 3,
|
22
|
-
:title => 'Child',
|
23
|
-
:breadcrumb => 'Child',
|
24
|
-
:slug => 'child-page',
|
25
|
-
:status_id => 100,
|
26
|
-
:parent_id => 2,
|
27
|
-
:published_at => '2008-01-01 08:00:00'
|
28
|
-
|
29
|
-
create_record :page, :other,
|
30
|
-
:id => 4,
|
31
|
-
:title => 'Other',
|
32
|
-
:breadcrumb => 'Other',
|
33
|
-
:slug => 'other',
|
34
|
-
:status_id => 100,
|
35
|
-
:parent_id => 1,
|
36
|
-
:published_at => '2008-01-01 08:00:00'
|
37
|
-
end
|
38
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require 'spec/spec_helper'
|
2
|
-
|
3
|
-
describe LayoutsExtension do
|
4
|
-
|
5
|
-
context 'activate' do
|
6
|
-
|
7
|
-
it 'should have a RailsPage class to call' do
|
8
|
-
RailsPage.should_not be_nil
|
9
|
-
end
|
10
|
-
|
11
|
-
it 'should extend ActionController base methods' do
|
12
|
-
ActionController::Base.included_modules.include?(ShareLayouts::RadiantLayouts).should be_true
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'should extend ActionView helper methods' do
|
16
|
-
ActionView::Base.included_modules.include?(ShareLayouts::Helper).should be_true
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'should extend Page base methods' do
|
20
|
-
Page.included_modules.include?(NestedLayouts::Tags).should be_true
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
end
|
data/spec/rcov.opts
DELETED