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.
- checksums.yaml +4 -4
- data/.gitignore +36 -36
- data/Gemfile +29 -29
- data/README.md +147 -147
- data/Rakefile +6 -6
- data/app/assets/javascripts/lolita/application.js +6 -6
- data/app/assets/javascripts/lolita/tab.js +100 -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 +6 -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 +553 -553
- data/app/helpers/components/lolita/configuration/list_component.rb +10 -10
- data/app/helpers/components/lolita/configuration_component.rb +20 -20
- 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/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 +7 -7
- data/app/views/components/lolita/configuration/search/_display.html.haml +2 -2
- data/app/views/components/lolita/configuration/tab/_display.html.haml +3 -3
- data/app/views/components/lolita/configuration/tabs/_form.html.haml +6 -6
- 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/routes.rb +6 -6
- data/lib/generators/lolita/install_generator.rb +19 -19
- data/lib/generators/lolita/uninstall_generator.rb +70 -70
- data/lib/generators/templates/lolita.rb +13 -13
- data/lib/lolita.rb +140 -140
- data/lib/lolita/adapter/abstract_adapter.rb +15 -15
- data/lib/lolita/adapter/active_record.rb +227 -227
- data/lib/lolita/adapter/common_helper.rb +221 -221
- data/lib/lolita/adapter/field_helper.rb +18 -18
- data/lib/lolita/adapter/mongoid.rb +241 -241
- data/lib/lolita/components/base.rb +11 -11
- data/lib/lolita/configuration.rb +60 -60
- data/lib/lolita/configuration/column.rb +181 -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 +116 -116
- data/lib/lolita/configuration/list.rb +200 -200
- data/lib/lolita/configuration/search.rb +104 -104
- data/lib/lolita/controllers/component_helpers.rb +156 -156
- data/lib/lolita/controllers/internal_helpers.rb +71 -71
- data/lib/lolita/controllers/url_helpers.rb +7 -7
- 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 +23 -23
- data/lib/lolita/rails/routes.rb +129 -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 +178 -178
- data/lib/lolita/test/matchers.rb +77 -77
- data/lib/lolita/version.rb +30 -30
- data/lib/tasks/tinymce-assets.rake +6 -6
- data/lolita.gemspec +34 -34
- data/spec/adapter/common_helper_spec.rb +95 -95
- data/spec/adapter_helper.rb +42 -42
- data/spec/builder_spec.rb +120 -120
- data/spec/configuration/base_spec.rb +22 -22
- data/spec/configuration/field_spec.rb +118 -118
- data/spec/configuration/filter_spec.rb +131 -131
- data/spec/configuration/tab_spec.rb +187 -187
- data/spec/configuration/tabs_spec.rb +120 -120
- data/spec/generators/lolita/install_generator_spec.rb +54 -54
- data/spec/generators/lolita/uninstall_generator_spec.rb +48 -48
- data/spec/orm/mongoid.rb +12 -12
- 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/mongoid/address.rb +7 -7
- data/spec/rails_app/app/mongoid/category.rb +18 -18
- data/spec/rails_app/app/mongoid/comment.rb +5 -5
- data/spec/rails_app/app/mongoid/post.rb +30 -30
- data/spec/rails_app/app/mongoid/preference.rb +5 -5
- data/spec/rails_app/app/mongoid/profile.rb +13 -13
- data/spec/rails_app/app/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 +33 -33
- data/spec/rails_app/config/boot.rb +7 -7
- data/spec/rails_app/config/environment.rb +5 -5
- data/spec/rails_app/config/environments/development.rb +23 -23
- data/spec/rails_app/config/environments/production.rb +37 -37
- data/spec/rails_app/config/environments/test.rb +37 -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 +2 -2
- 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 +51 -51
- data/vendor/assets/javascripts/application_vendor_lolita.js +4 -4
- data/vendor/assets/javascripts/jquery-numeric.js +279 -279
- data/vendor/assets/javascripts/modernizr_1_7_min.js +1 -1
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
- data/vendor/assets/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
- data/vendor/assets/stylesheets/jquery-ui-1.8.16.custom.css +567 -567
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: eb76e0a38d3fbac492b31e7c34877a1f0bb7ba17
|
|
4
|
+
data.tar.gz: 887a763c1a452b176a0d392b3e0da4b069127a9c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
[](https://travis-ci.org/ithouse/lolita) [](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
|
+
[](https://travis-ci.org/ithouse/lolita) [](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
|