derail 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (44) hide show
  1. data/Gemfile +3 -0
  2. data/LICENSE +20 -0
  3. data/README.md +87 -0
  4. data/VERSION +1 -0
  5. data/app/helpers/activated_link_helper.rb +48 -0
  6. data/app/helpers/flashes_helper.rb +9 -0
  7. data/app/helpers/text_helper.rb +55 -0
  8. data/derail.gemspec +24 -0
  9. data/lib/derail.rb +15 -0
  10. data/lib/derail/core_ext/string.rb +11 -0
  11. data/lib/derail/engine.rb +3 -0
  12. data/lib/derail/generators.rb +46 -0
  13. data/lib/generators/derail/app/USAGE +1 -0
  14. data/lib/generators/derail/app/app_generator.rb +147 -0
  15. data/lib/generators/derail/app/bootstrap.rb +124 -0
  16. data/lib/generators/derail/devise/USAGE +1 -0
  17. data/lib/generators/derail/devise/devise_generator.rb +25 -0
  18. data/lib/generators/derail/devise/haml/USAGE +1 -0
  19. data/lib/generators/derail/devise/haml/haml_generator.rb +13 -0
  20. data/lib/templates/devise/haml/views/_footer.html.haml +32 -0
  21. data/lib/templates/devise/haml/views/confirmations/new.html.haml +15 -0
  22. data/lib/templates/devise/haml/views/mailer/confirmation_instructions.html.erb +5 -0
  23. data/lib/templates/devise/haml/views/mailer/reset_password_instructions.html.erb +8 -0
  24. data/lib/templates/devise/haml/views/mailer/unlock_instructions.html.erb +7 -0
  25. data/lib/templates/devise/haml/views/passwords/edit.html.haml +18 -0
  26. data/lib/templates/devise/haml/views/passwords/new.html.haml +15 -0
  27. data/lib/templates/devise/haml/views/registrations/edit.html.haml +33 -0
  28. data/lib/templates/devise/haml/views/registrations/new.html.haml +17 -0
  29. data/lib/templates/devise/haml/views/sessions/new.html.haml +18 -0
  30. data/lib/templates/devise/haml/views/unlocks/new.html.haml +15 -0
  31. data/lib/templates/haml/scaffold/_form.html.haml +8 -0
  32. data/lib/templates/haml/scaffold/edit.html.haml +8 -0
  33. data/lib/templates/haml/scaffold/index.html.haml +17 -0
  34. data/lib/templates/haml/scaffold/new.html.haml +7 -0
  35. data/lib/templates/haml/scaffold/show.html.haml +12 -0
  36. data/lib/templates/scaffold_controller/controller.rb +38 -0
  37. data/vendor/assets/javascripts/innershiv.js +2 -0
  38. data/vendor/assets/javascripts/jquery_autolink.js +7 -0
  39. data/vendor/assets/javascripts/jquery_highlight.js +7 -0
  40. data/vendor/assets/javascripts/jquery_innershiv.js +21 -0
  41. data/vendor/assets/javascripts/jquery_mailto.js +8 -0
  42. data/vendor/assets/javascripts/jquery_timeago.js +149 -0
  43. data/vendor/assets/javascripts/modernizr.js +1116 -0
  44. metadata +112 -0
