kube-rails 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 (50) hide show
  1. data/README.md +1 -0
  2. data/Rakefile +14 -0
  3. data/lib/generators/kube/install/install_generator.rb +53 -0
  4. data/lib/generators/kube/install/templates/application.css +7 -0
  5. data/lib/generators/kube/install/templates/application.js +10 -0
  6. data/lib/generators/kube/install/templates/bootstrap.coffee +4 -0
  7. data/lib/generators/kube/install/templates/bootstrap_and_overrides.less +28 -0
  8. data/lib/generators/kube/layout/layout_generator.rb +23 -0
  9. data/lib/generators/kube/layout/templates/layout.html.erb +108 -0
  10. data/lib/generators/kube/layout/templates/layout.html.haml +68 -0
  11. data/lib/generators/kube/layout/templates/layout.html.slim +68 -0
  12. data/lib/generators/kube/partial/partial_generator.rb +20 -0
  13. data/lib/generators/kube/partial/templates/_login.html.erb +29 -0
  14. data/lib/generators/kube/partial/templates/_navbar.html.erb +13 -0
  15. data/lib/generators/kube/themed/templates/_form.html.erb +16 -0
  16. data/lib/generators/kube/themed/templates/_form.html.haml +10 -0
  17. data/lib/generators/kube/themed/templates/_form.html.slim +11 -0
  18. data/lib/generators/kube/themed/templates/edit.html.erb +6 -0
  19. data/lib/generators/kube/themed/templates/edit.html.haml +4 -0
  20. data/lib/generators/kube/themed/templates/edit.html.slim +4 -0
  21. data/lib/generators/kube/themed/templates/index.html.erb +40 -0
  22. data/lib/generators/kube/themed/templates/index.html.haml +25 -0
  23. data/lib/generators/kube/themed/templates/index.html.slim +27 -0
  24. data/lib/generators/kube/themed/templates/new.html.erb +6 -0
  25. data/lib/generators/kube/themed/templates/new.html.haml +4 -0
  26. data/lib/generators/kube/themed/templates/new.html.slim +4 -0
  27. data/lib/generators/kube/themed/templates/show.html.erb +23 -0
  28. data/lib/generators/kube/themed/templates/show.html.haml +15 -0
  29. data/lib/generators/kube/themed/templates/show.html.slim +17 -0
  30. data/lib/generators/kube/themed/templates/simple_form/_form.html.erb +14 -0
  31. data/lib/generators/kube/themed/templates/simple_form/_form.html.haml +11 -0
  32. data/lib/generators/kube/themed/templates/simple_form/_form.html.slim +12 -0
  33. data/lib/generators/kube/themed/themed_generator.rb +104 -0
  34. data/lib/kube/rails/engine.rb +13 -0
  35. data/lib/kube/rails/kube.rb +2 -0
  36. data/lib/kube/rails/version.rb +5 -0
  37. data/lib/kube-rails.rb +8 -0
  38. data/vendor/kube/base.less +199 -0
  39. data/vendor/kube/blocks.less +27 -0
  40. data/vendor/kube/buttons.less +138 -0
  41. data/vendor/kube/forms.less +219 -0
  42. data/vendor/kube/goodies.less +119 -0
  43. data/vendor/kube/grid.less +149 -0
  44. data/vendor/kube/kube.less +18 -0
  45. data/vendor/kube/mixins.less +76 -0
  46. data/vendor/kube/responsive.less +93 -0
  47. data/vendor/kube/tables.less +41 -0
  48. data/vendor/kube/typo.less +230 -0
  49. data/vendor/kube/variables.less +67 -0
  50. metadata +174 -0
