class Middleman::Blog::Ui::Extension
Middleman
extension entry point
Public Class Methods
new(app, options_hash = {}, &block)
click to toggle source
Calls superclass method
# File lib/middleman/blog/ui/extension.rb, line 10 def initialize(app, options_hash = {}, &block) super puts "== Starting API Server on /api" app.map "/api" do run ApiServer end ::Sprockets.register_preprocessor 'application/javascript', ::Sprockets::CoffeeReact end
Public Instance Methods
after_configuration()
click to toggle source
# File lib/middleman/blog/ui/extension.rb, line 21 def after_configuration # p "after_configuration" register_extension_templates Dir.glob( "#{SOURCE_DIR}/javascripts/**/*" ).each do |f| # p "Adding #{f}" app.sprockets.append_path File.dirname(f) end Dir.glob( "#{SOURCE_DIR}/stylesheets/*" ).each do |f| # p "Adding #{f}" app.sprockets.append_path File.dirname(f) end app.sprockets.append_path File.dirname(::React::Source.bundled_path_for('react.js')) end
manipulate_resource_list(resources)
click to toggle source
# File lib/middleman/blog/ui/extension.rb, line 35 def manipulate_resource_list(resources) # p "manipulate_resource_list" Dir.glob( "#{SOURCE_DIR}/**/*" ).each do |path| unless File.directory? path resources << make_template( path, path.gsub( /#{SOURCE_DIR}\//, "" ) ) end end # resources << make_template( "#{SOURCE_DIR}/stylesheets/admin.css.scss", "stylesheets/admin.css" ) resources end
Private Instance Methods
make_template( file, name )
click to toggle source
# File lib/middleman/blog/ui/extension.rb, line 54 def make_template( file, name ) name = name.gsub( /.erb/, "" ).gsub( /.haml/, "" ).gsub( /.coffee/, "" ).gsub( /.scss/, "" ) # puts "Adding #{name}" Middleman::Sitemap::Resource.new(app.sitemap, name, file).tap do |resource| resource.add_metadata(options: { layout: false }, locals: {}) end end
register_extension_templates()
click to toggle source
# File lib/middleman/blog/ui/extension.rb, line 47 def register_extension_templates # We call reload_path to register the templates directory with Middleman. # The path given to app.files must be relative to the Middleman site's root. templates_dir_relative_from_root = Pathname(SOURCE_DIR).relative_path_from(Pathname(app.root)) app.files.reload_path(templates_dir_relative_from_root) end