move to middleman-templates

i18n_v4
Karl Freeman 2014-03-11 11:07:55 +00:00
parent 23b1b8464d
commit 772de85ce3
126 changed files with 153 additions and 107 deletions

View File

@ -38,5 +38,6 @@ gem 'rubocop', :require => false
# Middleman itself
gem 'middleman-core', :path => 'middleman-core'
gem 'middleman-cli', :path => 'middleman-cli'
gem 'middleman-templates', :path => 'middleman-templates'
gem 'middleman-sprockets', :github => 'middleman/middleman-sprockets', :require => false
gem 'middleman', :path => 'middleman'

View File

@ -7,7 +7,7 @@ require File.expand_path('../middleman-core/lib/middleman-core/version.rb', __FI
ROOT = File.expand_path(File.dirname(__FILE__))
GEM_NAME = 'middleman'
middleman_gems = %w(middleman-core middleman-cli middleman)
middleman_gems = %w(middleman-core middleman-templates middleman-cli middleman)
GEM_PATHS = middleman_gems.freeze
def sh_rake(command)

View File

@ -1,4 +1,4 @@
require 'middleman-cli/templates'
require 'middleman-templates'
# CLI Module
module Middleman::Cli

View File

@ -1,99 +0,0 @@
# Use thor for template generation
require 'thor'
require 'thor/group'
# Templates namespace
module Middleman::Templates
# Static methods
class << self
# Get list of registered templates and add new ones
#
# Middleman::Templates.register(:ext_name, klass)
#
# @param [Symbol] name The name of the template
# @param [Class] klass The class to be executed for this template
# @return [Hash] List of registered templates
def register(name=nil, klass=nil)
@_template_mappings ||= {}
@_template_mappings[name] = klass if name && klass
@_template_mappings
end
# Middleman::Templates.register(name, klass)
alias :registered :register
end
# Base Template class. Handles basic options and paths.
class Base < ::Thor::Group
include Thor::Actions
def initialize(names, options)
super
source_paths << File.join(File.dirname(__FILE__), 'templates')
end
# The gemfile template to use. Individual templates can define this class
# method to override the template path.
def self.gemfile_template
'shared/Gemfile.tt'
end
# Required path for the new project to be generated
argument :location, :type => :string
# Name of the template being used to generate the project.
class_option :template, :default => 'default'
# Output a config.ru file for Rack if --rack is passed
class_option :rack, :type => :boolean, :default => false
# Write a Rack config.ru file for project
# @return [void]
def generate_rack!
return unless options[:rack]
template 'shared/config.ru', File.join(location, 'config.ru')
end
class_option :'skip-bundle', :type => :boolean, :default => false
class_option :'skip-gemfile', :type => :boolean, :default => false
# Write a Bundler Gemfile file for project
# @return [void]
def generate_bundler!
return if options[:'skip-gemfile']
template self.class.gemfile_template, File.join(location, 'Gemfile')
return if options[:'skip-bundle']
inside(location) do
::Middleman::Cli::Bundle.new.invoke(:bundle)
end unless ENV['TEST']
end
# Output a .gitignore file
class_option :'skip-git', :type => :boolean, :default => false
# Write a .gitignore file for project
# @return [void]
def generate_gitignore!
return if options[:'skip-git']
copy_file 'shared/gitignore', File.join(location, '.gitignore')
end
end
end
# Default template
require 'middleman-cli/templates/default'
# HTML5 template
require 'middleman-cli/templates/html5'
# HTML5 Mobile template
require 'middleman-cli/templates/mobile'
# Local templates
require 'middleman-cli/templates/local'
# Barebones template
require 'middleman-cli/templates/empty'

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,5 @@
SimpleCov.start do
add_filter '/fixtures/'
add_filter '/features/'
add_filter '/spec/'
end

View File

@ -0,0 +1,4 @@
lib/**/*.rb
--exclude lib/middleman-templates
--no-private
--hide-void-return

View File

@ -0,0 +1,5 @@
# coding:utf-8
RAKE_ROOT = __FILE__
GEM_NAME = 'middleman-templates'
require File.expand_path(File.dirname(__FILE__) + '/../gem_rake_helper')

View File

@ -0,0 +1,18 @@
#!/usr/bin/env ruby
require 'middleman-core/profiling'
if ARGV.include? '--profile'
Middleman::Profiling.profiler = Middleman::Profiling::RubyProfProfiler.new
end
Middleman::Profiling.start
require "middleman-core/load_paths"
Middleman.setup_load_paths
require "middleman-cli"
# Change directory to the root
Dir.chdir(ENV["MM_ROOT"]) if ENV["MM_ROOT"]
# Start the CLI
Middleman::Cli::Base.start

View File

View File

@ -0,0 +1,92 @@
# Setup our load paths
libdir = File.expand_path(File.dirname(__FILE__))
$LOAD_PATH.unshift(libdir) unless $LOAD_PATH.include?(libdir)
# Require Thor since that's what the whole CLI is built around
require 'thor'
require 'thor/group'
# Templates Module
module Middleman
module Templates
# Static methods
class << self
# Get list of registered templates and add new ones
#
# Middleman::Templates.register(:ext_name, klass)
#
# @param [Symbol] name The name of the template
# @param [Class] klass The class to be executed for this template
# @return [Hash] List of registered templates
def register(name=nil, klass=nil)
@_template_mappings ||= {}
@_template_mappings[name] = klass if name && klass
@_template_mappings
end
# Middleman::Templates.register(name, klass)
alias :registered :register
end
# Base Template class. Handles basic options and paths.
class Base < ::Thor::Group
include Thor::Actions
def initialize(names, options)
super
source_paths << File.join(File.dirname(__FILE__), 'middleman-templates')
end
# The gemfile template to use. Individual templates can define this class
# method to override the template path.
def self.gemfile_template
'shared/Gemfile.tt'
end
# Required path for the new project to be generated
argument :location, :type => :string
# Name of the template being used to generate the project.
class_option :template, :default => 'default'
# Output a config.ru file for Rack if --rack is passed
class_option :rack, :type => :boolean, :default => false
# Write a Rack config.ru file for project
# @return [void]
def generate_rack!
return unless options[:rack]
template 'shared/config.ru', File.join(location, 'config.ru')
end
class_option :'skip-bundle', :type => :boolean, :default => false
class_option :'skip-gemfile', :type => :boolean, :default => false
# Write a Bundler Gemfile file for project
# @return [void]
def generate_bundler!
return if options[:'skip-gemfile']
template self.class.gemfile_template, File.join(location, 'Gemfile')
return if options[:'skip-bundle']
inside(location) do
::Middleman::Cli::Bundle.new.invoke(:bundle)
end unless ENV['TEST']
end
# Output a .gitignore file
class_option :'skip-git', :type => :boolean, :default => false
# Write a .gitignore file for project
# @return [void]
def generate_gitignore!
return if options[:'skip-git']
copy_file 'shared/gitignore', File.join(location, '.gitignore')
end
end
end
end
Dir.glob(File.expand_path("../middleman-templates/*.rb", __FILE__), &method(:require))

View File

Before

Width:  |  Height:  |  Size: 318 B

After

Width:  |  Height:  |  Size: 318 B

Some files were not shown because too many files have changed in this diff Show More