mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Remove --haml and --slim views from Devise.
This commit is contained in:
parent
bbafb70655
commit
3109b0924b
2 changed files with 5 additions and 85 deletions
|
@ -1,5 +1,4 @@
|
||||||
* enhancements
|
* enhancements
|
||||||
* rails g devise:views supports slim templates (by github.com/fredwu)
|
|
||||||
* Make friendly_token 20 chars long
|
* Make friendly_token 20 chars long
|
||||||
|
|
||||||
* bug fix
|
* bug fix
|
||||||
|
@ -13,6 +12,7 @@
|
||||||
|
|
||||||
* deprecations
|
* deprecations
|
||||||
* Deprecated anybody_signed_in? in favor of signed_in? (by github.com/gavinhughes)
|
* Deprecated anybody_signed_in? in favor of signed_in? (by github.com/gavinhughes)
|
||||||
|
* Removed --haml and --slim view templates
|
||||||
|
|
||||||
== 1.2.rc
|
== 1.2.rc
|
||||||
|
|
||||||
|
|
|
@ -13,94 +13,14 @@ module Devise
|
||||||
:desc => "Template engine for the views. Available options are 'erb', 'haml' and 'slim'."
|
:desc => "Template engine for the views. Available options are 'erb', 'haml' and 'slim'."
|
||||||
|
|
||||||
def copy_views
|
def copy_views
|
||||||
case options[:template_engine].to_s
|
template = options[:template_engine].to_s
|
||||||
when "haml"
|
case template
|
||||||
verify_haml_existence
|
when "haml", "slim"
|
||||||
verify_haml_version
|
warn "#{template} templates have been removed from Devise gem"
|
||||||
create_and_copy_haml_views
|
|
||||||
when "slim"
|
|
||||||
verify_haml_existence
|
|
||||||
verify_haml_version
|
|
||||||
verify_haml2slim_existence
|
|
||||||
verify_haml2slim_version
|
|
||||||
create_and_copy_slim_views
|
|
||||||
else
|
else
|
||||||
directory "devise", "app/views/#{scope || :devise}"
|
directory "devise", "app/views/#{scope || :devise}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
|
||||||
|
|
||||||
def verify_haml_existence
|
|
||||||
begin
|
|
||||||
require 'haml'
|
|
||||||
rescue LoadError
|
|
||||||
say "Haml is not installed, or it is not specified in your Gemfile."
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def verify_haml2slim_existence
|
|
||||||
begin
|
|
||||||
require 'haml2slim'
|
|
||||||
rescue LoadError
|
|
||||||
say "Haml2Slim is not installed, or it is not specified in your Gemfile."
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def verify_haml_version
|
|
||||||
unless Haml.version[:major] == 2 && Haml.version[:minor] >= 3 || Haml.version[:major] >= 3
|
|
||||||
say "To generate Haml or Slim templates, you need to have Haml 2.3 or above installed."
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def verify_haml2slim_version
|
|
||||||
unless Haml2Slim::VERSION.to_f >= '0.4.0'.to_f
|
|
||||||
say "To generate Slim templates, you need to have Haml2Slim 0.4.0 or above installed."
|
|
||||||
exit
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_and_copy_haml_views
|
|
||||||
directory haml_tmp_root, "app/views/#{scope || :devise}"
|
|
||||||
FileUtils.rm_rf(haml_tmp_root)
|
|
||||||
end
|
|
||||||
|
|
||||||
def create_and_copy_slim_views
|
|
||||||
slim_tmp_root = Dir.mktmpdir("devise-slim.")
|
|
||||||
`haml2slim #{haml_tmp_root} #{slim_tmp_root}`
|
|
||||||
|
|
||||||
directory slim_tmp_root, "app/views/#{scope || :devise}"
|
|
||||||
|
|
||||||
FileUtils.rm_rf(haml_tmp_root)
|
|
||||||
FileUtils.rm_rf(slim_tmp_root)
|
|
||||||
end
|
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def create_haml_views
|
|
||||||
@haml_tmp_root ||= begin
|
|
||||||
html_root = "#{self.class.source_root}/devise"
|
|
||||||
haml_tmp_root = Dir.mktmpdir("devise-haml.")
|
|
||||||
|
|
||||||
Dir["#{html_root}/**/*"].each do |path|
|
|
||||||
relative_path = path.sub(html_root, "")
|
|
||||||
source_path = (haml_tmp_root + relative_path).sub(/erb$/, "haml")
|
|
||||||
|
|
||||||
if File.directory?(path)
|
|
||||||
FileUtils.mkdir_p(source_path)
|
|
||||||
else
|
|
||||||
`html2haml -r #{path} #{source_path}`
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
haml_tmp_root
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
alias :haml_tmp_root :create_haml_views
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue