Skip to content

Commit

Permalink
general update
Browse files Browse the repository at this point in the history
  • Loading branch information
WaYdotNET committed Aug 28, 2012
1 parent 10d269f commit d6afa8f
Show file tree
Hide file tree
Showing 23 changed files with 145 additions and 129 deletions.
14 changes: 13 additions & 1 deletion README.rdoc
@@ -1,3 +1,15 @@
== (Padrino Admin TwitterBootstrap 2.1)
* Slim, Haml, Erb engine
* Remove all locale, now only English
* Remove all unused helper
* Padrino-Modal: rack-flash and delete function into modal :D
* highlights error field
* Automatic replace true or false with relative image (list.slim, list.haml, list.erb)
* Breadcrumbs
* Automatic time_ago_in_words when column model is created_at or updated_at
* Migrate function for MiniRecord
* tag_icon helper

= Padrino

Padrino is the godfather of Sinatra. Follow us on
Expand Down Expand Up @@ -88,4 +100,4 @@ The individual Padrino sub-gems also contain README's which outlines their funct

== Copyright

Copyright (c) 2011 Padrino. See LICENSE for details.
Copyright (c) 2012 Padrino. See LICENSE for details.
5 changes: 0 additions & 5 deletions padrino-admin/lib/padrino-admin.rb
Expand Up @@ -21,11 +21,6 @@ module Admin; end
#
String.send(:include, Padrino::Admin::Utils::Crypt)

##
# Load our Padrino::Admin locales
#
I18n.load_path += Dir["#{File.dirname(__FILE__)}/padrino-admin/locale/**/*.yml"]

##
# Now we need to add admin generators to padrino-gen
#
Expand Down
Empty file modified padrino-admin/padrino-admin.gemspec 100755 → 100644
Empty file.
Empty file modified padrino-cache/padrino-cache.gemspec 100755 → 100644
Empty file.
Empty file modified padrino-core/padrino-core.gemspec 100755 → 100644
Empty file.
22 changes: 11 additions & 11 deletions padrino-gen/lib/padrino-gen/generators/actions.rb
Expand Up @@ -270,11 +270,11 @@ def require_dependencies(*gem_names)
# @api public
def insert_into_gemfile(name, options={})
after_pattern = options[:group] ? "#{options[:group].to_s.capitalize} requirements\n" : "Component requirements\n"
version = options.delete(:version)
gem_options = options.map { |k, v| "#{k.inspect} => #{v.inspect}" }.join(", ")
write_option = gem_options.present? ? ", #{gem_options}" : ""
write_version = version.present? ? ", #{version.inspect}" : ""
include_text = "gem '#{name}'"<< write_version << write_option << "\n"
version = options.delete(:version)
gem_options = options.map { |k, v| ":#{k} => '#{v.to_s}'" }.join(", ")
write_option = gem_options.present? ? ", #{gem_options}" : ''
write_version = version.present? ? ", '#{version.to_s}'" : ''
include_text = "gem '#{name}'" << write_version << write_option << "\n"
inject_into_file('Gemfile', include_text, :after => after_pattern)
end

Expand Down Expand Up @@ -351,14 +351,14 @@ def test?
#
# @api public
def tiny?
File.exist?(destination_root("app/controllers.rb"))
File.exist?(destination_root('app/controllers.rb'))
end

# Run the bundler
#
# @api semipublic
def run_bundler
say "Bundling application dependencies using bundler...", :yellow
say 'Bundling application dependencies using bundler...', :yellow
in_root { run 'bundle install' }
end

Expand Down Expand Up @@ -418,12 +418,12 @@ def check_app_existence(app)
#
# @api private
def app_skeleton(app, tiny=false)
directory("app/", destination_root(app))
directory('app/', destination_root(app))
if tiny # generate tiny structure
template "templates/controller.rb.tt", destination_root(app, "controllers.rb")
template "templates/helper.rb.tt", destination_root(app, "helpers.rb")
template 'templates/controller.rb.tt', destination_root(app, 'controllers.rb')
template 'templates/helper.rb.tt', destination_root(app, 'helpers.rb')
@short_name = 'notifier'
template "templates/mailer.rb.tt", destination_root(app, "mailers.rb")
template 'templates/mailer.rb.tt', destination_root(app, 'mailers.rb')
else # generate standard folders
empty_directory destination_root(app, 'controllers')
empty_directory destination_root(app, 'helpers')
Expand Down
22 changes: 10 additions & 12 deletions padrino-gen/lib/padrino-gen/generators/app.rb
Expand Up @@ -19,12 +19,10 @@ def self.banner; "padrino-gen project [name]"; end
include Padrino::Generators::Actions

desc "Description:\n\n\tpadrino-gen app generates a new Padrino application"

argument :name, :desc => "The name of your padrino application"

class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
argument :name, :desc => 'The name of your padrino application'
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
class_option :tiny, :desc => "Generate tiny app skeleton", :aliases => '-i', :default => false, :type => :boolean
class_option :tiny, :desc => 'Generate tiny app skeleton', :aliases => '-i', :default => false, :type => :boolean

