advanced_haml_scaffold_generator 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.document +5 -0
- data/.rspec +1 -0
- data/Gemfile +14 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +40 -0
- data/Rakefile +50 -0
- data/VERSION +1 -0
- data/advanced_haml_scaffold_generator.gemspec +70 -0
- data/lib/rails/generators/haml/base.rb +15 -0
- data/lib/rails/generators/haml/scaffold/scaffold_generator.rb +51 -0
- data/lib/rails/generators/haml/scaffold/templates/_form.html.haml +31 -0
- data/lib/rails/generators/haml/scaffold/templates/edit.html.haml +13 -0
- data/lib/rails/generators/haml/scaffold/templates/index.html.haml +122 -0
- data/lib/rails/generators/haml/scaffold/templates/layout.html.haml +31 -0
- data/lib/rails/generators/haml/scaffold/templates/new.html.haml +10 -0
- data/lib/rails/generators/haml/scaffold/templates/show.html.haml +22 -0
- data/spec/advanced_haml_scaffold_generator_spec.rb +7 -0
- data/spec/spec_helper.rb +29 -0
- metadata +134 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 99e670527e30e422696c59676f688de33381e398
|
4
|
+
data.tar.gz: 0cec9a295a47c75c3200db0c5238f18e324a5ac4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 6f2ba53390419b13c1c33cdf793504c035800f0691297fd876660d56f64d28ce19851e6f00e524828ac963d1461af49888180d61ea477d2a10a0475d990a7ace
|
7
|
+
data.tar.gz: 4309b23ce48638ff63f68d66ea2f31792aff858fa99d5973812bdf0b5fdda0bdb7ef5d9dc4ba5a6bc6ac65e0b4c516309cb8f3754a35e7e873e9db0f6f9d3544
|
data/.document
ADDED
data/.rspec
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
--color
|
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "rspec", "~> 3.1"
|
10
|
+
gem "rdoc", "~> 4.1"
|
11
|
+
gem "bundler", "~> 1.6"
|
12
|
+
gem "jeweler", "~> 2.0"
|
13
|
+
gem "simplecov", "~> 0.0"
|
14
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2014 Dmitri Koulikoff (acer)
|
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/README.rdoc
ADDED
@@ -0,0 +1,40 @@
|
|
1
|
+
= advanced_haml_scaffold_generator
|
2
|
+
|
3
|
+
This is the rails generator of scaffold that generates haml views that
|
4
|
+
* explore I18n
|
5
|
+
* use gem cancan (cancancan) if it is set in the setup
|
6
|
+
* use WiceGrid in index if it is used
|
7
|
+
* use helper :title
|
8
|
+
|
9
|
+
== Installation
|
10
|
+
|
11
|
+
Add to your Gemfile
|
12
|
+
|
13
|
+
gem 'advanced_haml_scaffold_generator'
|
14
|
+
|
15
|
+
Then bundle as usual.
|
16
|
+
|
17
|
+
== Usage
|
18
|
+
|
19
|
+
Next time you run
|
20
|
+
|
21
|
+
rails generate scaffold SomeModel ...
|
22
|
+
|
23
|
+
you will get the appropriate views. You can also add an option <code>--layout</code> to get the layout file in app/views/layout
|
24
|
+
|
25
|
+
|
26
|
+
== Contributing to advanced_haml_scaffold_generator
|
27
|
+
|
28
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
|
29
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
|
30
|
+
* Fork the project.
|
31
|
+
* Start a feature/bugfix branch.
|
32
|
+
* Commit and push until you are happy with your contribution.
|
33
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
34
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
35
|
+
|
36
|
+
== Copyright
|
37
|
+
|
38
|
+
Copyright (c) 2014 Dmitri Koulikoff. See LICENSE.txt for
|
39
|
+
further details.
|
40
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
|
17
|
+
gem.name = "advanced_haml_scaffold_generator"
|
18
|
+
gem.homepage = "http://github.com/dima4p/advanced_haml_scaffold_generator"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = %Q{Extention of the haml generator that is aware of i18n and so forth}
|
21
|
+
gem.description = %Q{Extention of the haml generator that generates templates with the use of i18n, cancan and WiceGrid, adds classes to buttons and uses :title helper}
|
22
|
+
gem.email = "dima@koulikoff.ru"
|
23
|
+
gem.authors = ["Dmitri Koulikoff"]
|
24
|
+
# dependencies defined in Gemfile
|
25
|
+
end
|
26
|
+
Jeweler::RubygemsDotOrgTasks.new
|
27
|
+
|
28
|
+
require 'rspec/core'
|
29
|
+
require 'rspec/core/rake_task'
|
30
|
+
RSpec::Core::RakeTask.new(:spec) do |spec|
|
31
|
+
spec.pattern = FileList['spec/**/*_spec.rb']
|
32
|
+
end
|
33
|
+
|
34
|
+
desc "Code coverage detail"
|
35
|
+
task :simplecov do
|
36
|
+
ENV['COVERAGE'] = "true"
|
37
|
+
Rake::Task['spec'].execute
|
38
|
+
end
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
require 'rdoc/task'
|
43
|
+
Rake::RDocTask.new do |rdoc|
|
44
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
45
|
+
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = "advanced_haml_scaffold_generator #{version}"
|
48
|
+
rdoc.rdoc_files.include('README*')
|
49
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
50
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,70 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
# stub: advanced_haml_scaffold_generator 1.0.0 ruby lib
|
6
|
+
|
7
|
+
Gem::Specification.new do |s|
|
8
|
+
s.name = "advanced_haml_scaffold_generator"
|
9
|
+
s.version = "1.0.0"
|
10
|
+
|
11
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
+
s.require_paths = ["lib"]
|
13
|
+
s.authors = ["Dmitri Koulikoff"]
|
14
|
+
s.date = "2014-09-12"
|
15
|
+
s.description = "Extention of the haml generator that generates templates with the use of i18n, cancan and WiceGrid, adds classes to buttons and uses :title helper"
|
16
|
+
s.email = "dima@koulikoff.ru"
|
17
|
+
s.extra_rdoc_files = [
|
18
|
+
"LICENSE.txt",
|
19
|
+
"README.rdoc"
|
20
|
+
]
|
21
|
+
s.files = [
|
22
|
+
".document",
|
23
|
+
".rspec",
|
24
|
+
"Gemfile",
|
25
|
+
"LICENSE.txt",
|
26
|
+
"README.rdoc",
|
27
|
+
"Rakefile",
|
28
|
+
"VERSION",
|
29
|
+
"advanced_haml_scaffold_generator.gemspec",
|
30
|
+
"lib/rails/generators/haml/base.rb",
|
31
|
+
"lib/rails/generators/haml/scaffold/scaffold_generator.rb",
|
32
|
+
"lib/rails/generators/haml/scaffold/templates/_form.html.haml",
|
33
|
+
"lib/rails/generators/haml/scaffold/templates/edit.html.haml",
|
34
|
+
"lib/rails/generators/haml/scaffold/templates/index.html.haml",
|
35
|
+
"lib/rails/generators/haml/scaffold/templates/layout.html.haml",
|
36
|
+
"lib/rails/generators/haml/scaffold/templates/new.html.haml",
|
37
|
+
"lib/rails/generators/haml/scaffold/templates/show.html.haml",
|
38
|
+
"spec/advanced_haml_scaffold_generator_spec.rb",
|
39
|
+
"spec/spec_helper.rb"
|
40
|
+
]
|
41
|
+
s.homepage = "http://github.com/dima4p/advanced_haml_scaffold_generator"
|
42
|
+
s.licenses = ["MIT"]
|
43
|
+
s.rubygems_version = "2.2.2"
|
44
|
+
s.summary = "Extention of the haml generator that is aware of i18n and so forth"
|
45
|
+
|
46
|
+
if s.respond_to? :specification_version then
|
47
|
+
s.specification_version = 4
|
48
|
+
|
49
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
50
|
+
s.add_development_dependency(%q<rspec>, ["~> 3.1"])
|
51
|
+
s.add_development_dependency(%q<rdoc>, ["~> 4.1"])
|
52
|
+
s.add_development_dependency(%q<bundler>, ["~> 1.6"])
|
53
|
+
s.add_development_dependency(%q<jeweler>, ["~> 2.0"])
|
54
|
+
s.add_development_dependency(%q<simplecov>, ["~> 0.0"])
|
55
|
+
else
|
56
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
57
|
+
s.add_dependency(%q<rdoc>, ["~> 4.1"])
|
58
|
+
s.add_dependency(%q<bundler>, ["~> 1.6"])
|
59
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
60
|
+
s.add_dependency(%q<simplecov>, ["~> 0.0"])
|
61
|
+
end
|
62
|
+
else
|
63
|
+
s.add_dependency(%q<rspec>, ["~> 3.1"])
|
64
|
+
s.add_dependency(%q<rdoc>, ["~> 4.1"])
|
65
|
+
s.add_dependency(%q<bundler>, ["~> 1.6"])
|
66
|
+
s.add_dependency(%q<jeweler>, ["~> 2.0"])
|
67
|
+
s.add_dependency(%q<simplecov>, ["~> 0.0"])
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'rails/generators/named_base'
|
2
|
+
|
3
|
+
module Haml
|
4
|
+
module Generators
|
5
|
+
class Base < ::Rails::Generators::NamedBase
|
6
|
+
# Automatically sets the source root based on the class name.
|
7
|
+
#
|
8
|
+
def self.source_root
|
9
|
+
@_haml_source_root ||= begin
|
10
|
+
File.expand_path(File.join(File.dirname(__FILE__), generator_name, 'templates')) if generator_name
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
require 'rails/generators/haml/base.rb'
|
2
|
+
require 'rails/generators/resource_helpers'
|
3
|
+
|
4
|
+
module Haml
|
5
|
+
module Generators
|
6
|
+
class ScaffoldGenerator < Haml::Generators::Base
|
7
|
+
include ::Rails::Generators::ResourceHelpers
|
8
|
+
|
9
|
+
argument :attributes, :type => :array, :default => [], :banner => "field:type field:type"
|
10
|
+
|
11
|
+
class_option :layout, type: :boolean
|
12
|
+
class_option :singleton, type: :boolean, desc: "Supply to skip index view"
|
13
|
+
class_option :cancan, type: :boolean, desc: "Use cancan patterns"
|
14
|
+
|
15
|
+
def create_root_folder
|
16
|
+
empty_directory File.join("app/views", controller_file_path)
|
17
|
+
end
|
18
|
+
|
19
|
+
def copy_index_file
|
20
|
+
return if options[:singleton]
|
21
|
+
copy_view :index
|
22
|
+
end
|
23
|
+
|
24
|
+
def copy_edit_file
|
25
|
+
copy_view :edit
|
26
|
+
end
|
27
|
+
|
28
|
+
def copy_show_file
|
29
|
+
copy_view :show
|
30
|
+
end
|
31
|
+
|
32
|
+
def copy_new_file
|
33
|
+
copy_view :new
|
34
|
+
end
|
35
|
+
|
36
|
+
def copy_form_file
|
37
|
+
copy_view :_form
|
38
|
+
end
|
39
|
+
|
40
|
+
def copy_layout_file
|
41
|
+
return unless options[:layout]
|
42
|
+
template "layout.html.haml", File.join("app/views/layouts", controller_class_path, "#{controller_file_name}.html.haml")
|
43
|
+
end
|
44
|
+
|
45
|
+
protected
|
46
|
+
def copy_view(view)
|
47
|
+
template "#{view}.html.haml", File.join("app/views", controller_file_path, "#{view}.html.haml")
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
<% if Gem::Specification.map(&:name).include?('simple_form') -%>
|
2
|
+
= simple_form_for(@<%= singular_table_name %>) do |f|
|
3
|
+
= f.error_notification
|
4
|
+
|
5
|
+
.form-inputs
|
6
|
+
<%- attributes.each do |attribute| -%>
|
7
|
+
= f.<%= attribute.reference? ? :association : :input %> :<%= attribute.name %>
|
8
|
+
<%- end -%>
|
9
|
+
|
10
|
+
.form-actions
|
11
|
+
= f.button :submit
|
12
|
+
<% else -%>
|
13
|
+
= form_for(@<%= singular_table_name %>) do |f|
|
14
|
+
- if @<%= singular_table_name %>.errors.any?
|
15
|
+
#error_explanation
|
16
|
+
%h2
|
17
|
+
= t 'errors.template.header', model: t('.<%= singular_table_name %>'), count: @<%= singular_table_name %>.errors.count
|
18
|
+
%ul
|
19
|
+
- @<%= singular_table_name %>.errors.full_messages.each do |msg|
|
20
|
+
%li= msg
|
21
|
+
|
22
|
+
<% for attribute in attributes -%>
|
23
|
+
.field
|
24
|
+
= f.label :<%= attribute.name %>
|
25
|
+
%br
|
26
|
+
= f.<%= attribute.field_type %> :<%= attribute.name %>
|
27
|
+
<% end -%>
|
28
|
+
|
29
|
+
.actions
|
30
|
+
= f.submit
|
31
|
+
<% end -%>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
- title t('.title')
|
2
|
+
|
3
|
+
%p.nav
|
4
|
+
<% if options[:cancan] -%>
|
5
|
+
- if can? :index, <%= class_name %>
|
6
|
+
= link_to t('back'), <%= plural_name %>_path, class: 'index'
|
7
|
+
- if can? :show, @<%= singular_name %>
|
8
|
+
= link_to t('show'), @<%= singular_name %>, class: 'show'
|
9
|
+
<% else -%>
|
10
|
+
= link_to t('back'), <%= plural_name %>_path, class: 'index'
|
11
|
+
= link_to t('show'), @<%= singular_name %>, class: 'show'
|
12
|
+
<% end -%>
|
13
|
+
= render 'form'
|
@@ -0,0 +1,122 @@
|
|
1
|
+
- title t('.title')
|
2
|
+
|
3
|
+
<% if options[:cancan] -%>
|
4
|
+
- if can? :new, <%= class_name %>
|
5
|
+
%p.nav= link_to t('.new_<%= singular_table_name %>'), new_<%= singular_table_name %>_path, class: 'new'
|
6
|
+
<% else -%>
|
7
|
+
%p.nav= link_to t('.new_<%= singular_table_name %>'), new_<%= singular_table_name %>_path, class: 'new'
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
<% if defined? Wice::WiceGrid -%>
|
11
|
+
- if @grid
|
12
|
+
= grid @grid do |g|
|
13
|
+
<% for attribute in attributes -%>
|
14
|
+
<% if attribute.reference? -%>
|
15
|
+
- g.column name: <%= class_name %>.human_attribute_name(:<%= attribute.name %>),
|
16
|
+
:attribute => '<%= attribute.name %>_id' do |<%= singular_table_name %>|
|
17
|
+
- <%= singular_table_name %>.<%= attribute.name %>.try :name
|
18
|
+
<% else -%>
|
19
|
+
- g.column name: <%= class_name %>.human_attribute_name(:<%= attribute.name %>),
|
20
|
+
:attribute => '<%= attribute.name %>' do |<%= singular_table_name %>|
|
21
|
+
- <%= singular_table_name %>.<%= attribute.name %>
|
22
|
+
<% end -%>
|
23
|
+
<% end -%>
|
24
|
+
<% if options[:cancan] -%>
|
25
|
+
- g.column do |<%= singular_table_name %>|
|
26
|
+
- if can? :show, <%= singular_table_name %>
|
27
|
+
- link_to t('show'), <%= singular_table_name %>, class: 'show'
|
28
|
+
- g.column do |<%= singular_table_name %>|
|
29
|
+
- if can? :edit, <%= singular_table_name %>
|
30
|
+
- link_to t('edit'), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'edit'
|
31
|
+
- g.column do |<%= singular_table_name %>|
|
32
|
+
- if can? :destroy, <%= singular_table_name %>
|
33
|
+
- link_to t('destroy'), <%= singular_table_name %>,
|
34
|
+
data: {confirm: t('.confirm', default: 'Are you sure?')},
|
35
|
+
method: :delete, class: 'destroy'
|
36
|
+
<% else -%>
|
37
|
+
- g.column do |<%= singular_table_name %>|
|
38
|
+
- link_to t('show'), <%= singular_table_name %>, class: 'show'
|
39
|
+
- g.column do |<%= singular_table_name %>|
|
40
|
+
- link_to t('edit'), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'edit'
|
41
|
+
- g.column do |<%= singular_table_name %>|
|
42
|
+
- link_to t('destroy'), <%= singular_table_name %>,
|
43
|
+
data: {confirm: t('.confirm', default: 'Are you sure?')},
|
44
|
+
method: :delete, class: 'destroy'
|
45
|
+
<% end -%>
|
46
|
+
-else
|
47
|
+
%table
|
48
|
+
%thead
|
49
|
+
%tr
|
50
|
+
<% for attribute in attributes -%>
|
51
|
+
%th= <%= class_name %>.human_attribute_name :<%= attribute.name %>
|
52
|
+
<% end -%>
|
53
|
+
%th{:colspan => 3}= t 'actions'
|
54
|
+
|
55
|
+
%tbody
|
56
|
+
- @<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
57
|
+
%tr{ :class => cycle(:odd, :even) }
|
58
|
+
<% for attribute in attributes -%>
|
59
|
+
<% if attribute.reference? -%>
|
60
|
+
%td= <%= singular_table_name %>.<%= attribute.name %>.try :name
|
61
|
+
<% else -%>
|
62
|
+
%td= <%= singular_table_name %>.<%= attribute.name %>
|
63
|
+
<% end -%>
|
64
|
+
<% end -%>
|
65
|
+
<% if options[:cancan] -%>
|
66
|
+
%td.action
|
67
|
+
- if can? :show, <%= singular_table_name %>
|
68
|
+
= link_to t('show'), <%= singular_table_name %>, class: 'show'
|
69
|
+
%td.action
|
70
|
+
- if can? :edit, <%= singular_table_name %>
|
71
|
+
= link_to t('edit'), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'edit'
|
72
|
+
%td.action
|
73
|
+
- if can? :destroy, <%= singular_table_name %>
|
74
|
+
= link_to t('destroy'), <%= singular_table_name %>,
|
75
|
+
data: {confirm: t('.confirm', default: 'Are you sure?')},
|
76
|
+
method: :delete, class: 'destroy'
|
77
|
+
<% else -%>
|
78
|
+
%td.action= link_to t('show'), <%= singular_table_name %>, class: 'show'
|
79
|
+
%td.action= link_to t('edit'), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'edit'
|
80
|
+
%td.action= link_to t('destroy'), <%= singular_table_name %>,
|
81
|
+
data: {confirm: t('.confirm', :default => 'Are you sure?')},
|
82
|
+
method: :delete, class: 'destroy'
|
83
|
+
<% end -%>
|
84
|
+
<% else -%>
|
85
|
+
%table
|
86
|
+
%thead
|
87
|
+
%tr
|
88
|
+
<% for attribute in attributes -%>
|
89
|
+
%th= <%= class_name %>.human_attribute_name :<%= attribute.name %>
|
90
|
+
<% end -%>
|
91
|
+
%th{:colspan => 3}= t 'actions'
|
92
|
+
|
93
|
+
%tbody
|
94
|
+
- @<%= plural_table_name %>.each do |<%= singular_table_name %>|
|
95
|
+
%tr{ :class => cycle(:odd, :even) }
|
96
|
+
<% for attribute in attributes -%>
|
97
|
+
<% if attribute.reference? -%>
|
98
|
+
%td= <%= singular_table_name %>.<%= attribute.name %>.try :name
|
99
|
+
<% else -%>
|
100
|
+
%td= <%= singular_table_name %>.<%= attribute.name %>
|
101
|
+
<% end -%>
|
102
|
+
<% end -%>
|
103
|
+
<% if options[:cancan] -%>
|
104
|
+
%td.action
|
105
|
+
- if can? :show, <%= singular_table_name %>
|
106
|
+
= link_to t('show'), <%= singular_table_name %>, class: 'show'
|
107
|
+
%td.action
|
108
|
+
- if can? :edit, <%= singular_table_name %>
|
109
|
+
= link_to t('edit'), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'edit'
|
110
|
+
%td.action
|
111
|
+
- if can? :destroy, <%= singular_table_name %>
|
112
|
+
= link_to t('destroy'), <%= singular_table_name %>,
|
113
|
+
data: {confirm: t('.confirm', default: 'Are you sure?')},
|
114
|
+
method: :delete, class: 'destroy'
|
115
|
+
<% else -%>
|
116
|
+
%td.action= link_to t('show'), <%= singular_table_name %>, class: 'show'
|
117
|
+
%td.action= link_to t('edit'), edit_<%= singular_table_name %>_path(<%= singular_table_name %>), class: 'edit'
|
118
|
+
%td.action= link_to t('destroy'), <%= singular_table_name %>,
|
119
|
+
data: {confirm: t('.confirm', :default => 'Are you sure?')},
|
120
|
+
method: :delete, class: 'destroy'
|
121
|
+
<% end -%>
|
122
|
+
<% end -%>
|
@@ -0,0 +1,31 @@
|
|
1
|
+
!!!
|
2
|
+
%html
|
3
|
+
%head
|
4
|
+
%title
|
5
|
+
= yield(:title) || "Untitled"
|
6
|
+
|
|
7
|
+
= t :application_name
|
8
|
+
%meta{"http-equiv"=>"Content-Type", :content=>"text/html; charset=utf-8"}/
|
9
|
+
= favicon_link_tag 'application.ico'
|
10
|
+
= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true
|
11
|
+
= javascript_include_tag 'application', 'data-turbolinks-track' => true
|
12
|
+
/[if lt IE 9]
|
13
|
+
= javascript_include_tag "http://html5shim.googlecode.com/svn/trunk/html5.js"
|
14
|
+
= csrf_meta_tag
|
15
|
+
= yield(:head)
|
16
|
+
|
17
|
+
%body{:lang => I18n.locale,
|
18
|
+
:class => [controller.controller_name, controller.action_name, yield(:body_class)]}
|
19
|
+
-# @debug_ability.each do |ability|
|
20
|
+
%p
|
21
|
+
= ability.inspect
|
22
|
+
#container
|
23
|
+
#content
|
24
|
+
- flash.each do |name, msg|
|
25
|
+
= content_tag :div, msg.html_safe, :id => "flash_#{name}"
|
26
|
+
|
27
|
+
- if respond_to?(:show_title?) and show_title?
|
28
|
+
%h1
|
29
|
+
= yield(:title)
|
30
|
+
|
31
|
+
= yield
|
@@ -0,0 +1,10 @@
|
|
1
|
+
- title t('.title')
|
2
|
+
|
3
|
+
<% if options[:cancan] -%>
|
4
|
+
- if can? :index, <%= class_name %>
|
5
|
+
%p.nav= link_to t('back'), <%= index_helper %>_path, class: 'index'
|
6
|
+
<% else -%>
|
7
|
+
%p= link_to t('back'), <%= index_helper %>_path, class: 'index'
|
8
|
+
<% end -%>
|
9
|
+
|
10
|
+
= render 'form'
|
@@ -0,0 +1,22 @@
|
|
1
|
+
- title t('.title')
|
2
|
+
|
3
|
+
%p.nav
|
4
|
+
<% if options[:cancan] -%>
|
5
|
+
- if can? :index, <%= class_name %>
|
6
|
+
= link_to t('back'), <%= index_helper %>_path, class: 'index'
|
7
|
+
- if can? :edit, @<%= singular_table_name %>
|
8
|
+
= link_to t('edit'), edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'edit'
|
9
|
+
<% else -%>
|
10
|
+
= link_to t('back'), <%= plural_name %>_path, class: 'index'
|
11
|
+
= link_to t('edit'), edit_<%= singular_table_name %>_path(@<%= singular_table_name %>), class: 'edit'
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
%dl
|
15
|
+
<% for attribute in attributes -%>
|
16
|
+
%dt= <%= class_name %>.human_attribute_name :<%= attribute.name %>
|
17
|
+
<% if attribute.reference? -%>
|
18
|
+
%dd= @<%= singular_table_name %>.<%= attribute.name %>.try :name
|
19
|
+
<% else -%>
|
20
|
+
%dd= @<%= singular_table_name %>.<%= attribute.name %>
|
21
|
+
<% end -%>
|
22
|
+
<% end -%>
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
|
3
|
+
module SimpleCov::Configuration
|
4
|
+
def clean_filters
|
5
|
+
@filters = []
|
6
|
+
end
|
7
|
+
end
|
8
|
+
|
9
|
+
SimpleCov.configure do
|
10
|
+
clean_filters
|
11
|
+
load_adapter 'test_frameworks'
|
12
|
+
end
|
13
|
+
|
14
|
+
ENV["COVERAGE"] && SimpleCov.start do
|
15
|
+
add_filter "/.rvm/"
|
16
|
+
end
|
17
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
18
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
19
|
+
|
20
|
+
require 'rspec'
|
21
|
+
require 'advanced_haml_scaffold_generator'
|
22
|
+
|
23
|
+
# Requires supporting files with custom matchers and macros, etc,
|
24
|
+
# in ./support/ and its subdirectories.
|
25
|
+
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f}
|
26
|
+
|
27
|
+
RSpec.configure do |config|
|
28
|
+
|
29
|
+
end
|
metadata
ADDED
@@ -0,0 +1,134 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: advanced_haml_scaffold_generator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Dmitri Koulikoff
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-09-12 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rspec
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.1'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '3.1'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rdoc
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '4.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '4.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: bundler
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '1.6'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '1.6'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: jeweler
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - "~>"
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '2.0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "~>"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '2.0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: simplecov
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.0'
|
83
|
+
description: Extention of the haml generator that generates templates with the use
|
84
|
+
of i18n, cancan and WiceGrid, adds classes to buttons and uses :title helper
|
85
|
+
email: dima@koulikoff.ru
|
86
|
+
executables: []
|
87
|
+
extensions: []
|
88
|
+
extra_rdoc_files:
|
89
|
+
- LICENSE.txt
|
90
|
+
- README.rdoc
|
91
|
+
files:
|
92
|
+
- ".document"
|
93
|
+
- ".rspec"
|
94
|
+
- Gemfile
|
95
|
+
- LICENSE.txt
|
96
|
+
- README.rdoc
|
97
|
+
- Rakefile
|
98
|
+
- VERSION
|
99
|
+
- advanced_haml_scaffold_generator.gemspec
|
100
|
+
- lib/rails/generators/haml/base.rb
|
101
|
+
- lib/rails/generators/haml/scaffold/scaffold_generator.rb
|
102
|
+
- lib/rails/generators/haml/scaffold/templates/_form.html.haml
|
103
|
+
- lib/rails/generators/haml/scaffold/templates/edit.html.haml
|
104
|
+
- lib/rails/generators/haml/scaffold/templates/index.html.haml
|
105
|
+
- lib/rails/generators/haml/scaffold/templates/layout.html.haml
|
106
|
+
- lib/rails/generators/haml/scaffold/templates/new.html.haml
|
107
|
+
- lib/rails/generators/haml/scaffold/templates/show.html.haml
|
108
|
+
- spec/advanced_haml_scaffold_generator_spec.rb
|
109
|
+
- spec/spec_helper.rb
|
110
|
+
homepage: http://github.com/dima4p/advanced_haml_scaffold_generator
|
111
|
+
licenses:
|
112
|
+
- MIT
|
113
|
+
metadata: {}
|
114
|
+
post_install_message:
|
115
|
+
rdoc_options: []
|
116
|
+
require_paths:
|
117
|
+
- lib
|
118
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
119
|
+
requirements:
|
120
|
+
- - ">="
|
121
|
+
- !ruby/object:Gem::Version
|
122
|
+
version: '0'
|
123
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
124
|
+
requirements:
|
125
|
+
- - ">="
|
126
|
+
- !ruby/object:Gem::Version
|
127
|
+
version: '0'
|
128
|
+
requirements: []
|
129
|
+
rubyforge_project:
|
130
|
+
rubygems_version: 2.2.2
|
131
|
+
signing_key:
|
132
|
+
specification_version: 4
|
133
|
+
summary: Extention of the haml generator that is aware of i18n and so forth
|
134
|
+
test_files: []
|