aureus 0.3.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (57) hide show
  1. data/Gemfile +8 -1
  2. data/Gemfile.lock +93 -2
  3. data/Rakefile +24 -6
  4. data/Readme.md +28 -1
  5. data/TODO.md +7 -0
  6. data/app/assets/stylesheets/aureus/base.scss +9 -4
  7. data/app/assets/stylesheets/aureus/content.scss +0 -24
  8. data/app/assets/stylesheets/aureus/form.scss +1 -16
  9. data/app/assets/stylesheets/aureus/index.scss +1 -0
  10. data/app/assets/stylesheets/aureus/navigation.scss +4 -5
  11. data/app/assets/stylesheets/aureus/table.scss +4 -14
  12. data/app/assets/stylesheets/aureus/topbar.scss +2 -2
  13. data/aureus.gemspec +6 -1
  14. data/config/initializers/formtastic.rb +82 -0
  15. data/config/locales/en.yml +2 -0
  16. data/lib/aureus/box.rb +37 -0
  17. data/lib/aureus/content.rb +15 -0
  18. data/lib/aureus/data_table.rb +139 -0
  19. data/lib/aureus/engine.rb +3 -1
  20. data/lib/aureus/helper.rb +56 -0
  21. data/lib/aureus/listing.rb +39 -0
  22. data/lib/aureus/messages.rb +23 -0
  23. data/lib/aureus/navigation.rb +42 -0
  24. data/lib/aureus/row.rb +65 -0
  25. data/lib/aureus/test/resource.rb +3 -0
  26. data/lib/aureus/test/schema.rb +8 -0
  27. data/lib/aureus/toolbar.rb +74 -0
  28. data/lib/aureus/version.rb +1 -1
  29. data/lib/aureus.rb +50 -1
  30. data/lib/generators/aureus/.DS_Store +0 -0
  31. data/lib/generators/aureus/devise_i18n/devise_i18n_generator.rb +20 -0
  32. data/lib/generators/aureus/devise_i18n/templates/devise_base.en.yml +54 -0
  33. data/lib/generators/aureus/devise_i18n/templates/devise_mail.en.yml +18 -0
  34. data/lib/generators/aureus/devise_i18n/templates/devise_ui.en.yml +54 -0
  35. data/lib/generators/aureus/devise_views/devise_views_generator.rb +23 -0
  36. data/lib/generators/aureus/devise_views/templates/devise/confirmations/new.html.haml +7 -0
  37. data/lib/generators/aureus/devise_views/templates/devise/mailer/confirmation_instructions.html.haml +3 -0
  38. data/lib/generators/aureus/devise_views/templates/devise/mailer/reset_password_instructions.html.haml +5 -0
  39. data/lib/generators/aureus/devise_views/templates/devise/mailer/unlock_instructions.html.haml +4 -0
  40. data/lib/generators/aureus/devise_views/templates/devise/passwords/edit.html.haml +9 -0
  41. data/lib/generators/aureus/devise_views/templates/devise/passwords/new.html.haml +7 -0
  42. data/lib/generators/aureus/devise_views/templates/devise/registrations/edit.html.haml +11 -0
  43. data/lib/generators/aureus/devise_views/templates/devise/registrations/new.html.haml +9 -0
  44. data/lib/generators/aureus/devise_views/templates/devise/sessions/new.html.haml +9 -0
  45. data/lib/generators/aureus/devise_views/templates/devise/shared/_links.html.haml +19 -0
  46. data/lib/generators/aureus/devise_views/templates/devise/unlocks/new.html.haml +7 -0
  47. data/lib/generators/aureus/views/templates/views/_form.html.haml +6 -0
  48. data/lib/generators/aureus/views/templates/views/_item.html.haml +6 -0
  49. data/lib/generators/aureus/views/templates/views/_list.html.haml +10 -0
  50. data/lib/generators/aureus/views/templates/views/edit.html.haml +7 -0
  51. data/lib/generators/aureus/views/templates/views/index.html.haml +6 -0
  52. data/lib/generators/aureus/views/templates/views/new.html.haml +7 -0
  53. data/lib/generators/aureus/views/templates/views/show.html.haml +7 -0
  54. data/lib/generators/aureus/views/views_generator.rb +78 -0
  55. data/test/html.haml +64 -0
  56. data/test/model.rb +3 -0
  57. metadata +101 -4
