app-themer 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (39) hide show
  1. data/.document +5 -0
  2. data/.gitignore +21 -0
  3. data/LICENSE +20 -0
  4. data/README.md +158 -0
  5. data/Rakefile +53 -0
  6. data/VERSION +1 -0
  7. data/app-themer.gemspec +82 -0
  8. data/images/avatar.png +0 -0
  9. data/images/icons/application_edit.png +0 -0
  10. data/images/icons/cross.png +0 -0
  11. data/images/icons/key.png +0 -0
  12. data/images/icons/tick.png +0 -0
  13. data/index.html +347 -0
  14. data/javascripts/dd_belatedpng.js +328 -0
  15. data/javascripts/modernizr-1.5.min.js +28 -0
  16. data/lib/app_themer.rb +2 -0
  17. data/lib/generators/app_themer/layout/layout_generator.rb +71 -0
  18. data/lib/generators/app_themer/layout/templates/admin.html.erb +59 -0
  19. data/lib/generators/app_themer/layout/templates/login.html.erb +0 -0
  20. data/lib/generators/app_themer/views/templates/_form.html.erb +13 -0
  21. data/lib/generators/app_themer/views/templates/_sidebar.html.erb +13 -0
  22. data/lib/generators/app_themer/views/templates/edit.html.erb +18 -0
  23. data/lib/generators/app_themer/views/templates/new.html.erb +16 -0
  24. data/lib/generators/app_themer/views/templates/show.html.erb +23 -0
  25. data/lib/generators/app_themer/views/templates/tables.html.erb +50 -0
  26. data/lib/generators/app_themer/views/templates/text.html.erb +16 -0
  27. data/lib/generators/app_themer/views/views_generator.rb +126 -0
  28. data/stylesheets/base.css +204 -0
  29. data/stylesheets/handheld.css +6 -0
  30. data/stylesheets/override.css +1 -0
  31. data/stylesheets/themes/default/images/arrow.png +0 -0
  32. data/stylesheets/themes/default/images/boxbar-background.png +0 -0
  33. data/stylesheets/themes/default/images/button-background-active.png +0 -0
  34. data/stylesheets/themes/default/images/button-background.png +0 -0
  35. data/stylesheets/themes/default/images/menubar-background.png +0 -0
  36. data/stylesheets/themes/default/style.css +444 -0
  37. data/test/helper.rb +10 -0
  38. data/test/test_app-themer.rb +5 -0
  39. metadata +115 -0
