troy 0.0.31 → 0.0.32
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.
- checksums.yaml +4 -4
- data/lib/troy/hacks.rb +1 -1
- data/lib/troy/helpers.rb +2 -1
- data/lib/troy/page.rb +5 -5
- data/lib/troy/server.rb +1 -1
- data/lib/troy/version.rb +1 -1
- data/lib/troy/xml.rb +2 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d79e121d0ea3b8f629e245813025288ad097666298e64f89dc004a496a63f3a3
|
4
|
+
data.tar.gz: c13b8993f2f329daf51ef2bbde77d31592bc6e983b3ad930cb168f4df830ac6f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7441493b148f2c1ed0f7804700e77b5702fef273d3d5177d67eb1a9475b006a3356bdfe27e411144e041622d49442e024f8a2d189a22e0129678add4fa7019f0
|
7
|
+
data.tar.gz: 2133cf27d04e92f9913e7d25625b11a233d7a93f5147f65f34dd83b2186f74cff4c71673ae96e35e6d66a478fcf3ae7034d237cc40c1f0424503b93f5c55ea40
|
data/lib/troy/hacks.rb
CHANGED
@@ -5,7 +5,7 @@ module HtmlPress
|
|
5
5
|
|
6
6
|
def self.js_compressor (text, options = nil)
|
7
7
|
options ||= {}
|
8
|
-
options[:output] ||= {:
|
8
|
+
options[:output] ||= {inline_script: true}
|
9
9
|
|
10
10
|
hash = Digest::SHA1.hexdigest(text)
|
11
11
|
CONTENT_CACHE[hash] ||= MultiJs.compile(text, options).gsub(/;$/,'')
|
data/lib/troy/helpers.rb
CHANGED
@@ -10,7 +10,8 @@ module Troy
|
|
10
10
|
|
11
11
|
def partial(name, locals = {})
|
12
12
|
path = site.root.join("partials/_#{name}.erb")
|
13
|
-
|
13
|
+
locals = locals.merge(site: site, page: page)
|
14
|
+
EmbeddedRuby.new(path.read, locals).render
|
14
15
|
rescue Exception, StandardError => error
|
15
16
|
raise "Unable to render #{path}; #{error.message}"
|
16
17
|
end
|
data/lib/troy/page.rb
CHANGED
@@ -21,10 +21,10 @@ module Troy
|
|
21
21
|
# Initialize a new page, which can be simply rendered or
|
22
22
|
# persisted to the filesystem.
|
23
23
|
#
|
24
|
-
def initialize(site, path)
|
24
|
+
def initialize(site, path, meta = nil)
|
25
25
|
@site = site
|
26
26
|
@path = path
|
27
|
-
@meta = Meta.new(path)
|
27
|
+
@meta = meta || Meta.new(path)
|
28
28
|
end
|
29
29
|
|
30
30
|
#
|
@@ -56,8 +56,8 @@ module Troy
|
|
56
56
|
#
|
57
57
|
def to_context
|
58
58
|
{
|
59
|
-
:
|
60
|
-
:
|
59
|
+
page: self,
|
60
|
+
site: site
|
61
61
|
}
|
62
62
|
end
|
63
63
|
|
@@ -108,7 +108,7 @@ module Troy
|
|
108
108
|
if layout.exist?
|
109
109
|
EmbeddedRuby.new(
|
110
110
|
layout.read,
|
111
|
-
to_context.merge(:
|
111
|
+
to_context.merge(content: content)
|
112
112
|
).render
|
113
113
|
else
|
114
114
|
content
|
data/lib/troy/server.rb
CHANGED
@@ -46,7 +46,7 @@ module Troy
|
|
46
46
|
render(200, "text/html; charset=utf-8", _path)
|
47
47
|
elsif (_path = Pathname.new("#{path}.xml")).file?
|
48
48
|
render(200, "text/xml; charset=utf-8", _path)
|
49
|
-
elsif path.file?
|
49
|
+
elsif path.file?
|
50
50
|
render(200, Rack::Mime.mime_type(path.extname, "text/plain"), path)
|
51
51
|
else
|
52
52
|
render(404, "text/html; charset=utf-8", root.join("404.html"))
|
data/lib/troy/version.rb
CHANGED
data/lib/troy/xml.rb
CHANGED
@@ -15,11 +15,11 @@ module Troy
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def context
|
18
|
-
@context ||= Context.new(data.merge(:
|
18
|
+
@context ||= Context.new(data.merge(xml: xml)).extend(Helpers)
|
19
19
|
end
|
20
20
|
|
21
21
|
def xml
|
22
|
-
@xml ||= Builder::XmlMarkup.new(:
|
22
|
+
@xml ||= Builder::XmlMarkup.new(indent: 2)
|
23
23
|
end
|
24
24
|
|
25
25
|
def to_xml
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: troy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Nando Vieira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-02-
|
11
|
+
date: 2018-02-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: i18n
|