data/Gemfile CHANGED
@@ -1,2 +1,9 @@
1
1
  source "http://rubygems.org"
2
- gemspec
2
+ gemspec
3
+
4
+ group :test do
5
+ gem "highline"
6
+ gem "rails"
7
+ gem "activerecord"
8
+ gem "sqlite3"
9
+ end
data/Gemfile.lock CHANGED
@@ -1,14 +1,105 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- Aureus (0.1.5)
4
+ aureus (1.0.0)
5
+ formtastic
6
+ haml
7
+ jquery-rails
5
8
 
6
9
  GEM
7
10
  remote: http://rubygems.org/
8
11
  specs:
12
+ actionmailer (3.2.6)
13
+ actionpack (= 3.2.6)
14
+ mail (~> 2.4.4)
15
+ actionpack (3.2.6)
16
+ activemodel (= 3.2.6)
17
+ activesupport (= 3.2.6)
18
+ builder (~> 3.0.0)
19
+ erubis (~> 2.7.0)
20
+ journey (~> 1.0.1)
21
+ rack (~> 1.4.0)
22
+ rack-cache (~> 1.2)
23
+ rack-test (~> 0.6.1)
24
+ sprockets (~> 2.1.3)
25
+ activemodel (3.2.6)
26
+ activesupport (= 3.2.6)
27
+ builder (~> 3.0.0)
28
+ activerecord (3.2.6)
29
+ activemodel (= 3.2.6)
30
+ activesupport (= 3.2.6)
31
+ arel (~> 3.0.2)
32
+ tzinfo (~> 0.3.29)
33
+ activeresource (3.2.6)
34
+ activemodel (= 3.2.6)
35
+ activesupport (= 3.2.6)
36
+ activesupport (3.2.6)
37
+ i18n (~> 0.6)
38
+ multi_json (~> 1.0)
39
+ arel (3.0.2)
40
+ builder (3.0.0)
41
+ erubis (2.7.0)
42
+ formtastic (2.2.0)
43
+ actionpack (>= 3.0)
44
+ haml (3.1.6)
45
+ highline (1.6.13)
46
+ hike (1.2.1)
47
+ i18n (0.6.0)
48
+ journey (1.0.4)
49
+ jquery-rails (2.0.2)
50
+ railties (>= 3.2.0, < 5.0)
51
+ thor (~> 0.14)
52
+ json (1.7.3)
53
+ mail (2.4.4)
54
+ i18n (>= 0.4.0)
55
+ mime-types (~> 1.16)
56
+ treetop (~> 1.4.8)
57
+ mime-types (1.19)
58
+ multi_json (1.3.6)
59
+ polyglot (0.3.3)
60
+ rack (1.4.1)
61
+ rack-cache (1.2)
62
+ rack (>= 0.4)
63
+ rack-ssl (1.3.2)
64
+ rack
65
+ rack-test (0.6.1)
66
+ rack (>= 1.0)
67
+ rails (3.2.6)
68
+ actionmailer (= 3.2.6)
69
+ actionpack (= 3.2.6)
70
+ activerecord (= 3.2.6)
71
+ activeresource (= 3.2.6)
72
+ activesupport (= 3.2.6)
73
+ bundler (~> 1.0)
74
+ railties (= 3.2.6)
75
+ railties (3.2.6)
76
+ actionpack (= 3.2.6)
77
+ activesupport (= 3.2.6)
78
+ rack-ssl (~> 1.3.2)
79
+ rake (>= 0.8.7)
80
+ rdoc (~> 3.4)
81
+ thor (>= 0.14.6, < 2.0)
82
+ rake (0.9.2.2)
83
+ rdoc (3.12)
84
+ json (~> 1.4)
85
+ sprockets (2.1.3)
86
+ hike (~> 1.2)
87
+ rack (~> 1.0)
88
+ tilt (~> 1.1, != 1.3.0)
89
+ sqlite3 (1.3.6)
90
+ thor (0.15.4)
91
+ tilt (1.3.3)
92
+ treetop (1.4.10)
93
+ polyglot
94
+ polyglot (>= 0.3.1)
95
+ tzinfo (0.3.33)
9
96
 
