lolita 3.4.2 → 3.4.3

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 (146) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +36 -36
  3. data/Gemfile +29 -29
  4. data/README.md +147 -147
  5. data/Rakefile +6 -6
  6. data/app/assets/javascripts/lolita/application.js +6 -6
  7. data/app/assets/javascripts/lolita/tab.js +100 -100
  8. data/app/assets/stylesheets/lolita/PIE-custom.htc +87 -87
  9. data/app/assets/stylesheets/lolita/PIE.htc +81 -81
  10. data/app/assets/stylesheets/lolita/application.css +6 -6
  11. data/app/assets/stylesheets/lolita/default.css.erb +169 -169
  12. data/app/assets/stylesheets/lolita/jquery-ui-1.8.16.lolita.css.erb +567 -567
  13. data/app/assets/stylesheets/lolita/style.css.erb +553 -553
  14. data/app/helpers/components/lolita/configuration/list_component.rb +10 -10
  15. data/app/helpers/components/lolita/configuration_component.rb +20 -20
  16. data/app/views/components/lolita/configuration/column/_first.html.haml +1 -1
  17. data/app/views/components/lolita/configuration/column/header/_first.html.haml +1 -1
  18. data/app/views/components/lolita/configuration/column/header/_sort.html.haml +6 -6
  19. data/app/views/components/lolita/configuration/columns/header/_display.html.haml +5 -5
  20. data/app/views/components/lolita/configuration/field/array/checkbox/_display.html.haml +7 -7
  21. data/app/views/components/lolita/configuration/field/string/text/_display.html.haml +7 -7
  22. data/app/views/components/lolita/configuration/search/_display.html.haml +2 -2
  23. data/app/views/components/lolita/configuration/tab/_display.html.haml +3 -3
  24. data/app/views/components/lolita/configuration/tabs/_form.html.haml +6 -6
  25. data/app/views/kaminari/lolita/_first_page.html.erb +11 -11
  26. data/app/views/kaminari/lolita/_gap.html.erb +8 -8
  27. data/app/views/kaminari/lolita/_last_page.html.erb +11 -11
  28. data/app/views/kaminari/lolita/_next_page.html.erb +11 -11
  29. data/app/views/kaminari/lolita/_page.html.erb +12 -12
  30. data/app/views/kaminari/lolita/_paginator.html.erb +23 -23
  31. data/app/views/kaminari/lolita/_prev_page.html.erb +11 -11
  32. data/app/views/lolita/info/index.html.erb +232 -232
  33. data/author +1 -1
  34. data/config/routes.rb +6 -6
  35. data/lib/generators/lolita/install_generator.rb +19 -19
  36. data/lib/generators/lolita/uninstall_generator.rb +70 -70
  37. data/lib/generators/templates/lolita.rb +13 -13
  38. data/lib/lolita.rb +140 -140
  39. data/lib/lolita/adapter/abstract_adapter.rb +15 -15
  40. data/lib/lolita/adapter/active_record.rb +227 -227
  41. data/lib/lolita/adapter/common_helper.rb +221 -221
  42. data/lib/lolita/adapter/field_helper.rb +18 -18
  43. data/lib/lolita/adapter/mongoid.rb +241 -241
  44. data/lib/lolita/components/base.rb +11 -11
  45. data/lib/lolita/configuration.rb +60 -60
  46. data/lib/lolita/configuration/column.rb +181 -181
  47. data/lib/lolita/configuration/field/big_decimal.rb +12 -12
  48. data/lib/lolita/configuration/field/boolean.rb +12 -12
  49. data/lib/lolita/configuration/field/date.rb +12 -12
  50. data/lib/lolita/configuration/field/hidden.rb +12 -12
  51. data/lib/lolita/configuration/field/integer.rb +11 -11
  52. data/lib/lolita/configuration/field/string.rb +16 -16
  53. data/lib/lolita/configuration/field/time.rb +13 -13
  54. data/lib/lolita/configuration/field_set.rb +25 -25
  55. data/lib/lolita/configuration/filter.rb +116 -116
  56. data/lib/lolita/configuration/list.rb +200 -200
  57. data/lib/lolita/configuration/search.rb +104 -104
  58. data/lib/lolita/controllers/component_helpers.rb +156 -156
  59. data/lib/lolita/controllers/internal_helpers.rb +71 -71
  60. data/lib/lolita/controllers/url_helpers.rb +7 -7
  61. data/lib/lolita/dbi/base.rb +56 -56
  62. data/lib/lolita/hooks/named_hook.rb +125 -125
  63. data/lib/lolita/lazy_loader.rb +54 -54
  64. data/lib/lolita/navigation/tree.rb +132 -132
  65. data/lib/lolita/rails/engine.rb +23 -23
  66. data/lib/lolita/rails/routes.rb +129 -129
  67. data/lib/lolita/ruby_ext/accessors.rb +26 -26
  68. data/lib/lolita/search/simple.rb +75 -75
  69. data/lib/lolita/support/formatter.rb +62 -62
  70. data/lib/lolita/support/formatter/rails.rb +56 -56
  71. data/lib/lolita/system_configuration/base.rb +178 -178
  72. data/lib/lolita/test/matchers.rb +77 -77
  73. data/lib/lolita/version.rb +30 -30
  74. data/lib/tasks/tinymce-assets.rake +6 -6
  75. data/lolita.gemspec +34 -34
  76. data/spec/adapter/common_helper_spec.rb +95 -95
  77. data/spec/adapter_helper.rb +42 -42
  78. data/spec/builder_spec.rb +120 -120
  79. data/spec/configuration/base_spec.rb +22 -22
  80. data/spec/configuration/field_spec.rb +118 -118
  81. data/spec/configuration/filter_spec.rb +131 -131
  82. data/spec/configuration/tab_spec.rb +187 -187
  83. data/spec/configuration/tabs_spec.rb +120 -120
  84. data/spec/generators/lolita/install_generator_spec.rb +54 -54
  85. data/spec/generators/lolita/uninstall_generator_spec.rb +48 -48
  86. data/spec/orm/mongoid.rb +12 -12
  87. data/spec/rails_app/app/controllers/application_controller.rb +3 -3
  88. data/spec/rails_app/app/helpers/application_helper.rb +3 -3
  89. data/spec/rails_app/app/mongoid/address.rb +7 -7
  90. data/spec/rails_app/app/mongoid/category.rb +18 -18
  91. data/spec/rails_app/app/mongoid/comment.rb +5 -5
  92. data/spec/rails_app/app/mongoid/post.rb +30 -30
  93. data/spec/rails_app/app/mongoid/preference.rb +5 -5
  94. data/spec/rails_app/app/mongoid/profile.rb +13 -13
  95. data/spec/rails_app/app/mongoid/tag.rb +3 -3
  96. data/spec/rails_app/app/views/components/lolita/configuration/list/_body_cell.html.erb +1 -1
  97. data/spec/rails_app/config/application.rb +33 -33
  98. data/spec/rails_app/config/boot.rb +7 -7
  99. data/spec/rails_app/config/environment.rb +5 -5
  100. data/spec/rails_app/config/environments/development.rb +23 -23
  101. data/spec/rails_app/config/environments/production.rb +37 -37
  102. data/spec/rails_app/config/environments/test.rb +37 -37
  103. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -7
  104. data/spec/rails_app/config/initializers/inflections.rb +2 -2
  105. data/spec/rails_app/config/initializers/secret_token.rb +1 -1
  106. data/spec/rails_app/config/routes.rb +2 -2
  107. data/spec/rails_app/lib/lolita/configuration/field/my_custom_collection.rb +13 -13
  108. data/spec/rails_app/public/javascripts/jquery-1.5.1.min.js +15 -15
  109. data/spec/rails_app/public/javascripts/lolita/main.js +6 -6
  110. data/spec/rails_app/public/javascripts/modernizr-1.7.min.js +1 -1
  111. data/spec/rails_app/public/javascripts/rails.js +137 -137
  112. data/spec/rails_app/public/javascripts/tinymce/langs/en.js +221 -221
  113. data/spec/rails_app/public/javascripts/tinymce/license.txt +504 -504
  114. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/about.htm +52 -52
  115. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/anchor.htm +26 -26
  116. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/charmap.htm +51 -51
  117. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/color_picker.htm +74 -74
  118. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/editor_template_src.js +1328 -1328
  119. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/image.htm +80 -80
  120. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/about.js +73 -73
  121. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/anchor.js +42 -42
  122. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/charmap.js +354 -354
  123. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/color_picker.js +329 -329
  124. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/image.js +247 -247
  125. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/link.js +153 -153
  126. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/source_editor.js +56 -56
  127. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en.js +68 -68
  128. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en_dlg.js +53 -53
  129. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/link.htm +57 -57
  130. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/shortcuts.htm +47 -47
  131. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
  132. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
  133. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
  134. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/source_editor.htm +25 -25
  135. data/spec/rails_app/public/javascripts/tinymce/tiny_mce_popup.js +4 -4
  136. data/spec/rails_app/public/stylesheets/lolita/default.css +169 -169
  137. data/spec/rails_app/public/stylesheets/lolita/style.css +214 -214
  138. data/spec/spec_helper.rb +51 -51
  139. data/vendor/assets/javascripts/application_vendor_lolita.js +4 -4
  140. data/vendor/assets/javascripts/jquery-numeric.js +279 -279
  141. data/vendor/assets/javascripts/modernizr_1_7_min.js +1 -1
  142. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
  143. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
  144. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
  145. data/vendor/assets/stylesheets/jquery-ui-1.8.16.custom.css +567 -567
  146. metadata +4 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c8f6b4828bc664dd5ccfb85ea2e86a0a7c06a0c7
