apps/blueprint/extensions/middleman.rb in brief-1.15.4 vs apps/blueprint/extensions/middleman.rb in brief-1.15.5
- old
+ new
@@ -3,19 +3,21 @@
option :blueprint_root, nil, 'Which path to use for the blueprint?'
def initialize(app, options_hash = {}, &block)
super
- app.set(:blueprint_root, options_hash.fetch(:blueprint_root) { ENV['BLUEPRINT_ROOT'] || "./blueprint" })
+ app.set(:blueprint_root, Pathname(options_hash.fetch(:blueprint_root) { ENV['BLUEPRINT_ROOT'] || "./blueprint" }))
# import the blueprint assets into the sprockets path
app.ready do
- logger.info "== Adding blueprint assets to sprockets paths"
+ logger.info "== Loading blueprint from #{ blueprint_root }"
+ logger.info "== Appending #{ blueprint.assets_path } to Sprockets paths" if blueprint.assets_path.exist?
+
patterns = [
'.png', '.gif', '.jpg', '.jpeg', '.svg', # Images
'.eot', '.otf', '.svc', '.woff', '.ttf', # Fonts
- '.js', # Javascript
+ '.js', '.slim', '.erb', '.md', # Javascript
].map { |e| File.join(blueprint.assets_path, "**", "*#{e}" ) }
sprockets.prepend_path(blueprint.assets_path)
patterns.map! {|p| Dir[p] }
@@ -31,19 +33,17 @@
def blueprint_model_groups
blueprint.model_classes.map {|m| m.name.to_s.pluralize }
end
def blueprint
- return @blueprint if @blueprint && !development?
-
- @blueprint = get_briefcase.tap do |b|
+ @blueprint ||= get_briefcase.tap do |b|
b.href_builder = ->(uri) {uri = uri.to_s; uri.gsub('brief://','').gsub(/\.\w+$/,'.html').gsub(b.docs_path.to_s,'') }
b.asset_finder = ->(asset) { needle = asset.relative_path_from(b.assets_path).to_s; image_path(needle) }
end
end
def get_briefcase
- Brief::Briefcase.new(root: blueprint_root, caching: !development?)
+ Brief::Briefcase.new(root: blueprint_root, caching: false)
end
end
end if defined?(::Middleman)
::Middleman::Extensions.register(:blueprint, BlueprintMiddlemanExtension) if defined?(::Middleman)