10
97
  PLATFORMS
11
98
  ruby
12
99
 
13
100
  DEPENDENCIES
14
- Aureus!
101
+ activerecord
102
+ aureus!
103
+ highline
104
+ rails
105
+ sqlite3
data/Rakefile CHANGED
@@ -1,12 +1,12 @@
1
- require 'rake/testtask'
2
- require 'highline/import'
1
+ require "rubygems"
3
2
 
4
- Rake::TestTask.new do |t|
5
- t.libs << 'test'
6
- end
3
+ gem "highline"
4
+ gem "activerecord"
5
+ gem "sqlite3"
7
6
 
8
7
  desc "build and publish"
9
8
  task :build do
9
+ require "highline/import"
10
10
  puts "build gem..."
11
11
  `gem build aureus.gemspec`
12
12
  Dir["*.gem"].each do |file|
@@ -17,4 +17,22 @@ task :build do
17
17
  end
18
18
  puts "remove gem..."
19
19
  `rm *.gem`
20
- end
20
+ end
21
+
22
+ task :check do
23
+ require "rails"
24
+ require "active_support"
25
+ require "action_view"
26
+ require "active_record"
27
+ require "aureus"
28
+ require "haml"
29
+ require "aureus/test/resource"
30
+ include Aureus::Helper
31
+ ActiveRecord::Base.establish_connection adapter: "sqlite3", database: ":memory:"
32
+ load "lib/aureus/test/schema.rb"
33
+ @resource = Resource.new
34
+ @resource.title = "the title"
35
+ @resource.text = "Some longer text"
36
+ @resources = [@resource,@resource]
37
+ puts Haml::Engine.new(File.read("test/html.haml")).render(self)
38
+ end
data/Readme.md CHANGED
@@ -1,3 +1,30 @@
1
1
  # Aureus Admin Template
2
2
 
3
- **a nice looking css framework for your rails admin interfaces**
3
+ **a nice looking css framework for your rails admin interfaces**
4
+
5
+ ## Installation
6
+
7
+ To use **aureus** simply require the gem:
8
+
9
+ ````ruby
10
+ gem "aureus"
11
+ ````
12
+
13
+ The rails engine will automatically load the following dependencies:
14
+
15
+ * formtastic
16
+ * haml
17
+ * jquery-rails
18
+
19
+ But you have to ensure that these gems are available:
20
+
21
+ * sass-rails
22
+ * coffee-rails
23
+
24
+ ## Helper Methods
25
+
26
+
27
+
28
+ ## The Layout
29
+
30
+ Here is a simple layout done with aureus helpers:
data/TODO.md ADDED
@@ -0,0 +1,7 @@
1
+ # ToDo
2
+
3
+ * box head buttons
4
+ * datatable improvements
5
+ * proper namespace css and clean up
6
+ * update javascripts
7
+ * datatable i18n
@@ -1,4 +1,4 @@
1
- $font-family: "Helvetica Neue", Arial, Helvetica, sans-serif;
1
+ $font-family: "Helvetica Neue", "Helvetica", "Arial", sans-serif;
2
2
 