# Show help if no argv given
require_arguments!
Expand All @@ -34,24 +32,24 @@ def self.banner; "padrino-gen project [name]"; end
# @api private
def create_app
self.destination_root = options[:root]
@app_name = name.gsub(/\W/, "_").underscore.camelize
@app_name = name.gsub(/\W/, '_').underscore.camelize
if in_app_root?
self.behavior = :revoke if options[:destroy]
app_skeleton(@app_name.downcase, options[:tiny])
empty_directory destination_root("public/#{@app_name.downcase}")
append_file destination_root("config/apps.rb"), "\nPadrino.mount(\"#{@app_name}\").to(\"/#{@app_name.downcase}\")"
append_file destination_root('config/apps.rb'), "\nPadrino.mount('#{@app_name}').to('/#{@app_name.downcase}')"

return if self.behavior == :revoke
say
say "="*65, :green
say '=' * 65, :green
say "Your #{@app_name} application has been installed."
say "="*65, :green
say '='*65, :green
say "This application has been mounted to /#{@app_name.downcase}"
say "You can configure a different path by editing 'config/apps.rb"
say "="*65, :green
say "You can configure a different path by editing 'config/apps.rb'"
say '=' * 65, :green
say
else
say "You are not at the root of a Padrino application! (config/boot.rb not found)"
say 'You are not at the root of a Padrino application! (config/boot.rb not found)'
end
end
end # App
Expand Down
6 changes: 3 additions & 3 deletions padrino-gen/lib/padrino-gen/generators/app/app.rb.tt
Expand Up @@ -27,10 +27,10 @@ class <%= @app_name %> < Padrino::Application
# set :dump_errors, true # Exception backtraces are written to STDERR (default for production/development)
# set :show_exceptions, true # Shows a stack trace in browser (default for development)
# set :logging, true # Logging in STDOUT for development and file for production (default only for development)
# set :public_folder, "foo/bar" # Location for static assets (default root/public)
# set :public_folder, 'foo/bar' # Location for static assets (default root/public)
# set :reload, false # Reload application files (default in development)
# set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder')
# set :locale_path, "bar" # Set path for I18n translations (default your_app/locales)
# set :default_builder, 'foo' # Set a custom form builder (default 'StandardFormBuilder')
# set :locale_path, 'bar' # Set path for I18n translations (default your_app/locales)
# disable :sessions # Disabled sessions by default (enable if needed)
# disable :flash # Disables sinatra-flash (enabled by default if Sinatra::Flash is defined)
# layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
Expand Down
6 changes: 3 additions & 3 deletions padrino-gen/lib/padrino-gen/generators/cli.rb
Expand Up @@ -20,8 +20,8 @@ class Cli < Thor::Group
# @api private
def load_boot
begin
ENV['PADRINO_LOG_LEVEL'] ||= "test"
ENV['BUNDLE_GEMFILE'] = File.join(options[:root], "Gemfile") if options[:root]
ENV['PADRINO_LOG_LEVEL'] ||= 'test'
ENV['BUNDLE_GEMFILE'] = File.join(options[:root], 'Gemfile') if options[:root]
boot = options[:root] ? File.join(options[:root], 'config/boot.rb') : 'config/boot.rb'
if File.exist?(boot)
require File.expand_path(boot)
Expand All @@ -47,7 +47,7 @@ def setup
generator_class = Padrino::Generators.mappings[generator_kind]

if generator_class
args = ARGV.empty? && generator_class.require_arguments? ? ["-h"] : ARGV
args = ARGV.empty? && generator_class.require_arguments? ? ['-h'] : ARGV
generator_class.start(args)
else
puts "Please specify generator to use (#{Padrino::Generators.mappings.keys.join(", ")})"
Expand Down
20 changes: 10 additions & 10 deletions padrino-gen/lib/padrino-gen/generators/controller.rb
Expand Up @@ -20,11 +20,11 @@ def self.banner; "padrino-gen controller [name]"; end

desc "Description:\n\n\tpadrino-gen controller generates a new Padrino controller"

argument :name, :desc => "The name of your padrino controller"
argument :fields, :desc => "The fields for the controller", :type => :array, :default => []
class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
class_option :app, :desc => "The application destination path", :aliases => '-a', :default => "/app", :type => :string
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
argument :name, :desc => 'The name of your padrino controller'
argument :fields, :desc => 'The fields for the controller', :default => [], :type => :array
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '/app', :type => :string
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean

# Show help if no argv given
require_arguments!
Expand All @@ -37,17 +37,17 @@ def create_controller
if in_app_root?
app = options[:app]
check_app_existence(app)
@app_name = fetch_app_name(app)
@actions = controller_actions(fields)
@app_name = fetch_app_name(app)
@actions = controller_actions(fields)
@controller = name.to_s.underscore
self.behavior = :revoke if options[:destroy]
template "templates/controller.rb.tt", destination_root(app, "controllers", "#{name.to_s.underscore}.rb")
template "templates/helper.rb.tt", destination_root(app, "helpers", "#{name.to_s.underscore}_helper.rb")
template 'templates/controller.rb.tt', destination_root(app, 'controllers', "#{name.to_s.underscore}.rb")
template 'templates/helper.rb.tt', destination_root(app, 'helpers', "#{name.to_s.underscore}_helper.rb")
empty_directory destination_root(app, "/views/#{name.to_s.underscore}")
include_component_module_for(:test)
generate_controller_test(name) if test?
else
say "You are not at the root of a Padrino application! (config/boot.rb not found)"
say 'You are not at the root of a Padrino application! (config/boot.rb not found)'
end
end
end # Controller
Expand Down
14 changes: 7 additions & 7 deletions padrino-gen/lib/padrino-gen/generators/mailer.rb
Expand Up @@ -11,7 +11,7 @@ class Mailer < Thor::Group
# Define the source template root
def self.source_root; File.expand_path(File.dirname(__FILE__)); end
# Defines the banner for this CLI generator
def self.banner; "padrino-gen mailer [name]"; end
def self.banner; 'padrino-gen mailer [name]'; end

# Include related modules
include Thor::Actions
Expand All @@ -20,11 +20,11 @@ def self.banner; "padrino-gen mailer [name]"; end

desc "Description:\n\n\tpadrino-gen mailer generates a new Padrino mailer"

argument :name, :desc => "The name of your padrino mailer"
argument :actions, :desc => "The delivery actions to add to your mailer", :type => :array, :default => []
class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
class_option :app, :desc => "The application destination path", :aliases => '-a', :default => "/app", :type => :string
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
argument :name, :desc => 'The name of your padrino mailer'
argument :actions, :desc => 'The delivery actions to add to your mailer', :type => :array, :default => []
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '/app', :type => :string
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean

# Show help if no argv given
require_arguments!
Expand All @@ -45,7 +45,7 @@ def create_mailer
template "templates/mailer.rb.tt", destination_root(app, 'mailers', "#{@mailer_basename}.rb")
empty_directory destination_root(app, 'views', 'mailers', @mailer_basename)
else
say "You are not at the root of a Padrino application! (config/boot.rb not found)"
say 'You are not at the root of a Padrino application! (config/boot.rb not found)'
end
end
end # Mailer
Expand Down
10 changes: 5 additions & 5 deletions padrino-gen/lib/padrino-gen/generators/migration.rb
Expand Up @@ -20,9 +20,9 @@ def self.banner; "padrino-gen migration [name] [fields]"; end

desc "Description:\n\n\tpadrino-gen migration generates a new migration file"

argument :name, :desc => "The name of your padrino migration"
argument :columns, :desc => "The columns for the migration", :type => :array, :default => []
class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
argument :name, :desc => 'The name of your padrino migration'
argument :columns, :desc => 'The columns for the migration', :type => :array, :default => []
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean

# Show help if no argv given
Expand All @@ -36,11 +36,11 @@ def create_migration
if include_component_module_for(:orm)
create_migration_file(name, name, columns)
else
say "<= You need an ORM adapter for run this generator. Sorry!"
say '<= You need an ORM adapter for run this generator. Sorry!'
raise SystemExit
end
else
say "You are not at the root of a Padrino application! (config/boot.rb not found)"
say 'You are not at the root of a Padrino application! (config/boot.rb not found)'
end
end
end # Migration
Expand Down
14 changes: 7 additions & 7 deletions padrino-gen/lib/padrino-gen/generators/model.rb
Expand Up @@ -20,12 +20,12 @@ def self.banner; "padrino-gen model [name] [fields]"; end

desc "Description:\n\n\tpadrino-gen model generates a new model and migration files"

argument :name, :desc => "The name of your padrino model"
argument :fields, :desc => "The fields for the model", :type => :array, :default => []
class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
class_option :app, :desc => "The application destination path", :aliases => '-a', :default => ".", :type => :string
argument :name, :desc => 'The name of your padrino model'
argument :fields, :desc => 'The fields for the model', :type => :array, :default => []
class_option :root, :desc => 'The root destination', :aliases => '-r', :default => '.', :type => :string
class_option :app, :desc => 'The application destination path', :aliases => '-a', :default => '.', :type => :string
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
class_option :skip_migration, :aliases => "-s", :default => false, :type => :boolean
class_option :skip_migration, :aliases => '-s', :default => false, :type => :boolean

# Show help if no argv given
require_arguments!
Expand All @@ -40,7 +40,7 @@ def create_model
check_app_existence(app)
self.behavior = :revoke if options[:destroy]
if invalids = invalid_fields(fields)
say "Invalid field name:", :red
say 'Invalid field name:', :red
say " #{invalids.join(", ")}"
return
end
Expand All @@ -54,7 +54,7 @@ def create_model
generate_model_test(name) if test?
create_model_migration(migration_name, name, fields) unless options[:skip_migration]
else
say "You are not at the root of a Padrino application! (config/boot.rb not found)"
say 'You are not at the root of a Padrino application! (config/boot.rb not found)'
end
end
end # Model
Expand Down

0 comments on commit d6afa8f

Please sign in to comment.