################### # Page options, layouts, aliases and proxies ################### # With alternative layout page '/**', layout: 'glyptotheque' # With no layout page "/glyptotheque/*", layout: false, directory_index: false page '*.css', layout: false page '*.js', layout: false page '*.json', layout: false set :site_title, 'Glyptotheque' ready do # Proxy default site index to Glyptotheque index template unless sitemap.find_resource_by_path '/index.html' proxy 'index.html', 'glyptotheque/site-index.html', locals: { section: { title: site_title, slug: 'index' } } end proxy 'sitemap.json', 'glyptotheque/sitemap.json' last_dir = nil # Prerender resources to populate models resources = resources_for('/', exclude_indexes: true, allow_hidden: true).each do |r| r.render end # Create mappings for isolated component pages (iframe embeddable) resources.each do |r| # Create virtual index files dir = File.dirname(r.path) section_slug = dir.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '-') index_exists = !!sitemap.find_resource_by_path("#{dir}/index.html") if last_dir != dir && !index_exists proxy "#{dir}/index.html", 'glyptotheque/directory-index.html', locals: { section: { title: dir.upcase, slug: dir.downcase.strip.gsub(' ', '-').gsub(/[^\w-]/, '-') } } last_dir = dir end if r.metadata[:models] r.metadata.models.each do |id, model| proxy "#{r.path.sub(r.ext, '')}-#{id}-isolated.html", r.path, layout: 'isolated', iframe: model.iframe, id: id end end end end activate :sculptor activate :syntax, css_class: 'codehilite' activate :autoprefixer ################### # Helpers ################### # helpers do # end <% if options[:css_dir] -%> set :css_dir, '<%= options[:css_dir] -%>' <% else -%> # Change the CSS directory # set :css_dir, "alternative_css_directory" <% end -%> <% if options[:js_dir] -%> set :js_dir, '<%= options[:js_dir] -%>' <% else -%> # Change the JS directory # set :js_dir, "alternative_js_directory" <% end -%> <% if options[:images_dir] -%> set :images_dir, '<%= options[:images_dir] -%>' <% else -%> # Change the images directory # set :images_dir, "alternative_image_directory" <% end -%> set :relative_links, true bowerrc_dir = JSON.parse(IO.read("#{root}/.bowerrc"))['directory'] # Compass configuration compass_config do |config| config.sass_options = { quiet: true } # For Style Guide CSS sources # config.output_style = :expanded end # Sprockets ready do sprockets.append_path(File.join(root, bowerrc_dir)) end Slim::Engine.disable_option_validator! Slim::Engine.set_options pretty: true Slim::Engine.set_options attr_list_delims: { '(' => ')', '[' => ']' } # Development-secific configuration configure :development do activate :livereload, no_swf: true end # Build-specific configuration configure :build do compass_config do |config| config.sass_options = { :line_comments => false } end # For example, change the Compass output style for deployment # activate :minify_css # Minify Javascript on build # activate :minify_javascript # Enable cache buster # activate :asset_hash # Use relative URLs activate :relative_assets # Or use a different image path # set :http_prefix, "/Content/images/" end ################### # Additional tasks ################### # Simple launcher for local evaluation build # Double click `build/launch.command` (Mac) after_build do |builder| file = "#{build_dir}/launch.command" open(file, 'w') do |f| f << "#!/bin/bash\n" f << 'cd `dirname $0` && open "http://localhost:8000" && python -m SimpleHTTPServer' end File.chmod(0555, file) end # Middleman Deploy activate :deploy do |deploy| deploy.method = :git # Optional Settings # deploy.remote = 'custom-remote' # remote name or git url, default: origin # deploy.branch = 'custom-branch' # default: gh-pages # deploy.strategy = :submodule # commit strategy: can be :force_push or :submodule, default: :force_push # deploy.commit_message = 'custom-message' # commit message (can be empty), default: Automated commit at `timestamp` by middleman-deploy `version` end