homeostasis 0.0.16 → 0.0.17
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -0
- data/lib/homeostasis.rb +10 -6
- data/lib/version.rb +1 -1
- metadata +1 -1
data/README.md
CHANGED
data/lib/homeostasis.rb
CHANGED
@@ -30,7 +30,7 @@ module Homeostasis
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def render_multi(path, body = nil, context = nil, locals = {})
|
33
|
-
body ||=
|
33
|
+
body ||= Helpers.read(path)
|
34
34
|
render_templates_for(path).each do |template|
|
35
35
|
blk = proc { body }
|
36
36
|
body = template.new(path, &blk).render(context, locals)
|
@@ -42,6 +42,10 @@ module Homeostasis
|
|
42
42
|
File.basename(path).split('.')[1..-1].reverse.map { |ext| Tilt[ext] }.compact
|
43
43
|
end
|
44
44
|
|
45
|
+
def self.read(path)
|
46
|
+
File.read(path, encoding: 'UTF-8')
|
47
|
+
end
|
48
|
+
|
45
49
|
def self.stasis_path
|
46
50
|
@@stasis_path
|
47
51
|
end
|
@@ -100,7 +104,7 @@ module Homeostasis
|
|
100
104
|
orig = full_orig[(@stasis.root.length+1)..-1]
|
101
105
|
full_dest = File.join(@stasis.destination, @@mapping[orig])
|
102
106
|
raise "File not found #{full_dest}" if !File.exists?(full_dest)
|
103
|
-
contents =
|
107
|
+
contents = Helpers.read(full_dest)
|
104
108
|
@@mapping.delete(orig)
|
105
109
|
File.delete(full_dest)
|
106
110
|
contents
|
@@ -124,7 +128,7 @@ module Homeostasis
|
|
124
128
|
inverted = @@mapping.invert
|
125
129
|
Dir.glob("#{@stasis.destination}/**/*").each do |file|
|
126
130
|
next if file !~ @@replace_matcher || File.directory?(file)
|
127
|
-
contents =
|
131
|
+
contents = Helpers.read(file)
|
128
132
|
front = front_site[inverted[file.sub("#{@stasis.destination}/", "")]]
|
129
133
|
assets.each do |old, new|
|
130
134
|
old = Regexp.escape(old)
|
@@ -276,7 +280,7 @@ module Homeostasis
|
|
276
280
|
return nil if path.nil? || path !~ @@matcher
|
277
281
|
Preamble.load(path)
|
278
282
|
rescue
|
279
|
-
[{},
|
283
|
+
[{}, Helpers.read(path)]
|
280
284
|
end
|
281
285
|
|
282
286
|
private
|
@@ -315,7 +319,7 @@ module Homeostasis
|
|
315
319
|
return if exts.nil? || exts.length < 2
|
316
320
|
|
317
321
|
yaml, body = Front.preamble_load(@stasis.path)
|
318
|
-
body ||=
|
322
|
+
body ||= Helpers.read(@stasis.path)
|
319
323
|
|
320
324
|
@tmpfile = Tempfile.new(["temp", ".txt"])
|
321
325
|
@tmpfile.puts(render_multi(@stasis.path, body))
|
@@ -451,7 +455,7 @@ module Homeostasis
|
|
451
455
|
post[:path] = post[:path].sub(
|
452
456
|
"/#{@@directory}/#{date}-",
|
453
457
|
File.join('/', @@path, '/'))
|
454
|
-
post[:body] = render_multi(filename,
|
458
|
+
post[:body] = render_multi(filename, Helpers.read(filename))
|
455
459
|
@@posts << post
|
456
460
|
end
|
457
461
|
@@posts = @@posts.sort_by { |post| post[:date] }.reverse
|
data/lib/version.rb
CHANGED