@@ -0,0 +1,124 @@
1
+ # This gets read via HTTP as a single file then executed in the app
2
+ # generator instance, so everything needs to be bundled in here.
3
+
4
+ # TODO: Sprockets require to include library files or some fancy shiznit.
5
+
6
+ class ::String
7
+ def dedent
8
+ indent = lines.reject(&:empty?).map { |line| line.index(/\S/) }.compact.min
9
+ gsub /^ {1,#{indent.to_i}}/, ''
10
+ end unless method_defined? :dedent
11
+
12
+ def redent prefix
13
+ prefix = " " * prefix if prefix.is_a? Numeric
14
+ dedent.gsub! /^(?=[ \t]*\S+)/, prefix
15
+ end unless method_defined? :redent
16
+ end
17
+
18
+ # The intention here is to bootstrap far enough that we can run some
19
+ # of our own generators, but prevent bundling too many times.
20
+
21
+ in_root do
22
+ say_status :rewrite, "Gemfile"
23
+
24
+ puts "Derail running from: #{__FILE__}"
25
+ derail_gemfile_entry = "gem 'derail', :git => 'git://github.com/sj26/derail.git'"
26
+ unless __FILE__ =~ /^https?\:\/\//
27
+ derail_gemfile_entry = "gem 'derail', :path => '#{File.expand_path("../../../../../", __FILE__)}'"
28
+ end
29
+
30
+ inject_into_file "Gemfile", <<-RUBY.dedent, :after => rails_gemfile_entry, :verbose => false
31
+
32
+ # Rails extensions
33
+ #{derail_gemfile_entry}
34
+ RUBY
35
+
36
+ # Get rid of some noise (after rails entry used above)
37
+ gsub_file "Gemfile", /^(^#[^\n]*\n)#[ \t]*gem[^\n]*\n/, "", :verbose => false
38
+ gsub_file "Gemfile", /\n{3,}/, "\n\n", :verbose => false
39
+
40
+ if not options[:skip_active_record] and gem_for_database == "pg"
41
+ inject_into_file "Gemfile", "# PostgreSQL is for winners!\n", :before => "gem 'pg'", :verbose => false
42
+ inject_into_file "Gemfile", <<-RUBY.dedent, :after => database_gemfile_entry, :verbose => false
43
+ # Stop PostgreSQL being quite so chatty
44
+ gem 'silent-postgres'
45
+ RUBY
46
+ end
47
+
48
+ inject_into_file "Gemfile", <<-RUBY.rstrip.dedent, :after => "# Asset template engines", :verbose => false
49
+ and helpers
50
+ gem 'haml-rails'
51
+ RUBY
52
+
53
+ inject_into_file "Gemfile", <<-RUBY.dedent, :after => "gem 'sass-rails'.*?\n", :verbose => false
54
+ gem "compass", :git => "git://github.com/sj26/compass.git", :branch => "rails31"
55
+ RUBY
56
+
57
+ inject_into_file "Gemfile", <<-RUBY.dedent, :after => "gem 'coffee-script'.*?\n", :verbose => false
58
+ gem "therubyracer"
59
+ RUBY
60
+
61
+ # Cut the crap from the end
62
+ gsub_file "Gemfile", /# Use unicorn.*\Z/, "", :verbose => false
63
+
64
+ append_file "Gemfile", <<-RUBY.dedent, :verbose => false
65
+ # Views helpers
66
+ gem 'nestive', :git => 'git://github.com/sj26/nestive.git'
67
+ gem 'formtastic', '~> 2.0.0.rc2'
68
+
69
+ group :development, :test do
70
+ # Debugging everywhere
71
+ gem 'ruby-debug', :platform => :ruby_18
72
+ gem 'ruby-debug19', :platform => :ruby_19, :require => 'ruby-debug'
73
+
74
+ # Testing
75
+ gem 'rspec-rails'
76
+ gem 'rcov'
77
+ gem 'rr'
78
+ gem 'factory_girl', '~> 2.0.0.beta2'
79
+ gem 'ffaker'
80
+
81
+ # Acceptance testing
82
+ gem 'cucumber-rails'
83
+
84
+ # Continuous testing/building
85
+ gem 'guard'
86
+ gem 'guard-ego'
87
+ gem 'guard-bundler'
88
+ gem 'guard-rspec'
89
+ gem 'guard-cucumber'
90
+ end
91
+
92
+ group :test do
93
+ # Remarkable matchers for terse and expressive specs
94
+ gem 'remarkable', '>= 4.0.0.alpha'
95
+ gem 'remarkable_activerecord', '>= 4.0.0.alpha'
96
+ end
97
+
98
+ # When testing on the mac in guard...
99
+ group :test_mac do
100
+ # Growl for notifications
101
+ gem 'growl'
102
+
103
+ # FSEvent for efficient file monitoring in
104
+ gem 'rb-fsevent'
105
+ end
106
+ RUBY
107
+
108
+ # Write rvmrc
109
+ rvm_string = ENV["rvm_ruby_string"] || ""
110
+ rvm_string += "@#{ENV["rvm_gemset_name"]}" if ENV["rvm_gemset_name"].present?
111
+ if rvm_string.present?
112
+ create_file ".rvmrc", <<-RVMRC.dedent
113
+ rvm #{rvm_string} --create
114
+ RVMRC
115
+ end
116
+
117
+ run "rvm rvmrc trust ."
118
+
119
+ # We need to bundle before continuing
120
+ run_bundle
121
+
122
+ # Now we do some real work
123
+ generate "derail:app"
124
+ end
@@ -0,0 +1 @@
1
+ Create a devise model, copies views, installs top-level routes and adds application helpers.
@@ -0,0 +1,25 @@
1
+ module Derail::Generators
2
+ class DeviseGenerator < Base
3
+ def install_devise
4
+ inject_into_file "Gemfile", <<-RUBY.dedent, :before => "group :development"
5
+ # Authentication
6
+ # FIXME: Until at least controller inheritence is available
7
+ gem 'devise', :git => 'git://github.com/sj26/devise.git', :branch => 'template-inheritence'
8
+
9
+ RUBY
10
+
11
+ inject_into_file "Gemfile", <<-RUBY.redent(2), :after => /gem (['"])remarkable_activerecord\1[^\n]*\n/
12
+ gem 'remarkable_devise', :git => 'git://github.com/sj26/remarkable_devise.git'
13
+ RUBY
14
+
15
+ puts __FILE__, Dir.pwd, ENV.inspect
16
+ bundle "install"
17
+ end
18
+
19
+ def generate_devise
20
+ generate "devise:install"
21
+ generate "devise", "user"
22
+ generate "derail:devise:haml";
23
+ end
24
+ end
25
+ end
@@ -0,0 +1 @@
1
+ Copies HAML/HTML5/Formtastic Devise views to your application.
@@ -0,0 +1,13 @@
1
+ module Derail
2
+ module Generators
3
+ module Devise
4
+ class HamlGenerator < Rails::Generators::Base
5
+ source_root File.expand_path("../../../../../templates/devise/haml", __FILE__)
6
+
7
+ def copy_views
8
+ directory "views", "app/views/devise"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,32 @@
1
+ %nav>
2
+ %ul<>
3
+ - if controller_name != 'sessions'
4
+ %li<>
5
+ = link_to new_session_path(resource_name) do
6
+ = t 'devise.footer.sessions.new.title', :default => "Sign in"
7
+
8
+ - if devise_mapping.registerable? && controller_name != 'registrations'
9
+ %li<>
10
+ = link_to new_registration_path(resource_name) do
11
+ = t 'devise.footer.registrations.new.title', :default => "Sign up"
12
+
13
+ - if devise_mapping.recoverable? && controller_name != 'passwords'
14
+ %li<>
15
+ = link_to new_password_path(resource_name) do
16
+ = t 'devise.footer.passwords.new.title', :default => "Forgot your password?"
17
+
18
+ - if devise_mapping.confirmable? && controller_name != 'confirmations'
19
+ %li<>
20
+ = link_to new_confirmation_path(resource_name) do
21
+ = t 'devise.footer.confirmations.new.title', :default => "Didn't receive confirmation instructions?"
22
+
23
+ - if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks'
24
+ %li<>
25
+ = link_to new_unlock_path(resource_name) do
26
+ = t 'devise.footer.unlocks.new.title', "Didn't receive unlock instructions?"
27
+
28
+ - if devise_mapping.omniauthable?
29
+ - resource_class.omniauth_providers.each do |provider|
30
+ %li<>
31
+ = link_to omniauth_authorize_path(resource_name, provider) do
32
+ = t "devise.footer.omniauth_authorize.#{provider}.title", "Sign in with #{provider.to_s.titleize}"
@@ -0,0 +1,15 @@
1
+ %section.devise-confirmations.new
2
+ %header.devise-confirmations.new
3
+ %h1= t 'devise.confirmations.new.title', :default => "Resend confirmation instructions"
4
+
5
+ = semantic_form_for resource, :as => resource_name, :url => confirmation_path(resource_name), :html => { :method => :post } do |form|
6
+ = devise_error_messages!
7
+
8
+ = form.inputs do
9
+ = form.input :email
10
+
11
+ = form.buttons do
12
+ = form.commit_button "Resend confirmation instructions"
13
+
14
+ %footer.devise-confirmations.new
15
+ = render :partial => "footer"
@@ -0,0 +1,5 @@
1
+ <p>Welcome <%= @resource.email %>!</p>
2
+
3
+ <p>You can confirm your account through the link below:</p>
4
+
5
+ <p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
@@ -0,0 +1,8 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Someone has requested a link to change your password, and you can do this through the link below.</p>
4
+
5
+ <p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
6
+
7
+ <p>If you didn't request this, please ignore this email.</p>
8
+ <p>Your password won't change until you access the link above and create a new one.</p>
@@ -0,0 +1,7 @@
1
+ <p>Hello <%= @resource.email %>!</p>
2
+
3
+ <p>Your account has been locked due to an excessive amount of unsuccessful sign in attempts.</p>
4
+
5
+ <p>Click the link below to unlock your account:</p>
6
+
7
+ <p><%= link_to 'Unlock my account', unlock_url(@resource, :unlock_token => @resource.unlock_token) %></p>
@@ -0,0 +1,18 @@
1
+ %section.devise-passwords.edit
2
+ %header.devise-passwords.edit
3
+ %h1= t 'devise.passwords.edit.title', :default => "Change your password"
4
+
5
+ = semantic_form_for resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :put } do |form|
6
+ = devise_error_messages!
7
+
8
+ = form.hidden_field :reset_password_token
9
+
10
+ = form.inputs do
11
+ = form.input :password, :label => "New password"
12
+ = form.input :password_confirmation, :label => "Confirm new password"
13
+
14
+ = form.buttons do
15
+ = form.commit_button "Change my password"
16
+
17
+ %footer
18
+ = render :partial => "footer"
@@ -0,0 +1,15 @@
1
+ %section.devise-passwords.new
2
+ %header.devise-passwords.new
3
+ %h1= t 'devise.passwords.new.title', :default => "Forgot your password?"
4
+
5
+ = semantic_form_for resource, :as => resource_name, :url => password_path(resource_name), :html => { :method => :post } do |form|
6
+ = devise_error_messages!
7
+
8
+ = form.inputs do
9
+ = form.input :email
10
+
11
+ = form.buttons do
12
+ = form.commit_button "Send me reset password instructions"
13
+
14
+ %footer
15
+ = render :partial => "footer"
@@ -0,0 +1,33 @@
1
+ %section.devise-registrations.edit
2
+ %header.devise-registrations.edit
3
+ %h1= t 'devise.registrations.edit.title', :default => "Edit #{resource_name.to_s.humanize}"
4
+
5
+ = semantic_form_for resource, :as => resource_name, :url => registration_path(resource_name), :html => { :method => :put } do |form|
6
+ = devise_error_messages!
7
+
8
+ = form.hidden_field :reset_password_token
9
+
10
+ = form.inputs do
11
+ = form.input :email
12
+ = form.input :password, :hint => "leave blank if you don't want to change it"
13
+ = form.input :password_confirmation
14
+ = form.input :current_password, :hint => "we need your current password to confirm your changes"
15
+
16
+ = form.buttons do
17
+ = form.commit_button "Update"
18
+
19
+ %aside.devise-registrations.destroy
20
+ %header.devise-registrations.destroy
21
+ %h1= t 'devise.registrations.cancel.title', :default => "Cancel my account"
22
+
23
+ %p
24
+ = t 'devise.registrations.cancel.intro', :default => "Unhappy?"
25
+ = link_to registration_path(resource_name), :confirm => "Are you sure?", :method => :delete do
26
+ = t 'devise.registrations.cancel.link_title', :default => "Cancel my account"
27
+
28
+ %footer.devise-registrations.edit
29
+ %nav>
30
+ %ul<>
31
+ %li<>
32
+ = link_to :back do
33
+ = t 'devise.registrations.edit.back', "Back"
@@ -0,0 +1,17 @@
1
+ %section.devise-registrations.new
2
+ %header.devise-registrations.new
3
+ %h1= t 'devise.registrations.new.title', :default => "Sign Up"
4
+
5
+ = semantic_form_for resource, :as => resource_name, :url => registration_path(resource_name) do |form|
6
+ = devise_error_messages!
7
+
8
+ = form.inputs do
9
+ = form.input :email
10
+ = form.input :password
11
+ = form.input :password_confirmation
12
+
13
+ = form.buttons do
14
+ = form.commit_button "Sign up"
15
+
16
+ %footer.devise-registrations.new
17
+ = render 'footer'
@@ -0,0 +1,18 @@
1
+ %section.devise-sessions.new
2
+ %header.devise-sessions.new
3
+ %h1= t 'devise.sessions.new.title', :default => "Sign In"
4
+
5
+ = semantic_form_for resource, :as => resource_name, :url => session_path(resource_name) do |form|
6
+ = devise_error_messages!
7
+
8
+ = form.inputs do
9
+ = form.input :email
10
+ = form.input :password
11
+ - if devise_mapping.rememberable?
12
+ = form.input :remember_me, :as => :boolean
13
+
14
+ = form.buttons do
15
+ = form.commit_button "Sign in"
16
+
17
+ %footer.devise-sessions.new
18
+ = render 'footer'
@@ -0,0 +1,15 @@
1
+ %section.devise-unlocks.new
2
+ %header.devise-unlocks.new
3
+ %h1= t 'devise.unlocks.new.title', :default => "Resend unlock instructions"
4
+
5
+ = semantic_form_for resource, :as => resource_name, :url => session_path(resource_name) do |form|
6
+ = devise_error_messages!
7
+
8
+ = form.inputs do
9
+ = form.input :email
10
+
11
+ = form.buttons do
12
+ = form.commit_button "Resend unlock instructions"
13
+
14
+ %footer.devise-unlocks.new
15
+ = render 'footer'
@@ -0,0 +1,8 @@
1
+ = semantic_form_for @<%= singular_table_name %> do |form|
2
+ = form.inputs do
3
+ <%- attributes.each do |attribute| %>
4
+ = form.input :<%= attribute.name %>
5
+ <%- end %>
6
+
7
+ = form.buttons do
8
+ = form.commit_button
@@ -0,0 +1,8 @@
1
+ - replace :title, "Edit #{@<%= singular_table_name %>}"
2
+ %article.<%= singular_table_name %>.new
3
+ = render "form"
4
+ %footer.<%= singular_table_name %>
5
+ %nav>
6
+ %ul<>
7
+ %li.show<>= link_to "Show", <%= singular_table_name %>_path(@<%= singular_table_name %>), :class => "button"
8
+ %li.destroy<>= link_to "Destroy", <%= singular_table_name %>_path(@<%= singular_table_name %>), :method => "delete", :confirm => "Are you sure?", :class => "danger button"
@@ -0,0 +1,17 @@
1
+ - replace :title, "<%= plural_name.humanize %>"
2
+
3
+ %section.<%= plural_table_name %>
4
+ - @<%= plural_table_name %>.each do |<%= singular_table_name %>|
5
+ %article.<%= singular_table_name %>
6
+ %header.<%= singular_table_name %>
7
+ %h1= <%= singular_table_name %>.name
8
+ %footer.<%= singular_table_name %>
9
+ %nav
10
+ %ul
11
+ %li.edit<>= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>), :class => "button"
12
+ %li.destroy<>= link_to 'Destroy', <%= singular_table_name %>, :confirm => 'Are you sure?', :method => :delete, :class => "danger button"
13
+
14
+ %footer.<%= singular_table_name %>
15
+ %nav>
16
+ %ul<>
17
+ %li.new<>= link_to 'New <%= human_name %>', new_<%= singular_table_name %>_path, :class => "button"
@@ -0,0 +1,7 @@
1
+ - replace :title, "New <%= human_name %>"
2
+ %article.<%= singular_table_name %>.new
3
+ = render "form"
4
+ %footer.<%= singular_table_name %>
5
+ %nav>
6
+ %ul<>
7
+ %li.index<>= link_to "Back", <%= plural_table_name %>_path, :class => "button"
@@ -0,0 +1,12 @@
1
+ - replace :title, @<%= singular_table_name %>
2
+ %article.<%= singular_table_name %>
3
+ %header.<%= singular_table_name %>
4
+ %h1= @<%= singular_table_name %>
5
+ <% attributes.reject { |attribute| [:updated_at, :created_at].include? attribute }.each do |attribute| -%>
6
+ .<%= attribute.name %>= @<%= singular_table_name %>.<%= attribute.name %>
7
+ <% end -%>
8
+ %footer
9
+ %nav>
10
+ %ul<>
11
+ %li.edit<>= link_to "Edit", edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), :class => "button"
12
+ %li.destroy<>= link_to "Destroy", <%= singular_table_name %>_path(@<%= singular_table_name %>), :method => "delete", :confirm => "Are you sure?", :class => "danger button"
@@ -0,0 +1,38 @@
1
+ <%= module_namespacing do %>
2
+ class <%= controller_name %> < ApplicationController
3
+ respond_to :html
4
+
5
+ before_filter :find_<%= singular_table_name %>, :only => [:show, :edit, :update, :destroy]
6
+
7
+ def index
8
+ respond_with @<%= plural_table_name %> = <%= orm_class.all(class_name) %>
9
+ end
10
+
11
+ def new
12
+ respond_with @<%= singular_table_name %> = <%= class_name %>.new
13
+ end
14
+
15
+ def create
16
+ respond_with @<%= singular_table_name %>
17
+ end
18
+
19
+ def edit
20
+ respond_with @<%= singular_table_name %>
21
+ end
22
+
23
+ def update
24
+ respond_with @<%= singular_table_name %>
25
+ end
26
+
27
+ def destroy
28
+ @<%= singular_table_name %>.destroy
29
+ respond_with @<%= singular_table_name %>
30
+ end
31
+
32
+ protected
33
+
34
+ def find_<%= singular_table_name %>
35
+ @<%= singular_table_name %> = <%= class_name %>.find params[:id]
36
+ end
37
+ end
38
+ <% end %>