homeostasis 0.0.13 → 0.0.14
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +4 -2
- data/lib/homeostasis.rb +15 -10
- metadata +2 -2
data/README.md
CHANGED
@@ -54,8 +54,9 @@ Blog
|
|
54
54
|
In your controller:
|
55
55
|
|
56
56
|
Homeostasis::Blog.config(
|
57
|
-
:directory => 'blog',
|
58
|
-
:
|
57
|
+
:directory => 'blog', # directory of posts, required
|
58
|
+
:path => '', # post path prefix, defaults to directory - '' for none
|
59
|
+
:url => 'http://example.com', # site url, required
|
59
60
|
:title => 'Blog Title',
|
60
61
|
:desc => 'Blog Description for RSS feed')
|
61
62
|
|
@@ -160,6 +161,7 @@ slashes to URLs.
|
|
160
161
|
TODO
|
161
162
|
====
|
162
163
|
|
164
|
+
* fix links, images, etc... in RSS
|
163
165
|
* make each plugin optional
|
164
166
|
* single version endpoint
|
165
167
|
|
data/lib/homeostasis.rb
CHANGED
@@ -6,7 +6,7 @@ require 'yaml'
|
|
6
6
|
require 'cgi'
|
7
7
|
|
8
8
|
module Homeostasis
|
9
|
-
VERSION = '0.0.
|
9
|
+
VERSION = '0.0.14'
|
10
10
|
|
11
11
|
module Helpers
|
12
12
|
private
|
@@ -268,7 +268,7 @@ module Homeostasis
|
|
268
268
|
pages.each do |page|
|
269
269
|
front = front_site[page]
|
270
270
|
filename = File.join(@stasis.root, page)
|
271
|
-
next if page !~ /\.html/ || front[:private] || front[:path].nil?
|
271
|
+
next if page !~ /\.html/ || !front || front[:private] || front[:path].nil?
|
272
272
|
|
273
273
|
log = `git log -n1 #{filename} 2> /dev/null | grep "Date:"`
|
274
274
|
lastmod = log.length > 0 ?
|
@@ -298,6 +298,7 @@ module Homeostasis
|
|
298
298
|
def initialize(stasis)
|
299
299
|
@stasis = stasis
|
300
300
|
@@directory = nil
|
301
|
+
@@path = nil
|
301
302
|
@@url = nil
|
302
303
|
@@title = nil
|
303
304
|
@@desc = nil
|
@@ -306,6 +307,7 @@ module Homeostasis
|
|
306
307
|
|
307
308
|
def self.config(options)
|
308
309
|
@@directory = options[:directory]
|
310
|
+
@@path = options[:path] || options[:directory]
|
309
311
|
@@url = options[:url]
|
310
312
|
@@title = options[:title]
|
311
313
|
@@desc = options[:desc]
|
@@ -320,7 +322,9 @@ module Homeostasis
|
|
320
322
|
date = $1
|
321
323
|
post = front_site[filename.sub(@stasis.root, '')[1..-1]] || {}
|
322
324
|
post[:date] = Date.parse(date)
|
323
|
-
post[:path] = post[:path].sub(
|
325
|
+
post[:path] = post[:path].sub(
|
326
|
+
"/#{@@directory}/#{date}-",
|
327
|
+
File.join('/', @@path, '/'))
|
324
328
|
post[:body] = BlueCloth.new(File.read(filename)).to_html if filename =~ /\.md$/
|
325
329
|
@@posts << post
|
326
330
|
end
|
@@ -329,13 +333,14 @@ module Homeostasis
|
|
329
333
|
|
330
334
|
def after_all
|
331
335
|
return if @@directory.nil?
|
336
|
+
blog_dest = File.join(@stasis.destination, @@path)
|
337
|
+
FileUtils.mkdir_p(blog_dest) if !Dir.exist?(blog_dest)
|
332
338
|
Dir.glob("#{File.join(@stasis.destination, @@directory)}/*").each do |filename|
|
333
339
|
next if (base = File.basename(filename)) !~ DATE_REGEX
|
334
|
-
FileUtils.mv(
|
335
|
-
filename,
|
336
|
-
File.join(File.dirname(filename), base.sub(DATE_REGEX, '')))
|
340
|
+
FileUtils.mv(filename, File.join(blog_dest, base.sub(DATE_REGEX, '')))
|
337
341
|
end
|
338
|
-
url = h(
|
342
|
+
url = h(File.join(@@url, @@path))
|
343
|
+
zone = Time.new.zone
|
339
344
|
rss = "<?xml version=\"1.0\"?>\n"
|
340
345
|
rss += "<rss version=\"2.0\">\n"
|
341
346
|
rss += " <channel>\n"
|
@@ -345,14 +350,14 @@ module Homeostasis
|
|
345
350
|
blog_posts[0..5].each do |post|
|
346
351
|
rss += " <item>\n"
|
347
352
|
rss += " <title>#{h post[:title]}</title>\n"
|
348
|
-
rss += " <link>#{h(@@url
|
349
|
-
rss += " <pubDate>#{post[:date].strftime(
|
353
|
+
rss += " <link>#{h(File.join(@@url, post[:path]))}</link>\n"
|
354
|
+
rss += " <pubDate>#{post[:date].strftime("%a, %d %b %Y 0:00:01 #{zone}")}</pubDate>\n"
|
350
355
|
rss += " <description>#{h post[:body]}</description>\n"
|
351
356
|
rss += " </item>\n"
|
352
357
|
end
|
353
358
|
rss += " </channel>\n"
|
354
359
|
rss += "</rss>"
|
355
|
-
File.open(File.join(
|
360
|
+
File.open(File.join(blog_dest, @@path, 'rss.xml'), 'w') do |f|
|
356
361
|
f.puts(rss)
|
357
362
|
end
|
358
363
|
end
|
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.14
|
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:
|
12
|
+
date: 2013-01-27 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Provides asset stamping using git revisions, environments, and a few
|
15
15
|
view helpers.
|