index_for 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/Rakefile +14 -0
- data/lib/generators/index_for/USAGE +3 -0
- data/lib/generators/index_for/install_generator.rb +22 -0
- data/lib/generators/index_for/templates/en.yml +14 -0
- data/lib/generators/index_for/templates/index.html.erb +8 -0
- data/lib/generators/index_for/templates/index.html.haml +7 -0
- data/lib/generators/index_for/templates/index_for.rb +24 -0
- data/lib/index_for/attribute.rb +30 -0
- data/lib/index_for/builder.rb +118 -0
- data/lib/index_for/builders/action_builder.rb +31 -0
- data/lib/index_for/builders/body_column_builder.rb +23 -0
- data/lib/index_for/builders/head_column_builder.rb +19 -0
- data/lib/index_for/builders/list_column_builder.rb +32 -0
- data/lib/index_for/helper.rb +140 -0
- data/lib/index_for/share_helper.rb +20 -0
- data/lib/index_for/version.rb +3 -0
- data/lib/index_for.rb +96 -0
- metadata +149 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ea4e0afe260da5eec24621e4bd92dd33be8324b1
|
4
|
+
data.tar.gz: e227a16664cc72ad69259e5a0e70344d30744e29
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: eadee2671a17f880efdb5b007b35156a4180e3b62cc5a36416bc02dfc867df4cc7609c809e1166730ae5b59214f900628ae1585bd85d351972654b65617aed72
|
7
|
+
data.tar.gz: bd245387e4eb295aa3f3f482f0a8bb37a93af756437c2a3e74809d1ef9df6d88d3f17ec1c7c50a2eecd26f0569a7cc2bdd27e70d49bc9ea23ddb4ce6c68134f5
|
data/Rakefile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
|
3
|
+
require 'rake/testtask'
|
4
|
+
|
5
|
+
desc 'Test the index_for plugin.'
|
6
|
+
Rake::TestTask.new(:test) do |t|
|
7
|
+
t.libs << 'lib'
|
8
|
+
t.libs << 'test'
|
9
|
+
t.pattern = 'test/**/*_test.rb'
|
10
|
+
t.verbose = true
|
11
|
+
end
|
12
|
+
|
13
|
+
# If you want to make this the default task
|
14
|
+
task :default => :test
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module IndexFor
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
desc "Copy IndexFor installation files"
|
5
|
+
class_option :template_engine, :desc => 'Template engine to be invoked (erb or haml or slim).'
|
6
|
+
source_root File.expand_path('../templates', __FILE__)
|
7
|
+
|
8
|
+
def copy_initializers
|
9
|
+
copy_file 'index_for.rb', 'config/initializers/index_for.rb'
|
10
|
+
end
|
11
|
+
|
12
|
+
def copy_locale_file
|
13
|
+
copy_file 'en.yml', 'config/locales/index_for.en.yml'
|
14
|
+
end
|
15
|
+
|
16
|
+
def copy_generator_template
|
17
|
+
engine = options[:template_engine]
|
18
|
+
copy_file "index.html.#{engine}", "lib/templates/#{engine}/scaffold/index.html.#{engine}"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
en:
|
2
|
+
index_for:
|
3
|
+
blank: "Not specified"
|
4
|
+
# If you want to use html tags with blank value use blank html translation
|
5
|
+
# blank_html: "<span>Not specified</span>"
|
6
|
+
"yes": "Yes"
|
7
|
+
"no": "No"
|
8
|
+
actions:
|
9
|
+
actions: Actions
|
10
|
+
show: Show
|
11
|
+
new: New
|
12
|
+
edit: Edit
|
13
|
+
destroy: Destroy
|
14
|
+
confirmation: "Are you sure?"
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%%= index_for @<%= plural_name %> do |i| %>
|
2
|
+
<% attributes.each do |attribute| -%>
|
3
|
+
<%%= i.<%= attribute.reference? ? :association : :attribute %> :<%= attribute.name %> %>
|
4
|
+
<% end -%>
|
5
|
+
<%%= i.actions :all %>
|
6
|
+
<%% end %>
|
7
|
+
|
8
|
+
<%%= link_to 'New', new_<%= singular_name %>_path(@<%= singular_name %>) %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
= index_for(@<%= plural_name %>) do |i|
|
2
|
+
<%- attributes.each do |attribute| -%>
|
3
|
+
= i.<%= attribute.reference? ? :association : :attribute %> :<%= attribute.name %>
|
4
|
+
<% end -%>
|
5
|
+
= i.actions :all
|
6
|
+
|
7
|
+
= link_to 'New', new_<%= singular_name %>_path(@<%= singular_name %>)
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# Use this setup block to configure all options available in IndexFor.
|
2
|
+
IndexFor.setup do |config|
|
3
|
+
# The tag which wraps index_for calls.
|
4
|
+
# config.index_for_tag = :div
|
5
|
+
|
6
|
+
# The DOM class set for index_for tag. Default is nil
|
7
|
+
# config.index_for_class = :custom
|
8
|
+
|
9
|
+
# The tag which wraps header call. Default is :thead, set nil to turn off header.
|
10
|
+
# config.head_tag = nil
|
11
|
+
|
12
|
+
# The tag which wraps body call. Default is :tbody.
|
13
|
+
# config.body_tag = :ul
|
14
|
+
|
15
|
+
# The tag which wraps each head column call. Default is :th.
|
16
|
+
# config.head_column_tag = :li
|
17
|
+
|
18
|
+
# The tag which wraps each body column call. Default is :td.
|
19
|
+
# config.body_column_tag = :li
|
20
|
+
|
21
|
+
# The tag which wraps each row call. Default is :tr.
|
22
|
+
# config.row_tag = :p
|
23
|
+
|
24
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module IndexFor
|
2
|
+
module Attribute
|
3
|
+
|
4
|
+
private
|
5
|
+
|
6
|
+
def attribute_value attribute_name, options
|
7
|
+
attribute_name = options[:value] if options[:value]
|
8
|
+
attribute_name = :"#{attribute_name}.#{options[:with]}" if options[:with]
|
9
|
+
|
10
|
+
parts = attribute_name.to_s.split(".")
|
11
|
+
attribute_name = parts.pop
|
12
|
+
|
13
|
+
object = @object
|
14
|
+
parts.each do |attribute_name|
|
15
|
+
object = object.send(attribute_name)
|
16
|
+
end if parts.any?
|
17
|
+
|
18
|
+
if object.respond_to?(:"human_#{attribute_name}")
|
19
|
+
object.send :"human_#{attribute_name}"
|
20
|
+
else
|
21
|
+
object.send(attribute_name)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def attribute_label attribute_name
|
26
|
+
@object.class.human_attribute_name(attribute_name)
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,118 @@
|
|
1
|
+
require 'index_for/attribute'
|
2
|
+
|
3
|
+
module IndexFor
|
4
|
+
class Builder
|
5
|
+
include IndexFor::ShareHelper
|
6
|
+
include IndexFor::Attribute
|
7
|
+
|
8
|
+
attr_accessor :object, :html_options, :template
|
9
|
+
|
10
|
+
def initialize object, html_options, template
|
11
|
+
@object, @html_options, @template = object, html_options, template
|
12
|
+
end
|
13
|
+
|
14
|
+
def attribute attribute_name, options = {}, █ end
|
15
|
+
def association attribute_name, options = {}, &block
|
16
|
+
attribute attribute_name, options, &block
|
17
|
+
end
|
18
|
+
|
19
|
+
def attributes *attribute_names
|
20
|
+
options = attribute_names.extract_options!
|
21
|
+
|
22
|
+
attribute_names.map do |attribute_name|
|
23
|
+
attribute attribute_name, options
|
24
|
+
end.join.html_safe
|
25
|
+
end
|
26
|
+
|
27
|
+
def actions *action_names, █ end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def apply_html type, options = {} #:nodoc:
|
32
|
+
type_tag = html_options[:"#{type}_tag"] || IndexFor.try(:"#{type}_tag")
|
33
|
+
type_html_options = apply_html_options type, options
|
34
|
+
|
35
|
+
return type_tag, type_html_options
|
36
|
+
end
|
37
|
+
|
38
|
+
def apply_html_options type, options = {}
|
39
|
+
type_class = IndexFor.send :"#{type}_class"
|
40
|
+
|
41
|
+
type_html_options = {}
|
42
|
+
type_html_options.merge!(html_options[:"#{type}_html"]) if html_options[:"#{type}_html"]
|
43
|
+
type_html_options.merge!(options[:html]) if options[:html]
|
44
|
+
|
45
|
+
append_class type_html_options, type_class
|
46
|
+
|
47
|
+
type_html_options
|
48
|
+
end
|
49
|
+
|
50
|
+
|
51
|
+
def wrap_content_with type, content, options = {}, &block #:nodoc:
|
52
|
+
type_tag, type_html_options = apply_html type, options
|
53
|
+
append_class type_html_options, IndexFor.blank_content_class if content.blank?
|
54
|
+
|
55
|
+
@template.content_tag type_tag, type_html_options do
|
56
|
+
format_content(content, options, &block)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
def format_content content, options = {}, &block
|
61
|
+
# We need to convert content to_a because when dealing with ActiveRecord
|
62
|
+
# Array proxies, the follow statement Array# === content return false
|
63
|
+
if block && block.arity == 1
|
64
|
+
content = block
|
65
|
+
elsif content.respond_to?(:to_ary)
|
66
|
+
content = content.to_a
|
67
|
+
end
|
68
|
+
|
69
|
+
case content
|
70
|
+
when Date, Time, DateTime
|
71
|
+
I18n.l content, :format => options[:format] || IndexFor.i18n_format
|
72
|
+
when TrueClass
|
73
|
+
translate :"show_for.yes", :default => "Yes"
|
74
|
+
when FalseClass
|
75
|
+
translate :"show_for.no", :default => "No"
|
76
|
+
when Array, Hash
|
77
|
+
content.empty? ? blank_content(options) :
|
78
|
+
collection_content(content, options, &block)
|
79
|
+
when Proc
|
80
|
+
@template.capture(@object, &content)
|
81
|
+
when NilClass
|
82
|
+
blank_content(options)
|
83
|
+
else
|
84
|
+
content.to_s
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
def blank_content options
|
89
|
+
options[:if_blank] || translate(:blank, :default => "Not specified")
|
90
|
+
end
|
91
|
+
|
92
|
+
def collection_content collection, options, &block
|
93
|
+
collection_tag = options[:collection_tag] || IndexFor.collection_tag
|
94
|
+
collection_column_tag = options[:collection_column_tag] || IndexFor.collection_column_tag
|
95
|
+
@template.content_tag collection_tag do
|
96
|
+
collection.map do |content|
|
97
|
+
if block
|
98
|
+
@template.capture content, collection, @object, &block
|
99
|
+
else
|
100
|
+
@template.content_tag collection_column_tag, content
|
101
|
+
end
|
102
|
+
end.join.html_safe
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
# Gets the default tag set in IndexFor module and apply (if defined)
|
107
|
+
# around the given content. It also check for html_options in @options
|
108
|
+
# hash related to the current type.
|
109
|
+
def wrap_with type, content, options = {} #:nodoc:
|
110
|
+
type_tag, type_html_options = apply_html type, options
|
111
|
+
if type_tag
|
112
|
+
@template.content_tag type_tag, content, type_html_options
|
113
|
+
else
|
114
|
+
content
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
118
|
+
end
|
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'index_for/builder'
|
2
|
+
|
3
|
+
module IndexFor
|
4
|
+
class ActionBuilder < Builder
|
5
|
+
|
6
|
+
def action_link action_name, options = {}, &block
|
7
|
+
if block
|
8
|
+
@template.capture(@object, &block)
|
9
|
+
else
|
10
|
+
action_title = translate(:"actions.#{action_name}",
|
11
|
+
default: action_name.to_s.humanize).html_safe
|
12
|
+
action_html_options = apply_html_options :action_link, options[:html] || {}
|
13
|
+
append_class action_html_options, :"action_#{action_name}"
|
14
|
+
|
15
|
+
case action_name
|
16
|
+
when :show
|
17
|
+
@template.link_to action_title, @template.polymorphic_path(@object),
|
18
|
+
action_html_options
|
19
|
+
when :destroy
|
20
|
+
@template.link_to action_title, @template.polymorphic_path(@object),
|
21
|
+
{ data: { method: :destroy, confirm: translate(:"actions.confirmation")
|
22
|
+
}}.merge(action_html_options)
|
23
|
+
else
|
24
|
+
@template.link_to action_title, @template.polymorphic_path(@object,
|
25
|
+
action: action_name), action_html_options
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'index_for/builder'
|
2
|
+
|
3
|
+
module IndexFor
|
4
|
+
class BodyColumnBuilder < Builder
|
5
|
+
|
6
|
+
def attribute attribute_name, options = {}, &block
|
7
|
+
append_html_class options, :"attr_#{attribute_name}"
|
8
|
+
wrap_content_with :table_body_cell, attribute_value(attribute_name,
|
9
|
+
options), options, &block
|
10
|
+
end
|
11
|
+
|
12
|
+
def actions *action_names, &block
|
13
|
+
options = action_names.extract_options!
|
14
|
+
options[:html] = apply_html_options :table_actions_cell, options
|
15
|
+
|
16
|
+
content = @template.index_for_actions @object, *action_names,
|
17
|
+
options, &block
|
18
|
+
|
19
|
+
wrap_with :table_body_cell, content, options
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
require 'index_for/builder'
|
2
|
+
|
3
|
+
module IndexFor
|
4
|
+
class HeadColumnBuilder < Builder
|
5
|
+
|
6
|
+
def attribute attribute_name, options = {}
|
7
|
+
append_html_class options, :"attr_#{attribute_name}"
|
8
|
+
wrap_with :table_head_cell, attribute_label(attribute_name), options
|
9
|
+
end
|
10
|
+
|
11
|
+
def actions *action_names
|
12
|
+
options = action_names.extract_options!
|
13
|
+
options[:html] = apply_html_options :table_actions_cell, options
|
14
|
+
|
15
|
+
wrap_with :table_head_cell, translate(:"actions.actions"), options
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'index_for/builder'
|
2
|
+
|
3
|
+
module IndexFor
|
4
|
+
class ListColumnBuilder < Builder
|
5
|
+
|
6
|
+
def attribute attribute_name, options = {}, &block
|
7
|
+
label_options = options
|
8
|
+
label_options[:html] = options[:label_html]
|
9
|
+
|
10
|
+
content_options = options
|
11
|
+
content_options[:html] = options[:content_html]
|
12
|
+
|
13
|
+
row_options = options
|
14
|
+
row_options[:html] = options[:row_html]
|
15
|
+
|
16
|
+
wrap_with :list_row, label(attribute_name, label_options) +
|
17
|
+
content(attribute_name, options, &block), row_options
|
18
|
+
end
|
19
|
+
|
20
|
+
def label attribute_name, options
|
21
|
+
append_html_class options, :"attr_#{attribute_name}"
|
22
|
+
wrap_with :list_label, attribute_label(attribute_name), options
|
23
|
+
end
|
24
|
+
|
25
|
+
def content attribute_name, options, &block
|
26
|
+
append_html_class options, :"attr_#{attribute_name}"
|
27
|
+
wrap_content_with :list_content, attribute_value(attribute_name,
|
28
|
+
options), options, &block
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,140 @@
|
|
1
|
+
module IndexFor
|
2
|
+
module Helper
|
3
|
+
include IndexFor::ShareHelper
|
4
|
+
|
5
|
+
# Creates a table around the objects and yields a builder.
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
#
|
9
|
+
# index_for @users do |t|
|
10
|
+
# t.attribute :name
|
11
|
+
# t.attribute :email
|
12
|
+
# end
|
13
|
+
#
|
14
|
+
def index_for objects, html_options = {}, &block
|
15
|
+
html_options = html_options.dup
|
16
|
+
|
17
|
+
tag = html_options[:table_tag] || IndexFor.table_tag
|
18
|
+
|
19
|
+
klass = html_options[:klass] || objects.try(:klass) || objects.first.class
|
20
|
+
|
21
|
+
html_options[:id] ||= index_for_id(klass)
|
22
|
+
html_options[:class] = index_for_class(klass, html_options)
|
23
|
+
|
24
|
+
head = index_for_head(klass.new, html_options, &block)
|
25
|
+
body = index_for_body(objects, html_options, &block)
|
26
|
+
content = head + body
|
27
|
+
|
28
|
+
content_tag(tag, content, html_options)
|
29
|
+
end
|
30
|
+
|
31
|
+
# Create action links and yields a builder.
|
32
|
+
#
|
33
|
+
# Example:
|
34
|
+
#
|
35
|
+
# index_for_actions @user do |a|
|
36
|
+
# a.action_link :show
|
37
|
+
# a.action_link :edit
|
38
|
+
# end
|
39
|
+
#
|
40
|
+
# index_for_actions @user, :show, :edit
|
41
|
+
#
|
42
|
+
def index_for_actions object, *action_names, &block
|
43
|
+
html_options = action_names.extract_options!
|
44
|
+
action_names = [:show, :edit, :destroy] if action_names == [:all]
|
45
|
+
|
46
|
+
builder = IndexFor::ActionBuilder.new(object, html_options, self)
|
47
|
+
|
48
|
+
content = capture(builder) do |a|
|
49
|
+
action_names.map do |action_name|
|
50
|
+
a.action_link action_name
|
51
|
+
end.join.html_safe
|
52
|
+
end
|
53
|
+
|
54
|
+
content += capture(builder, &block) if block
|
55
|
+
|
56
|
+
content
|
57
|
+
end
|
58
|
+
|
59
|
+
# Creates a desc list around the object and yields a builder.
|
60
|
+
#
|
61
|
+
# Example:
|
62
|
+
#
|
63
|
+
# show_for @user do |l|
|
64
|
+
# l.attribute :name
|
65
|
+
# l.attribute :email
|
66
|
+
# end
|
67
|
+
#
|
68
|
+
def show_for object, html_options = {}, &block
|
69
|
+
html_options = html_options.dup
|
70
|
+
|
71
|
+
tag = html_options[:list_tag] || IndexFor.list_tag
|
72
|
+
|
73
|
+
html_options[:id] ||= show_for_id(object)
|
74
|
+
html_options[:class] = show_for_class(object, html_options)
|
75
|
+
|
76
|
+
content = capture(IndexFor::ListColumnBuilder.new(object, html_options, self), &block)
|
77
|
+
|
78
|
+
content_tag(tag, content, html_options)
|
79
|
+
end
|
80
|
+
|
81
|
+
private
|
82
|
+
|
83
|
+
def index_for_head object, html_options = {}, &block
|
84
|
+
head_tag = html_options[:head_tag] || IndexFor.table_head_tag
|
85
|
+
row_tag = html_options[:row_tag] || IndexFor.table_row_tag
|
86
|
+
|
87
|
+
head_html_options = html_options[:head_html] || {}
|
88
|
+
append_class head_html_options, IndexFor.table_head_class
|
89
|
+
|
90
|
+
row_html_options = html_options[:row_html] || {}
|
91
|
+
append_class row_html_options, IndexFor.table_row_class, dom_class(object)
|
92
|
+
|
93
|
+
content = capture(IndexFor::HeadColumnBuilder.new(object, html_options, self), &block)
|
94
|
+
|
95
|
+
content_tag(head_tag, head_html_options) do
|
96
|
+
content_tag(row_tag, content, row_html_options)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def index_for_body objects, html_options = {}, &block
|
101
|
+
body_tag = html_options[:body_tag] || IndexFor.table_body_tag
|
102
|
+
row_tag = html_options[:row_tag] || IndexFor.table_row_tag
|
103
|
+
|
104
|
+
body_html_options = html_options[:body_html] || {}
|
105
|
+
append_class body_html_options, IndexFor.table_body_class
|
106
|
+
|
107
|
+
content_tag(body_tag, body_html_options) do
|
108
|
+
objects.map do |object|
|
109
|
+
row_html_options = html_options[:row_html] || {}
|
110
|
+
row_html_options[:id] ||= dom_id(object)
|
111
|
+
append_class row_html_options, IndexFor.table_row_class, dom_class(object)
|
112
|
+
|
113
|
+
content = capture(IndexFor::BodyColumnBuilder.new(object, html_options, self), &block)
|
114
|
+
content_tag(row_tag, content, row_html_options)
|
115
|
+
end.join.html_safe
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# Finds the class representing the collection
|
120
|
+
# IndexFor
|
121
|
+
def index_for_id klass
|
122
|
+
klass.model_name.plural
|
123
|
+
end
|
124
|
+
|
125
|
+
def index_for_class klass, html_options
|
126
|
+
append_class html_options, "index_for", klass.model_name.plural, IndexFor.table_class
|
127
|
+
end
|
128
|
+
|
129
|
+
# ShowFor
|
130
|
+
def show_for_id object
|
131
|
+
dom_id object
|
132
|
+
end
|
133
|
+
|
134
|
+
def show_for_class object, html_options
|
135
|
+
append_class html_options, "show_for", dom_class(object), IndexFor.table_class
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
140
|
+
ActionView::Base.send :include, IndexFor::Helper
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module IndexFor
|
2
|
+
module ShareHelper
|
3
|
+
private
|
4
|
+
|
5
|
+
def append_class html_options, *classes
|
6
|
+
classes << html_options[:class]
|
7
|
+
classes.compact!
|
8
|
+
html_options[:class] = classes.join(" ") if classes.any?
|
9
|
+
end
|
10
|
+
|
11
|
+
def append_html_class options, *classes
|
12
|
+
options[:html] ||= {}
|
13
|
+
append_class options[:html], *classes
|
14
|
+
end
|
15
|
+
|
16
|
+
def translate i18n_key, options = {}
|
17
|
+
I18n.t(i18n_key, options.reverse_merge(scope: :index_for))
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
data/lib/index_for.rb
ADDED
@@ -0,0 +1,96 @@
|
|
1
|
+
require 'action_view'
|
2
|
+
require 'index_for/share_helper'
|
3
|
+
require 'index_for/helper'
|
4
|
+
|
5
|
+
module IndexFor
|
6
|
+
autoload :Builder, 'index_for/builder'
|
7
|
+
autoload :ActionBuilder, 'index_for/builders/action_builder'
|
8
|
+
autoload :HeadColumnBuilder, 'index_for/builders/head_column_builder'
|
9
|
+
autoload :BodyColumnBuilder, 'index_for/builders/body_column_builder'
|
10
|
+
autoload :ListColumnBuilder, 'index_for/builders/list_column_builder'
|
11
|
+
|
12
|
+
# IndexFor
|
13
|
+
mattr_accessor :table_tag
|
14
|
+
@@table_tag = :table
|
15
|
+
mattr_accessor :table_class
|
16
|
+
@@table_class = nil
|
17
|
+
|
18
|
+
mattr_accessor :table_head_tag
|
19
|
+
@@table_head_tag = :thead
|
20
|
+
mattr_accessor :table_head_class
|
21
|
+
@@table_head_class = nil
|
22
|
+
|
23
|
+
mattr_accessor :table_body_tag
|
24
|
+
@@table_body_tag = :tbody
|
25
|
+
mattr_accessor :table_body_class
|
26
|
+
@@table_body_class = nil
|
27
|
+
|
28
|
+
mattr_accessor :table_row_tag
|
29
|
+
@@table_row_tag = :tr
|
30
|
+
mattr_accessor :table_row_class
|
31
|
+
@@table_row_class = nil
|
32
|
+
|
33
|
+
mattr_accessor :table_head_cell_tag
|
34
|
+
@@table_head_cell_tag = :th
|
35
|
+
mattr_accessor :table_head_cell_class
|
36
|
+
@@table_head_cell_class = nil
|
37
|
+
|
38
|
+
mattr_accessor :table_body_cell_tag
|
39
|
+
@@table_body_cell_tag = :td
|
40
|
+
mattr_accessor :table_body_cell_class
|
41
|
+
@@table_body_cell_class = nil
|
42
|
+
|
43
|
+
mattr_accessor :table_actions_cell_class
|
44
|
+
@@table_actions_cell_class = :actions
|
45
|
+
|
46
|
+
mattr_accessor :action_link_class
|
47
|
+
@@action_link_class = :action
|
48
|
+
|
49
|
+
# ShowFor
|
50
|
+
mattr_accessor :list_tag
|
51
|
+
@@list_tag = :dl
|
52
|
+
mattr_accessor :list_class
|
53
|
+
@@list_class = nil
|
54
|
+
|
55
|
+
mattr_accessor :list_row_tag
|
56
|
+
@@list_row_tag = nil
|
57
|
+
mattr_accessor :list_row_class
|
58
|
+
@@list_row_class = nil
|
59
|
+
|
60
|
+
mattr_accessor :list_label_tag
|
61
|
+
@@list_label_tag = :dt
|
62
|
+
mattr_accessor :list_label_class
|
63
|
+
@@list_label_class = nil
|
64
|
+
|
65
|
+
mattr_accessor :list_content_tag
|
66
|
+
@@list_content_tag = :dd
|
67
|
+
mattr_accessor :list_content_class
|
68
|
+
@@list_content_class = nil
|
69
|
+
|
70
|
+
mattr_accessor :list_label_proc
|
71
|
+
@@list_label_proc = nil
|
72
|
+
|
73
|
+
mattr_accessor :blank_content_class
|
74
|
+
@@blank_content_class = "blank"
|
75
|
+
|
76
|
+
mattr_accessor :i18n_format
|
77
|
+
@@i18n_format = :default
|
78
|
+
|
79
|
+
mattr_accessor :association_methods
|
80
|
+
@@association_methods = [ :name, :title, :to_s ]
|
81
|
+
|
82
|
+
mattr_accessor :collection_tag
|
83
|
+
@@collection_tag = :ul
|
84
|
+
mattr_accessor :collection_column_tag
|
85
|
+
@@collection_column_tag = :li
|
86
|
+
|
87
|
+
# Yield self for configuration block:
|
88
|
+
#
|
89
|
+
# IndexFor.setup do |config|
|
90
|
+
# config.index_for_tag = :div
|
91
|
+
# end
|
92
|
+
#
|
93
|
+
def self.setup
|
94
|
+
yield self
|
95
|
+
end
|
96
|
+
end
|
metadata
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: index_for
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Theo
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-07-17 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activemodel
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '3.2'
|
20
|
+
- - "<"
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '5'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '3.2'
|
30
|
+
- - "<"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '5'
|
33
|
+
- !ruby/object:Gem::Dependency
|
34
|
+
name: actionpack
|
35
|
+
requirement: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - ">="
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '3.2'
|
40
|
+
- - "<"
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
version: '5'
|
43
|
+
type: :runtime
|
44
|
+
prerelease: false
|
45
|
+
version_requirements: !ruby/object:Gem::Requirement
|
46
|
+
requirements:
|
47
|
+
- - ">="
|
48
|
+
- !ruby/object:Gem::Version
|
49
|
+
version: '3.2'
|
50
|
+
- - "<"
|
51
|
+
- !ruby/object:Gem::Version
|
52
|
+
version: '5'
|
53
|
+
- !ruby/object:Gem::Dependency
|
54
|
+
name: bundler
|
55
|
+
requirement: !ruby/object:Gem::Requirement
|
56
|
+
requirements:
|
57
|
+
- - "~>"
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '1.6'
|
60
|
+
type: :development
|
61
|
+
prerelease: false
|
62
|
+
version_requirements: !ruby/object:Gem::Requirement
|
63
|
+
requirements:
|
64
|
+
- - "~>"
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: '1.6'
|
67
|
+
- !ruby/object:Gem::Dependency
|
68
|
+
name: rake
|
69
|
+
requirement: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
version: '0'
|
74
|
+
type: :development
|
75
|
+
prerelease: false
|
76
|
+
version_requirements: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
version: '0'
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
name: railties
|
83
|
+
requirement: !ruby/object:Gem::Requirement
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '3.2'
|
88
|
+
- - "<"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '5'
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - ">="
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '3.2'
|
98
|
+
- - "<"
|
99
|
+
- !ruby/object:Gem::Version
|
100
|
+
version: '5'
|
101
|
+
description: Wrap your objects with a helper to easily list them
|
102
|
+
email:
|
103
|
+
- bbtfrr@gmail.com
|
104
|
+
executables: []
|
105
|
+
extensions: []
|
106
|
+
extra_rdoc_files: []
|
107
|
+
files:
|
108
|
+
- Rakefile
|
109
|
+
- lib/generators/index_for/USAGE
|
110
|
+
- lib/generators/index_for/install_generator.rb
|
111
|
+
- lib/generators/index_for/templates/en.yml
|
112
|
+
- lib/generators/index_for/templates/index.html.erb
|
113
|
+
- lib/generators/index_for/templates/index.html.haml
|
114
|
+
- lib/generators/index_for/templates/index_for.rb
|
115
|
+
- lib/index_for.rb
|
116
|
+
- lib/index_for/attribute.rb
|
117
|
+
- lib/index_for/builder.rb
|
118
|
+
- lib/index_for/builders/action_builder.rb
|
119
|
+
- lib/index_for/builders/body_column_builder.rb
|
120
|
+
- lib/index_for/builders/head_column_builder.rb
|
121
|
+
- lib/index_for/builders/list_column_builder.rb
|
122
|
+
- lib/index_for/helper.rb
|
123
|
+
- lib/index_for/share_helper.rb
|
124
|
+
- lib/index_for/version.rb
|
125
|
+
homepage: https://github.com/bbtfr/index_for
|
126
|
+
licenses:
|
127
|
+
- MIT
|
128
|
+
metadata: {}
|
129
|
+
post_install_message:
|
130
|
+
rdoc_options: []
|
131
|
+
require_paths:
|
132
|
+
- lib
|
133
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
requirements: []
|
144
|
+
rubyforge_project:
|
145
|
+
rubygems_version: 2.2.2
|
146
|
+
signing_key:
|
147
|
+
specification_version: 4
|
148
|
+
summary: Wrap your objects with a helper to easily list them
|
149
|
+
test_files: []
|