require 'rack/utils' require 'middleman-syntax' require 'bootstrap-sass' require 'compass/import-once/activate' ### # Compass ### compass_config do |config| config.output_style = :compact config.http_path = '/' config.css_dir = 'source/stylesheets' config.sass_dir = 'source/sass' config.images_dir = 'source/images' config.javascripts_dir = 'source/javascripts' end ### # Page options, layouts, aliases and proxies ### page '/', layout: 'home' page '/atom.xml', layout: false page '/ml/*', layout: false with_layout :guides do page '/guides/*' end with_layout :blog do page '/blog/*' end ### # Helpers ### activate :directory_indexes activate :syntax, css_class: 'language-ruby' activate :blog do |blog| blog.prefix = 'blog' blog.permalink = '{year}/{month}/{day}/{title}.html' end # Automatic image dimensions on image_tag helper # activate :automatic_image_sizes # Reload the browser automatically whenever files change configure :development do activate :livereload end activate :deploy do |deploy| deploy.method = :git deploy.branch = 'master' end set :url_root, 'http://lotusrb.org' activate :search_engine_sitemap # Methods defined in the helpers block are available in templates helpers do # # BLOG # def articles(limit = 5) blog.articles[0...limit] end def article_title(article) article.data.title end def article_author(article) article.data.author end def article_date(article) date = article.date date.strftime('%B %d, %Y') end def article_summary(article) article.data.excerpt end def article_image(article) if article.data.image %() end end def article_image_url(article) path = if article.data.image article.url.gsub(/\.html/, '') else "/images" end "#{ path }/cover.jpg" end # # GUIDES # GUIDES_ROOT = 'source/guides'.freeze GUIDES_EDIT_URL = 'https://github.com/lotus/lotus.github.io/edit/build/'.freeze def guides_navigation result = '' Dir.glob("#{ GUIDES_ROOT }/*").each do |section| next unless ::File.directory?(section) result << guides_section(section) end result end def guides_section(section) title = section.sub("#{ GUIDES_ROOT }/", '').titleize %(