happy_seed 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.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/Rakefile +32 -0
- data/bin/happy_seed +7 -0
- data/happy_seed.rb +45 -0
- data/lib/generators/happy_seed/.DS_Store +0 -0
- data/lib/generators/happy_seed/bootstrap/bootstrap_generator.rb +31 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/assets/javascripts/application.js +15 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/application/index.css.scss +7 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/assets/stylesheets/application/variables.css.scss +12 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/helpers/application_helper.rb +19 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_chromeframe.html.haml +4 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_flashes.html.haml +8 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_footer.html.haml +8 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_head.html.haml +13 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_header.html.haml +16 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_javascripts.html.haml +12 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_stylesheets.html.haml +4 -0
- data/lib/generators/happy_seed/bootstrap/templates/app/views/layouts/application.html.haml +16 -0
- data/lib/generators/happy_seed/bootstrap/templates/docs/README.01.bootstrap.rdoc +31 -0
- data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/_form.html.haml +19 -0
- data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/edit.html.haml +10 -0
- data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/index.html.haml +26 -0
- data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/new.html.haml +8 -0
- data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/show.html.haml +15 -0
- data/lib/generators/happy_seed/bootstrap/templates/lib/templates/rails/.DS_Store +0 -0
- data/lib/generators/happy_seed/bootstrap/templates/lib/templates/rails/scaffold_controller/controller.rb +54 -0
- data/lib/generators/happy_seed/devise/devise_generator.rb +37 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/passwords/edit.html.haml +31 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/passwords/new.html.haml +27 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/registrations/new.html.haml +34 -0
- data/lib/generators/happy_seed/devise/templates/app/views/devise/sessions/new.html.haml +38 -0
- data/lib/generators/happy_seed/devise/templates/docs/README.03.devise.rdoc +24 -0
- data/lib/generators/happy_seed/facebook/facebook_generator.rb +50 -0
- data/lib/generators/happy_seed/facebook/templates/docs/README.06.facebook.rdoc +24 -0
- data/lib/generators/happy_seed/foreman/foreman_generator.rb +27 -0
- data/lib/generators/happy_seed/foreman/templates/.env +5 -0
- data/lib/generators/happy_seed/foreman/templates/.foreman +1 -0
- data/lib/generators/happy_seed/foreman/templates/Procfile +1 -0
- data/lib/generators/happy_seed/foreman/templates/app/controllers/.DS_Store +0 -0
- data/lib/generators/happy_seed/foreman/templates/app/controllers/setup_controller.rb +29 -0
- data/lib/generators/happy_seed/foreman/templates/app/views/setup/index.html.haml +31 -0
- data/lib/generators/happy_seed/foreman/templates/application_controller.rb +10 -0
- data/lib/generators/happy_seed/foreman/templates/config/unicorn.rb +33 -0
- data/lib/generators/happy_seed/foreman/templates/docs/README.00.base.rdoc +34 -0
- data/lib/generators/happy_seed/omniauth/omniauth_generator.rb +48 -0
- data/lib/generators/happy_seed/omniauth/templates/app/controllers/omniauth_callbacks_controller.rb +29 -0
- data/lib/generators/happy_seed/omniauth/templates/app/models/identity.rb +11 -0
- data/lib/generators/happy_seed/omniauth/templates/docs/README.04.omniauth.rdoc +27 -0
- data/lib/generators/happy_seed/omniauth/templates/user.rb +51 -0
- data/lib/generators/happy_seed/splash/splash_generator.rb +44 -0
- data/lib/generators/happy_seed/splash/templates/app/controllers/splash_controller.rb +55 -0
- data/lib/generators/happy_seed/splash/templates/app/views/layouts/splash.html.haml +14 -0
- data/lib/generators/happy_seed/splash/templates/app/views/splash/_environment_checks.html.haml +45 -0
- data/lib/generators/happy_seed/splash/templates/app/views/splash/index.html.haml +23 -0
- data/lib/generators/happy_seed/splash/templates/app/views/splash/signup.js.erb +8 -0
- data/lib/generators/happy_seed/splash/templates/docs/README.02.splash.rdoc +29 -0
- data/lib/generators/happy_seed/twitter/.DS_Store +0 -0
- data/lib/generators/happy_seed/twitter/templates/docs/README.05.twitter.rdoc +24 -0
- data/lib/generators/happy_seed/twitter/twitter_generator.rb +50 -0
- data/lib/generators/seed/bootstrap/templates/lib/templates/rails/.DS_Store +0 -0
- data/lib/happy_seed.rb +2 -0
- data/lib/happy_seed/version.rb +3 -0
- data/lib/tasks/seed_tasks.rake +4 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +13 -0
- data/test/dummy/app/assets/stylesheets/application.css +15 -0
- data/test/dummy/app/controllers/application_controller.rb +5 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/views/layouts/application.html.erb +14 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +23 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +37 -0
- data/test/dummy/config/environments/production.rb +82 -0
- data/test/dummy/config/environments/test.rb +39 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +56 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/test.log +10 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/seed_test.rb +7 -0
- data/test/test_helper.rb +15 -0
- metadata +213 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c649d741ca69ce898a76ec5c40db6468dfcf79f4
|
4
|
+
data.tar.gz: 54628084f1500db87ba92088d38da4f735607bad
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dfa39ba5c3e063d12a083238113502803a641c6af935bbdc72f61d02a8ec611fcc33d75b514cc52506a29bae140978da0e41b976b6aa7b245c7fede95dfc7edb
|
7
|
+
data.tar.gz: 95a4f08dbff007c8c50e87ce105b6219b261a03f95b6fa1f2e92f206237905defb54a42b80feb137ce82e440d08a394592b7baa162dae2be35b9b8a7e4862254
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
require 'rdoc/task'
|
8
|
+
|
9
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
10
|
+
rdoc.rdoc_dir = 'rdoc'
|
11
|
+
rdoc.title = 'HappySeed'
|
12
|
+
rdoc.options << '--line-numbers'
|
13
|
+
rdoc.rdoc_files.include('README.rdoc')
|
14
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
15
|
+
end
|
16
|
+
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
Bundler::GemHelper.install_tasks
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
|
24
|
+
Rake::TestTask.new(:test) do |t|
|
25
|
+
t.libs << 'lib'
|
26
|
+
t.libs << 'test'
|
27
|
+
t.pattern = 'test/**/*_test.rb'
|
28
|
+
t.verbose = false
|
29
|
+
end
|
30
|
+
|
31
|
+
|
32
|
+
task default: :test
|
data/bin/happy_seed
ADDED
data/happy_seed.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
gem 'haml-rails'
|
2
|
+
gem 'meta-tags', :require => 'meta_tags'
|
3
|
+
if ENV['SEED_DEVELOPMENT']
|
4
|
+
gem 'happy_seed', :path => File.dirname(__FILE__)
|
5
|
+
else
|
6
|
+
gem 'happy_seed'
|
7
|
+
end
|
8
|
+
gsub_file "Gemfile", /^#\s*Turbolinks.*$/,'# No one likes Turbolinks.'
|
9
|
+
gsub_file "Gemfile", /^gem\s+["']turbolinks["'].*$/,'# gem \'turbolinks\''
|
10
|
+
#gsub_file "Gemfile", /^gem\s+["']spring["'].*$/,'# gem \'spring\''
|
11
|
+
|
12
|
+
run 'bundle install'
|
13
|
+
|
14
|
+
gsub_file "app/assets/javascripts/application.js", /= require turbolinks/, "require turbolinks"
|
15
|
+
|
16
|
+
# Run the base generator
|
17
|
+
generate "happy_seed:foreman"
|
18
|
+
|
19
|
+
if yes? "Would you like to install bootstrap?"
|
20
|
+
generate "happy_seed:bootstrap"
|
21
|
+
|
22
|
+
if yes? "Would you like to install splash page?"
|
23
|
+
generate "happy_seed:splash"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if yes? "Would you like to install devise?"
|
28
|
+
generate "happy_seed:devise"
|
29
|
+
|
30
|
+
if yes? "Would you like to install twitter?"
|
31
|
+
generate "happy_seed:twitter"
|
32
|
+
end
|
33
|
+
|
34
|
+
if yes? "Would you like to install facebook connect?"
|
35
|
+
generate "happy_seed:facebook"
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
if yes? "Would you like to install active admin?"
|
40
|
+
generate "happy_seed:admin"
|
41
|
+
end
|
42
|
+
|
43
|
+
puts "Setting up git"
|
44
|
+
git :init
|
45
|
+
|
Binary file
|
@@ -0,0 +1,31 @@
|
|
1
|
+
module HappySeed
|
2
|
+
module Generators
|
3
|
+
class BootstrapGenerator < Rails::Generators::Base
|
4
|
+
source_root File.expand_path('../templates', __FILE__)
|
5
|
+
|
6
|
+
def update_application_haml
|
7
|
+
gem 'bootstrap-sass'
|
8
|
+
gem 'modernizr-rails'
|
9
|
+
|
10
|
+
Bundler.with_clean_env do
|
11
|
+
run "bundle install"
|
12
|
+
end
|
13
|
+
|
14
|
+
remove_file 'app/views/layouts/application.html.erb'
|
15
|
+
remove_file 'app/assets/javascripts/application.js'
|
16
|
+
remove_file 'app/helpers/application_helper.rb'
|
17
|
+
directory 'app'
|
18
|
+
directory 'lib'
|
19
|
+
directory 'docs'
|
20
|
+
|
21
|
+
inject_into_file 'config/application.rb', before: "end\nend\n" do <<-'RUBY'
|
22
|
+
config.generators do |g|
|
23
|
+
g.stylesheets = false
|
24
|
+
end
|
25
|
+
RUBY
|
26
|
+
end
|
27
|
+
append_to_file ".env", "GOOGLE_ANALYTICS_SITE_ID=\n"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
//= require jquery
|
14
|
+
//= require jquery_ujs
|
15
|
+
//= require bootstrap-sprockets
|
@@ -0,0 +1,12 @@
|
|
1
|
+
@import url(http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,700,300,600);
|
2
|
+
|
3
|
+
$font-family-sans-serif: 'Open Sans', "Helvetica Neue", Helvetica, Arial, sans-serif;
|
4
|
+
|
5
|
+
// $brand-primary: #ff6000;
|
6
|
+
// $body-bg: #747474;
|
7
|
+
// $text-color: #d7d7d7;
|
8
|
+
|
9
|
+
// $panel-bg: rgba(16,16,16,0.8);
|
10
|
+
// $panel-default-border: #000;
|
11
|
+
// $panel-default-heading-bg: rgba(64,64,64,0.8);
|
12
|
+
// $panel-default-text: #fff;
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ApplicationHelper
|
2
|
+
def flash_class(level)
|
3
|
+
case level.to_sym
|
4
|
+
when :notice then "alert alert-info"
|
5
|
+
when :success then "alert alert-success"
|
6
|
+
when :alert then "alert alert-warning"
|
7
|
+
when :error then "alert alert-danger"
|
8
|
+
else "alert-danger alert"
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def error_for( model_class, attribute, err_class )
|
13
|
+
if model_class.errors[attribute].size > 0
|
14
|
+
err_class
|
15
|
+
else
|
16
|
+
nil
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_chromeframe.html.haml
ADDED
@@ -0,0 +1,4 @@
|
|
1
|
+
/[if lt IE 7 ]
|
2
|
+
%p.chromeframe
|
3
|
+
You are using an <strong>outdated</strong> browser.
|
4
|
+
Please <a href="http://browsehappy.com/">upgrade your browser</a> or <a href="http://www.google.com/chromeframe/?redirect=true">activate Google Chrome Frame</a> to improve your experience.
|
@@ -0,0 +1,8 @@
|
|
1
|
+
- if !flash.empty?
|
2
|
+
#flash
|
3
|
+
- flash.each do |key, value|
|
4
|
+
%div{ :title => key.to_s.humanize, :class => flash_class(key), :role => "alert" }
|
5
|
+
%button.close{ "type" => "button", "data-dismiss" => "alert"}
|
6
|
+
%span{ "aria-hidden" => "true" } ×
|
7
|
+
%span{ "class" => "sr-only" } Close
|
8
|
+
%p= value
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%head
|
2
|
+
%meta{ :charset => 'utf-8' }/
|
3
|
+
%meta{ 'http-equiv' => 'X-UA-Compatible', :content => 'IE=edge,chrome=1' }/
|
4
|
+
|
5
|
+
= display_meta_tags :site => 'New'
|
6
|
+
|
7
|
+
%meta{ :name => 'description', :content => '' }/
|
8
|
+
%meta{ :name => 'viewport', :content => 'width=device-width' }/
|
9
|
+
|
10
|
+
= render 'stylesheets'
|
11
|
+
= javascript_include_tag 'modernizr'
|
12
|
+
|
13
|
+
= csrf_meta_tag
|
@@ -0,0 +1,16 @@
|
|
1
|
+
%header#top.navbar{:role=>:banner}
|
2
|
+
.container
|
3
|
+
.navbar-header
|
4
|
+
%button.navbar-toggle{:type=>:button, 'data-toggle'=>:collapse, 'data-target'=>'.navbar-collapse'}
|
5
|
+
%span.sr-only Toggle navigations
|
6
|
+
%span.icon-bar
|
7
|
+
%span.icon-bar
|
8
|
+
%span.icon-bar
|
9
|
+
= link_to root_path, :class=>'navbar-brand' do
|
10
|
+
%span.glyphicon.glyphicon-cloud
|
11
|
+
App name
|
12
|
+
%nav.collapse.navbar-collapse{:role=>:navigation}
|
13
|
+
%ul.nav.navbar-nav
|
14
|
+
%li= link_to 'Contact', '#'
|
15
|
+
%li= link_to 'Blog', '#'
|
16
|
+
/ USER NAV
|
data/lib/generators/happy_seed/bootstrap/templates/app/views/application/_javascripts.html.haml
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
= javascript_include_tag 'application'
|
2
|
+
|
3
|
+
-# Append your own using content_for :javascripts
|
4
|
+
= yield :javascripts
|
5
|
+
|
6
|
+
-# Google Analytics
|
7
|
+
- if !ENV['GOOGLE_ANALYTICS_SITE_ID'].blank?
|
8
|
+
:javascript
|
9
|
+
var _gaq=[['_setAccount','#{ ENV['GOOGLE_ANALYTICS_SITE_ID'] }'],['_trackPageview']];
|
10
|
+
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];
|
11
|
+
g.src=('https:'==location.protocol?'//ssl':'//www')+'.google-analytics.com/ga.js';
|
12
|
+
s.parentNode.insertBefore(g,s)}(document,'script'));
|
@@ -0,0 +1,16 @@
|
|
1
|
+
!!! 5
|
2
|
+
%html.no-js
|
3
|
+
= render 'head'
|
4
|
+
|
5
|
+
%body{ :class => "#{ controller.controller_name }" }
|
6
|
+
= render 'chromeframe'
|
7
|
+
.container
|
8
|
+
= render 'header'
|
9
|
+
= render 'flashes'
|
10
|
+
|
11
|
+
= yield
|
12
|
+
|
13
|
+
= render 'footer'
|
14
|
+
|
15
|
+
-# Javascript at the bottom for fast page loading
|
16
|
+
= render 'javascripts'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
HappySeed Bootstrap Install
|
2
|
+
======================
|
3
|
+
|
4
|
+
### What does this do?
|
5
|
+
|
6
|
+
The happy_seed bootstrap generator
|
7
|
+
|
8
|
+
* Installs bootstrap-sass
|
9
|
+
* Installs modernizr-rails
|
10
|
+
* Organizes the app/assets directory
|
11
|
+
* Organizes the app/views/layouts and app/views/application directories
|
12
|
+
* Sets up some application_helper methods to make working with forms easier
|
13
|
+
* Sets up an application layout with flash notice support, etc.
|
14
|
+
* Updates the rails scaffolding template to use bootstrap style forms.
|
15
|
+
* Turns off scaffolding stylesheet generation.
|
16
|
+
|
17
|
+
### Why do you want this?
|
18
|
+
|
19
|
+
Bootstrap should be the base of all our projects going forward. This creates a variables.css.scss where you can configure bootstrap to your needs, and you can put the custom css stuff after that.
|
20
|
+
|
21
|
+
Better scaffolding means that it's easier to just whip up things to get started. While you will obviously eventually rewrite all of this code, it's good to have working stuff to start with that doesn't look painful.
|
22
|
+
|
23
|
+
### Environment Variables
|
24
|
+
|
25
|
+
```
|
26
|
+
GOOGLE_ANALYTICS_SITE_ID=
|
27
|
+
```
|
28
|
+
|
29
|
+
### What needs to be done?
|
30
|
+
|
31
|
+
Signup for google analytics and setup the site id.
|
data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/_form.html.haml
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= form_for @<%= singular_table_name %>, :html => { :class => "form-horizontal" } do |f|
|
2
|
+
-if @<%= singular_table_name %>.errors.any?
|
3
|
+
.alert.alert-danger.alert-dismissable
|
4
|
+
%button.close{"aria-hidden" => "true", "data-dismiss" => "alert", :type => "button"} ×
|
5
|
+
%h4= "#{pluralize(@<%= singular_table_name %>.errors.count, "error")} prohibited this <%= singular_table_name %> from being saved:"
|
6
|
+
|
7
|
+
%ul
|
8
|
+
- @<%= singular_table_name %>.errors.full_messages.each do |msg|
|
9
|
+
%li= msg
|
10
|
+
|
11
|
+
<% for attribute in attributes -%>
|
12
|
+
.form-group{ :class => error_for( @<%= singular_table_name %>, :<%= attribute.name %>, "has-error" ) }
|
13
|
+
= f.label :<%= attribute.name %>, :class => 'col-sm-2 control-label'
|
14
|
+
.col-sm-10
|
15
|
+
= f.<%= attribute.field_type %> :<%= attribute.name %>, :class => 'form-control'
|
16
|
+
<% end -%>
|
17
|
+
.form-group
|
18
|
+
.col-sm-offset-2.col-sm-10
|
19
|
+
= f.submit :class => 'btn btn-primary'
|
@@ -0,0 +1,10 @@
|
|
1
|
+
.page-header
|
2
|
+
= link_to <%= index_helper %>_path, :class => 'btn btn-default' do
|
3
|
+
%span.glyphicon.glyphicon-list-alt
|
4
|
+
Back
|
5
|
+
= link_to @<%= singular_table_name %>, :class => 'btn btn-primary' do
|
6
|
+
%span.glyphicon.glyphicon-info-sign
|
7
|
+
Show
|
8
|
+
%h1 Editing <%= singular_table_name %>
|
9
|
+
|
10
|
+
= render 'form'
|
data/lib/generators/happy_seed/bootstrap/templates/lib/templates/haml/scaffold/index.html.haml
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
.page-header
|
2
|
+
= link_to new_<%= singular_table_name %>_path, :class => 'btn btn-primary' do
|
3
|
+
%span.glyphicon.glyphicon-plus
|
4
|
+
New <%= human_name %>
|
5
|
+
%h1 Listing <%= plural_table_name %>
|
6
|
+
|
7
|
+
.table-responsive
|
8
|
+
%table.table.table-striped.table-bordered.table-hover
|
9
|
+
%thead
|
10
|
+
%tr
|
11
|
+
<% for attribute in attributes -%>
|
12
|
+
%th <%= attribute.human_name %>
|
13
|
+
<% end -%>
|
14
|
+
%th
|
15
|
+
%th
|
16
|
+
%th
|
17
|
+
|
18
|
+
%tbody
|
19
|
+
- @<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
20
|
+
%tr
|
21
|
+
<% for attribute in attributes -%>
|
22
|
+
%td= <%= singular_table_name %>.<%= attribute.name %>
|
23
|
+
<% end -%>
|
24
|
+
%td= link_to 'Show', <%= singular_table_name %>
|
25
|
+
%td= link_to 'Edit', edit_<%= singular_table_name %>_path(<%= singular_table_name %>)
|
26
|
+
%td= link_to 'Destroy', <%= singular_table_name %>, :data => { confirm: 'Are you sure?' }, :method => :delete
|
@@ -0,0 +1,15 @@
|
|
1
|
+
.page-header
|
2
|
+
= link_to <%= index_helper %>_path, :class => 'btn btn-default' do
|
3
|
+
%span.glyphicon.glyphicon-list-alt
|
4
|
+
Back
|
5
|
+
= link_to edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), :class => 'btn btn-primary' do
|
6
|
+
%span.glyphicon.glyphicon-pencil
|
7
|
+
Edit
|
8
|
+
%h1 Show <%= singular_table_name %>
|
9
|
+
|
10
|
+
%dl.dl-horizontal
|
11
|
+
<%- for attribute in attributes -%>
|
12
|
+
%dt <%= attribute.human_name %>:
|
13
|
+
%dd= @<%= singular_table_name %>.<%= attribute.name %>
|
14
|
+
<%- end -%>
|
15
|
+
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<% if namespaced? -%>
|
2
|
+
require_dependency "<%= namespaced_file_path %>/application_controller"
|
3
|
+
<% end -%>
|
4
|
+
<% module_namespacing do -%>
|
5
|
+
class <%= controller_class_name %>Controller < ApplicationController
|
6
|
+
before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
|
7
|
+
|
8
|
+
respond_to :html, :json, :js
|
9
|
+
|
10
|
+
def index
|
11
|
+
@<%= plural_table_name %> = <%= orm_class.all(class_name) %>
|
12
|
+
end
|
13
|
+
|
14
|
+
def show
|
15
|
+
end
|
16
|
+
|
17
|
+
def new
|
18
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name) %>
|
19
|
+
end
|
20
|
+
|
21
|
+
def edit
|
22
|
+
end
|
23
|
+
|
24
|
+
def create
|
25
|
+
@<%= singular_table_name %> = <%= orm_class.build(class_name, "#{singular_table_name}_params") %>
|
26
|
+
@<%= orm_instance.save %>
|
27
|
+
respond_with(@<%= singular_table_name %>)
|
28
|
+
end
|
29
|
+
|
30
|
+
def update
|
31
|
+
@<%= orm_instance.update("#{singular_table_name}_params") %>
|
32
|
+
flash[:notice] = <%= "'#{human_name} was successfully updated.'" %>
|
33
|
+
respond_with(@<%= singular_table_name %>)
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
@<%= orm_instance.destroy %>
|
38
|
+
redirect_to <%= index_helper %>_url, notice: <%= "'#{human_name} was successfully destroyed.'" %>
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def set_<%= singular_table_name %>
|
43
|
+
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
|
44
|
+
end
|
45
|
+
|
46
|
+
def <%= "#{singular_table_name}_params" %>
|
47
|
+
<%- if attributes_names.empty? -%>
|
48
|
+
params[:<%= singular_table_name %>]
|
49
|
+
<%- else -%>
|
50
|
+
params.require(:<%= singular_table_name %>).permit(<%= attributes_names.map { |name| ":#{name}" }.join(', ') %>)
|
51
|
+
<%- end -%>
|
52
|
+
end
|
53
|
+
end
|
54
|
+
<% end -%>
|