@@ -0,0 +1,23 @@
1
+ <%%- model_class = <%= resource_name.classify %> -%>
2
+ <div class="page-header">
3
+ <h1><%%=t '.title', :default => model_class.model_name.human %></h1>
4
+ </div>
5
+
6
+ <dl class="dl-horizontal">
7
+ <%- columns.each do |column| -%>
8
+ <dt><strong><%%= model_class.human_attribute_name(:<%= column.name %>) %>:</strong></dt>
9
+ <dd><%%= @<%= resource_name %>.<%= column.name %> %></dd>
10
+ <%- end -%>
11
+ </dl>
12
+
13
+ <div class="form-actions">
14
+ <%%= link_to t('.back', :default => t("helpers.links.back")),
15
+ <%= controller_routing_path %>_path, :class => 'btn' %>
16
+ <%%= link_to t('.edit', :default => t("helpers.links.edit")),
17
+ edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn' %>
18
+ <%%= link_to t('.destroy', :default => t("helpers.links.destroy")),
19
+ <%= singular_controller_routing_path %>_path(@<%= resource_name %>),
20
+ :method => 'delete',
21
+ :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) },
22
+ :class => 'btn btn-danger' %>
23
+ </div>
@@ -0,0 +1,15 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ .page-header
3
+ %h1=t '.title', :default => model_class.model_name.human
4
+
5
+ <%- columns.each do |column| -%>
6
+ %p
7
+ %strong= model_class.human_attribute_name(:<%= column.name %>) + ':'
8
+ %br
9
+ = @<%= resource_name %>.<%= column.name %>
10
+ <%- end -%>
11
+
12
+ .form-actions
13
+ = link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn'
14
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
15
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
@@ -0,0 +1,17 @@
1
+ - model_class = <%= resource_name.classify %>
2
+ div class="page-header"
3
+ h1=t '.title', :default => model_class.model_name.human
4
+
5
+ <%- columns.each do |column| -%>
6
+ p
7
+ strong= model_class.human_attribute_name(:<%= column.name %>) + ':'
8
+ br
9
+ = @<%= resource_name %>.<%= column.name %>
10
+ <%- end -%>
11
+
12
+ .form-actions
13
+ = link_to t('.back', :default => t("helpers.links.back")), <%= controller_routing_path %>_path, :class => 'btn'
14
+ '
15
+ = link_to t('.edit', :default => t("helpers.links.edit")), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => 'btn'
16
+ '
17
+ = link_to t('.destroy', :default => t("helpers.links.destroy")), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :data => { :confirm => t('.confirm', :default => t("helpers.links.confirm", :default => 'Are you sure?')) }, :class => 'btn btn-danger'
@@ -0,0 +1,14 @@
1
+ <%%= simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f| %>
2
+ <%- columns.each do |column| -%>
3
+ <%%= f.input :<%= column.name %> %>
4
+ <%- end -%>
5
+ <%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
6
+ <%%= f.button :wrapped, :cancel => <%= controller_routing_path %>_path %>
7
+ <%- else -%>
8
+ <div class="form-actions">
9
+ <%%= f.button :submit, :class => 'btn-primary' %>
10
+ <%%= link_to t('.cancel', :default => t("helpers.links.cancel")),
11
+ <%= controller_routing_path %>_path, :class => 'btn' %>
12
+ </div>
13
+ <%- end -%>
14
+ <%% end %>
@@ -0,0 +1,11 @@
1
+ = simple_form_for @<%= resource_name %>, :html => { :class => 'form-horizontal' } do |f|
2
+ <%- columns.each do |column| -%>
3
+ = f.input :<%= column.name %>
4
+ <%- end -%>
5
+ <%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
6
+ = f.button :wrapped, :cancel => <%= controller_routing_path %>_path
7
+ <%- else -%>
8
+ .form-actions
9
+ = f.button :submit, :class => 'btn-primary'
10
+ = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
11
+ <%- end -%>
@@ -0,0 +1,12 @@
1
+ = simple_form_for @<%= resource_name %>, :html => { :class => "form-horizontal" } do |f|
2
+ <%- columns.each do |column| -%>
3
+ = f.input :<%= column.name %>
4
+ <%- end -%>
5
+ <%- if ::SimpleForm::FormBuilder.instance_methods.include?(:wrapped_button) -%>
6
+ = f.button :wrapped, :cancel => <%= controller_routing_path %>_path
7
+ <%- else -%>
8
+ .form-actions
9
+ = f.button :submit, :class => 'btn-primary'
10
+ '
11
+ = link_to t('.cancel', :default => t("helpers.links.cancel")), <%= controller_routing_path %>_path, :class => 'btn'
12
+ <%- end -%>
@@ -0,0 +1,104 @@
1
+ require 'rails/generators'
2
+ require 'rails/generators/generated_attribute'
3
+
4
+ module Bootstrap
5
+ module Generators
6
+ class ThemedGenerator < ::Rails::Generators::Base
7
+ source_root File.expand_path('../templates', __FILE__)
8
+ argument :controller_path, :type => :string
9
+ argument :model_name, :type => :string, :required => false
10
+ argument :layout, :type => :string, :default => "application",
11
+ :banner => "Specify application layout"
12
+
13
+ def initialize(args, *options)
14
+ super(args, *options)
15
+ initialize_views_variables
16
+ end
17
+
18
+ def copy_views
19
+ generate_views
20
+ end
21
+
22
+ protected
23
+
24
+ def initialize_views_variables
25
+ @base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
26
+ @controller_routing_path = @controller_file_path.gsub(/\//, '_')
27
+ @model_name = @controller_class_nesting + "::#{@base_name.singularize.camelize}" unless @model_name
28
+ @model_name = @model_name.camelize
29
+ end
30
+
31
+ def controller_routing_path
32
+ @controller_routing_path
33
+ end
34
+
35
+ def singular_controller_routing_path
36
+ @controller_routing_path.singularize
37
+ end
38
+
39
+ def model_name
40
+ @model_name
41
+ end
42
+
43
+ def plural_model_name
44
+ @model_name.pluralize
45
+ end
46
+
47
+ def resource_name
48
+ @model_name.demodulize.underscore
49
+ end
50
+
51
+ def plural_resource_name
52
+ resource_name.pluralize
53
+ end
54
+
55
+ def columns
56
+ begin
57
+ excluded_column_names = %w[id created_at updated_at]
58
+ begin
59
+ @model_name.constantize.columns.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
60
+ rescue ActiveRecord::StatementInvalid => e
61
+ say e.message, :red
62
+ exit
63
+ end
64
+ rescue NoMethodError
65
+ @model_name.constantize.fields.collect{|c| c[1]}.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| ::Rails::Generators::GeneratedAttribute.new(c.name, c.type.to_s)}
66
+ end
67
+ end
68
+
69
+ def extract_modules(name)
70
+ modules = name.include?('/') ? name.split('/') : name.split('::')
71
+ name = modules.pop
72
+ path = modules.map { |m| m.underscore }
73
+ file_path = (path + [name.underscore]).join('/')
74
+ nesting = modules.map { |m| m.camelize }.join('::')
75
+ [name, path, file_path, nesting, modules.size]
76
+ end
77
+
78
+ def generate_views
79
+ views = {
80
+ "index.html.#{ext}" => File.join('app/views', @controller_file_path, "index.html.#{ext}"),
81
+ "new.html.#{ext}" => File.join('app/views', @controller_file_path, "new.html.#{ext}"),
82
+ "edit.html.#{ext}" => File.join('app/views', @controller_file_path, "edit.html.#{ext}"),
83
+ "#{form_builder}_form.html.#{ext}" => File.join('app/views', @controller_file_path, "_form.html.#{ext}"),
84
+ "show.html.#{ext}" => File.join('app/views', @controller_file_path, "show.html.#{ext}")}
85
+ selected_views = views
86
+ options.engine == generate_erb(selected_views)
87
+ end
88
+
89
+ def generate_erb(views)
90
+ views.each do |template_name, output_path|
91
+ template template_name, output_path
92
+ end
93
+ end
94
+
95
+ def ext
96
+ ::Rails.application.config.generators.options[:rails][:template_engine] || :erb
97
+ end
98
+
99
+ def form_builder
100
+ defined?(::SimpleForm) ? 'simple_form/' : ''
101
+ end
102
+ end
103
+ end
104
+ end
@@ -0,0 +1,13 @@
1
+ require 'rails'
2
+
3
+ module Kube
4
+ module Rails
5
+ class Engine < ::Rails::Engine
6
+ initializer 'kube-rails.setup',
7
+ :after => 'less-rails.after.load_config_initializers',
8
+ :group => :all do |app|
9
+ app.config.less.paths << File.join(config.root, 'vendor', 'kube')
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,2 @@
1
+ require "kube/rails/engine"
2
+ require "kube/rails/version"
@@ -0,0 +1,5 @@
1
+ module Kube
2
+ module Rails
3
+ VERSION = "0.0.1"
4
+ end
5
+ end
data/lib/kube-rails.rb ADDED
@@ -0,0 +1,8 @@
1
+ module Kube
2
+ module Rails
3
+ require 'kube/rails/engine' if defined?(Rails)
4
+ end
5
+ end
6
+
7
+ require 'less-rails'
8
+ require 'kube/rails/kube' if defined?(Rails)
@@ -0,0 +1,199 @@
1
+ /*
2
+ Kube Professional CSS-framework
3
+
4
+ Copyright (c) 2012, Imperavi Inc.
5
+
6
+ http://imperavi.com/kube/
7
+
8
+ License: free
9
+
10
+ */
11
+
12
+ /* =Base, reset, normalize
13
+ -----------------------------------------------------------------------------*/
14
+ html,
15
+ body,
16
+ div,
17
+ span,
18
+ object,
19
+ iframe,
20
+ p,
21
+ blockquote,
22
+ pre,
23
+ a,
24
+ abbr,
25
+ acronym,
26
+ address,
27
+ big,
28
+ cite,
29
+ code,
30
+ del,
31
+ dfn,
32
+ em,
33
+ img,
34
+ ins,
35
+ kbd,
36
+ q,
37
+ s,
38
+ samp,
39
+ small,
40
+ strike,
41
+ strong,
42
+ sub,
43
+ sup,
44
+ tt,
45
+ var,
46
+ b,
47
+ u,
48
+ i,
49
+ center,
50
+ dl,
51
+ dt,
52
+ dd,
53
+ ol,
54
+ ul,
55
+ li,
56
+ fieldset,
57
+ form,
58
+ label,
59
+ legend,
60
+ table,
61
+ caption,
62
+ tbody,
63
+ tfoot,
64
+ thead,
65
+ tr,
66
+ th,
67
+ td,
68
+ article,
69
+ aside,
70
+ canvas,
71
+ details,
72
+ embed,
73
+ figure,
74
+ figcaption,
75
+ footer,
76
+ header,
77
+ hgroup,
78
+ menu,
79
+ nav,
80
+ output,
81
+ ruby,
82
+ section,
83
+ summary,
84
+ time,
85
+ mark,
86
+ audio,
87
+ video,
88
+ h1,
89
+ h2,
90
+ h3,
91
+ h4,
92
+ h5,
93
+ h6 {
94
+ margin: 0;
95
+ padding: 0;
96
+ border: 0;
97
+ outline: 0;
98
+ font-size: 100%;
99
+ vertical-align: baseline;
100
+ background: transparent;
101
+ font-style: normal;
102
+ }
103
+ /* Structure tags */
104
+ article,
105
+ aside,
106
+ details,
107
+ figcaption,
108
+ figure,
109
+ footer,
110
+ header,
111
+ hgroup,
112
+ nav,
113
+ section {
114
+ display: block;
115
+ }
116
+ /* Responsive images and other embedded objects */
117
+ img,
118
+ object,
119
+ embed,
120
+ video,
121
+ iframe {
122
+ width: auto;
123
+ max-width: 100%;
124
+ }
125
+ /* Responsive images aspeсt ratio */
126
+ img,
127
+ video,
128
+ iframe {
129
+ height: auto;
130
+ }
131
+ /* To prevent some browsers from inserting quotes on q and p */
132
+ blockquote, q {
133
+ quotes: none;
134
+ }
135
+ blockquote p:before,
136
+ blockquote p:after,
137
+ q:before,
138
+ q:after {
139
+ content: '';
140
+ content: none;
141
+ }
142
+ /* Table reset */
143
+ table {
144
+ border-collapse: collapse;
145
+ border-spacing: 0;
146
+ }
147
+ caption,
148
+ th,
149
+ td {
150
+ text-align: left;
151
+ vertical-align: top;
152
+ font-weight: normal;
153
+ }
154
+ thead th,
155
+ thead td {
156
+ font-weight: bold;
157
+ vertical-align: bottom;
158
+ }
159
+ /* Image inside */
160
+ a img, th img, td img {
161
+ vertical-align: top;
162
+ }
163
+ /* Webkit browsers reset margin */
164
+ button,
165
+ input,
166
+ select,
167
+ textarea {
168
+ margin: 0;
169
+ }
170
+ textarea {
171
+ overflow: auto;
172
+ }
173
+ /* Normalize buttons in IE */
174
+ button {
175
+ width: auto; overflow: visible;
176
+ }
177
+ /* Hand cursor on clickable controls */
178
+ input[type=button],
179
+ input[type=submit],
180
+ button {
181
+ cursor: pointer;
182
+ }
183
+ /* Trick with vertical align for radio and checkbox */
184
+ input[type="radio"],
185
+ input[type="checkbox"]
186
+ {
187
+ font-size: 110%;
188
+ }
189
+ /* Horizontal rule reset */
190
+ hr {
191
+ display: block;
192
+ height: 1px;
193
+ border: 0;
194
+ border-top: 1px solid #ddd;
195
+ }
196
+ /* Clearfix */
197
+ .group {
198
+ .clearfixing;
199
+ }
@@ -0,0 +1,27 @@
1
+ /* =Blocks
2
+ -----------------------------------------------------------------------------*/
3
+ .block-two,
4
+ .block-three,
5
+ .block-four,
6
+ .block-five,
7
+ .block-six {
8
+ list-style: none;
9
+ margin-left: -@gridGutterWidth/(@gridWidth/100)*1%;
10
+ margin-bottom: 0;
11
+ .clearfixing;
12
+ }
13
+ .block-two > li,
14
+ .block-three > li,
15
+ .block-four > li,
16
+ .block-five > li,
17
+ .block-six > li {
18
+ height: auto;
19
+ float: left;
20
+ margin-bottom: @baseLine/@em;
21
+ margin-left: @gridGutterWidth/(@gridWidth/100)*1%;
22
+ }
23
+ .block-two > li { .block(2); }
24
+ .block-three > li { .block(3); }
25
+ .block-four > li { .block(4); }
26
+ .block-five > li { .block(5); }
27
+ .block-six > li { .block(6); }
@@ -0,0 +1,138 @@
1
+ .btn {
2
+ position: relative;
3
+ cursor: pointer;
4
+ outline: none;
5
+ display: inline-block;
6
+ text-align: center;
7
+ text-decoration: none;
8
+ font-family: Arial, Helvetica, sans-serif;
9
+ line-height: 1;
10
+ font-size: 13px;
11
+ font-weight: normal;
12
+ padding: 6px 16px;
13
+ border-radius: 4px;
14
+
15
+ .gradient(#fff, #e1e1e1);
16
+ border: 1px solid #dadada;
17
+ border-left: 1px solid #d2d2d2;
18
+ border-right: 1px solid #d2d2d2;
19
+ border-bottom-color: #a9a9a9;
20
+ box-shadow: 0 1px 0 rgba(0, 0, 0, .15), inset 0 1px 1px 0 rgba(255, 255, 255, 0.6);
21
+ text-shadow: 0 1px 0px rgba(255, 255, 255, 1);
22
+ }
23
+ .btn, .btn:hover {
24
+ color: #000;
25
+ }
26
+ .btn:hover {
27
+ filter: none;
28
+ background: none;
29
+ background: #eee;
30
+ text-shadow: 0 1px 0px rgba(255, 255, 255, .8);
31
+ text-decoration: none;
32
+ box-shadow: 0 1px 0 rgba(0, 0, 0, .15);
33
+ }
34
+
35
+
36
+ /* Active */
37
+ .btn-big.btn-active, .btn-big.btn-active:hover {
38
+ padding: 11px 25px;
39
+ }
40
+ .btn-active, .btn-active:hover {
41
+ box-shadow: 0 2px 4px rgba(0, 0, 0, .4) inset;
42
+ color: #555;
43
+ border: none;
44
+ background: none;
45
+ filter: none;
46
+ background-color: #ddd;
47
+ text-shadow: 0 1px 0px rgba(255, 255, 255, .8);
48
+ padding: 7px 17px 8px 17px;
49
+ }
50
+
51
+
52
+ /* Small */
53
+ .btn-small {
54
+ padding: 4px 12px;
55
+ font-size: 11px;
56
+ }
57
+ .btn-small.btn-active {
58
+ padding: 5px 12px;
59
+ }
60
+
61
+ /* Big */
62
+ .btn-big {
63
+ padding: 10px 24px;
64
+ font-size: 20px;
65
+ }
66
+
67
+
68
+ /* Square */
69
+ .btn-square {
70
+ -moz-border-radius: 0;
71
+ -webkit-border-radius: 0;
72
+ border-radius: 0;
73
+ }
74
+
75
+ /* Round */
76
+ .btn-round {
77
+ border-radius: 15px;
78
+ border-radius: 0 \0; /* ie9 hack */
79
+ }
80
+
81
+ /* Full */
82
+ .btn-full {
83
+ width: 100%;
84
+ }
85
+
86
+
87
+ /* Group */
88
+ .btn-group {
89
+ display: inline-block;
90
+ margin-right: 2px;
91
+ .clearfixing();
92
+ vertical-align: bottom;
93
+ }
94
+ .btn-group > .btn, .btn-group > input {
95
+ float: left;
96
+ -moz-border-radius: 0;
97
+ -webkit-border-radius: 0;
98
+ border-radius: 0;
99
+ margin-left: -1px;
100
+ }
101
+ .btn-group > .btn:first-child {
102
+ border-radius: 4px 0 0 4px;
103
+ }
104
+ .btn-group > .btn:last-child {
105
+ border-radius: 0 4px 4px 0;
106
+ }
107
+ .btn-group > .btn.btn-round:first-child, .btn-group > .input-search:first-child {
108
+ border-radius: 15px 0 0 15px;
109
+ }
110
+ .btn-group > .btn.btn-round:last-child, .btn-group > .input-search:last-child {
111
+ border-radius: 0 15px 15px 0;
112
+ }
113
+
114
+
115
+ /* Append */
116
+ .btn-append {
117
+ margin-left: -2px;
118
+ border-radius: 0 4px 4px 0;
119
+ }
120
+
121
+
122
+ /* Disabled */
123
+ .btn.disabled,
124
+ .btn[disabled] {
125
+ border: none;
126
+ filter: none;
127
+ background: none;
128
+ background-color: #e9e9e9;
129
+ opacity: 0.6;
130
+ cursor: default;
131
+ box-shadow: 0 1px 0 rgba(0, 0, 0, .6);
132
+ }
133
+
134
+
135
+ /* FF fix */
136
+ @-moz-document url-prefix("http://") {
137
+ input[type=submit].btn::-moz-focus-inner, button.btn::-moz-focus-inner { border: 0; padding: 0; }
138
+ }