hot-glue 0.1.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile.lock +8 -7
  3. data/README.md +95 -17
  4. data/app/helpers/hot_glue/controller_helper.rb +1 -1
  5. data/lib/generators/hot_glue/install_generator.rb +8 -3
  6. data/lib/generators/hot_glue/markup_templates/base.rb +7 -0
  7. data/lib/generators/hot_glue/markup_templates/erb.rb +227 -0
  8. data/lib/generators/hot_glue/markup_templates/haml.rb +236 -0
  9. data/lib/generators/hot_glue/markup_templates/slim.rb +9 -0
  10. data/lib/generators/hot_glue/scaffold_generator.rb +143 -258
  11. data/lib/generators/hot_glue/templates/controller.rb.erb +16 -4
  12. data/lib/generators/hot_glue/templates/erb/_errors.erb +11 -0
  13. data/lib/generators/hot_glue/templates/erb/_flash_notices.erb +12 -0
  14. data/lib/generators/hot_glue/templates/erb/_form.erb +8 -0
  15. data/lib/generators/hot_glue/templates/erb/_line.erb +10 -0
  16. data/lib/generators/hot_glue/templates/erb/_list.erb +19 -0
  17. data/lib/generators/hot_glue/templates/erb/_new_button.erb +3 -0
  18. data/lib/generators/hot_glue/templates/erb/_new_form.erb +8 -0
  19. data/lib/generators/hot_glue/templates/erb/_show.erb +8 -0
  20. data/lib/generators/hot_glue/templates/erb/create.turbo_stream.erb +18 -0
  21. data/lib/generators/hot_glue/templates/erb/destroy.turbo_stream.erb +3 -0
  22. data/lib/generators/hot_glue/templates/erb/edit.erb +30 -0
  23. data/lib/generators/hot_glue/templates/erb/edit.turbo_stream.erb +3 -0
  24. data/lib/generators/hot_glue/templates/erb/index.erb +10 -0
  25. data/lib/generators/hot_glue/templates/erb/new.erb +1 -0
  26. data/lib/generators/hot_glue/templates/erb/update.turbo_stream.erb +10 -0
  27. data/lib/generators/hot_glue/templates/{_errors.haml → haml/_errors.haml} +0 -0
  28. data/lib/generators/hot_glue/templates/{_flash_notices.haml → haml/_flash_notices.haml} +0 -0
  29. data/lib/generators/hot_glue/templates/{_form.haml → haml/_form.haml} +0 -0
  30. data/lib/generators/hot_glue/templates/{_line.haml → haml/_line.haml} +0 -0
  31. data/lib/generators/hot_glue/templates/{_list.haml → haml/_list.haml} +0 -0
  32. data/lib/generators/hot_glue/templates/{_new_button.haml → haml/_new_button.haml} +0 -0
  33. data/lib/generators/hot_glue/templates/{_new_form.haml → haml/_new_form.haml} +0 -0
  34. data/lib/generators/hot_glue/templates/{_show.haml → haml/_show.haml} +0 -0
  35. data/lib/generators/hot_glue/templates/{create.turbo_stream.haml → haml/create.turbo_stream.haml} +0 -0
  36. data/lib/generators/hot_glue/templates/{destroy.turbo_stream.haml → haml/destroy.turbo_stream.haml} +0 -0
  37. data/lib/generators/hot_glue/templates/{edit.haml → haml/edit.haml} +0 -0
  38. data/lib/generators/hot_glue/templates/{edit.turbo_stream.haml → haml/edit.turbo_stream.haml} +0 -0
  39. data/lib/generators/hot_glue/templates/{index.haml → haml/index.haml} +0 -0
  40. data/lib/generators/hot_glue/templates/{new.haml → haml/new.haml} +0 -0
  41. data/lib/generators/hot_glue/templates/{update.turbo_stream.haml → haml/update.turbo_stream.haml} +0 -0
  42. data/lib/generators/hot_glue/templates/system_spec.rb.erb +1 -1
  43. data/lib/hot-glue.rb +6 -20
  44. data/lib/hotglue/version.rb +1 -1
  45. metadata +49 -24
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3b265c8c7f5e9fb424122d2d40eec712a7cb4f846f5daf581b75a8e4981790fa
4
- data.tar.gz: 23e8b5857b4e8fa2391a46128a282a952355fe64c9097868b98bf8d462c9a35c
3
+ metadata.gz: 0a29f1b4b001de5e14dbfc1ce046aae144d53f81eb5efecb05c88a69cad06b09
4
+ data.tar.gz: e4efb4c1d9d87cda11f835750475b6cfc86ea9daa4c25ce5cc08eebca1968d97
5
5
  SHA512:
