lolita 3.4.3 → 4.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (190) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +37 -36
  3. data/Gemfile +31 -29
  4. data/README.md +147 -147
  5. data/Rakefile +17 -7
  6. data/app/assets/javascripts/lolita/application.js +5 -6
  7. data/app/assets/javascripts/lolita/tab.js +98 -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 +7 -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 +554 -553
  14. data/app/assets/stylesheets/tinymce/skins/lolita/content.inline.min.css +1 -0
  15. data/app/assets/stylesheets/tinymce/skins/lolita/content.min.css +1 -0
  16. data/app/assets/stylesheets/tinymce/skins/lolita/fonts/readme.md +1 -0
  17. data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce-small.eot +0 -0
  18. data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce-small.svg +175 -0
  19. data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce-small.ttf +0 -0
  20. data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce-small.woff +0 -0
  21. data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce.eot +0 -0
  22. data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce.svg +153 -0
  23. data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce.ttf +0 -0
  24. data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce.woff +0 -0
  25. data/app/assets/stylesheets/tinymce/skins/lolita/img/anchor.gif +0 -0
  26. data/app/assets/stylesheets/tinymce/skins/lolita/img/loader.gif +0 -0
  27. data/app/assets/stylesheets/tinymce/skins/lolita/img/object.gif +0 -0
  28. data/app/assets/stylesheets/tinymce/skins/lolita/img/trans.gif +0 -0
  29. data/app/assets/stylesheets/tinymce/skins/lolita/img/wline.gif +0 -0
  30. data/app/assets/stylesheets/tinymce/skins/lolita/skin.ie7.min.css +1 -0
  31. data/app/assets/stylesheets/tinymce/skins/lolita/skin.min.css +2 -0
  32. data/app/helpers/components/lolita/configuration/list_component.rb +10 -10
  33. data/app/helpers/components/lolita/configuration_component.rb +21 -21
  34. data/app/views/components/lolita/configuration/column/_first.html.haml +1 -1
  35. data/app/views/components/lolita/configuration/column/header/_first.html.haml +1 -1
  36. data/app/views/components/lolita/configuration/column/header/_sort.html.haml +6 -6
  37. data/app/views/components/lolita/configuration/columns/body/_display.html.haml +1 -1
  38. data/app/views/components/lolita/configuration/columns/header/_display.html.haml +5 -5
  39. data/app/views/components/lolita/configuration/field/array/checkbox/_display.html.haml +7 -7
  40. data/app/views/components/lolita/configuration/field/string/text/_display.html.haml +4 -7
  41. data/app/views/components/lolita/configuration/search/_display.html.haml +2 -2
  42. data/app/views/components/lolita/configuration/tab/_display.html.haml +4 -4
  43. data/app/views/components/lolita/configuration/tabs/_form.html.haml +7 -6
  44. data/app/views/components/lolita/configuration/tabs/yo.html +1 -0
  45. data/app/views/kaminari/lolita/_first_page.html.erb +11 -11
  46. data/app/views/kaminari/lolita/_gap.html.erb +8 -8
  47. data/app/views/kaminari/lolita/_last_page.html.erb +11 -11
  48. data/app/views/kaminari/lolita/_next_page.html.erb +11 -11
  49. data/app/views/kaminari/lolita/_page.html.erb +12 -12
  50. data/app/views/kaminari/lolita/_paginator.html.erb +23 -23
  51. data/app/views/kaminari/lolita/_prev_page.html.erb +11 -11
  52. data/app/views/lolita/info/index.html.erb +232 -232
  53. data/author +1 -1
  54. data/config/locales/sv_SE.yml +37 -0
  55. data/config/routes.rb +6 -6
  56. data/lib/generators/lolita/install_generator.rb +22 -19
  57. data/lib/generators/lolita/uninstall_generator.rb +76 -71
  58. data/lib/generators/templates/lolita.rb +17 -14
  59. data/lib/generators/templates/tinymce.yml +22 -0
  60. data/lib/lolita.rb +142 -141
  61. data/lib/lolita/adapter/abstract_adapter.rb +17 -16
  62. data/lib/lolita/adapter/active_record.rb +229 -227
  63. data/lib/lolita/adapter/common_helper.rb +220 -221
  64. data/lib/lolita/adapter/field_helper.rb +18 -18
  65. data/lib/lolita/adapter/mongoid.rb +244 -241
  66. data/lib/lolita/components/base.rb +10 -12
  67. data/lib/lolita/configuration.rb +61 -61
  68. data/lib/lolita/configuration/column.rb +170 -181
  69. data/lib/lolita/configuration/field/big_decimal.rb +12 -12
  70. data/lib/lolita/configuration/field/boolean.rb +12 -12
  71. data/lib/lolita/configuration/field/date.rb +12 -12
  72. data/lib/lolita/configuration/field/hidden.rb +12 -12
  73. data/lib/lolita/configuration/field/integer.rb +11 -11
  74. data/lib/lolita/configuration/field/string.rb +16 -16
  75. data/lib/lolita/configuration/field/time.rb +13 -13
  76. data/lib/lolita/configuration/field_set.rb +25 -25
  77. data/lib/lolita/configuration/filter.rb +130 -116
  78. data/lib/lolita/configuration/list.rb +201 -201
  79. data/lib/lolita/configuration/search.rb +105 -105
  80. data/lib/lolita/controllers/component_helpers.rb +156 -156
  81. data/lib/lolita/controllers/internal_helpers.rb +74 -71
  82. data/lib/lolita/dbi/base.rb +56 -56
  83. data/lib/lolita/hooks/named_hook.rb +125 -125
  84. data/lib/lolita/lazy_loader.rb +54 -54
  85. data/lib/lolita/navigation/tree.rb +132 -132
  86. data/lib/lolita/rails/engine.rb +29 -24
  87. data/lib/lolita/rails/routes.rb +133 -129
  88. data/lib/lolita/ruby_ext/accessors.rb +26 -26
  89. data/lib/lolita/search/simple.rb +75 -75
  90. data/lib/lolita/support/formatter.rb +62 -62
  91. data/lib/lolita/support/formatter/rails.rb +56 -56
  92. data/lib/lolita/system_configuration/base.rb +182 -178
  93. data/lib/lolita/test/matchers.rb +77 -77
  94. data/lib/lolita/version.rb +30 -30
  95. data/lolita.gemspec +35 -34
  96. data/spec/adapter/common_helper_spec.rb +96 -96
  97. data/spec/builder_spec.rb +120 -120
  98. data/spec/configuration/base_spec.rb +23 -23
  99. data/spec/configuration/field_spec.rb +117 -118
  100. data/spec/configuration/filter_spec.rb +145 -131
  101. data/spec/configuration/tab_spec.rb +184 -187
  102. data/spec/configuration/tabs_spec.rb +116 -120
  103. data/spec/generators/lolita/install_generator_spec.rb +70 -55
  104. data/spec/generators/lolita/uninstall_generator_spec.rb +65 -49
  105. data/spec/helpers/url_for_spec.rb +8 -0
  106. data/spec/orm/active_record.rb +53 -0
  107. data/spec/orm/mongoid.rb +2 -13
  108. data/spec/orm/mongoid.yml +6 -0
  109. data/spec/rails_app/app/controllers/application_controller.rb +3 -3
  110. data/spec/rails_app/app/helpers/application_helper.rb +3 -3
  111. data/spec/rails_app/app/orm/active_record/address.rb +3 -0
  112. data/spec/rails_app/app/orm/active_record/category.rb +16 -0
  113. data/spec/rails_app/app/orm/active_record/comment.rb +4 -0
  114. data/spec/rails_app/app/orm/active_record/post.rb +24 -0
  115. data/spec/rails_app/app/orm/active_record/preference.rb +4 -0
  116. data/spec/rails_app/app/orm/active_record/profile.rb +9 -0
  117. data/spec/rails_app/app/orm/active_record/tag.rb +2 -0
  118. data/spec/rails_app/app/{mongoid → orm/mongoid}/address.rb +7 -7
  119. data/spec/rails_app/app/{mongoid → orm/mongoid}/category.rb +18 -19
  120. data/spec/rails_app/app/{mongoid → orm/mongoid}/comment.rb +5 -5
  121. data/spec/rails_app/app/{mongoid → orm/mongoid}/post.rb +30 -30
  122. data/spec/rails_app/app/{mongoid → orm/mongoid}/preference.rb +5 -5
  123. data/spec/rails_app/app/{mongoid → orm/mongoid}/profile.rb +13 -14
  124. data/spec/rails_app/app/{mongoid → orm/mongoid}/tag.rb +3 -3
  125. data/spec/rails_app/app/views/components/lolita/configuration/list/_body_cell.html.erb +1 -1
  126. data/spec/rails_app/config/application.rb +34 -33
  127. data/spec/rails_app/config/boot.rb +7 -8
  128. data/spec/rails_app/config/environment.rb +5 -5
  129. data/spec/rails_app/config/environments/development.rb +22 -23
  130. data/spec/rails_app/config/environments/production.rb +37 -37
  131. data/spec/rails_app/config/environments/test.rb +36 -37
  132. data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -7
  133. data/spec/rails_app/config/initializers/inflections.rb +2 -2
  134. data/spec/rails_app/config/initializers/secret_token.rb +1 -1
  135. data/spec/rails_app/config/routes.rb +4 -3
  136. data/spec/rails_app/lib/lolita/configuration/field/my_custom_collection.rb +13 -13
  137. data/spec/rails_app/public/javascripts/jquery-1.5.1.min.js +15 -15
  138. data/spec/rails_app/public/javascripts/lolita/main.js +6 -6
  139. data/spec/rails_app/public/javascripts/modernizr-1.7.min.js +1 -1
  140. data/spec/rails_app/public/javascripts/rails.js +137 -137
  141. data/spec/rails_app/public/javascripts/tinymce/langs/en.js +221 -221
  142. data/spec/rails_app/public/javascripts/tinymce/license.txt +504 -504
  143. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/about.htm +52 -52
  144. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/anchor.htm +26 -26
  145. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/charmap.htm +51 -51
  146. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/color_picker.htm +74 -74
  147. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/editor_template_src.js +1328 -1328
  148. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/image.htm +80 -80
  149. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/about.js +73 -73
  150. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/anchor.js +42 -42
  151. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/charmap.js +354 -354
  152. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/color_picker.js +329 -329
  153. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/image.js +247 -247
  154. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/link.js +153 -153
  155. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/source_editor.js +56 -56
  156. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en.js +68 -68
  157. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en_dlg.js +53 -53
  158. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/link.htm +57 -57
  159. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/shortcuts.htm +47 -47
  160. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
  161. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
  162. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
  163. data/spec/rails_app/public/javascripts/tinymce/themes/advanced/source_editor.htm +25 -25
  164. data/spec/rails_app/public/javascripts/tinymce/tiny_mce_popup.js +4 -4
  165. data/spec/rails_app/public/stylesheets/lolita/default.css +169 -169
  166. data/spec/rails_app/public/stylesheets/lolita/style.css +214 -214
  167. data/spec/spec_helper.rb +44 -51
  168. data/spec/support/cleaner.rb +12 -0
  169. data/vendor/assets/javascripts/application_vendor_lolita.js +5 -4
  170. data/vendor/assets/javascripts/jquery-numeric.js +279 -279
  171. data/vendor/assets/javascripts/modernizr_1_7_min.js +1 -1
  172. data/vendor/assets/stylesheets/jquery-ui-1.8.16.custom.css +567 -567
  173. metadata +105 -72
  174. data/lib/tasks/tinymce-assets.rake +0 -7
  175. data/spec/adapter_helper.rb +0 -43
  176. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +0 -66
  177. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +0 -117
  178. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/butt2.png +0 -0
  179. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/button-bg.png +0 -0
  180. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/buttons.png +0 -0
  181. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/down_arrow.gif +0 -0
  182. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/fade-butt.png +0 -0
  183. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/icons.png +0 -0
  184. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/items.gif +0 -0
  185. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/menu-arrow.png +0 -0
  186. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/menu-check.png +0 -0
  187. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/progress.gif +0 -0
  188. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/tabs.gif +0 -0
  189. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/toolbarbg.png +0 -0
  190. data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +0 -988
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eb76e0a38d3fbac492b31e7c34877a1f0bb7ba17
4
- data.tar.gz: 887a763c1a452b176a0d392b3e0da4b069127a9c
3
+ metadata.gz: 1d0bf149b77902829b5affa625a55dc0292a4889
4
+ data.tar.gz: 1b6dfaa21383b9c7325d7bdc43a855b9b7a8b1a8
5
5
  SHA512:
