make data dir configurable
This commit is contained in:
parent
6a3de0768c
commit
59a07d4cc0
|
@ -5,6 +5,7 @@ require "thor"
|
||||||
module Middleman::CoreExtensions::Data
|
module Middleman::CoreExtensions::Data
|
||||||
class << self
|
class << self
|
||||||
def registered(app)
|
def registered(app)
|
||||||
|
app.set :data_dir, "data"
|
||||||
app.extend ClassMethods
|
app.extend ClassMethods
|
||||||
app.helpers Helpers
|
app.helpers Helpers
|
||||||
end
|
end
|
||||||
|
@ -33,7 +34,7 @@ module Middleman::CoreExtensions::Data
|
||||||
elsif @@remote_sources.has_key?(path.to_s)
|
elsif @@remote_sources.has_key?(path.to_s)
|
||||||
response = HTTParty.get(@@remote_sources[path.to_s]).parsed_response
|
response = HTTParty.get(@@remote_sources[path.to_s]).parsed_response
|
||||||
else
|
else
|
||||||
file_path = File.join(@app.class.root, "data", "#{path}.yml")
|
file_path = File.join(@app.class.root, @app.class.data_dir, "#{path}.yml")
|
||||||
if File.exists? file_path
|
if File.exists? file_path
|
||||||
response = YAML.load_file(file_path)
|
response = YAML.load_file(file_path)
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue