homeostasis 0.0.17 → 0.0.18
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/README.md +1 -0
- data/lib/homeostasis.rb +32 -11
- data/lib/version.rb +1 -1
- metadata +2 -34
data/README.md
CHANGED
data/lib/homeostasis.rb
CHANGED
@@ -26,7 +26,7 @@ module Homeostasis
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def h(html)
|
29
|
-
CGI::escapeHTML(html)
|
29
|
+
CGI::escapeHTML(html.to_s)
|
30
30
|
end
|
31
31
|
|
32
32
|
def render_multi(path, body = nil, context = nil, locals = {})
|
@@ -230,10 +230,10 @@ module Homeostasis
|
|
230
230
|
if !ignore?(path)
|
231
231
|
relative = path[(@stasis.root.length+1)..-1]
|
232
232
|
ext = Tilt.mappings.keys.find { |ext| File.extname(path)[1..-1] == ext }
|
233
|
-
dest =
|
233
|
+
dest = (ext && File.extname(relative) == ".#{ext}") ?
|
234
234
|
relative[0..-1*ext.length-2] :
|
235
|
-
relative
|
236
|
-
yaml[:path] = dest
|
235
|
+
relative
|
236
|
+
yaml[:path] = trailify(Multi.drop_tilt_exts(dest))
|
237
237
|
end
|
238
238
|
@@front_site[front_key(path)] = yaml
|
239
239
|
end
|
@@ -272,6 +272,10 @@ module Homeostasis
|
|
272
272
|
@@front_site
|
273
273
|
end
|
274
274
|
|
275
|
+
def self._front_key(stasis, filename) # for other plugins
|
276
|
+
filename.sub(stasis.root, '')[1..-1]
|
277
|
+
end
|
278
|
+
|
275
279
|
def self.config(options)
|
276
280
|
@@matcher = options[:matcher] if options[:matcher]
|
277
281
|
end
|
@@ -285,7 +289,7 @@ module Homeostasis
|
|
285
289
|
|
286
290
|
private
|
287
291
|
def front_key(filename)
|
288
|
-
|
292
|
+
self.class._front_key(@stasis, filename)
|
289
293
|
end
|
290
294
|
|
291
295
|
def trailify(filename)
|
@@ -322,7 +326,7 @@ module Homeostasis
|
|
322
326
|
body ||= Helpers.read(@stasis.path)
|
323
327
|
|
324
328
|
@tmpfile = Tempfile.new(["temp", ".txt"])
|
325
|
-
@tmpfile.puts(render_multi(@stasis.path, body))
|
329
|
+
@tmpfile.puts(render_multi(@stasis.path, body, @stasis.action))
|
326
330
|
@tmpfile.close
|
327
331
|
Helpers.set_stasis_path(@stasis, @stasis.path)
|
328
332
|
@stasis.path = @tmpfile.path
|
@@ -340,15 +344,20 @@ module Homeostasis
|
|
340
344
|
|
341
345
|
def after_write
|
342
346
|
return if @stasis.path.nil? || ignore?(@stasis.path)
|
343
|
-
|
344
|
-
|
347
|
+
dest = self.class.drop_tilt_exts(@stasis.dest)
|
348
|
+
File.rename(@stasis.dest, dest) if dest != @stasis.dest
|
349
|
+
end
|
350
|
+
|
351
|
+
def self.drop_tilt_exts(path)
|
352
|
+
dirname = File.dirname(path)
|
353
|
+
basename = File.basename(path)
|
345
354
|
exts = basename.split('.')[2..-1]
|
355
|
+
return path if exts.nil? || exts.length < 1
|
346
356
|
|
347
|
-
return if exts.nil? || exts.length < 1
|
348
357
|
exts.each do |ext|
|
349
358
|
basename = basename.sub(/\.#{ext}/, '')
|
350
359
|
end
|
351
|
-
File.
|
360
|
+
File.join(dirname, basename)
|
352
361
|
end
|
353
362
|
end
|
354
363
|
|
@@ -421,6 +430,7 @@ module Homeostasis
|
|
421
430
|
include Helpers
|
422
431
|
DATE_REGEX = /^(\d{4}-\d{2}-\d{2})-/
|
423
432
|
before_all :before_all
|
433
|
+
before_render :before_render
|
424
434
|
after_all :after_all
|
425
435
|
action_method :blog_posts
|
426
436
|
priority 3
|
@@ -451,16 +461,27 @@ module Homeostasis
|
|
451
461
|
next if File.basename(filename) !~ DATE_REGEX
|
452
462
|
date = $1
|
453
463
|
post = front_site[filename.sub(@stasis.root, '')[1..-1]] || {}
|
464
|
+
post[:blog] = true
|
454
465
|
post[:date] = Date.parse(date)
|
455
466
|
post[:path] = post[:path].sub(
|
456
467
|
"/#{@@directory}/#{date}-",
|
457
468
|
File.join('/', @@path, '/'))
|
458
|
-
post[:body] = render_multi(filename, Helpers.read(filename))
|
459
469
|
@@posts << post
|
460
470
|
end
|
461
471
|
@@posts = @@posts.sort_by { |post| post[:date] }.reverse
|
462
472
|
end
|
463
473
|
|
474
|
+
def before_render
|
475
|
+
path = Helpers.stasis_path || @stasis.path
|
476
|
+
return if path.nil?
|
477
|
+
|
478
|
+
post = Homeostasis::Front._front_site[Homeostasis::Front._front_key(@stasis, path)]
|
479
|
+
if post && post[:blog] && post[:date] && post[:path]
|
480
|
+
yaml, body = Front.preamble_load(path)
|
481
|
+
post[:body] = render_multi(path, body, @stasis.action)
|
482
|
+
end
|
483
|
+
end
|
484
|
+
|
464
485
|
def after_all
|
465
486
|
return if @@directory.nil?
|
466
487
|
blog_dest = File.join(@stasis.destination, @@path)
|
data/lib/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: homeostasis
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: stasis
|
@@ -59,38 +59,6 @@ dependencies:
|
|
59
59
|
- - ! '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
|
-
- !ruby/object:Gem::Dependency
|
63
|
-
name: bluecloth
|
64
|
-
requirement: !ruby/object:Gem::Requirement
|
65
|
-
none: false
|
66
|
-
requirements:
|
67
|
-
- - ! '>='
|
68
|
-
- !ruby/object:Gem::Version
|
69
|
-
version: '0'
|
70
|
-
type: :development
|
71
|
-
prerelease: false
|
72
|
-
version_requirements: !ruby/object:Gem::Requirement
|
73
|
-
none: false
|
74
|
-
requirements:
|
75
|
-
- - ! '>='
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version: '0'
|
78
|
-
- !ruby/object:Gem::Dependency
|
79
|
-
name: haml
|
80
|
-
requirement: !ruby/object:Gem::Requirement
|
81
|
-
none: false
|
82
|
-
requirements:
|
83
|
-
- - ! '>='
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: '0'
|
86
|
-
type: :development
|
87
|
-
prerelease: false
|
88
|
-
version_requirements: !ruby/object:Gem::Requirement
|
89
|
-
none: false
|
90
|
-
requirements:
|
91
|
-
- - ! '>='
|
92
|
-
- !ruby/object:Gem::Version
|
93
|
-
version: '0'
|
94
62
|
description: Provides asset stamping using git revisions, environments, and a few
|
95
63
|
view helpers.
|
96
64
|
email:
|