3
3
  * {
4
4
  font-family: $font-family;
@@ -19,15 +19,20 @@ strong {
19
19
  font-weight: bold;
20
20
  }
21
21
 
22
+ .translation_missing {
23
+ color: red !important;
24
+ text-decoration: line-through !important;
25
+ }
26
+
22
27
  #messages {
23
- .error, .notice {
28
+ .error, .notice, .alert {
24
29
  padding: 10px 30px;
25
30
  color: white;
26
31
  font-size: 14px;
27
32
  text-shadow: -1px -1px 0 black;
28
33
  }
29
- .error {
30
- @include gradient($color_main,$color_main_dark);
34
+ .error, .alert {
35
+ @include gradient($color_warn,$color_warn_dark);
31
36
  }
32
37
  .notice {
33
38
  @include gradient(#666,#444);
@@ -85,30 +85,6 @@
85
85
  }
86
86
  }
87
87
  }
88
- .w1 {
89
- margin-right: 1%;
90
- width: 24%;
91
- }
92
- .w2 {
93
- margin-right: 1%;
94
- width: 49%;
95
- }
96
- .w3 {
97
- margin-right: 1%;
98
- width: 74%;
99
- }
100
- .w4 {
101
- width: 100%;
102
- }
103
- .w1-last {
104
- width: 25%;
105
- }
106
- .w2-last {
107
- width: 50%;
108
- }
109
- .w3-last {
110
- width: 75%;
111
- }
112
88
  .centered {
113
89
  margin: 0 auto;
114
90
  margin-top: 15%;
@@ -3,7 +3,7 @@ form {
3
3
  list-style: none;
4
4
  margin: 7px 0px;
5
5
  .inline-errors {
6
- color: $color_main;
6
+ color: $color_warn;
7
7
  }
8
8
  }
9
9
  p {
@@ -55,19 +55,4 @@ form {
55
55
  input[type=checkbox], input[type=radio] {
56
56
  margin-right: 7px;
57
57
  }
58
- /*#error_explanation {
59
- border: 1px solid $color_main;
60
- @include border-radius(3px);
61
- padding: 5px;
62
- margin-bottom: 10px;
63
- h2 {
64
- display: none;
65
- }
66
- ul {
67
- li {
68
- color: $color_main;
69
- font-size: 14px;
70
- }
71
- }
72
- }*/
73
58
  }
@@ -26,6 +26,7 @@ $asset_icon_print: image-path("aureus/icon-print.png");
26
26
 
27
27
  // colors
28
28
  $color_main_dark: darken($color_main,15);
29
+ $color_warn_dark: darken($color_warn,15);
29
30
 
30
31
  @import "reset";
31
32
  @import "mixins";
@@ -1,21 +1,20 @@
1
1
  #navigation {
2
2
  border-bottom: 1px solid #bbb;
3
- padding: 10px 40px;
3
+ padding: 20px 40px;
4
4
  overflow: hidden;
5
5
  @include gradient(#eee,#ddd);
6
6
  h2 {
7
+ float: left;
7
8
  span {
8
- padding: 10px 0;
9
9
  color: #222;
10
10
  font-size: 36px;
11
11
  font-weight: bold;
12
12
  text-shadow: 1px 1px 0 white;
13
- display: block;
14
13
  overflow: hidden;
15
14
  }
16
15
  }
17
16
  ul {
18
- margin-top: 20px;
17
+ margin-top: 10px;
19
18
  float: right;
20
19
  li {
21
20
  display: inline;
@@ -36,7 +35,7 @@
36
35
  }
37
36
  }
38
37
  li:hover {
39
- a {
38
+ a, span {
40
39
  color: $color_main;
41
40
  }
42
41
  }
@@ -31,18 +31,6 @@
31
31
  th.center {
32
32
  text-align: center;
33
33
  }
34
- th.b1 {
35
- width: 1px;
36
- }
37
- th.b2 {
38
- width: 80px;
39
- }
40
- th.b3 {
41
- width: 120px;
42
- }
43
- th.b4 {
44
- width: 160px;
45
- }
46
34
  }
47
35
  }
48
36
  tbody {
@@ -79,6 +67,8 @@
79
67
  color: #444;
80
68
  }
81
69
  td.buttons {
70
+ width: 1px;
71
+ white-space: nowrap;
82
72
  text-align: right;
83
73
  padding: 7px !important;
84
74
  vertical-align: middle;
@@ -98,7 +88,7 @@
98
88
  text-shadow: 1px 1px 0 #eee;
99
89
  }
100
90
  }
101
- a.edit, a.delete, a.show, a.recover, a.print {
91
+ a.edit, a.destroy, a.show, a.recover, a.print {
102
92
  width: 16px;
103
93
  height: 16px;
104
94
  display: inline-block;
@@ -117,7 +107,7 @@
117
107
  a.edit span {
118
108
  background: url($asset_icon_pencil);
119
109
  }
120
- a.delete span {
110
+ a.destroy span {
121
111
  background: url($asset_icon_cross);
122
112
  }
123
113
  a.show span {
@@ -1,5 +1,5 @@
1
- #topbar {
2
- padding: 11px 30px;
1
+ #aureus-toolbar {
2
+ padding: 11px 40px;
3
3
  overflow: hidden;
4
4
  @include gradient(#333,#222);
5
5
  background-image: url($asset_topbar_background);
data/aureus.gemspec CHANGED
@@ -19,5 +19,10 @@ Gem::Specification.new do |s|
19
19
  # Files
20
20
  s.files = `git ls-files`.split("\n")
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
- #s.require_paths = ["lib"]
22
+
23
+ # Dependencies
24
+ s.add_dependency "formtastic"
25
+ s.add_dependency "jquery-rails"
26
+ s.add_dependency "haml"
27
+
23
28
  end
@@ -0,0 +1,82 @@
1
+ # encoding: utf-8
2
+
3
+ # Set the default text field size when input is a string. Default is nil.
4
+ # Formtastic::FormBuilder.default_text_field_size = 50
5
+
6
+ # Set the default text area height when input is a text. Default is 20.
7
+ # Formtastic::FormBuilder.default_text_area_height = 5
8
+
9
+ # Set the default text area width when input is a text. Default is nil.
10
+ # Formtastic::FormBuilder.default_text_area_width = 50
11
+
12
+ # Should all fields be considered "required" by default?
13
+ # Defaults to true.
14
+ # Formtastic::FormBuilder.all_fields_required_by_default = true
15
+
16
+ # Should select fields have a blank option/prompt by default?
17
+ # Defaults to true.
18
+ # Formtastic::FormBuilder.include_blank_for_select_by_default = true
19
+
20
+ # Set the string that will be appended to the labels/fieldsets which are required
21
+ # It accepts string or procs and the default is a localized version of
22
+ # '<abbr title="required">*</abbr>'. In other words, if you configure formtastic.required
23
+ # in your locale, it will replace the abbr title properly. But if you don't want to use
24
+ # abbr tag, you can simply give a string as below
25
+ # Formtastic::FormBuilder.required_string = "(required)"
26
+
27
+ # Set the string that will be appended to the labels/fieldsets which are optional
28
+ # Defaults to an empty string ("") and also accepts procs (see required_string above)
29
+ # Formtastic::FormBuilder.optional_string = "(optional)"
30
+
31
+ # Set the way inline errors will be displayed.
32
+ # Defaults to :sentence, valid options are :sentence, :list, :first and :none
33
+ # Formtastic::FormBuilder.inline_errors = :sentence
34
+ # Formtastic uses the following classes as default for hints, inline_errors and error list
35
+
36
+ # If you override the class here, please ensure to override it in your stylesheets as well
37
+ # Formtastic::FormBuilder.default_hint_class = "inline-hints"
38
+ # Formtastic::FormBuilder.default_inline_error_class = "inline-errors"
39
+ # Formtastic::FormBuilder.default_error_list_class = "errors"
40
+
41
+ # Set the method to call on label text to transform or format it for human-friendly
42
+ # reading when formtastic is used without object. Defaults to :humanize.
43
+ # Formtastic::FormBuilder.label_str_method = :humanize
44
+
45
+ # Set the array of methods to try calling on parent objects in :select and :radio inputs
46
+ # for the text inside each @<option>@ tag or alongside each radio @<input>@. The first method
47
+ # that is found on the object will be used.
48
+ # Defaults to ["to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
49
+ # Formtastic::FormBuilder.collection_label_methods = [
50
+ # "to_label", "display_name", "full_name", "name", "title", "username", "login", "value", "to_s"]
51
+
52
+ # Additionally, you can customize the order for specific types of inputs.
53
+ # This is configured on a type basis and if a type is not found it will
54
+ # fall back to the default order as defined by #inline_order
55
+ # Formtastic::FormBuilder.custom_inline_order[:checkbox] = [:errors, :hints, :input]
56
+ # Formtastic::FormBuilder.custom_inline_order[:select] = [:hints, :input, :errors]
57
+
58
+ # Specifies if labels/hints for input fields automatically be looked up using I18n.
59
+ # Default value: true. Overridden for specific fields by setting value to true,
60
+ # i.e. :label => true, or :hint => true (or opposite depending on initialized value)
61
+ # Formtastic::FormBuilder.i18n_lookups_by_default = false
62
+
63
+ # Specifies if I18n lookups of the default I18n Localizer should be cached to improve performance.
64
+ # Defaults to false.
65
+ # Formtastic::FormBuilder.i18n_cache_lookups = true
66
+
67
+ # Specifies the class to use for localization lookups. You can create your own
68
+ # class and use it instead by subclassing Formtastic::Localizer (which is the default).
69
+ # Formtastic::FormBuilder.i18n_localizer = MyOwnLocalizer
70
+
71
+ # You can add custom inputs or override parts of Formtastic by subclassing Formtastic::FormBuilder and
72
+ # specifying that class here. Defaults to Formtastic::FormBuilder.
73
+ # Formtastic::Helpers::FormHelper.builder = MyCustomBuilder
74
+
75
+ # You can opt-in to Formtastic's use of the HTML5 `required` attribute on `<input>`, `<select>`
76
+ # and `<textarea>` tags by setting this to false (defaults to true).
77
+ #Formtastic::FormBuilder.use_required_attribute = true
78
+
79
+ # You can opt-in to new HTML5 browser validations (for things like email and url inputs) by setting
80
+ # this to false. Doing so will add a `novalidate` attribute to the `<form>` tag.
81
+ # See http://diveintohtml5.org/forms.html#validation for more info.
82
+ #Formtastic::FormBuilder.perform_browser_validations = true
@@ -0,0 +1,2 @@
1
+ en:
2
+ test: "Test"
data/lib/aureus/box.rb ADDED
@@ -0,0 +1,37 @@
1
+ module Aureus
2
+
3
+ class Box < Renderable
4
+
5
+ def initialize title, options, &block
6
+ init options, :for => :text, :centered => false
7
+ init_haml_helpers
8
+ @title = title
9
+ @content = capture_haml self, &block
10
+ end
11
+
12
+ def content &block
13
+ @new_content = capture_haml &block
14
+ end
15
+
16
+ def foot &block
17
+ @foot = capture_haml &block
18
+ end
19
+
20
+ def render
21
+ title = content_tag("h3",@title)
22
+ classes = ["box"]
23
+ classes << "centered" if @options[:centered]
24
+ @content = @new_content if not @new_content.nil?
25
+ content_tag "div", :class => classes.join(" ") do
26
+ case @options[:for]
27
+ when :form
28
+ @content = content_tag("ul",@content,:class => "content")
29
+ end
30
+ footer = @foot.nil? ? "" : content_tag("div",@foot,:class => "foot")
31
+ compact title, content_tag("div",@content), footer
32
+ end
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -0,0 +1,15 @@
1
+ module Aureus
2
+
3
+ class Content < Renderable
4
+
5
+ def initialize content
6
+ @content = content
7
+ end
8
+
9
+ def render
10
+ content_tag "div", @content, :id => "content"
11
+ end
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,139 @@
1
+ module Aureus
2
+
3
+ class DataTable < Renderable
4
+
5
+ def initialize resource, toolbar = true
6
+ @resource = resource
7
+ @toolbar = toolbar
8
+ @head = DataTableHead.new
9
+ @rows = Array.new
10
+ end
11
+
12
+ def head
13
+ yield @head
14
+ end
15
+
16
+ def row
17
+ @resource.each do |r|
18
+ row = DataTableRow.new
19
+ yield row, r
20
+ @rows << row
21
+ end
22
+ end
23
+
24
+ def render
25
+ content_tag "table", :id => @resource.class.name.downcase, :class => (@toolbar?"datatable":"datatable-no-toolbar") do
26
+ compact @head.render, content_tag("tbody",compact_render(*@rows))
27
+ end
28
+ end
29
+
30
+ end
31
+
32
+ class DataTableHead < Renderable
33
+
34
+ def initialize
35
+ @columns = Array.new
36
+ end
37
+
38
+ def text name
39
+ @columns << DataTableHeadColumn.new(name,"text-sorting")
40
+ end
41
+
42
+ def date name
43
+ @columns << DataTableHeadColumn.new(name,"date-sorting")
44
+ end
45
+
46
+ def raw name
47
+ @columns << DataTableHeadColumn.new(name,"no-sorting")
48
+ end
49
+
50
+ def render
51
+ raw ""
52
+ content_tag "thead" do
53
+ content_tag "tr", compact_render(*@columns)
54
+ end
55
+ end
56
+
57
+ end
58
+
59
+ class DataTableHeadColumn < Renderable
60
+
61
+ def initialize name, sorting
62
+ @name = name
63
+ @sorting = sorting
64
+ end
65
+
66
+ def render
67
+ content_tag "th", @name, :class => @sorting
68
+ end
69
+
70
+ end
71
+
72
+ class DataTableRow < Renderable
73
+
74
+ def initialize
75
+ @cells = Array.new
76
+ @buttons = Array.new
77
+ end
78
+
79
+ def cell data
80
+ @cells << DataTableRowCell.new(data)
81
+ end
82
+
83
+ def button type_or_title, url, *args
84
+ if type_or_title.is_a? Symbol
85
+ @buttons << DataTableRowButton.new(type_or_title,type_or_title.to_s,url,args)
86
+ else
87
+ @buttons << DataTableRowButton.new(:text,type_or_title.to_s,url,args)
88
+ end
89
+ end
90
+
91
+ def render
92
+ content_tag "tr", compact_render(*@cells)+content_tag("td",compact_render(*@buttons),:class => "buttons")
93
+ end
94
+
95
+ end
96
+
97
+ class DataTableRowCell < Renderable
98
+
99
+ def initialize data
100
+ @data = data
101
+ end
102
+
103
+ def render
104
+ content_tag "td", @data
105
+ end
106
+
107
+ end
108
+
109
+ class DataTableRowButton < Renderable
110
+
111
+ def initialize type, text, url, options
112
+ init options, :remote => true, :confirm => "Delete resource?"
113
+ @type = type
114
+ @text = text
115
+ @url = url
116
+ end
117
+
118
+ def render
119
+ case @type
120
+ when :text
121
+ link_to @text, @url
122
+ when :print
123
+ link_to @text, @url, :class => :print
124
+ when :show
125
+ link_to @text, @url, :class => :show
126
+ when :edit
127
+ link_to @text, @url, :class => :edit
128
+ when :destroy
129
+ if @options[:remote]
130
+ link_to @text, @url, :class => :destroy, :method => :delete, :data => { :confirm => @options[:confirm] }
131
+ else
132
+ link_to @text, @url, :class => :destroy
133
+ end
134
+ end
135
+ end
136
+
137
+ end
138
+
139
+ end
data/lib/aureus/engine.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  module Aureus
2
2
  class Engine < Rails::Engine
3
- # auto wire
3
+ ActiveSupport.on_load :action_view do
4
+ include Aureus::Helper
5
+ end
4
6
  end
5
7
  end