6
- metadata.gz: 3a304db4b93d3edf92657178e0057830f224dda0e1b08c5957169d2e6f378ac6cc9137513e18001c38881d7f2594d2d608ba3de07ffa86291089c01cccecc462
7
- data.tar.gz: 884d154c85a9688b66db56498f2f66dbda7356d06d2f5590e80c911f86e46fee5bcefc1809f6d5deb339b79fe95a95d45f823a89128105ec367f0d7b6c67a85d
6
+ metadata.gz: 1b2b2f354390c5d2d0cef4fbd87dfee63de72b69112efc4e1c24c23037ca96f899d077b8876f81a6b8347787d3b997b1b5a7d08608c3039640003398c4974071
7
+ data.tar.gz: f933f8f06deff1d2f80632ed4b2e4d9ed5ff4d70246c8c99562a15b13ece0a75b3aa9fa86e27935de4555744ee6039183d960debd89eb9bc82f6f2937ab99730
data/Gemfile.lock CHANGED
@@ -1,11 +1,11 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- hot-glue (0.1.1)
4
+ hot-glue (0.2.2)
5
5
  ffaker (~> 2.16)
6
6
  haml-rails (~> 2.0)
7
7
  kaminari (~> 1.2)
8
- rails (~> 6.0)
8
+ rails (> 5.1, <= 7.0.0)
9
9
  sass-rails
10
10
  turbo-rails (~> 0.5)
11
11
 
@@ -84,11 +84,11 @@ GEM
84
84
  warden (~> 1.2.3)
85
85
  erubi (1.10.0)
86
86
  erubis (2.7.0)
87
- ffaker (2.18.0)
88
- ffi (1.15.3)
87
+ ffaker (2.19.0)
88
+ ffi (1.15.4)
89
89
  globalid (0.4.2)
90
90
  activesupport (>= 4.2.0)
91
- haml (5.2.1)
91
+ haml (5.2.2)
92
92
  temple (>= 0.8.0)
93
93
  tilt
94
94
  haml-rails (2.0.1)
@@ -169,7 +169,7 @@ GEM
169
169
  responders (3.0.1)
170
170
  actionpack (>= 5.0)
171
171
  railties (>= 5.0)
172
- ruby_parser (3.16.0)
172
+ ruby_parser (3.17.0)
173
173
  sexp_processor (~> 4.15, >= 4.15.1)
174
174
  sass-rails (6.0.0)
175
175
  sassc-rails (~> 2.1, >= 2.1.1)
@@ -193,7 +193,7 @@ GEM
193
193
  temple (0.8.2)
194
194
  thor (1.1.0)
195
195
  tilt (2.0.10)
196
- turbo-rails (0.5.11)
196
+ turbo-rails (0.7.11)
197
197
  rails (>= 6.0.0)
198
198
  tzinfo (2.0.4)
199
199
  concurrent-ruby (~> 1.0)
@@ -206,6 +206,7 @@ GEM
206
206
 
207
207
  PLATFORMS
208
208
  -darwin-20
209
+ ruby
209
210
 
210
211
  DEPENDENCIES
211
212
  byebug
data/README.md CHANGED
@@ -1,4 +1,3 @@
1
- # Hot Glue
2
1
 
3
2
  Hot Glue is a Rails scaffold builder for the Turbo era. It is an evolution of the admin-interface style scaffolding systems of the 2010s ([activeadmin](https://github.com/activeadmin/activeadmin), [rails_admin](https://github.com/sferik/rails_admin), and [active_scaffold](https://github.com/activescaffold/active_scaffold)).
4
3
 
@@ -45,8 +44,20 @@ Instantly get a simple CRUD interface
45
44
 
46
45
  ![hot-glue-4](https://user-images.githubusercontent.com/59002/116405517-c2b2e300-a7fd-11eb-8423-d43e3afc9fa6.gif)
47
46
 
47
+ ## TO INSTALL (RAILS 7)
48
48
 
49
- ## TO INSTALL
49
+ - Install Turbo `rails turbo:install` (?)
50
+
51
+ - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
52
+ `rails generate hot_glue:install --markup=erb`
53
+
54
+ - Add to your `application.html.erb`
55
+ ```
56
+ <%= render partial: 'layouts/flash_notices' %>
57
+ ```
58
+
59
+
60
+ ## TO INSTALL (RAILS 6)
50
61
 
51
62
  - Add `gem 'turbo-rails'` to your Gemfile & `bundle install`
52
63
 
@@ -56,14 +67,27 @@ Instantly get a simple CRUD interface
56
67
 
57
68
  - Add `gem 'hot-glue'` to your Gemfile & `bundle install`
58
69
 
59
- - Run the hot-glue installation with `rails generate hot_glue:install`
70
+ - in `javascript/packs/application.js` remove this line:
71
+ `import Turbolinks from "turbolinks"`
72
+
73
+ - in the same file (`javascript/packs/application.js`) add this line:
74
+ `import { Turbo } from "@hotwired/turbo-rails"`
75
+
76
+ - Run the hot-glue install generator
77
+
78
+ FOR ERB:
79
+ `rails generate hot_glue:install --markup=erb`
80
+
81
+ FOR HAML:
82
+ `rails generate hot_glue:install --markup=haml`
60
83
 
61
84
  - Add to your `application.html.erb`
62
85
  ```
63
86
  <%= render partial: 'layouts/flash_notices' %>
64
87
  ```
65
88
 
66
- - Rspec setup
89
+
90
+ ## Rspec setup
67
91
  - add `gem 'rspec-rails'` to your gemfile inside :development and :test
68
92
  - add `gem 'factory_bot_rails'` to your gemfile inside :development and :test
69
93
  - run `rails generate rspec:install`
@@ -89,10 +113,28 @@ Instantly get a simple CRUD interface
89
113
  end
90
114
  ```
91
115
 
92
- - Install Bootstrap (optional)
116
+ ## Install Bootstrap using Sprockets (IMPORTANT: YOU DO NOT NEED JQUERY*)
117
+ - Bootstrap with Sprockets for Rails 5 or 7 default — Rails 6 custom
118
+ - use twbs/bootstrap-rubygem gem
119
+ - see README for bootstrap-rubygem to install
120
+ - Bootstrap with Webpack for FOR RAILS 7 :
121
+
122
+ - add to Gemfile
123
+ - gem 'bootstrap', '~> 5.1.0'
124
+
125
+
126
+ - completely delete the file `app/assets/application.css`
127
+ - create new file where it was `app/assets/application.scss` with this contents (do not keep the contents of the old application.css file):
128
+
129
+ ```
130
+ // Custom bootstrap variables must be set or imported *before* bootstrap.
131
+ @import "bootstrap";
132
+ ```
93
133
 
94
- Bootstrap with Webpack:
95
- - change `stylesheet_link_tag` to `stylesheet_pack_tag` in your application layout
134
+ * You do not need jQuery for HotGlue to work *
135
+
136
+ ### Bootstrap with Webpack RAILS 6 ONLY:
137
+ - change `stylesheet_link_tag` to `stylesheet_pack_tag` in your application layout
96
138
  - run `yarn add bootstrap`
97
139
  - create a new file at `app/javascript/require_bootstrap.scss` with this content
98
140
  ```
@@ -103,16 +145,14 @@ Bootstrap with Webpack:
103
145
  ```
104
146
  import 'require_bootstrap'
105
147
  ```
106
-
107
- Bootstrap with Sprockets:
108
- - use bootstrap-rubygem gem
109
- - see README for bootstrap-rubygem to install
110
148
 
111
149
 
112
- - Install Devise or implement your own authentication
150
+
151
+
152
+ ## Install Devise or implement your own authentication
113
153
  (or only use --gd mode, see below)
114
154
 
115
- - font-awesome
155
+ ## install font-awesome. I recommend https://github.com/tomkra/font_awesome5_rails or https://github.com/FortAwesome/font-awesome-sass
116
156
 
117
157
 
118
158
  ### First Argument
@@ -304,11 +344,43 @@ IMPORTANT: By default, all fields that begin with an underscore (`_`) are automa
304
344
 
305
345
  I would recommend this for fields you want globally non-editable by users in your app. For example, a counter cache or other field set only by a backend mechanism.
306
346
 
347
+ ### `stimulus_syntax` (default is false for Rails <=6; true for Rails 7)
348
+
349
+ Your delete buttons will look like so:
350
+ ```
351
+ <%= button_to "Delete <i class='fa fa-1x fa-remove'></i>".html_safe,
352
+ thing_path(branch), method: :delete,
353
+ data: {
354
+ 'controller: 'confirmable',
355
+ 'confirm-message': 'Are you sure you want to delete Thing?',
356
+ 'action': 'confirmation#confirm'
357
+ },
358
+ disable_with: "Loading...", class: "delete-branch-button btn btn-primary " %>
359
+
360
+
361
+ ```
362
+
363
+ Your install script will output an additional stimulus controller:
364
+
365
+ ```
366
+
367
+ ```
368
+
369
+
370
+
371
+ ### `--markup` (default: 'erb')
372
+
373
+ ERB is default. For HAML, `--markup=haml`.
374
+
375
+
376
+ ## FLAGS (Options with no values)
377
+ These options (flags) also uses `--` syntax but do not take any values. Everything is assumed (default) to be false unless specified.
378
+
307
379
  ### `--god` or `--gd`
308
380
 
309
381
  Use this flag to create controllers with no root authentication. You can still use an auth_identifier, which can be useful for a meta-leval authentication to the controller.
310
382
 
311
- For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use `--god` flag.
383
+ For example, FOR ADMIN CONTROLLERS ONLY, supply a auth_identifier and use `--god` flag.
312
384
 
313
385
  In Gd mode, the objects are loaded directly from the base class (these controllers have full access)
314
386
  ```
@@ -318,8 +390,6 @@ end
318
390
 
319
391
  ```
320
392
 
321
- ## FLAGS (Options with no values)
322
- These options (flags) also uses `--` syntax but do not take any values. Everything is assumed (default) to be false unless specified.
323
393
 
324
394
  ### `--specs-only`
325
395
 
@@ -353,9 +423,17 @@ If you do not want inline editing of your list items but instead to fall back to
353
423
 
354
424
 
355
425
  # VERSION HISTORY
426
+ #### 2021-09-30 - v0.2.3 - fixes ERB output for show-only fields; fixes flash_notices for erb or haml; adds @stimulus_syntax flag for delete confirmations with stimulus
427
+
428
+ #### 2021-09-27 - v0.2.2 - Fixes some issues with related fields; unlocks Rails 7 in Gemspec file
429
+
430
+ #### 2021-09-20 - v0.2.1 - Fixes nesting behavior when using gd option
431
+
432
+ #### 2021-09-06 - v0.2.0 - ERB or HAML; use the option --markup=erb or --markup=haml (default is now erb)
356
433
 
357
- #### - v0.1.1 -
434
+ #### 2021-06-28 - v0.1.2 - fixes problem with namespaces on path helpers
358
435
 
436
+ #### 2021-05-09 (yanked) - v0.1.1 - add cancellation buttons
359
437
 
360
438
  #### 2021-04-28 - v0.1.0 - Very pleased to introduce full behavior specs, found in specs/system/, generated by default on all build code; also many fixes involving nesting and authentication"
361
439
 
@@ -43,7 +43,7 @@ module HotGlue
43
43
  type: 'time',
44
44
  value: date_to_current_timezone(value, timezone))
45
45
 
46
- res << timezonize(tz)
46
+ res << timezonize(timezone)
47
47
  res
48
48
  end
49
49
 
@@ -4,15 +4,20 @@ require 'ffaker'
4
4
  module HotGlue
5
5
  class InstallGenerator < Rails::Generators::Base
6
6
  hook_for :form_builder, :as => :scaffold
7
+ class_option :markup, type: :string, default: "erb"
7
8
 
8
9
  source_root File.expand_path('templates', __dir__)
9
10
 
10
11
 
11
12
  def initialize(*args) #:nodoc:
12
13
  super
13
- # copy_file "hot_glue.js", "#{'spec/dummy/' if Rails.env.test?}app/javascript/hot_glue.js"
14
- # copy_file "hot_glue.scss", "#{'spec/dummy/' if Rails.env.test?}app/assets/stylesheets/hot_glue.scss"
15
- copy_file "_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
14
+ @markup = options['markup']
15
+ if @markup == "haml"
16
+ copy_file "haml/_flash_notices.haml", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.haml"
17
+ elsif @markup == "erb"
18
+ copy_file "erb/_flash_notices.erb", "#{'spec/dummy/' if Rails.env.test?}app/views/layouts/_flash_notices.erb"
19
+
20
+ end
16
21
  end
17
22
  end
18
23
  end
@@ -0,0 +1,7 @@
1
+ module HotGlue
2
+ class TemplateBase
3
+ def initialize()
4
+ end
5
+
6
+ end
7
+ end
@@ -0,0 +1,227 @@
1
+ module HotGlue
2
+ class ErbTemplate < TemplateBase
3
+
4
+ # include GeneratorHelper
5
+ attr_accessor :singular
6
+
7
+ def field_output(col, type = nil, width, col_identifier )
8
+ "<div class='col form-group <%='alert-danger' if @#{singular}.errors.details.keys.include?(:#{col.to_s})%>' > \n" +
9
+ " <%= f.text_field :#{col.to_s}, value: @#{@singular}.#{col.to_s}, size: #{width}, class: 'form-control', type: '#{type}' %>\n "+
10
+ " <label class='form-text' >#{col.to_s.humanize}</label>\n" +
11
+ "</div>"
12
+ end
13
+
14
+ def list_column_headings(*args)
15
+ columns = args[0][:columns]
16
+
17
+ columns.map(&:to_s).map{|col_name| "<div class='col'>#{col_name.humanize}</div>"}.join("\n")
18
+ end
19
+
20
+
21
+ def all_form_fields(*args)
22
+
23
+ columns = args[0][:columns]
24
+ show_only = args[0][:show_only]
25
+ singular_class = args[0][:singular_class]
26
+
27
+ # TODO: CLEAN ME
28
+ @singular = args[0][:singular]
29
+ singular = @singular
30
+
31
+
32
+ col_identifier = "col"
33
+ col_spaces_prepend = " "
34
+
35
+ res = columns.map { |col|
36
+
37
+ if show_only.include?(col)
38
+
39
+ "<div class=\"#{col_identifier} form-group <%= 'alert-danger' if #{singular}.errors.details.keys.include?(:#{col}) %>\">" +
40
+ "<%= @#{singular}.#{col.to_s} %>" +
41
+ "<label class='form-text'>#{col.to_s.humanize}</label>" +
42
+ "</div>"
43
+
44
+ else
45
+
46
+
47
+ type = eval("#{singular_class}.columns_hash['#{col}']").type
48
+ limit = eval("#{singular_class}.columns_hash['#{col}']").limit
49
+ sql_type = eval("#{singular_class}.columns_hash['#{col}']").sql_type
50
+
51
+ case type
52
+ when :integer
53
+ # look for a belongs_to on this object
54
+ if col.to_s.ends_with?("_id")
55
+ assoc_name = col.to_s.gsub("_id","")
56
+ assoc = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
57
+ if assoc.nil?
58
+ exit_message= "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
59
+ exit
60
+ end
61
+ display_column = HotGlue.derrive_reference_name(assoc.class_name)
62
+
63
+ "<div class='#{col_identifier} form-group <%= 'alert-danger' if #{singular}.errors.details.keys.include?(:#{assoc_name.to_s}) %>' >
64
+ <%= f.collection_select(:#{col.to_s}, #{assoc.class_name}.all, :id, :#{display_column}, {prompt: true, selected: @#{singular}.#{col.to_s} }, class: 'form-control') %>
65
+ <label class='small form-text text-muted'>#{col.to_s.humanize}</label></div>"
66
+
67
+ else
68
+ "<div class=\"#{col_identifier} form-group <%= 'alert-danger' if #{singular}.errors.details.keys.include?(:#{col}) %> \" >
69
+ <%= f.text_field :#{col.to_s}, value: #{singular}.#{col.to_s}, class: 'form-control', size: 4, type: 'number' %>
70
+ <label class='small form-text text-muted'>#{col.to_s.humanize}</label></div>"
71
+
72
+ end
73
+ when :string
74
+ limit ||= 256
75
+ if limit <= 256
76
+ field_output(col, nil, limit, col_identifier)
77
+ else
78
+ text_area_output(col, limit, col_identifier)
79
+ end
80
+
81
+ when :text
82
+ limit ||= 256
83
+ if limit <= 256
84
+ field_output(col, nil, limit, col_identifier)
85
+ else
86
+ text_area_output(col, limit, col_identifier)
87
+ end
88
+ when :float
89
+ limit ||= 256
90
+ field_output(col, nil, limit, col_identifier)
91
+
92
+
93
+ when :datetime
94
+
95
+
96
+ "<div class='col form-group <%='alert-danger' if @#{singular}.errors.details.keys.include?(:#{col.to_s})%>' > \n" +
97
+ "<%= datetime_field_localized(f, :#{col.to_s}, #{singular}.#{col.to_s}, '#{ col.to_s.humanize }', #{@auth ? @auth+'.timezone' : 'nil'}) %>" +
98
+ "</div>"
99
+ when :date
100
+ "<div class='col form-group <%='alert-danger' if @#{singular}.errors.details.keys.include?(:#{col.to_s})%>' > \n" +
101
+ "<%= date_field_localized(f, :#{col.to_s}, #{singular}.#{col.to_s}, '#{ col.to_s.humanize }', #{@auth ? @auth+'.timezone' : 'nil'}) %>" +
102
+ "</div>"
103
+ when :time
104
+ "<div class='col form-group <%='alert-danger' if @#{singular}.errors.details.keys.include?(:#{col.to_s})%>' > \n" +
105
+ "<%= time_field_localized(f, :#{col.to_s}, #{singular}.#{col.to_s}, '#{ col.to_s.humanize }', #{@auth ? @auth+'.timezone' : 'nil'}) %>" +
106
+ "</div>"
107
+
108
+ when :boolean
109
+ "<div class='col form-group <%='alert-danger' if @#{singular}.errors.details.keys.include?(:#{col.to_s})%>' > \n" +
110
+ " <span>#{col.to_s.humanize}</span>" +
111
+ " <%= f.radio_button(:#{col.to_s}, '0', checked: #{singular}.#{col.to_s} ? '' : 'checked') %>\n" +
112
+ " <%= f.label(:#{col.to_s}, value: 'No', for: '#{singular}_#{col.to_s}_0') %>\n" +
113
+ " <%= f.radio_button(:#{col.to_s}, '1', checked: #{singular}.#{col.to_s} ? 'checked' : '') %>\n" +
114
+ " <%= f.label(:#{col.to_s}, value: 'Yes', for: '#{singular}_#{col.to_s}_1') %>\n" +
115
+ "</div>"
116
+ end
117
+ end
118
+ }.join("\n")
119
+ return res
120
+ end
121
+
122
+
123
+
124
+ def paginate(*args)
125
+ plural = args[0][:plural]
126
+
127
+ "<% if #{plural}.respond_to?(:total_pages) %><%= paginate(#{plural}) %> <% end %>"
128
+ end
129
+
130
+ def all_line_fields(*args)
131
+ columns = args[0][:columns]
132
+ show_only = args[0][:show_only]
133
+ singular_class = args[0][:singular_class]
134
+ singular = args[0][:singular]
135
+
136
+ columns_count = columns.count + 1
137
+ perc_width = (100/columns_count).floor
138
+
139
+ col_identifer = "col"
140
+ columns.map { |col|
141
+ type = eval("#{singular_class}.columns_hash['#{col}']").type
142
+ limit = eval("#{singular_class}.columns_hash['#{col}']").limit
143
+ sql_type = eval("#{singular_class}.columns_hash['#{col}']").sql_type
144
+
145
+ case type
146
+ when :integer
147
+ # look for a belongs_to on this object
148
+ if col.to_s.ends_with?("_id")
149
+
150
+ assoc_name = col.to_s.gsub("_id","")
151
+
152
+
153
+ assoc = eval("#{singular_class}.reflect_on_association(:#{assoc_name})")
154
+
155
+ if assoc.nil?
156
+ exit_message = "*** Oops. on the #{singular_class} object, there doesn't seem to be an association called '#{assoc_name}'"
157
+ raise(HotGlue::Error,exit_message)
158
+ end
159
+
160
+ display_column = HotGlue.derrive_reference_name(assoc.class_name)
161
+
162
+ "<div class='#{col_identifer}'>
163
+ <%= #{singular}.#{assoc.name.to_s}.try(:#{display_column}) || '<span class=\"content alert-danger\">MISSING</span>'.html_safe %>
164
+ </div>"
165
+
166
+ else
167
+ "<div class='#{col_identifer}'>
168
+ <%= #{singular}.#{col}%></div>"
169
+ end
170
+ when :float
171
+ width = (limit && limit < 40) ? limit : (40)
172
+ "<div class='#{col_identifer}'>
173
+ <%= #{singular}.#{col}%></div>"
174
+ when :string
175
+ width = (limit && limit < 40) ? limit : (40)
176
+ "<div class='#{col_identifer}'>
177
+ <%= #{singular}.#{col} %>
178
+ </div>"
179
+ when :text
180
+ "<div class='#{col_identifer}'>
181
+ <%= #{singular}.#{col} %>
182
+ </div>"
183
+ when :datetime
184
+
185
+ "<div class='#{col_identifer}'>
186
+ <% unless #{singular}.#{col}.nil? %>
187
+ <%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%m/%d/%Y @ %l:%M %p ') + timezonize(current_timezone) %>
188
+ <% else %>
189
+ <span class='alert-danger'>MISSING</span>
190
+ <% end %>
191
+ </div>"
192
+ when :date
193
+ "<div class='#{col_identifer}'>
194
+ <% unless #{singular}.#{col}.nil? %>
195
+ <%= #{singular}.#{col} %>
196
+ <% else %>
197
+ <span class='alert-danger'>MISSING</span>
198
+ <% end %>
199
+ </div>"
200
+ when :time
201
+ "<div class='#{col_identifer}'>
202
+ <% unless #{singular}.#{col}.nil? %>
203
+ <%= #{singular}.#{col}.in_time_zone(current_timezone).strftime('%l:%M %p ') + timezonize(current_timezone) %>
204
+ <% else %>
205
+ <span class='alert-danger'>MISSING</span>
206
+ <% end %>
207
+ </div>
208
+ "
209
+ when :boolean
210
+ "<div class='#{col_identifer}'>
211
+ <% if #{singular}.#{col}.nil? %>
212
+ <span class='alert-danger'>MISSING</span>
213
+ <% elsif #{singular}.#{col} %>
214
+ YES
215
+ <% else %>
216
+ NO
217
+ <% end %>
218
+ </div>
219
+ "
220
+ end #end of switch
221
+ }.join("\n")
222
+ end
223
+ end
224
+
225
+
226
+
227
+ end