6
- metadata.gz: ec31c97d37d2f6331423f03fadf4db4e166b28ad4a4bbee4fbee6b887af04f3a84d81e7c941a0a5bfd2120f9eb1b70c479cf7f65745b55e2309a554c7f9d5977
7
- data.tar.gz: dd093d46ff4d99894a37739320bad3863081d6cc94b9dc647f12c478483b8dd4916977a24ba2e215ef88f5b90c605130af831263a7ad1428d277e8c2e4e8b5b6
6
+ metadata.gz: f37023830f2c2eac49bcc1a9797b24a7842b9859d78fd9c9e04f9c77daf8584f123ce326541e482d9bdba5122c80f067311d42ff7499c4284e737f06ffb4bf87
7
+ data.tar.gz: 71634b76ed81447172cab01f052bb0523bbb6cc717ee2af1e3ec5962ed58d20e6b0951a78eccb6b7fa2f55de4435fd701fd7a3b481a2905904ad4f81d5508a0c
data/.gitignore CHANGED
@@ -1,36 +1,37 @@
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
+ .tags_sorted_by_file
35
+ .gemtags
36
+ .ruby-version
37
+ .local.vimrc
data/Gemfile CHANGED
@@ -1,29 +1,31 @@
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", "~> 2.9.3"
10
+ gem "rspec", "~> 2.14"
11
+ gem "capybara", "~> 2"
12
+ gem "ffaker", "~> 1"
13
+ gem "generator_spec", "~> 0.9.0"
14
+ gem "sqlite3"
15
+ gem "database_cleaner"
16
+ end
17
+
18
+ gem 'simplecov', :require => false, :group => :test
19
+
20
+ group :rails do
21
+ gem "rails" , "~> 4.1.0"
22
+ gem "rspec-rails", "~> 2.14"
23
+ gem "coffee-rails", "~> 4.0.1"
24
+ gem "therubyracer", "~> 0.12.0"
25
+ end
26
+
27
+ group :mongoid do
28
+ gem "bson_ext"
29
+ gem 'kaminari', '~> 0.16.1'
30
+ gem "mongoid", "~> 4.0.0"
31
+ 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,17 @@
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
- task :default => :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
+
8
+ task :default do
9
+ puts "ORM: ActiveRecord"
10
+ ENV["LOLITA_ORM"] = "active_record"
11
+ Rake::Task[:spec].execute
12
+ Rake::Task[:spec].reenable
13
+
14
+ puts "ORM: Mongoid"
15
+ ENV["LOLITA_ORM"] = "mongoid"
16
+ Rake::Task[:spec].execute
17
+ end