activoate 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile +4 -0
- data/README +3 -0
- data/Rakefile +1 -0
- data/activoate.gemspec +25 -0
- data/app/.DS_Store +0 -0
- data/app/assets/.DS_Store +0 -0
- data/app/assets/images/.DS_Store +0 -0
- data/app/assets/images/activo-2/.DS_Store +0 -0
- data/app/assets/images/activo-2/arrow.png +0 -0
- data/app/assets/images/activo-2/avatar.png +0 -0
- data/app/assets/images/activo-2/bgd.jpg +0 -0
- data/app/assets/images/activo-2/boxbar-background.png +0 -0
- data/app/assets/images/activo-2/breadcrumb.png +0 -0
- data/app/assets/images/activo-2/button-background-active.png +0 -0
- data/app/assets/images/activo-2/button-background.png +0 -0
- data/app/assets/images/activo-2/icons/24/about-this-folder.txt +12 -0
- data/app/assets/images/activo-2/icons/24/anchor-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/anchor.png +0 -0
- data/app/assets/images/activo-2/icons/24/cross-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/cross.png +0 -0
- data/app/assets/images/activo-2/icons/24/download-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/download.png +0 -0
- data/app/assets/images/activo-2/icons/24/edit-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/edit.png +0 -0
- data/app/assets/images/activo-2/icons/24/export-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/export.png +0 -0
- data/app/assets/images/activo-2/icons/24/show-hover.png +0 -0
- data/app/assets/images/activo-2/icons/24/show.png +0 -0
- data/app/assets/images/activo-2/icons/about-this-folder.txt +1 -0
- data/app/assets/images/activo-2/icons/add.png +0 -0
- data/app/assets/images/activo-2/icons/application_edit.png +0 -0
- data/app/assets/images/activo-2/icons/calendar-hover.png +0 -0
- data/app/assets/images/activo-2/icons/calendar.png +0 -0
- data/app/assets/images/activo-2/icons/cross.png +0 -0
- data/app/assets/images/activo-2/icons/delete.png +0 -0
- data/app/assets/images/activo-2/icons/download.png +0 -0
- data/app/assets/images/activo-2/icons/edit.png +0 -0
- data/app/assets/images/activo-2/icons/key.png +0 -0
- data/app/assets/images/activo-2/icons/pdf.png +0 -0
- data/app/assets/images/activo-2/icons/search.png +0 -0
- data/app/assets/images/activo-2/icons/see-less.png +0 -0
- data/app/assets/images/activo-2/icons/see-more.png +0 -0
- data/app/assets/images/activo-2/icons/send-mail.png +0 -0
- data/app/assets/images/activo-2/icons/show.png +0 -0
- data/app/assets/images/activo-2/icons/tick.png +0 -0
- data/app/assets/images/activo-2/icons/upload.png +0 -0
- data/app/assets/images/activo-2/logo.png +0 -0
- data/app/assets/images/activo-2/messages/error.png +0 -0
- data/app/assets/images/activo-2/messages/notice.png +0 -0
- data/app/assets/images/activo-2/messages/warning.png +0 -0
- data/app/assets/images/activo-2/search-button.png +0 -0
- data/app/assets/images/activo-2/session/about-this-folder.txt +1 -0
- data/app/assets/images/activo-2/session/account.png +0 -0
- data/app/assets/images/activo-2/session/config.png +0 -0
- data/app/assets/images/activo-2/session/home.png +0 -0
- data/app/assets/images/activo-2/session/logout.png +0 -0
- data/app/assets/images/activo-2/tipsy/tipsy.gif +0 -0
- data/app/assets/images/activo-2/uniform/bg-input-focus.png +0 -0
- data/app/assets/images/activo-2/uniform/bg-input.png +0 -0
- data/app/assets/images/activo-2/uniform/sprite.png +0 -0
- data/app/assets/javascripts/.DS_Store +0 -0
- data/app/assets/javascripts/activo-2/activo-2.js +81 -0
- data/app/assets/javascripts/activo-2/jquery.localscroll.js +104 -0
- data/app/assets/javascripts/activo-2/jquery.scrollTo.js +150 -0
- data/app/assets/javascripts/activo-2/jquery.tipsy.js +104 -0
- data/app/assets/javascripts/activo-2/jquery.uniform.min.js +1 -0
- data/app/assets/javascripts/activo-2.js +10 -0
- data/app/assets/javascripts/users.js.coffee +3 -0
- data/app/assets/stylesheets/.DS_Store +0 -0
- data/app/assets/stylesheets/activo-2/.DS_Store +0 -0
- data/app/assets/stylesheets/activo-2/attrtastic_changes.sass +62 -0
- data/app/assets/stylesheets/activo-2/base.css +390 -0
- data/app/assets/stylesheets/activo-2/fonts/.DS_Store +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museo700-regular-webfont.eot +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museo700-regular-webfont.svg +242 -0
- data/app/assets/stylesheets/activo-2/fonts/museo700-regular-webfont.ttf +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museo700-regular-webfont.woff +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500-webfont.eot +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500-webfont.svg +240 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500-webfont.ttf +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500-webfont.woff +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500_italic-webfont.eot +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500_italic-webfont.svg +240 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500_italic-webfont.ttf +0 -0
- data/app/assets/stylesheets/activo-2/fonts/museosans_500_italic-webfont.woff +0 -0
- data/app/assets/stylesheets/activo-2/fonts.sass +49 -0
- data/app/assets/stylesheets/activo-2/formtastic_changes.sass +157 -0
- data/app/assets/stylesheets/activo-2/libs/jquery.tipsy.css +9 -0
- data/app/assets/stylesheets/activo-2/libs/uniform.default.css +610 -0
- data/app/assets/stylesheets/activo-2/mixins.sass +22 -0
- data/app/assets/stylesheets/activo-2/style.sass +666 -0
- data/app/assets/stylesheets/activo-2.css +11 -0
- data/app/assets/stylesheets/application.css +7 -0
- data/app/assets/stylesheets/scaffolds.css.scss +56 -0
- data/app/assets/stylesheets/users.css.scss +3 -0
- data/app/helpers/activo_helper.rb +290 -0
- data/config.ru +4 -0
- data/lib/activoate/engine.rb +6 -0
- data/lib/activoate/version.rb +3 -0
- data/lib/activoate.rb +5 -0
- data/lib/generators/activoate/activated/activated_generator.rb +140 -0
- data/lib/generators/activoate/activated/templates/view_edit.html.erb +17 -0
- data/lib/generators/activoate/activated/templates/view_form.html.erb +16 -0
- data/lib/generators/activoate/activated/templates/view_form_formtastic.html.erb +18 -0
- data/lib/generators/activoate/activated/templates/view_new.html.erb +16 -0
- data/lib/generators/activoate/activated/templates/view_show.html.erb +26 -0
- data/lib/generators/activoate/activated/templates/view_show_attrtastic.html.erb +27 -0
- data/lib/generators/activoate/activated/templates/view_sidebar.html.erb +13 -0
- data/lib/generators/activoate/activated/templates/view_signin.html.erb +36 -0
- data/lib/generators/activoate/activated/templates/view_signup.html.erb +52 -0
- data/lib/generators/activoate/activated/templates/view_tables.html.erb +56 -0
- data/lib/generators/activoate/activated/templates/view_text.html.erb +18 -0
- data/lib/generators/activoate/install/install_generator.rb +40 -0
- data/lib/generators/activoate/install/templates/layout_admin.html.erb +49 -0
- data/lib/templates/web_app_theme/theme/layout_admin.html.erb +57 -0
- data/lib/templates/web_app_theme/theme/layout_sign.html.erb +15 -0
- data/lib/templates/web_app_theme/theme/web_app_theme.css.erb +9 -0
- metadata +197 -0
@@ -0,0 +1,56 @@
|
|
1
|
+
body {
|
2
|
+
background-color: #fff;
|
3
|
+
color: #333;
|
4
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
5
|
+
font-size: 13px;
|
6
|
+
line-height: 18px; }
|
7
|
+
|
8
|
+
p, ol, ul, td {
|
9
|
+
font-family: verdana, arial, helvetica, sans-serif;
|
10
|
+
font-size: 13px;
|
11
|
+
line-height: 18px; }
|
12
|
+
|
13
|
+
pre {
|
14
|
+
background-color: #eee;
|
15
|
+
padding: 10px;
|
16
|
+
font-size: 11px; }
|
17
|
+
|
18
|
+
a {
|
19
|
+
color: #000;
|
20
|
+
&:visited {
|
21
|
+
color: #666; }
|
22
|
+
&:hover {
|
23
|
+
color: #fff;
|
24
|
+
background-color: #000; } }
|
25
|
+
|
26
|
+
div {
|
27
|
+
&.field, &.actions {
|
28
|
+
margin-bottom: 10px; } }
|
29
|
+
|
30
|
+
#notice {
|
31
|
+
color: green; }
|
32
|
+
|
33
|
+
.field_with_errors {
|
34
|
+
padding: 2px;
|
35
|
+
background-color: red;
|
36
|
+
display: table; }
|
37
|
+
|
38
|
+
#error_explanation {
|
39
|
+
width: 450px;
|
40
|
+
border: 2px solid red;
|
41
|
+
padding: 7px;
|
42
|
+
padding-bottom: 0;
|
43
|
+
margin-bottom: 20px;
|
44
|
+
background-color: #f0f0f0;
|
45
|
+
h2 {
|
46
|
+
text-align: left;
|
47
|
+
font-weight: bold;
|
48
|
+
padding: 5px 5px 5px 15px;
|
49
|
+
font-size: 12px;
|
50
|
+
margin: -7px;
|
51
|
+
margin-bottom: 0px;
|
52
|
+
background-color: #c00;
|
53
|
+
color: #fff; }
|
54
|
+
ul li {
|
55
|
+
font-size: 12px;
|
56
|
+
list-style: square; } }
|
@@ -0,0 +1,290 @@
|
|
1
|
+
module ActivoHelper
|
2
|
+
|
3
|
+
# Get or set the page title
|
4
|
+
#
|
5
|
+
# title - The title to set. (optional)
|
6
|
+
#
|
7
|
+
# Example:
|
8
|
+
# page_title("Hello, world!")
|
9
|
+
# # => "Hello, world!"
|
10
|
+
# page_title
|
11
|
+
# # => "Hello, world!"
|
12
|
+
#
|
13
|
+
# Returns the page title, first setting it if title is not nil.
|
14
|
+
def page_title(title = nil)
|
15
|
+
@title = title unless title.nil?
|
16
|
+
@title
|
17
|
+
end
|
18
|
+
|
19
|
+
# Displays a badge
|
20
|
+
#
|
21
|
+
# content - The bagde`s content
|
22
|
+
# color - null for white, or grey, red, yellow, green
|
23
|
+
#
|
24
|
+
# Example:
|
25
|
+
# <%= badge 'New!', 'yellow' %>
|
26
|
+
#
|
27
|
+
# Returns a div tag
|
28
|
+
def badge(content, color = '')
|
29
|
+
color = "-#{color}" unless color.length == 0
|
30
|
+
|
31
|
+
content_tag('div', { :class => "badge#{color}" }) do
|
32
|
+
content
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# Wraps the button helper, creating an add button
|
37
|
+
#
|
38
|
+
# path - The button`s action
|
39
|
+
#
|
40
|
+
# Example:
|
41
|
+
# <%= add_button new_user_path %>
|
42
|
+
#
|
43
|
+
# Returns an anchor tag
|
44
|
+
def add_button(path)
|
45
|
+
button(path, t("web-app-theme.add", :default => 'Add'), 'add')
|
46
|
+
end
|
47
|
+
|
48
|
+
# Wraps the button helper, creating an edit button
|
49
|
+
#
|
50
|
+
# path - The button`s action
|
51
|
+
# alternative_icon - True for the alternative icon
|
52
|
+
#
|
53
|
+
# Example:
|
54
|
+
# <%= edit_button edit_user_path(@user) %>
|
55
|
+
# <%= edit_button edit_user_path(@user), true %>
|
56
|
+
#
|
57
|
+
# Returns an anchor tag
|
58
|
+
def edit_button(path, alternative_icon = false)
|
59
|
+
button(path, t("web-app-theme.edit", :default => 'Edit'), alternative_icon ? 'edit' : 'application_edit')
|
60
|
+
end
|
61
|
+
|
62
|
+
# Wraps the button helper, creating a delete button
|
63
|
+
#
|
64
|
+
# path - The button`s action
|
65
|
+
# alternative_icon - True for the alternative icon
|
66
|
+
#
|
67
|
+
# Example:
|
68
|
+
# <%= delete_button users_path(@user) %>
|
69
|
+
# <%= delete_button users_path(@user), true %>
|
70
|
+
#
|
71
|
+
# Returns an anchor tag
|
72
|
+
def delete_button(path, alternative_icon = false)
|
73
|
+
options = {
|
74
|
+
:confirm => t("web-app-theme.confirm", :default => "Are you sure?"),
|
75
|
+
:method => :delete
|
76
|
+
}
|
77
|
+
button(path, t("web-app-theme.delete", :default => 'Delete'), alternative_icon ? 'delete' : 'cross', options)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Displays a button
|
81
|
+
#
|
82
|
+
# path - The button`s action
|
83
|
+
# caption - The button`s caption
|
84
|
+
# icon - The icon file name, without the extension
|
85
|
+
# options - A hash of attributes to apply to the wrapping anchor tag
|
86
|
+
#
|
87
|
+
# Example:
|
88
|
+
# <%= button root_path, { :caption => 'home', :icon => 'home' } %>
|
89
|
+
#
|
90
|
+
# Returns an anchor tag
|
91
|
+
def button(path, caption = 'click-me', icon = 'show', options = {})
|
92
|
+
default_options = { :class => "button", :confirm => false, :method => :get }
|
93
|
+
options = default_options.merge(options)
|
94
|
+
|
95
|
+
link_to path, options do
|
96
|
+
image_tag("activo-2/icons/#{icon}.png", :alt => caption) + " " + caption
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
# Creates a set of buttons
|
101
|
+
#
|
102
|
+
# options - A hash of attributes to apply to the wrapping div tag
|
103
|
+
#
|
104
|
+
# Example:
|
105
|
+
# <div class="block">
|
106
|
+
# <div class="content">
|
107
|
+
# <%= controls do |c|
|
108
|
+
# c.item add_button(new_user_path)
|
109
|
+
# c.item button(root_path, { :caption => 'home', :icon => 'home' })
|
110
|
+
# c.item delete_button(users_path(@user), true)
|
111
|
+
# end %>
|
112
|
+
# </div>
|
113
|
+
# </div>
|
114
|
+
#
|
115
|
+
# Returns a set of controls to be displayed.
|
116
|
+
def controls(options = {})
|
117
|
+
options[:class] ||= ""
|
118
|
+
options[:class] << " control"
|
119
|
+
options[:class] = options[:class].strip.html_safe
|
120
|
+
|
121
|
+
items = ControlsBuilder.new
|
122
|
+
yield items if block_given?
|
123
|
+
|
124
|
+
content_tag("div", options) do
|
125
|
+
items.to_a.join("").html_safe
|
126
|
+
end
|
127
|
+
end
|
128
|
+
|
129
|
+
# Displays an icon
|
130
|
+
#
|
131
|
+
# name - The icon file name, without the extension
|
132
|
+
# options - A hash of attributes to apply to the image tag
|
133
|
+
#
|
134
|
+
# Example:
|
135
|
+
# <%= icon 'add', { :alt => "Add item" } %>
|
136
|
+
#
|
137
|
+
# Returns an img tag.
|
138
|
+
def icon(name, options = {})
|
139
|
+
return "" if name.nil?
|
140
|
+
|
141
|
+
options[:alt] ||= name.capitalize.gsub("_", " ")
|
142
|
+
|
143
|
+
path = "activo-2/icons/#{name}.png"
|
144
|
+
|
145
|
+
image_tag path, { :alt => options[:alt] }
|
146
|
+
end
|
147
|
+
|
148
|
+
# Displays a navigation menu
|
149
|
+
#
|
150
|
+
# options - A hash of attributes to apply to the wrapping div tag
|
151
|
+
#
|
152
|
+
# Example:
|
153
|
+
# <div class="block">
|
154
|
+
# <%= navigation do |nav|
|
155
|
+
# nav.item "List People", people_path, :active => true
|
156
|
+
# nav.item "New Person", new_person_path
|
157
|
+
# nav.item "Search", search_path(:type => "people")
|
158
|
+
# end %>
|
159
|
+
# <div class="content">
|
160
|
+
# <h2 class="title">List People</h2>
|
161
|
+
# </div>
|
162
|
+
# </div>
|
163
|
+
#
|
164
|
+
# Returns a navigation block to be displayed.
|
165
|
+
def navigation(options = {}, &block)
|
166
|
+
options[:class] ||= ""
|
167
|
+
options[:class] = options[:class].strip.html_safe
|
168
|
+
|
169
|
+
menu = NavigationBuilder.new
|
170
|
+
yield menu if block_given?
|
171
|
+
|
172
|
+
content_tag("div", options) do
|
173
|
+
content_tag("ul", "", :class => "wat-cf") do
|
174
|
+
menu.collect { |item|
|
175
|
+
content_tag("li", :class => item[:class]) do
|
176
|
+
link_to(item[:label], item[:href], item[:link_options])
|
177
|
+
end
|
178
|
+
}.join("").html_safe
|
179
|
+
end
|
180
|
+
end
|
181
|
+
end
|
182
|
+
|
183
|
+
# Displays a secondary navigation menu
|
184
|
+
def secondary_navigation(options = {}, &block)
|
185
|
+
options[:class] ||= ""
|
186
|
+
options[:class] << " secondary-navigation"
|
187
|
+
|
188
|
+
navigation(options, &block)
|
189
|
+
end
|
190
|
+
|
191
|
+
# Displays a secondary inner navigation menu
|
192
|
+
def secondary_inner_navigation(options = {}, &block)
|
193
|
+
options[:class] ||= ""
|
194
|
+
options[:class] << " secondary-inner-nav"
|
195
|
+
|
196
|
+
navigation(options, &block)
|
197
|
+
end
|
198
|
+
|
199
|
+
# Displays a breadcrumb trail
|
200
|
+
#
|
201
|
+
# options - A hash of attributes to apply to the wrapping div tag
|
202
|
+
#
|
203
|
+
# Example:
|
204
|
+
# <div class="block">
|
205
|
+
# <div class="content">
|
206
|
+
# <h2><%= @news_item.title %></h2>
|
207
|
+
# <p><%= @news_item.content %></p>
|
208
|
+
# </div>
|
209
|
+
# <%= breadcrumbs do |b|
|
210
|
+
# b.item "Home", root_path
|
211
|
+
# b.item "News", news_path
|
212
|
+
# b.item "Awesome New Things", news_path(@news_item), :active => true
|
213
|
+
# %>
|
214
|
+
# </div>
|
215
|
+
#
|
216
|
+
# Returns the breadcrumb trail.
|
217
|
+
def breadcrumbs(options = {})
|
218
|
+
items = NavigationBuilder.new
|
219
|
+
yield items if block_given?
|
220
|
+
|
221
|
+
options[:class] ||= ""
|
222
|
+
options[:class] << " breadcrumb"
|
223
|
+
options[:class] = options[:class].strip.html_safe
|
224
|
+
|
225
|
+
content_tag("div", options) do
|
226
|
+
content_tag("ul") do
|
227
|
+
items.collect { |item|
|
228
|
+
content_tag("li", :class => item[:class]) do
|
229
|
+
if item[:active]
|
230
|
+
item[:label]
|
231
|
+
else
|
232
|
+
link_to(item[:label], item[:href])
|
233
|
+
end
|
234
|
+
end
|
235
|
+
}.join("").html_safe
|
236
|
+
end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
|
240
|
+
# Assists in the creation of navigation menus
|
241
|
+
class NavigationBuilder
|
242
|
+
attr_reader :item_list
|
243
|
+
include Enumerable
|
244
|
+
|
245
|
+
def initialize
|
246
|
+
@item_list = []
|
247
|
+
end
|
248
|
+
|
249
|
+
def each(&blk)
|
250
|
+
item_list.each(&blk)
|
251
|
+
end
|
252
|
+
|
253
|
+
def item(label, path, options = {})
|
254
|
+
options[:class] ||= ""
|
255
|
+
options[:class] << " first" if item_list.empty?
|
256
|
+
options[:class] << " active" if options[:active]
|
257
|
+
|
258
|
+
options[:link_options] ||= {}
|
259
|
+
options[:link_options].merge!(:method => options[:method]) if options[:method]
|
260
|
+
|
261
|
+
item_list << {
|
262
|
+
:label => label,
|
263
|
+
:href => path,
|
264
|
+
:class => options[:class].strip,
|
265
|
+
:link_options => options[:link_options],
|
266
|
+
:icon => options[:icon],
|
267
|
+
:active => !!options[:active]
|
268
|
+
}
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
# Assists in the creation of control bars
|
273
|
+
class ControlsBuilder
|
274
|
+
attr_reader :item_list
|
275
|
+
include Enumerable
|
276
|
+
|
277
|
+
def initialize
|
278
|
+
@item_list = []
|
279
|
+
end
|
280
|
+
|
281
|
+
def each(&blk)
|
282
|
+
item_list.each(&blk)
|
283
|
+
end
|
284
|
+
|
285
|
+
def item(button)
|
286
|
+
item_list << button
|
287
|
+
end
|
288
|
+
end
|
289
|
+
|
290
|
+
end
|
data/config.ru
ADDED
data/lib/activoate.rb
ADDED
@@ -0,0 +1,140 @@
|
|
1
|
+
require 'rails/generators/generated_attribute'
|
2
|
+
|
3
|
+
module Activoate
|
4
|
+
class ActivatedGenerator < Rails::Generators::Base
|
5
|
+
source_root File.expand_path('../templates', __FILE__)
|
6
|
+
|
7
|
+
argument :controller_path, :type => :string
|
8
|
+
argument :model_name, :type => :string, :required => false
|
9
|
+
|
10
|
+
class_option :layout, :type => :string, :desc => 'Specify the layout name'
|
11
|
+
class_option :engine, :type => :string, :default => 'erb', :desc => 'Specify the template engine'
|
12
|
+
class_option :will_paginate, :type => :boolean, :default => false, :desc => 'Specify if you use will_paginate'
|
13
|
+
class_option :themed_type, :type => :string, :default => 'crud', :desc => 'Specify the themed type, crud or text. Default is crud'
|
14
|
+
|
15
|
+
class_option :formtastic, :type => :boolean, :default => false, :desc => 'Specify if you use formtastic'
|
16
|
+
class_option :attrtastic, :type => :boolean, :default => false, :desc => 'Specify if you use attrtastic'
|
17
|
+
|
18
|
+
def initialize(args, *options)
|
19
|
+
super(args, *options)
|
20
|
+
initialize_views_variables
|
21
|
+
end
|
22
|
+
|
23
|
+
def copy_views
|
24
|
+
generate_views
|
25
|
+
unless options.layout.blank?
|
26
|
+
if options.engine =~ /erb/
|
27
|
+
gsub_file(File.join('app/views/layouts', "#{options[:layout]}.html.#{options.engine}"), /\<div\s+id=\"main-navigation\">.*\<\/ul\>/mi) do |match|
|
28
|
+
match.gsub!(/\<\/ul\>/, "")
|
29
|
+
%|#{match} <li class="<%= controller.controller_path == '#{@controller_file_path}' ? 'active' : '' %>"><a href="<%= #{controller_routing_path}_path %>">#{plural_model_name}</a></li></ul>|
|
30
|
+
end
|
31
|
+
elsif options.engine =~ /haml/
|
32
|
+
gsub_file(File.join('app/views/layouts', "#{options[:layout]}.html.#{options.engine}"), /#main-navigation.*#wrapper.wat-cf/mi) do |match|
|
33
|
+
match.gsub!(/ #wrapper.wat-cf/, "")
|
34
|
+
%|#{match}| +
|
35
|
+
" "*6 + %|%li{:class => controller.controller_path == '#{@controller_file_path}' ? 'active' : '' }\n| +
|
36
|
+
" "*7 + %|%a{:href => #{controller_routing_path}_path} #{plural_model_name}\n| +
|
37
|
+
" "*3 + %|#wrapper.wat-cf|
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
protected
|
44
|
+
|
45
|
+
def initialize_views_variables
|
46
|
+
@base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
|
47
|
+
@controller_routing_path = @controller_file_path.gsub(/\//, '_')
|
48
|
+
@model_name = @base_name.singularize unless @model_name
|
49
|
+
@model_name = @model_name.camelize
|
50
|
+
end
|
51
|
+
|
52
|
+
def controller_routing_path
|
53
|
+
@controller_routing_path
|
54
|
+
end
|
55
|
+
|
56
|
+
def singular_controller_routing_path
|
57
|
+
@controller_routing_path.singularize
|
58
|
+
end
|
59
|
+
|
60
|
+
def model_name
|
61
|
+
@model_name
|
62
|
+
end
|
63
|
+
|
64
|
+
def plural_model_name
|
65
|
+
@model_name.pluralize
|
66
|
+
end
|
67
|
+
|
68
|
+
def resource_name
|
69
|
+
@model_name.underscore
|
70
|
+
end
|
71
|
+
|
72
|
+
def plural_resource_name
|
73
|
+
resource_name.pluralize
|
74
|
+
end
|
75
|
+
|
76
|
+
##
|
77
|
+
# Attempts to call #columns on the model's class
|
78
|
+
# If the (Active Record) #columns method does not exist, it attempts to
|
79
|
+
# perform the (Mongoid) #fields method instead
|
80
|
+
def columns
|
81
|
+
begin
|
82
|
+
excluded_column_names = %w[id created_at updated_at]
|
83
|
+
Kernel.const_get(@model_name).columns.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
|
84
|
+
rescue NoMethodError
|
85
|
+
Kernel.const_get(@model_name).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)}
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def extract_modules(name)
|
90
|
+
modules = name.include?('/') ? name.split('/') : name.split('::')
|
91
|
+
name = modules.pop
|
92
|
+
path = modules.map { |m| m.underscore }
|
93
|
+
file_path = (path + [name.underscore]).join('/')
|
94
|
+
nesting = modules.map { |m| m.camelize }.join('::')
|
95
|
+
[name, path, file_path, nesting, modules.size]
|
96
|
+
end
|
97
|
+
|
98
|
+
def generate_views
|
99
|
+
views = {
|
100
|
+
'crud' => {
|
101
|
+
'view_tables.html.erb' => File.join('app/views', @controller_file_path, "index.html.#{options.engine}"),
|
102
|
+
'view_new.html.erb' => File.join('app/views', @controller_file_path, "new.html.#{options.engine}"),
|
103
|
+
'view_edit.html.erb' => File.join('app/views', @controller_file_path, "edit.html.#{options.engine}"),
|
104
|
+
options.formtastic ? 'view_form_formtastic.html.erb' : 'view_form.html.erb' => File.join('app/views', @controller_file_path, "_form.html.#{options.engine}"),
|
105
|
+
options.attrtastic ? 'view_show_attrtastic.html.erb' : 'view_show.html.erb' => File.join('app/views', @controller_file_path, "show.html.#{options.engine}"),
|
106
|
+
'view_sidebar.html.erb' => File.join('app/views', @controller_file_path, "_sidebar.html.#{options.engine}")
|
107
|
+
},
|
108
|
+
'text' => {
|
109
|
+
'view_text.html.erb' => File.join('app/views', @controller_file_path, "show.html.#{options.engine}"),
|
110
|
+
'view_sidebar.html.erb' => File.join('app/views', @controller_file_path, "_sidebar.html.#{options.engine}")
|
111
|
+
}
|
112
|
+
}
|
113
|
+
selected_views = views[options.themed_type]
|
114
|
+
options.engine == 'haml' ? generate_haml_views(selected_views) : generate_erb_views(selected_views)
|
115
|
+
end
|
116
|
+
|
117
|
+
def generate_erb_views(views)
|
118
|
+
views.each do |template_name, output_path|
|
119
|
+
template template_name, output_path
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def generate_haml_views(views)
|
124
|
+
require 'haml'
|
125
|
+
Dir.mktmpdir('web-app-theme-haml') do |haml_root|
|
126
|
+
views.each do |template_name, output_path|
|
127
|
+
tmp_html_path = "#{haml_root}/#{template_name}"
|
128
|
+
tmp_haml_path = "#{haml_root}/#{template_name}.haml"
|
129
|
+
template template_name, tmp_html_path, :verbose => false
|
130
|
+
`html2haml --erb --xhtml #{tmp_html_path} #{tmp_haml_path}`
|
131
|
+
copy_file tmp_haml_path, output_path
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
rescue LoadError
|
136
|
+
say "HAML is not installed, or it is not specified in your Gemfile."
|
137
|
+
exit
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<div class="block">
|
2
|
+
<div class="secondary-navigation">
|
3
|
+
<ul class="wat-cf">
|
4
|
+
<li class="first"><%%= link_to "#{t("web-app-theme.list", :default => "List")}", <%= controller_routing_path %>_path %></li>
|
5
|
+
<li><%%= link_to "#{t("web-app-theme.new", :default => "New")}", new_<%= singular_controller_routing_path %>_path %></li>
|
6
|
+
<li class="active"><%%= link_to "#{t("web-app-theme.edit", :default => "Edit")}", edit_<%= singular_controller_routing_path %>_path %></li>
|
7
|
+
</ul>
|
8
|
+
</div>
|
9
|
+
<div class="content">
|
10
|
+
<h2 class="title"><%%= t("web-app-theme.edit", :default => "Edit") %> <%= model_name %></h2>
|
11
|
+
<div class="inner">
|
12
|
+
<%%= render :partial => "form" %>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
</div>
|
16
|
+
|
17
|
+
<%% content_for :sidebar, render(:partial => 'sidebar') -%>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<%%= form_for @<%= model_name.underscore %>, :url => <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :html => { :class => :form } do |f| -%>
|
2
|
+
<% columns.each do |column| %>
|
3
|
+
<div class="group">
|
4
|
+
<%%= f.label :<%= column.name %>, t("activerecord.attributes.<%= model_name.underscore %>.<%= column.name %>", :default => "<%= column.name.humanize %>"), :class => :label %>
|
5
|
+
<%%= f.<%= column.field_type %> :<%= column.name %>, :class => '<%= column.field_type %>' %>
|
6
|
+
<span class="description">Ex: a simple text</span>
|
7
|
+
</div>
|
8
|
+
<%- end -%>
|
9
|
+
<div class="group navform wat-cf">
|
10
|
+
<button class="button" type="submit">
|
11
|
+
<%%= image_tag("web-app-theme/icons/tick.png", :alt => "#{t("web-app-theme.save", :default => "Save")}") %> <%%= t("web-app-theme.save", :default => "Save") %>
|
12
|
+
</button>
|
13
|
+
<span class="text_button_padding"><%%= t("web-app-theme.or", :default => "or") %></span>
|
14
|
+
<%%= link_to t("web-app-theme.cancel", :default => "Cancel"), <%= controller_routing_path %>_path, :class => "text_button_padding link_button" %>
|
15
|
+
</div>
|
16
|
+
<%% end -%>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<%%= semantic_form_for @<%= model_name.underscore %> do |f| %>
|
2
|
+
<%%= f.inputs do %>
|
3
|
+
<% columns.each do |column| %>
|
4
|
+
<%%= f.input :<%= column.name %> %>
|
5
|
+
<%- end %>
|
6
|
+
<%% end %>
|
7
|
+
|
8
|
+
<div class="group navform wat-cf">
|
9
|
+
<button class="button" type="submit">
|
10
|
+
<%%= image_tag("activo-2/icons/tick.png", :alt => "#{t("web-app-theme.save", :default => "Save")}") %>
|
11
|
+
<%%= t("web-app-theme.save", :default => "Save") %>
|
12
|
+
</button>
|
13
|
+
<span class="text_button_padding">
|
14
|
+
<%%= t("web-app-theme.or", :default => "or") %>
|
15
|
+
</span>
|
16
|
+
<%%= link_to t("web-app-theme.cancel", :default => "Cancel"), users_path, :class => "text_button_padding link_button" %>
|
17
|
+
</div>
|
18
|
+
<%% end %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<div class="block">
|
2
|
+
<div class="secondary-navigation">
|
3
|
+
<ul class="wat-cf">
|
4
|
+
<li class="first"><%%= link_to "#{t("web-app-theme.list", :default => "List")}", <%= controller_routing_path %>_path %></li>
|
5
|
+
<li class="active"><%%= link_to "#{t("web-app-theme.new", :default => "New")}", new_<%= singular_controller_routing_path %>_path %></li>
|
6
|
+
</ul>
|
7
|
+
</div>
|
8
|
+
<div class="content">
|
9
|
+
<h2 class="title"><%%= t("web-app-theme.new", :default => "New")%> <%= model_name %></h2>
|
10
|
+
<div class="inner">
|
11
|
+
<%%= render :partial => "form" %>
|
12
|
+
</div>
|
13
|
+
</div>
|
14
|
+
</div>
|
15
|
+
|
16
|
+
<%% content_for :sidebar, render(:partial => 'sidebar') -%>
|
@@ -0,0 +1,26 @@
|
|
1
|
+
<div class="block">
|
2
|
+
<div class="secondary-navigation">
|
3
|
+
<ul class="wat-cf">
|
4
|
+
<li class="first"><%%= link_to "#{t("web-app-theme.list", :default => "List")}", <%= controller_routing_path %>_path %></li>
|
5
|
+
<li><%%= link_to "#{t("web-app-theme.new", :default => "New")}", new_<%= singular_controller_routing_path %>_path %></li>
|
6
|
+
<li class="active"><%%= link_to "#{t("web-app-theme.show", :default => "Show")}", <%= singular_controller_routing_path %>_path %></li>
|
7
|
+
</ul>
|
8
|
+
</div>
|
9
|
+
<div class="content">
|
10
|
+
<h2 class="title"><%%= t("web-app-theme.show", :default => "Show")%> <%= model_name %></h2>
|
11
|
+
<div class="inner">
|
12
|
+
<% columns.each do |column| %>
|
13
|
+
<p>
|
14
|
+
<b><%%= t("activerecord.attributes.<%= singular_controller_routing_path %>.<%= column.name %>", :default => t("activerecord.labels.<%= column.name %>", :default => "<%= column.name.humanize %>")) %>:</b>
|
15
|
+
<%%= @<%= resource_name %>.<%= column.name %> %>
|
16
|
+
</p>
|
17
|
+
<%- end -%>
|
18
|
+
<div class="wat-cf">
|
19
|
+
<%%= link_to image_tag("web-app-theme/icons/application_edit.png", :alt => "#{t("web-app-theme.edit", :default=> "Edit")}") + " " + t("web-app-theme.edit", :default=> "Edit"), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => "button" %>
|
20
|
+
<%%= link_to image_tag("web-app-theme/icons/cross.png", :alt => "#{t("web-app-theme.delete", :default=> "Delete")}") + " " + t("web-app-theme.delete", :default => "Delete"), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :class => "button", :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}" %>
|
21
|
+
</div>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
|
26
|
+
<%% content_for :sidebar, render(:partial => 'sidebar') -%>
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<div class="block">
|
2
|
+
<div class="secondary-navigation">
|
3
|
+
<ul class="wat-cf">
|
4
|
+
<li class="first"><%%= link_to "#{t("web-app-theme.list", :default => "List")}", <%= controller_routing_path %>_path %></li>
|
5
|
+
<li><%%= link_to "#{t("web-app-theme.new", :default => "New")}", new_<%= singular_controller_routing_path %>_path %></li>
|
6
|
+
<li class="active"><%%= link_to "#{t("web-app-theme.show", :default => "Show")}", <%= singular_controller_routing_path %>_path %></li>
|
7
|
+
</ul>
|
8
|
+
</div>
|
9
|
+
<div class="content">
|
10
|
+
<h2 class="title"><%%= t("web-app-theme.show", :default => "Show")%> <%= model_name %></h2>
|
11
|
+
<div class="inner">
|
12
|
+
<%%= semantic_attributes_for @user do |attr| %>
|
13
|
+
<%%= attr.attributes do %>
|
14
|
+
<% columns.each do |column| %>
|
15
|
+
<%%= attr.attribute :<%= column.name %> %>
|
16
|
+
<%- end %>
|
17
|
+
<%% end %>
|
18
|
+
<%% end %>
|
19
|
+
<div class="wat-cf">
|
20
|
+
<%%= link_to image_tag("activo-2/icons/application_edit.png", :alt => "#{t("web-app-theme.edit", :default=> "Edit")}") + " " + t("web-app-theme.edit", :default=> "Edit"), edit_<%= singular_controller_routing_path %>_path(@<%= resource_name %>), :class => "button" %>
|
21
|
+
<%%= link_to image_tag("activo-2/icons/cross.png", :alt => "#{t("web-app-theme.delete", :default=> "Delete")}") + " " + t("web-app-theme.delete", :default => "Delete"), <%= singular_controller_routing_path %>_path(@<%= resource_name %>), :method => "delete", :class => "button", :confirm => "#{t("web-app-theme.confirm", :default => "Are you sure?")}" %>
|
22
|
+
</div>
|
23
|
+
</div>
|
24
|
+
</div>
|
25
|
+
</div>
|
26
|
+
|
27
|
+
<%% content_for :sidebar, render(:partial => 'sidebar') -%>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<div class="block notice">
|
2
|
+
<h3>Simple Block</h3>
|
3
|
+
<div class="content">
|
4
|
+
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
|
5
|
+
</div>
|
6
|
+
</div>
|
7
|
+
<div class="block">
|
8
|
+
<h3>Links</h3>
|
9
|
+
<ul class="navigation">
|
10
|
+
<li><a href="#">Link 1</a></li>
|
11
|
+
<li><a href="#">Link 2</a></li>
|
12
|
+
</ul>
|
13
|
+
</div>
|