simple_decorator 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +1 -0
- data/README.md +45 -3
- data/lib/simple_decorator/filter/decorator.rb +1 -1
- data/lib/simple_decorator/version.rb +1 -1
- metadata +21 -17
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: a3705f4b7e47edbdec2c08854a97cf70be990bd8
|
4
|
+
data.tar.gz: f96a61aadcabb28d92f409260720391e658b26ed
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d6f3393c96a1cc8a3b4a36722cf042094167e2e490c9cc7a84deec2376a8c1eeec2bddb0b5865cdf476e7b5d61ca3bc3e5229c126a659883e412b6396bf10886
|
7
|
+
data.tar.gz: 2ca10a8d8f0a83676982584de6ddd566be36e084f4b8563fc4b71eadad4170c88ee244fea5b9dd05b9aebf98994b08f36722fe4013acbaeb9fbd7e03f532b047
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -8,12 +8,54 @@ This gem lets you specify a url to a place to fetch the layout for your applicat
|
|
8
8
|
|
9
9
|
In your Gemfile
|
10
10
|
|
11
|
-
gem 'simple_decorator'
|
11
|
+
gem 'simple_decorator'
|
12
|
+
|
13
|
+
|
14
|
+
Create a decorator lets say at 'http://www.mysite.com/decorator' containing your site's layout:
|
15
|
+
|
16
|
+
<html>
|
17
|
+
<head>
|
18
|
+
<title>$title - SiteName</title>
|
19
|
+
$head
|
20
|
+
</head>
|
21
|
+
<body>
|
22
|
+
<div class="somestyling">
|
23
|
+
$body
|
24
|
+
</div>
|
25
|
+
</body>
|
26
|
+
</html>
|
27
|
+
|
28
|
+
In your layout file (typically application.html.erb)
|
29
|
+
|
30
|
+
<html>
|
31
|
+
<head>
|
32
|
+
<title>My apps page</title>
|
33
|
+
<link rel="stylesheet" href="my_app_styles.css" type="text/css" media="screen" />
|
34
|
+
</head>
|
35
|
+
<body>
|
36
|
+
<h1>My apps dynamic response</h1>
|
37
|
+
</body>
|
38
|
+
</html>
|
12
39
|
|
13
40
|
In any controller
|
14
41
|
|
15
42
|
# usually you put this in your ApplicationController
|
16
43
|
# but feel free to override in any other controller
|
17
44
|
def decorator_url
|
18
|
-
"
|
19
|
-
end
|
45
|
+
"http://www.mysite.com/decorator"
|
46
|
+
end
|
47
|
+
|
48
|
+
|
49
|
+
The response will now have the layout of your decorator, but display dynamic contents from your app, including your stylesheets and javacripts
|
50
|
+
|
51
|
+
<html>
|
52
|
+
<head>
|
53
|
+
<title>My apps page - SiteName</title>
|
54
|
+
<link rel="stylesheet" href="my_app_styles.css" type="text/css" media="screen" />
|
55
|
+
</head>
|
56
|
+
<body>
|
57
|
+
<div class="somestyling">
|
58
|
+
<h1>My apps dynamic response</h1>
|
59
|
+
</div>
|
60
|
+
</body>
|
61
|
+
</html>
|
@@ -6,11 +6,11 @@ module SimpleDecorator
|
|
6
6
|
class Decorator < Rack::Plastic
|
7
7
|
def change_html_string(html)
|
8
8
|
return html unless request.env["simple_decorator.layout.url"]
|
9
|
+
return html if request.xhr?
|
9
10
|
|
10
11
|
layout = request.env["simple_decorator.layout.url"]
|
11
12
|
|
12
13
|
decorator = open(layout, :proxy => nil).read
|
13
|
-
|
14
14
|
weaver = ResponseWeaver.new(decorator)
|
15
15
|
weaver.apply(html)
|
16
16
|
end
|
metadata
CHANGED
@@ -1,38 +1,43 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: simple_decorator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
5
|
-
prerelease:
|
4
|
+
version: 0.0.2
|
6
5
|
platform: ruby
|
7
6
|
authors:
|
8
7
|
- Eirik Lied
|
9
8
|
autorequire:
|
10
9
|
bindir: bin
|
11
10
|
cert_chain: []
|
12
|
-
date:
|
11
|
+
date: 2013-12-17 00:00:00.000000000 Z
|
13
12
|
dependencies:
|
14
13
|
- !ruby/object:Gem::Dependency
|
15
14
|
name: rspec
|
16
|
-
requirement:
|
17
|
-
none: false
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
18
16
|
requirements:
|
19
|
-
- -
|
17
|
+
- - '>='
|
20
18
|
- !ruby/object:Gem::Version
|
21
19
|
version: '0'
|
22
20
|
type: :development
|
23
21
|
prerelease: false
|
24
|
-
version_requirements:
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
25
27
|
- !ruby/object:Gem::Dependency
|
26
28
|
name: rack-plastic
|
27
|
-
requirement:
|
28
|
-
none: false
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
29
30
|
requirements:
|
30
|
-
- -
|
31
|
+
- - '>='
|
31
32
|
- !ruby/object:Gem::Version
|
32
33
|
version: '0'
|
33
34
|
type: :runtime
|
34
35
|
prerelease: false
|
35
|
-
version_requirements:
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - '>='
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
36
41
|
description: A simple gem to give sitemesh-like functionality in a rack app using
|
37
42
|
decorators.
|
38
43
|
email:
|
@@ -57,27 +62,26 @@ files:
|
|
57
62
|
- spec/spec_helper.rb
|
58
63
|
homepage: https://github.com/Posten-Konsernportal/simple_decorator
|
59
64
|
licenses: []
|
65
|
+
metadata: {}
|
60
66
|
post_install_message:
|
61
67
|
rdoc_options: []
|
62
68
|
require_paths:
|
63
69
|
- lib
|
64
70
|
required_ruby_version: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
71
|
requirements:
|
67
|
-
- -
|
72
|
+
- - '>='
|
68
73
|
- !ruby/object:Gem::Version
|
69
74
|
version: '0'
|
70
75
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
71
|
-
none: false
|
72
76
|
requirements:
|
73
|
-
- -
|
77
|
+
- - '>='
|
74
78
|
- !ruby/object:Gem::Version
|
75
79
|
version: '0'
|
76
80
|
requirements: []
|
77
81
|
rubyforge_project: simple_decorator
|
78
|
-
rubygems_version:
|
82
|
+
rubygems_version: 2.0.3
|
79
83
|
signing_key:
|
80
|
-
specification_version:
|
84
|
+
specification_version: 4
|
81
85
|
summary: A ruby sitemesh-like implementation
|
82
86
|
test_files:
|
83
87
|
- spec/matchers/have_same_markup.rb
|