@@ -0,0 +1,16 @@
1
+ <section>
2
+ <div class="content">
3
+ <h2><%= resource_name.capitalize %></h2>
4
+ <p class="first">
5
+ 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <span class="hightlight">Excepteur sint occaecat cupidatat non proident</span>, sunt in culpa qui officia deserunt mollit anim id est laborum.
6
+ </p>
7
+ <p> <span class="small">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore</span></p>
8
+ <p> <span class="gray">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore</span></p>
9
+ <hr />
10
+ <p>
11
+ 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. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. <span class="hightlight">Excepteur sint occaecat cupidatat non proident</span>, sunt in culpa qui officia deserunt mollit anim id est laborum.
12
+ </p>
13
+ </div>
14
+ </section>
15
+
16
+ <%% content_for :sidebar, render(:partial => 'sidebar') -%>
@@ -0,0 +1,126 @@
1
+ require 'rails/generators/generated_attribute'
2
+
3
+ module AppThemer
4
+ class ViewsGenerator < 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 :view_type, :type => :string, :default => 'crud', :desc => 'Specify the theme type, crud or text. Default is crud'
14
+
15
+ def initialize(args, *options)
16
+ super(args, *options)
17
+ initialize_views_variables
18
+ end
19
+
20
+ def copy_views
21
+ generate_views
22
+ unless options.layout.blank?
23
+ gsub_file(File.join('app/views/layouts', "#{options[:layout]}.html.#{options.engine}"), /\<nav\s+id=\"main-navigation\">.*\<\/ul\>/mi) do |match|
24
+ match.gsub!(/\<\/ul\>/, "")
25
+ if @engine.to_s =~ /haml/
26
+ %|#{match}
27
+ %li{:class => controller.controller_path == '#{@controller_file_path}' ? 'active' : '' }
28
+ %a{:href => #{controller_routing_path}_path} #{plural_model_name}
29
+ </ul>|
30
+ else
31
+ %|#{match} <li class="<%= controller.controller_path == '#{@controller_file_path}' ? 'active' : '' %>"><a href="<%= #{controller_routing_path}_path %>">#{plural_model_name}</a></li></ul>|
32
+ end
33
+ end
34
+ end
35
+ end
36
+
37
+ protected
38
+
39
+ def initialize_views_variables
40
+ @base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(controller_path)
41
+ @controller_routing_path = @controller_file_path.gsub(/\//, '_')
42
+ @model_name = @base_name.singularize unless @model_name
43
+ @model_name = @model_name.camelize
44
+ end
45
+
46
+ def controller_routing_path
47
+ @controller_routing_path
48
+ end
49
+
50
+ def singular_controller_routing_path
51
+ @controller_routing_path.singularize
52
+ end
53
+
54
+ def model_name
55
+ @model_name
56
+ end
57
+
58
+ def plural_model_name
59
+ @model_name.pluralize
60
+ end
61
+
62
+ def resource_name
63
+ @model_name.underscore
64
+ end
65
+
66
+ def plural_resource_name
67
+ resource_name.pluralize
68
+ end
69
+
70
+ def columns
71
+ excluded_column_names = %w[id created_at updated_at]
72
+ Kernel.const_get(@model_name).columns.reject{|c| excluded_column_names.include?(c.name) }.collect{|c| Rails::Generators::GeneratedAttribute.new(c.name, c.type)}
73
+ end
74
+
75
+ def extract_modules(name)
76
+ modules = name.include?('/') ? name.split('/') : name.split('::')
77
+ name = modules.pop
78
+ path = modules.map { |m| m.underscore }
79
+ file_path = (path + [name.underscore]).join('/')
80
+ nesting = modules.map { |m| m.camelize }.join('::')
81
+ [name, path, file_path, nesting, modules.size]
82
+ end
83
+
84
+ def generate_views
85
+ views = {
86
+ 'crud' => {
87
+ 'tables.html.erb' => File.join('app/views', @controller_file_path, "index.html.#{options.engine}"),
88
+ 'new.html.erb' => File.join('app/views', @controller_file_path, "new.html.#{options.engine}"),
89
+ 'edit.html.erb' => File.join('app/views', @controller_file_path, "edit.html.#{options.engine}"),
90
+ '_form.html.erb' => File.join('app/views', @controller_file_path, "_form.html.#{options.engine}"),
91
+ 'show.html.erb' => File.join('app/views', @controller_file_path, "show.html.#{options.engine}"),
92
+ '_sidebar.html.erb' => File.join('app/views', @controller_file_path, "_sidebar.html.#{options.engine}")
93
+ },
94
+ 'text' => {
95
+ 'text.html.erb' => File.join('app/views', @controller_file_path, "show.html.#{options.engine}"),
96
+ '_sidebar.html.erb' => File.join('app/views', @controller_file_path, "_sidebar.html.#{options.engine}")
97
+ }
98
+ }
99
+ selected_views = views[options.view_type]
100
+ options.engine == 'haml' ? generate_haml_views(selected_views) : generate_erb_views(selected_views)
101
+ end
102
+
103
+ def generate_erb_views(views)
104
+ views.each do |template_name, output_path|
105
+ template template_name, output_path
106
+ end
107
+ end
108
+
109
+ def generate_haml_views(views)
110
+ require 'haml'
111
+ Dir.mktmpdir('web-app-theme-haml') do |haml_root|
112
+ views.each do |template_name, output_path|
113
+ tmp_html_path = "#{haml_root}/#{template_name}"
114
+ tmp_haml_path = "#{haml_root}/#{template_name}.haml"
115
+ template template_name, tmp_html_path, :verbose => false
116
+ `html2haml --erb --xhtml #{tmp_html_path} #{tmp_haml_path}`
117
+ copy_file tmp_haml_path, output_path
118
+ end
119
+ end
120
+
121
+ rescue LoadError
122
+ say "HAML is not installed, or it is not specified in your Gemfile."
123
+ exit
124
+ end
125
+ end
126
+ end
@@ -0,0 +1,204 @@
1
+ html, body, div, span, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre,
2
+ abbr, address, cite, code, del, dfn, em, img, ins, kbd, q, samp,
3
+ small, strong, sub, sup, var, b, i, dl, dt, dd, ol, ul, li,
4
+ fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td,
5
+ article, aside, figure, footer, header, hgroup, menu, nav, section, menu,
6
+ time, mark, audio, video {
7
+ margin:0;
8
+ padding:0;
9
+ border:0;
10
+ outline:0;
11
+ font-size:100%;
12
+ vertical-align:baseline;
13
+ background:transparent;
14
+ }
15
+ article, aside, figure, footer, header, hgroup, nav, section { display:block; }
16
+ nav ul { list-style:none; margin: 0; }
17
+ blockquote, q { quotes:none; }
18
+ blockquote:before, blockquote:after, q:before, q:after { content:''; content:none; }
19
+ a { margin:0; padding:0; font-size:100%; vertical-align:baseline; background:transparent; }
20
+ ins { background-color:#ff9; color:#000; text-decoration:none; }
21
+ mark { background-color:#ff9; color:#000; font-style:italic; font-weight:bold; }
22
+ del { text-decoration: line-through; }
23
+ abbr[title], dfn[title] { border-bottom:1px dotted #000; cursor:help; }
24
+ table { border-collapse:collapse; border-spacing:0; }
25
+ hr { display:block; height:1px; border:0; border-top:1px solid #ccc; margin:1em 0; padding:0; }
26
+ input, select { vertical-align:middle; }
27
+
28
+ table { font-size:inherit; font:100%; }
29
+ select, input, textarea { font:99% sans-serif; }
30
+ pre, code, kbd, samp { font-family: monospace, sans-serif; }
31
+
32
+ h1,h2,h3,h4,h5,h6 { font-weight: bold; text-rendering: optimizeLegibility; }
33
+ html { -webkit-font-smoothing: antialiased; }
34
+ a:hover, a:active { outline: none; }
35
+ ul { margin-left:30px; }
36
+ ol { margin-left:30px; list-style-type: decimal; }
37
+ small { font-size:85%; }
38
+ strong, th { font-weight: bold; }
39
+ td, td img { vertical-align:top; }
40
+ sub { vertical-align: sub; font-size: smaller; }
41
+ sup { vertical-align: super; font-size: smaller; }
42
+
43
+ pre { padding: 15px; white-space: pre; white-space: pre-wrap; white-space: pre-line; word-wrap: break-word; }
44
+
45
+ input[type="radio"] { vertical-align: text-bottom; }
46
+ input[type="checkbox"] { vertical-align: bottom; *vertical-align: baseline; }
47
+ .ie6 input { vertical-align: text-bottom; }
48
+ label, input[type=button], input[type=submit], button { cursor: pointer; }
49
+
50
+ html { overflow-y: scroll; }
51
+ button { width: auto; overflow: visible; }
52
+ .ie7 img { -ms-interpolation-mode: bicubic; }
53
+
54
+ .ir { display:block; text-indent:-999em; overflow:hidden; background-repeat: no-repeat; }
55
+ .hidden { display:none; visibility:hidden; }
56
+ .visuallyhidden { position:absolute !important; clip: rect(1px 1px 1px 1px); clip: rect(1px, 1px, 1px, 1px); }
57
+ .invisible { visibility: hidden; }
58
+ .clearfix:after { content: "."; display: block; height: 0; clear: both; visibility: hidden; }
59
+ .clearfix { display: inline-block; }
60
+ * html .clearfix { height: 1%; }
61
+ .clearfix { display: block; }
62
+
63
+ .left {float: left;}
64
+ .right {float: right;}
65
+
66
+
67
+ /*
68
+ * base styles
69
+ */
70
+
71
+ body {
72
+ font:13px "Lucida Grande","Lucida Sans Unicode",Arial,Verdana,sans-serif; *font-size:small; *font:x-small; line-height:1.22;
73
+ line-height: 160%;
74
+ background-color: #e5e5e5;
75
+ }
76
+ body, select, input, textarea { color:#111; }
77
+ a {color: #111;}
78
+ h1 {font-size: 197%; letter-spacing: -1px;}
79
+ h2 {font-size: 182%;margin: 15px 0;letter-spacing: -1px;}
80
+ p {margin: 15px 0;}
81
+ .small {font-size: 85%;}
82
+ .gray {
83
+ color: #999;
84
+ font-style: italic;
85
+ font-family: Georgia, serif;
86
+ }
87
+
88
+ .highlight {
89
+ color: #363636;
90
+ background-color: #ff8;
91
+ font-weight: bold;
92
+ }
93
+
94
+ nav ul li {
95
+ float: left;
96
+ padding: 0 15px;
97
+ }
98
+
99
+ nav ul li a {
100
+ text-decoration: none;
101
+ }
102
+
103
+ #wrapper {
104
+ padding: 20px;
105
+ }
106
+
107
+ #main {
108
+ float:left;
109
+ width:71%;
110
+ }
111
+
112
+ .pagination a, .pagination span, .pagination em {
113
+ padding: 2px 5px;
114
+ margin-right: 5px;
115
+ display: block;
116
+ float: left;
117
+ border-style: solid;
118
+ border-width: 1px;
119
+ }
120
+
121
+ .pagination em {
122
+ font-weight: bold;
123
+ }
124
+
125
+ .pagination a {
126
+ text-decoration: none;
127
+ }
128
+
129
+ a.button:link, a.button:visited, a.button:hover, a.button:active, button.button {
130
+ color: #222;
131
+ display:block;
132
+ float:left;
133
+ margin:0 7px 0 0;
134
+ background-color: #eee;
135
+ border:1px solid #bfbfbf;
136
+ font-size: 1em;
137
+ line-height: 1.3em;
138
+ font-weight:bold;
139
+ cursor:pointer;
140
+ padding:5px 10px 6px 7px;
141
+ text-decoration: none;
142
+ }
143
+
144
+ button.button {
145
+ width:auto;
146
+ overflow:visible;
147
+ padding:4px 10px 3px 7px; /* IE6 */
148
+ }
149
+ button.button[type] {
150
+ padding:5px 10px 5px 7px; /* Firefox */
151
+ line-height:17px; /* Safari */
152
+ }
153
+
154
+ *:first-child+html button.button[type] {
155
+ padding:4px 10px 3px 7px; /* IE7 */
156
+ }
157
+
158
+ button.button img, a.button img {
159
+ margin:0 3px -3px 0 !important;
160
+ padding:0;
161
+ border:none;
162
+ width:16px;
163
+ height:16px;
164
+ }
165
+
166
+ button.button:hover, a.button:hover {
167
+ background-color:#dedede;
168
+ }
169
+
170
+ button.button:active, a.button:active {
171
+ background-color:#e5e5e5;
172
+ }
173
+
174
+ /*
175
+ * print styles
176
+ */
177
+ @media print {
178
+ * { background: transparent !important; color: #111 !important; text-shadow: none; }
179
+ a, a:visited { color: #111 !important; text-decoration: underline; }
180
+ a:after { content: " (" attr(href) ")"; }
181
+ abbr:after { content: " (" attr(title) ")"; }
182
+ .ir a:after { content: ""; } /* Don't show links for images */
183
+ pre, blockquote { border: 1px solid #999; page-break-inside: avoid; }
184
+ img { page-break-inside: avoid; }
185
+ @page { margin: 0.5cm; }
186
+ p, h2, h3 { orphans: 3; widows: 3; }
187
+ h2, h3{ page-break-after: avoid; }
188
+ }
189
+
190
+
191
+
192
+ @media all and (orientation:portrait) {
193
+
194
+ }
195
+
196
+ @media all and (orientation:landscape) {
197
+
198
+ }
199
+
200
+ /* Grade-A Mobile Browsers */
201
+ @media screen and (max-device-width: 480px) {
202
+ html { -webkit-text-size-adjust:none; -ms-text-size-adjust:none; }
203
+
204
+ }
@@ -0,0 +1,6 @@
1
+ * {
2
+ float: none;
3
+ font-size: 80%;
4
+ background: #fff;
5
+ color: #000;
6
+ }
@@ -0,0 +1 @@
1
+ /* Override here any style defined by app-themer */