rack-app-front_end 0.5.0 → 0.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/lib/rack/app/front_end/folder_mounter.rb +1 -1
- data/lib/rack/app/front_end/instance_methods.rb +15 -0
- data/lib/rack/app/front_end/singleton_methods.rb +14 -0
- data/lib/rack/app/front_end/template.rb +1 -1
- data/lib/rack/app/front_end.rb +9 -11
- data/rack-app-front_end.gemspec +1 -2
- metadata +6 -19
- data/lib/rack/app/front_end/endpoint_methods.rb +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8a98853e4d1d6ba49e9ed62fac3721dc0dc69303
|
4
|
+
data.tar.gz: 89f90e9bbdee9d46c78a37361162ce7c2ed1efeb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5350fee85341ee409fb3eb249714b297b4121b01dea778ea837045730f769c2666421b5c7d9d8ac2c4791a639ebf9362231eb613c8d123e064163f7e1b03572c
|
7
|
+
data.tar.gz: a860de2ad2cbfa5ac3a4950deb2969f6f9ca16a4b80eba4d212edb44746254942f930c0ee07f6851dde4433cadabdf928745d1fedc47881fd5d8c4a9838a73cb
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.6.0
|
@@ -32,7 +32,7 @@ class Rack::App::FrontEnd::FolderMounter
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def request_path_by(source_folder_path, template_path)
|
35
|
-
Rack::Utils.clean_path_info(template_path.sub(source_folder_path, '').
|
35
|
+
Rack::Utils.clean_path_info(template_path.sub(source_folder_path, '').sub(/\..*$/, ''))
|
36
36
|
end
|
37
37
|
|
38
38
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Rack::App::FrontEnd::InstanceMethods
|
2
|
+
|
3
|
+
def render(template_path)
|
4
|
+
|
5
|
+
options = {}
|
6
|
+
options[:layout]= self.class.layout if self.class.respond_to?(:layout)
|
7
|
+
extended_template_path = Rack::App::Utils.expand_path(template_path)
|
8
|
+
full_path = File.exist?(extended_template_path) ? extended_template_path : template_path
|
9
|
+
template = Rack::App::FrontEnd::Template.new(full_path, options)
|
10
|
+
|
11
|
+
return template.render(self)
|
12
|
+
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
module Rack::App::FrontEnd::SingletonMethods
|
2
|
+
|
3
|
+
def mount_folder(folder_path)
|
4
|
+
Rack::App::FrontEnd::FolderMounter.new(self).mount(Rack::App::Utils.expand_path(folder_path))
|
5
|
+
end
|
6
|
+
|
7
|
+
alias mount_templates_from mount_folder
|
8
|
+
|
9
|
+
def layout(layout_path=nil)
|
10
|
+
@layout = Rack::App::Utils.expand_path(layout_path) unless layout_path.nil?
|
11
|
+
@layout
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -17,7 +17,7 @@ class Rack::App::FrontEnd::Template
|
|
17
17
|
def render_result(*args, &block)
|
18
18
|
return Rack::App::File::Streamer.new(@file_path) unless it_is_a_template?
|
19
19
|
|
20
|
-
layout.render{ Tilt.new(@file_path).render(*args
|
20
|
+
layout.render { Tilt.new(@file_path).render(*args, &block) }
|
21
21
|
end
|
22
22
|
|
23
23
|
def it_is_a_template?
|
data/lib/rack/app/front_end.rb
CHANGED
@@ -9,21 +9,19 @@ module Rack::App::FrontEnd
|
|
9
9
|
require 'rack/app/front_end/template'
|
10
10
|
require 'rack/app/front_end/view'
|
11
11
|
require 'rack/app/front_end/folder_mounter'
|
12
|
-
require 'rack/app/front_end/endpoint_methods'
|
13
12
|
|
14
|
-
|
15
|
-
|
16
|
-
end
|
13
|
+
require 'rack/app/front_end/instance_methods'
|
14
|
+
require 'rack/app/front_end/singleton_methods'
|
17
15
|
|
18
|
-
|
19
|
-
Rack::App::FrontEnd::FolderMounter.new(self).mount(Rack::App::FrontEnd::Utils.get_full_path(folder_path))
|
20
|
-
end
|
16
|
+
class << self
|
21
17
|
|
22
|
-
|
18
|
+
[:extended, :included].each do |method|
|
19
|
+
define_method(method) do |klass|
|
20
|
+
klass.__send__(:include, self::InstanceMethods)
|
21
|
+
klass.__send__(:extend, self::SingletonMethods)
|
22
|
+
end
|
23
|
+
end
|
23
24
|
|
24
|
-
def layout(layout_path=nil)
|
25
|
-
@layout = Rack::App::FrontEnd::Utils.get_full_path(layout_path) unless layout_path.nil?
|
26
|
-
@layout
|
27
25
|
end
|
28
26
|
|
29
27
|
end
|
data/rack-app-front_end.gemspec
CHANGED
@@ -22,8 +22,7 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_development_dependency "rake"
|
23
23
|
spec.add_development_dependency "rspec"
|
24
24
|
|
25
|
-
spec.add_dependency 'rack-app','>= 0.
|
26
|
-
spec.add_dependency 'kramdown'
|
25
|
+
spec.add_dependency 'rack-app','>= 0.24.0'
|
27
26
|
spec.add_dependency 'tilt'
|
28
27
|
|
29
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-app-front_end
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Luzsi
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-25 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -58,28 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.24.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
69
|
-
- !ruby/object:Gem::Dependency
|
70
|
-
name: kramdown
|
71
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
-
requirements:
|
73
|
-
- - ">="
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: '0'
|
76
|
-
type: :runtime
|
77
|
-
prerelease: false
|
78
|
-
version_requirements: !ruby/object:Gem::Requirement
|
79
|
-
requirements:
|
80
|
-
- - ">="
|
81
|
-
- !ruby/object:Gem::Version
|
82
|
-
version: '0'
|
68
|
+
version: 0.24.0
|
83
69
|
- !ruby/object:Gem::Dependency
|
84
70
|
name: tilt
|
85
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -112,8 +98,9 @@ files:
|
|
112
98
|
- bin/console
|
113
99
|
- bin/setup
|
114
100
|
- lib/rack/app/front_end.rb
|
115
|
-
- lib/rack/app/front_end/endpoint_methods.rb
|
116
101
|
- lib/rack/app/front_end/folder_mounter.rb
|
102
|
+
- lib/rack/app/front_end/instance_methods.rb
|
103
|
+
- lib/rack/app/front_end/singleton_methods.rb
|
117
104
|
- lib/rack/app/front_end/template.rb
|
118
105
|
- lib/rack/app/front_end/template/default_layout.rb
|
119
106
|
- lib/rack/app/front_end/utils.rb
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Rack::App::FrontEnd::EndpointMethods
|
2
|
-
|
3
|
-
def render(template_path)
|
4
|
-
|
5
|
-
template_full_path = if template_path.to_s[0] == '/'
|
6
|
-
project_file_path = Rack::App::Utils.pwd(template_path)
|
7
|
-
File.exist?(project_file_path) ? project_file_path : template_path
|
8
|
-
|
9
|
-
else
|
10
|
-
|
11
|
-
app_dirname = File.join(
|
12
|
-
File.dirname([caller[0]].flatten.first.split(/\.(?:rb|ru):\d/)[0]),
|
13
|
-
Rack::App::FrontEnd::Utils.underscore(self.class)
|
14
|
-
)
|
15
|
-
|
16
|
-
File.join(app_dirname, template_path)
|
17
|
-
|
18
|
-
end
|
19
|
-
|
20
|
-
options = {}
|
21
|
-
options[:layout]= self.class.layout if self.class.respond_to?(:layout)
|
22
|
-
template = Rack::App::FrontEnd::Template.new(template_full_path, options)
|
23
|
-
|
24
|
-
return template.render(self)
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|