lolita 3.4.3 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +37 -36
- data/Gemfile +31 -29
- data/README.md +147 -147
- data/Rakefile +17 -7
- data/app/assets/javascripts/lolita/application.js +5 -6
- data/app/assets/javascripts/lolita/tab.js +98 -100
- data/app/assets/stylesheets/lolita/PIE-custom.htc +87 -87
- data/app/assets/stylesheets/lolita/PIE.htc +81 -81
- data/app/assets/stylesheets/lolita/application.css +7 -6
- data/app/assets/stylesheets/lolita/default.css.erb +169 -169
- data/app/assets/stylesheets/lolita/jquery-ui-1.8.16.lolita.css.erb +567 -567
- data/app/assets/stylesheets/lolita/style.css.erb +554 -553
- data/app/assets/stylesheets/tinymce/skins/lolita/content.inline.min.css +1 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/content.min.css +1 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/fonts/readme.md +1 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce-small.eot +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce-small.svg +175 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce-small.ttf +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce-small.woff +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce.eot +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce.svg +153 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce.ttf +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/fonts/tinymce.woff +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/img/anchor.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/img/loader.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/img/object.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/img/trans.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/img/wline.gif +0 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/skin.ie7.min.css +1 -0
- data/app/assets/stylesheets/tinymce/skins/lolita/skin.min.css +2 -0
- data/app/helpers/components/lolita/configuration/list_component.rb +10 -10
- data/app/helpers/components/lolita/configuration_component.rb +21 -21
- data/app/views/components/lolita/configuration/column/_first.html.haml +1 -1
- data/app/views/components/lolita/configuration/column/header/_first.html.haml +1 -1
- data/app/views/components/lolita/configuration/column/header/_sort.html.haml +6 -6
- data/app/views/components/lolita/configuration/columns/body/_display.html.haml +1 -1
- data/app/views/components/lolita/configuration/columns/header/_display.html.haml +5 -5
- data/app/views/components/lolita/configuration/field/array/checkbox/_display.html.haml +7 -7
- data/app/views/components/lolita/configuration/field/string/text/_display.html.haml +4 -7
- data/app/views/components/lolita/configuration/search/_display.html.haml +2 -2
- data/app/views/components/lolita/configuration/tab/_display.html.haml +4 -4
- data/app/views/components/lolita/configuration/tabs/_form.html.haml +7 -6
- data/app/views/components/lolita/configuration/tabs/yo.html +1 -0
- data/app/views/kaminari/lolita/_first_page.html.erb +11 -11
- data/app/views/kaminari/lolita/_gap.html.erb +8 -8
- data/app/views/kaminari/lolita/_last_page.html.erb +11 -11
- data/app/views/kaminari/lolita/_next_page.html.erb +11 -11
- data/app/views/kaminari/lolita/_page.html.erb +12 -12
- data/app/views/kaminari/lolita/_paginator.html.erb +23 -23
- data/app/views/kaminari/lolita/_prev_page.html.erb +11 -11
- data/app/views/lolita/info/index.html.erb +232 -232
- data/author +1 -1
- data/config/locales/sv_SE.yml +37 -0
- data/config/routes.rb +6 -6
- data/lib/generators/lolita/install_generator.rb +22 -19
- data/lib/generators/lolita/uninstall_generator.rb +76 -71
- data/lib/generators/templates/lolita.rb +17 -14
- data/lib/generators/templates/tinymce.yml +22 -0
- data/lib/lolita.rb +142 -141
- data/lib/lolita/adapter/abstract_adapter.rb +17 -16
- data/lib/lolita/adapter/active_record.rb +229 -227
- data/lib/lolita/adapter/common_helper.rb +220 -221
- data/lib/lolita/adapter/field_helper.rb +18 -18
- data/lib/lolita/adapter/mongoid.rb +244 -241
- data/lib/lolita/components/base.rb +10 -12
- data/lib/lolita/configuration.rb +61 -61
- data/lib/lolita/configuration/column.rb +170 -181
- data/lib/lolita/configuration/field/big_decimal.rb +12 -12
- data/lib/lolita/configuration/field/boolean.rb +12 -12
- data/lib/lolita/configuration/field/date.rb +12 -12
- data/lib/lolita/configuration/field/hidden.rb +12 -12
- data/lib/lolita/configuration/field/integer.rb +11 -11
- data/lib/lolita/configuration/field/string.rb +16 -16
- data/lib/lolita/configuration/field/time.rb +13 -13
- data/lib/lolita/configuration/field_set.rb +25 -25
- data/lib/lolita/configuration/filter.rb +130 -116
- data/lib/lolita/configuration/list.rb +201 -201
- data/lib/lolita/configuration/search.rb +105 -105
- data/lib/lolita/controllers/component_helpers.rb +156 -156
- data/lib/lolita/controllers/internal_helpers.rb +74 -71
- data/lib/lolita/dbi/base.rb +56 -56
- data/lib/lolita/hooks/named_hook.rb +125 -125
- data/lib/lolita/lazy_loader.rb +54 -54
- data/lib/lolita/navigation/tree.rb +132 -132
- data/lib/lolita/rails/engine.rb +29 -24
- data/lib/lolita/rails/routes.rb +133 -129
- data/lib/lolita/ruby_ext/accessors.rb +26 -26
- data/lib/lolita/search/simple.rb +75 -75
- data/lib/lolita/support/formatter.rb +62 -62
- data/lib/lolita/support/formatter/rails.rb +56 -56
- data/lib/lolita/system_configuration/base.rb +182 -178
- data/lib/lolita/test/matchers.rb +77 -77
- data/lib/lolita/version.rb +30 -30
- data/lolita.gemspec +35 -34
- data/spec/adapter/common_helper_spec.rb +96 -96
- data/spec/builder_spec.rb +120 -120
- data/spec/configuration/base_spec.rb +23 -23
- data/spec/configuration/field_spec.rb +117 -118
- data/spec/configuration/filter_spec.rb +145 -131
- data/spec/configuration/tab_spec.rb +184 -187
- data/spec/configuration/tabs_spec.rb +116 -120
- data/spec/generators/lolita/install_generator_spec.rb +70 -55
- data/spec/generators/lolita/uninstall_generator_spec.rb +65 -49
- data/spec/helpers/url_for_spec.rb +8 -0
- data/spec/orm/active_record.rb +53 -0
- data/spec/orm/mongoid.rb +2 -13
- data/spec/orm/mongoid.yml +6 -0
- data/spec/rails_app/app/controllers/application_controller.rb +3 -3
- data/spec/rails_app/app/helpers/application_helper.rb +3 -3
- data/spec/rails_app/app/orm/active_record/address.rb +3 -0
- data/spec/rails_app/app/orm/active_record/category.rb +16 -0
- data/spec/rails_app/app/orm/active_record/comment.rb +4 -0
- data/spec/rails_app/app/orm/active_record/post.rb +24 -0
- data/spec/rails_app/app/orm/active_record/preference.rb +4 -0
- data/spec/rails_app/app/orm/active_record/profile.rb +9 -0
- data/spec/rails_app/app/orm/active_record/tag.rb +2 -0
- data/spec/rails_app/app/{mongoid → orm/mongoid}/address.rb +7 -7
- data/spec/rails_app/app/{mongoid → orm/mongoid}/category.rb +18 -19
- data/spec/rails_app/app/{mongoid → orm/mongoid}/comment.rb +5 -5
- data/spec/rails_app/app/{mongoid → orm/mongoid}/post.rb +30 -30
- data/spec/rails_app/app/{mongoid → orm/mongoid}/preference.rb +5 -5
- data/spec/rails_app/app/{mongoid → orm/mongoid}/profile.rb +13 -14
- data/spec/rails_app/app/{mongoid → orm/mongoid}/tag.rb +3 -3
- data/spec/rails_app/app/views/components/lolita/configuration/list/_body_cell.html.erb +1 -1
- data/spec/rails_app/config/application.rb +34 -33
- data/spec/rails_app/config/boot.rb +7 -8
- data/spec/rails_app/config/environment.rb +5 -5
- data/spec/rails_app/config/environments/development.rb +22 -23
- data/spec/rails_app/config/environments/production.rb +37 -37
- data/spec/rails_app/config/environments/test.rb +36 -37
- data/spec/rails_app/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/rails_app/config/initializers/inflections.rb +2 -2
- data/spec/rails_app/config/initializers/secret_token.rb +1 -1
- data/spec/rails_app/config/routes.rb +4 -3
- data/spec/rails_app/lib/lolita/configuration/field/my_custom_collection.rb +13 -13
- data/spec/rails_app/public/javascripts/jquery-1.5.1.min.js +15 -15
- data/spec/rails_app/public/javascripts/lolita/main.js +6 -6
- data/spec/rails_app/public/javascripts/modernizr-1.7.min.js +1 -1
- data/spec/rails_app/public/javascripts/rails.js +137 -137
- data/spec/rails_app/public/javascripts/tinymce/langs/en.js +221 -221
- data/spec/rails_app/public/javascripts/tinymce/license.txt +504 -504
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/about.htm +52 -52
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/anchor.htm +26 -26
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/charmap.htm +51 -51
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/color_picker.htm +74 -74
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/editor_template_src.js +1328 -1328
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/image.htm +80 -80
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/about.js +73 -73
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/anchor.js +42 -42
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/charmap.js +354 -354
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/color_picker.js +329 -329
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/image.js +247 -247
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/link.js +153 -153
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/js/source_editor.js +56 -56
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en.js +68 -68
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/langs/en_dlg.js +53 -53
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/link.htm +57 -57
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/shortcuts.htm +47 -47
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
- data/spec/rails_app/public/javascripts/tinymce/themes/advanced/source_editor.htm +25 -25
- data/spec/rails_app/public/javascripts/tinymce/tiny_mce_popup.js +4 -4
- data/spec/rails_app/public/stylesheets/lolita/default.css +169 -169
- data/spec/rails_app/public/stylesheets/lolita/style.css +214 -214
- data/spec/spec_helper.rb +44 -51
- data/spec/support/cleaner.rb +12 -0
- data/vendor/assets/javascripts/application_vendor_lolita.js +5 -4
- data/vendor/assets/javascripts/jquery-numeric.js +279 -279
- data/vendor/assets/javascripts/modernizr_1_7_min.js +1 -1
- data/vendor/assets/stylesheets/jquery-ui-1.8.16.custom.css +567 -567
- metadata +105 -72
- data/lib/tasks/tinymce-assets.rake +0 -7
- data/spec/adapter_helper.rb +0 -43
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +0 -66
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +0 -117
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/butt2.png +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/button-bg.png +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/buttons.png +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/down_arrow.gif +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/fade-butt.png +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/icons.png +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/items.gif +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/menu-arrow.png +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/menu-check.png +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/progress.gif +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/tabs.gif +0 -0
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/img/toolbarbg.png +0 -0
- 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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1d0bf149b77902829b5affa625a55dc0292a4889
|
4
|
+
data.tar.gz: 1b6dfaa21383b9c7325d7bdc43a855b9b7a8b1a8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
.
|
35
|
-
.
|
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
|
+
.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
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
group :
|
19
|
-
|
20
|
-
|
21
|
-
gem
|
22
|
-
gem
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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", "~> 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
|
-
|
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
|