Sha256: ebcce87fc0432d5244d42b1566ae14cc4aa936b6bb672855a97dea9448d6d391

Contents?: true

Size: 1.91 KB

Versions: 1

Compression:

Stored size: 1.91 KB

Contents

require 'thor'
require 'alula/site'

module Alula
  class CLI < Thor
    include Thor::Actions
    
    source_root File.expand_path(File.join(File.dirname(__FILE__), *%w[.. .. template]))
    
    
    desc "init [PATH]", "Creates a new aLula blog in given path or current directory"
    def init(path = ".")
      # Create directory structure
      %w{attachments attachments/_originals attachments/_thumbnails posts}.each do |dir|
        empty_directory File.join(path, dir)
      end
      
      # Insert templates
      %w{Gemfile config.yml}.each do |tpl|
        template "#{tpl}.erb", File.join(path, tpl)
      end
      
      # Initialize system
      inside File.join(path) do
        run "bundle install"
      end
    end
    
    desc "generate", "Generates blog"
    method_option :development, :type => :boolean, :default => true,
      :desc => "Generate site using development settings. Keeps all assets and HTML uncompressed."
    method_option :production, :type => :boolean, :default => false,
      :desc => "Generate site suing production settings. Compresses all assets and HTML."
    def generate
      site = Alula::Site.new("asset_compress" => (!options["development"] or options["production"]))
      site.generate
    end

    desc "preview", "Preview blog"
    method_option :development, :type => :boolean, :default => true,
      :desc => "Preview site using development settings. Keeps all assets and HTML uncompressed."
    method_option :production, :type => :boolean, :default => false,
      :desc => "Preview site suing production settings. Compresses all assets and HTML."
    def preview
      site = Alula::Site.new("asset_compress" => (!options["development"] or options["production"]))
      site.preview
    end
    
    desc "attach POST ASSET", "Attached given asset, photo or video to given post"
    def attach(post, *asset)
      puts "Adding to post #{post} assets #{asset.inspect}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
alula-0.1.1 lib/alula/cli.rb