4
- data.tar.gz: effe4caad3092762a9ed1f6ecbefc8e6620425c0
3
+ metadata.gz: eb76e0a38d3fbac492b31e7c34877a1f0bb7ba17
4
+ data.tar.gz: 887a763c1a452b176a0d392b3e0da4b069127a9c
5
5
  SHA512:
6
- metadata.gz: 6f44d2af71a34f341113439e8bf93e15c13d30728edbf9656e0adbee25ffd4317ff397d0f74e54d42563dd247864689f7ba9d77ca6a6127d37f8b7fb8c591f86
7
- data.tar.gz: d0767db7fd8ee50c6b8b8f7070f493fc9c25db2473479f6b3236ad24f95471ea7c19413b94bcbf72a9f664fa908fcbad066ddc171c94286712997d6fc7bcc242
6
+ metadata.gz: ec31c97d37d2f6331423f03fadf4db4e166b28ad4a4bbee4fbee6b887af04f3a84d81e7c941a0a5bfd2120f9eb1b70c479cf7f65745b55e2309a554c7f9d5977
7
+ data.tar.gz: dd093d46ff4d99894a37739320bad3863081d6cc94b9dc647f12c478483b8dd4916977a24ba2e215ef88f5b90c605130af831263a7ad1428d277e8c2e4e8b5b6
data/.gitignore CHANGED
@@ -1,36 +1,36 @@
1
- coverage.data
2
- sinatra-test.rb
3
- tmp/
4
- diagramm.rb
5
- log/
6
- nbproject/
7
- _public/_gsdata
8
- .DS_Store
9
- _public/_gsdata_/*
10
- .rvmrc
11
- .document
12
- *~
13
- doc/
14
- rdoc/
15
- unused_classes/
16
- spec/debug.log
17
- .git.zip
18
- .idea/
19
- .gem
20
- lib/test.rb
21
- coverage/
22
- spec/rails_app/log/
23
- spec/rails_app/tmp/
24
- .project
25
- Gemfile.lock
26
- .redcar
27
- pkg
28
- .bundle
29
- .pivotalrc
30
- .project
31
- *.swp
32
- .tags*
33
- tags
34
- .gemtags
35
- .ruby-version
36
- .local.vimrc
1
+ coverage.data
2
+ sinatra-test.rb
3
+ tmp/
4
+ diagramm.rb
5
+ log/
6
+ nbproject/
7
+ _public/_gsdata
8
+ .DS_Store
9
+ _public/_gsdata_/*
10
+ .rvmrc
11
+ .document
12
+ *~
13
+ doc/
14
+ rdoc/
15
+ unused_classes/
16
+ spec/debug.log
17
+ .git.zip
18
+ .idea/
19
+ .gem
20
+ lib/test.rb
21
+ coverage/
22
+ spec/rails_app/log/
23
+ spec/rails_app/tmp/
24
+ .project
25
+ Gemfile.lock
26
+ .redcar
27
+ pkg
28
+ .bundle
29
+ .pivotalrc
30
+ .project
31
+ *.swp
32
+ .tags*
33
+ tags
34
+ .gemtags
35
+ .ruby-version
36
+ .local.vimrc
data/Gemfile CHANGED
@@ -1,29 +1,29 @@
1
- source 'http://rubygems.org'
2
-
3
- gemspec
4
-
5
- group :test, :development do
6
- unless ENV['CI']
7
- gem 'pry-byebug'
8
- end
9
- gem 'fabrication', '~> 1.3.2'
10
- gem 'rspec', '~> 2.13'
11
- gem 'capybara', '~> 2.2'
12
- gem 'ffaker', '~> 1'
13
- gem 'generator_spec', '~> 0.9.0'
14
- end
15
-
16
- gem 'simplecov', :require => false, :group => :test
17
-
18
- group :rails do
19
- gem 'rails' , '~> 3.2.0'
20
- gem 'rspec-rails', '~> 2.13'
21
- gem 'coffee-rails', '~> 3.2.0'
22
- gem 'therubyracer', '~> 0.11.4'
23
- end
24
-
25
- group :mongoid do
26
- gem 'bson_ext', '~> 1.9.0'
27
- gem 'mongo', '~> 1.9.0'
28
- gem 'mongoid', '~> 2.7.1'
29
- end
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :test, :development do
6
+ unless ENV['CI']
7
+ gem 'pry-byebug'
8
+ end
9
+ gem 'fabrication', '~> 1.3.2'
10
+ gem 'rspec', '~> 2.13'
11
+ gem 'capybara', '~> 2.2'
12
+ gem 'ffaker', '~> 1'
13
+ gem 'generator_spec', '~> 0.9.0'
14
+ end
15
+
16
+ gem 'simplecov', :require => false, :group => :test
17
+
18
+ group :rails do
19
+ gem 'rails' , '~> 3.2.0'
20
+ gem 'rspec-rails', '~> 2.13'
21
+ gem 'coffee-rails', '~> 3.2.0'
22
+ gem 'therubyracer', '~> 0.11.4'
23
+ end
24
+
25
+ group :mongoid do
26
+ gem 'bson_ext', '~> 1.9.0'
27
+ gem 'mongo', '~> 1.9.0'
28
+ gem 'mongoid', '~> 2.7.1'
29
+ end
data/README.md CHANGED
@@ -1,147 +1,147 @@
1
- #Lolita
2
-
3
- Great Rails CMS, that turns your business logic into good-looking, fully functional workspace.
4
- Works with Rails 3.2
5
-
6
- [![Build Status](https://travis-ci.org/ithouse/lolita.png)](https://travis-ci.org/ithouse/lolita) [![Code Climate](https://codeclimate.com/github/ithouse/lolita.png)](https://codeclimate.com/github/ithouse/lolita)
7
-
8
- ##Demo
9
- See the demo page at [Demo](http://lolita-demo.ithouse.lv/lolita)
10
- email: lolita@ithouse.lv
11
- password: lolita
12
-
13
- ##Installation
14
-
15
- First add Lolita gem to your Gemfile
16
-
17
- gem 'lolita', '~> 3.4.0'
18
-
19
- Then go to your rails project and
20
-
21
- rails g lolita:install
22
-
23
- That will create initializer and copy all assets.
24
- Also it will call *install* on all added modules to lolita.
25
- So if you in Gemfile have following
26
-
27
- ```ruby
28
- gem "lolita"
29
- gem "lolita-file-upload"
30
- ```
31
-
32
- It will also call *lolita_file_upload:install*.
33
- ##Usage
34
-
35
- To make your model use Lolita do like this
36
-
37
- ```ruby
38
- class Post < ActiveRecord::Base
39
- include Lolita::Configuration
40
- lolita
41
- end
42
- ```
43
-
44
- Then in routes.rb file make resources accessable for lolita with
45
-
46
- lolita_for :posts
47
- This will make routes like
48
- `/lolita/posts`
49
- `/lolita/posts/1/edit`
50
- `/lolita/posts/new`
51
- or open `/lolita` and it will redirect to first available resource list view.
52
-
53
- For more detailed usage read [Usage](https://github.com/ithouse/lolita/wiki/Usage) at wiki.
54
-
55
- ###Add authorization to Lolita
56
-
57
- Easiest way to add authentication is with Devise. First install Devise as gem, than add it to your project.
58
- Make Devise model, lets say, *User*. After that add these lines in */config/initializers/lolita.rb*
59
-
60
- ```ruby
61
- config.user_classes << User
62
- config.authentication = :authenticate_user!
63
- ```
64
-
65
- This will make before each Lolita requests call before filter, that than will call *authenticate_user!*
66
- that is Devise method for authenticating user. Without it Lolita will be acessable for everyone.
67
- You can also add any other authentication method like
68
-
69
- ```ruby
70
- config.authentication = :authenticate_admin
71
- ```
72
-
73
- And than put this method for common use in *ApplicationController* or in some other place that is accessable
74
- to all controllers.
75
-
76
- ###Using hooks
77
-
78
- Lolita define hooks for RestController and for components.
79
- ####RestController hooks
80
-
81
- There are two kind of hooks for all actions - *before_[action name]* and *after_[action name]*.
82
- Define callbacks for those hooks outside of controller. This will call User#log_action each time when #destroy
83
- action is requested.
84
-
85
- ```ruby
86
- Lolita::RestController.before_destroy do
87
- User.log_action("Going to delete #{params[:id]}")
88
- end
89
- ```
90
-
91
- Also you can define callbacks in your controllers that extend Lolita::RestController. This will call #set\_default\_params
92
- each time #new action is requested.
93
-
94
- ```ruby
95
- class PostController < Lolita::RestController
96
- before_new :set_default_params
97
-
98
- private
99
-
100
- def set_default_params
101
- params[:post][:title]="-Your title goes here-"
102
- end
103
- end
104
- ```
105
-
106
- ####Component hooks
107
-
108
- Components have three hooks - *before*, *after* and *around*.
109
- Component hooks are different from controller hooks with names. Each component has it's own name, that is used to
110
- call component, like
111
-
112
- ```ruby
113
- render_component :"lolita/configuration/list/display"
114
- #same as
115
- render_component :"lolita/configuration/list", :display
116
- ```
117
-
118
- and this name is used to add callback for component. As components is not related to specific class, then there
119
- are only one way to define callback for them.
120
-
121
- ```ruby
122
- Lolita::Hooks.component(:"/lolita/configuration/list/display").before do
123
- "<div>My Custom text</div>"
124
- end
125
- ```
126
-
127
- That what are inside of blocks depends on place where you define callback if it is in _.rb_ file, than you
128
- should put HTML in quotes, if in _.erb_ and similar files then there is no need for that. Also blocks with
129
- Ruby code only return last line, so you should probably define HTML as shown in previous example.
130
- For _around_ callback if you pass block, then original content will be replaced with that, but if you want
131
- to let original content inside of your block content than it is done like this with #let_content method.
132
-
133
- ```ruby
134
- Lolita::Hooks.component(:"/lolita/configuration/list/display").around do
135
- "<div style='color:red'>#{let_content}</div>"
136
- end
137
- ```
138
-
139
- ##Tests
140
- To run all specs run rake, it will run all specs for all supported ORM's.
141
-
142
- $ rake
143
-
144
-
145
- ##License
146
-
147
- Lolita is under MIT license. See [LICENSE.txt](https://github.com/ithouse/lolita/blob/master/LICENSE.txt)
1
+ #Lolita
2
+
3
+ Great Rails CMS, that turns your business logic into good-looking, fully functional workspace.
4
+ Works with Rails 3.2
5
+
6
+ [![Build Status](https://travis-ci.org/ithouse/lolita.png)](https://travis-ci.org/ithouse/lolita) [![Code Climate](https://codeclimate.com/github/ithouse/lolita.png)](https://codeclimate.com/github/ithouse/lolita)
7
+
8
+ ##Demo
9
+ See the demo page at [Demo](http://lolita-demo.ithouse.lv/lolita)
10
+ email: lolita@ithouse.lv
11
+ password: lolita
12
+
13
+ ##Installation
14
+
15
+ First add Lolita gem to your Gemfile
16
+
17
+ gem 'lolita', '~> 3.4.0'
18
+
19
+ Then go to your rails project and
20
+
21
+ rails g lolita:install
22
+
23
+ That will create initializer and copy all assets.
24
+ Also it will call *install* on all added modules to lolita.
25
+ So if you in Gemfile have following
26
+
27
+ ```ruby
28
+ gem "lolita"
29
+ gem "lolita-file-upload"
30
+ ```
31
+
32
+ It will also call *lolita_file_upload:install*.
33
+ ##Usage
34
+
35
+ To make your model use Lolita do like this
36
+
37
+ ```ruby
38
+ class Post < ActiveRecord::Base
39
+ include Lolita::Configuration
40
+ lolita
41
+ end
42
+ ```
43
+
44
+ Then in routes.rb file make resources accessable for lolita with
45
+
46
+ lolita_for :posts
47
+ This will make routes like
48
+ `/lolita/posts`
49
+ `/lolita/posts/1/edit`
50
+ `/lolita/posts/new`
51
+ or open `/lolita` and it will redirect to first available resource list view.
52
+
53
+ For more detailed usage read [Usage](https://github.com/ithouse/lolita/wiki/Usage) at wiki.
54
+
55
+ ###Add authorization to Lolita
56
+
57
+ Easiest way to add authentication is with Devise. First install Devise as gem, than add it to your project.
58
+ Make Devise model, lets say, *User*. After that add these lines in */config/initializers/lolita.rb*
59
+
60
+ ```ruby
61
+ config.user_classes << User
62
+ config.authentication = :authenticate_user!
63
+ ```
64
+
65
+ This will make before each Lolita requests call before filter, that than will call *authenticate_user!*
66
+ that is Devise method for authenticating user. Without it Lolita will be acessable for everyone.
67
+ You can also add any other authentication method like
68
+
69
+ ```ruby
70
+ config.authentication = :authenticate_admin
71
+ ```
72
+
73
+ And than put this method for common use in *ApplicationController* or in some other place that is accessable
74
+ to all controllers.
75
+
76
+ ###Using hooks
77
+
78
+ Lolita define hooks for RestController and for components.
79
+ ####RestController hooks
80
+
81
+ There are two kind of hooks for all actions - *before_[action name]* and *after_[action name]*.
82
+ Define callbacks for those hooks outside of controller. This will call User#log_action each time when #destroy
83
+ action is requested.
84
+
85
+ ```ruby
86
+ Lolita::RestController.before_destroy do
87
+ User.log_action("Going to delete #{params[:id]}")
88
+ end
89
+ ```
90
+
91
+ Also you can define callbacks in your controllers that extend Lolita::RestController. This will call #set\_default\_params
92
+ each time #new action is requested.
93
+
94
+ ```ruby
95
+ class PostController < Lolita::RestController
96
+ before_new :set_default_params
97
+
98
+ private
99
+
100
+ def set_default_params
101
+ params[:post][:title]="-Your title goes here-"
102
+ end
103
+ end
104
+ ```
105
+
106
+ ####Component hooks
107
+
108
+ Components have three hooks - *before*, *after* and *around*.
109
+ Component hooks are different from controller hooks with names. Each component has it's own name, that is used to
110
+ call component, like
111
+
112
+ ```ruby
113
+ render_component :"lolita/configuration/list/display"
114
+ #same as
115
+ render_component :"lolita/configuration/list", :display
116
+ ```
117
+
118
+ and this name is used to add callback for component. As components is not related to specific class, then there
119
+ are only one way to define callback for them.
120
+
121
+ ```ruby
122
+ Lolita::Hooks.component(:"/lolita/configuration/list/display").before do
123
+ "<div>My Custom text</div>"
124
+ end
125
+ ```
126
+
127
+ That what are inside of blocks depends on place where you define callback if it is in _.rb_ file, than you
128
+ should put HTML in quotes, if in _.erb_ and similar files then there is no need for that. Also blocks with
129
+ Ruby code only return last line, so you should probably define HTML as shown in previous example.
130
+ For _around_ callback if you pass block, then original content will be replaced with that, but if you want
131
+ to let original content inside of your block content than it is done like this with #let_content method.
132
+
133
+ ```ruby
134
+ Lolita::Hooks.component(:"/lolita/configuration/list/display").around do
135
+ "<div style='color:red'>#{let_content}</div>"
136
+ end
137
+ ```
138
+
139
+ ##Tests
140
+ To run all specs run rake, it will run all specs for all supported ORM's.
141
+
142
+ $ rake
143
+
144
+
145
+ ##License
146
+
147
+ Lolita is under MIT license. See [LICENSE.txt](https://github.com/ithouse/lolita/blob/master/LICENSE.txt)
data/Rakefile CHANGED
@@ -1,7 +1,7 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- require 'rspec/core/rake_task'
4
-
5
- Bundler::GemHelper.install_tasks
6
- RSpec::Core::RakeTask.new(:spec)
1
+ require 'rubygems'
2
+ require 'bundler'
3
+ require 'rspec/core/rake_task'
4
+
5
+ Bundler::GemHelper.install_tasks
6
+ RSpec::Core::RakeTask.new(:spec)
7
7
  task :default => :spec