lolita 3.1.10 → 3.1.11
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -5
- data/.rspec +2 -2
- data/GUIDELINES.rdoc +24 -24
- data/Gemfile +26 -26
- data/History.rdoc +162 -154
- data/LICENSE.txt +22 -22
- data/README.rdoc +98 -98
- data/Rakefile +40 -40
- data/VERSION +1 -1
- data/app/controllers/lolita/info_controller.rb +41 -41
- data/app/controllers/lolita/rest_controller.rb +130 -130
- data/app/helpers/components/lolita/configuration/list_component.rb +10 -10
- data/app/helpers/lolita_helper.rb +11 -11
- data/app/views/components/lolita/configuration/column/_display.html.erb +4 -4
- data/app/views/components/lolita/configuration/column/_header.html.erb +7 -7
- data/app/views/components/lolita/configuration/column/_sort.html.erb +4 -4
- data/app/views/components/lolita/configuration/columns/_body.html.erb +4 -4
- data/app/views/components/lolita/configuration/columns/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/columns/_first.html.erb +2 -2
- data/app/views/components/lolita/configuration/columns/_first_column_header.html.erb +3 -3
- data/app/views/components/lolita/configuration/columns/_header.html.erb +8 -8
- data/app/views/components/lolita/configuration/columns/_last.html.erb +4 -4
- data/app/views/components/lolita/configuration/columns/_last_column_header.html.erb +2 -2
- data/app/views/components/lolita/configuration/columns/_row.html.erb +7 -7
- data/app/views/components/lolita/configuration/field/_display.html.erb +9 -9
- data/app/views/components/lolita/configuration/field/_label.html.erb +1 -1
- data/app/views/components/lolita/configuration/field/_object.html.erb +1 -1
- data/app/views/components/lolita/configuration/field/array/_display.html.erb +4 -4
- data/app/views/components/lolita/configuration/field/array/habtm/_display.html.erb +26 -26
- data/app/views/components/lolita/configuration/field/array/select/_display.html.erb +5 -5
- data/app/views/components/lolita/configuration/field/boolean/filter/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/field/date/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/field/date_time/date/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/field/integer/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/field/string/_display.html.erb +4 -4
- data/app/views/components/lolita/configuration/field/string/disabled/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/field/string/password/_display.html.erb +3 -3
- data/app/views/components/lolita/configuration/field/string/text/_display.html.erb +18 -18
- data/app/views/components/lolita/configuration/field_set/_display.html.erb +5 -5
- data/app/views/components/lolita/configuration/list/_display.html.erb +10 -10
- data/app/views/components/lolita/configuration/list/_filter.html.erb +7 -7
- data/app/views/components/lolita/configuration/list/_new_resource.html.erb +4 -4
- data/app/views/components/lolita/configuration/list/_title.html.erb +4 -4
- data/app/views/components/lolita/configuration/tab/_display.html.erb +17 -17
- data/app/views/components/lolita/configuration/tab/_fields.html.erb +6 -6
- data/app/views/components/lolita/configuration/tab/content/_display.html.erb +1 -1
- data/app/views/components/lolita/configuration/tab/default/_display.html.erb +8 -8
- data/app/views/components/lolita/configuration/tabs/_display.html.erb +10 -10
- data/app/views/components/lolita/navigation/_display.html.erb +2 -2
- data/app/views/components/lolita/navigation/_tree.html.erb +38 -38
- data/app/views/components/lolita/shared/_flash.html.erb +5 -5
- data/app/views/components/lolita/shared/_header.html.erb +8 -8
- data/app/views/components/lolita/shared/_right_sidebar.html.erb +13 -13
- data/app/views/layouts/lolita/application.html.erb +44 -44
- data/app/views/lolita/info/index.html.erb +232 -232
- data/app/views/lolita/rest/form.html.erb +1 -1
- data/app/views/lolita/rest/index.html.erb +1 -1
- data/author +1 -1
- data/config/locales/default/lv.yml +180 -180
- data/config/locales/en.yml +20 -20
- data/config/locales/lv.yml +20 -20
- data/config/routes.rb +3 -3
- data/db/seed.rb +1 -1
- data/features/create_page.feature +19 -19
- data/features/step_definitions/lolita_steps.rb +7 -7
- data/features/step_definitions/web_steps.rb +219 -219
- data/features/support/env.rb +73 -73
- data/features/support/paths.rb +35 -35
- data/lib/generators/helpers/file_helper.rb +22 -22
- data/lib/generators/lolita/assets_generator.rb +18 -18
- data/lib/generators/lolita/install_generator.rb +28 -28
- data/lib/generators/templates/lolita.rb +19 -19
- data/lib/lolita.rb +184 -184
- data/lib/lolita/adapter/abstract_adapter.rb +13 -13
- data/lib/lolita/adapter/active_record.rb +148 -148
- data/lib/lolita/adapter/mongoid.rb +127 -127
- data/lib/lolita/base_configuration.rb +165 -165
- data/lib/lolita/builder.rb +249 -249
- data/lib/lolita/configuration/base.rb +76 -76
- data/lib/lolita/configuration/column.rb +93 -94
- data/lib/lolita/configuration/columns.rb +66 -66
- data/lib/lolita/configuration/factory.rb +55 -55
- data/lib/lolita/configuration/field.rb +216 -216
- data/lib/lolita/configuration/field/array.rb +75 -75
- 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/date_time.rb +13 -13
- data/lib/lolita/configuration/field/integer.rb +12 -12
- data/lib/lolita/configuration/field/string.rb +13 -13
- data/lib/lolita/configuration/field/time.rb +13 -13
- data/lib/lolita/configuration/field_set.rb +25 -25
- data/lib/lolita/configuration/fields.rb +35 -35
- data/lib/lolita/configuration/filter.rb +108 -108
- data/lib/lolita/configuration/list.rb +104 -104
- data/lib/lolita/configuration/page.rb +125 -124
- data/lib/lolita/configuration/tab.rb +187 -187
- data/lib/lolita/configuration/tab/content.rb +21 -21
- data/lib/lolita/configuration/tab/default.rb +25 -25
- data/lib/lolita/configuration/tabs.rb +132 -132
- data/lib/lolita/controllers/component_helpers.rb +127 -127
- data/lib/lolita/controllers/internal_helpers.rb +109 -109
- data/lib/lolita/controllers/url_helpers.rb +111 -111
- data/lib/lolita/controllers/user_helpers.rb +32 -32
- data/lib/lolita/controllers/view_user_helpers.rb +12 -12
- data/lib/lolita/dbi/base.rb +50 -50
- data/lib/lolita/errors.rb +12 -12
- data/lib/lolita/hooks.rb +355 -355
- data/lib/lolita/hooks/named_hook.rb +125 -125
- data/lib/lolita/lazy_loader.rb +46 -46
- data/lib/lolita/mapping.rb +55 -55
- data/lib/lolita/modules.rb +6 -6
- data/lib/lolita/modules/rest.rb +10 -10
- data/lib/lolita/navigation/branch.rb +132 -132
- data/lib/lolita/navigation/tree.rb +116 -116
- data/lib/lolita/observed_array.rb +74 -74
- data/lib/lolita/rails.rb +20 -20
- data/lib/lolita/rails/all.rb +10 -10
- data/lib/lolita/rails/routes.rb +133 -133
- data/lib/lolita/ruby_ext/accessors.rb +26 -26
- data/lib/lolita/support/formatter.rb +62 -62
- data/lib/lolita/support/formatter/rails.rb +56 -56
- data/lib/lolita/test/matchers.rb +77 -77
- data/lolita.gemspec +2 -2
- data/public/javascripts/jquery-1.6.min.js +15 -15
- data/public/javascripts/jquery-ui-1.8.13.min.js +407 -407
- data/public/javascripts/lolita/main.js +39 -39
- data/public/javascripts/lolita/tab.js +41 -41
- data/public/javascripts/modernizr-1.7.min.js +1 -1
- data/public/javascripts/rails.js +137 -137
- data/public/javascripts/tinymce/langs/en.js +221 -221
- data/public/javascripts/tinymce/license.txt +504 -504
- data/public/javascripts/tinymce/themes/advanced/about.htm +52 -52
- data/public/javascripts/tinymce/themes/advanced/anchor.htm +26 -26
- data/public/javascripts/tinymce/themes/advanced/charmap.htm +51 -51
- data/public/javascripts/tinymce/themes/advanced/color_picker.htm +74 -74
- data/public/javascripts/tinymce/themes/advanced/editor_template_src.js +1328 -1328
- data/public/javascripts/tinymce/themes/advanced/image.htm +80 -80
- data/public/javascripts/tinymce/themes/advanced/js/about.js +73 -73
- data/public/javascripts/tinymce/themes/advanced/js/anchor.js +42 -42
- data/public/javascripts/tinymce/themes/advanced/js/charmap.js +354 -354
- data/public/javascripts/tinymce/themes/advanced/js/color_picker.js +329 -329
- data/public/javascripts/tinymce/themes/advanced/js/image.js +247 -247
- data/public/javascripts/tinymce/themes/advanced/js/link.js +153 -153
- data/public/javascripts/tinymce/themes/advanced/js/source_editor.js +56 -56
- data/public/javascripts/tinymce/themes/advanced/langs/en.js +68 -68
- data/public/javascripts/tinymce/themes/advanced/langs/en_dlg.js +53 -53
- data/public/javascripts/tinymce/themes/advanced/link.htm +57 -57
- data/public/javascripts/tinymce/themes/advanced/shortcuts.htm +47 -47
- data/public/javascripts/tinymce/themes/advanced/skins/cirkuit/content.css +66 -66
- data/public/javascripts/tinymce/themes/advanced/skins/cirkuit/dialog.css +117 -117
- data/public/javascripts/tinymce/themes/advanced/skins/cirkuit/ui.css +988 -988
- data/public/javascripts/tinymce/themes/advanced/source_editor.htm +25 -25
- data/public/javascripts/tinymce/tiny_mce_popup.js +4 -4
- data/public/javascripts/tinymce_config.js +15 -15
- data/public/stylesheets/lolita/default.css +169 -169
- data/public/stylesheets/lolita/style.css +253 -253
- data/spec/adapter_helper.rb +43 -43
- data/spec/builder_spec.rb +120 -120
- data/spec/configuration/base_spec.rb +44 -44
- data/spec/configuration/column_spec.rb +89 -89
- data/spec/configuration/columns_spec.rb +54 -54
- data/spec/configuration/field_set_spec.rb +12 -12
- data/spec/configuration/field_spec.rb +118 -118
- data/spec/configuration/filter_spec.rb +122 -122
- data/spec/configuration/list_spec.rb +76 -76
- data/spec/configuration/page_spec.rb +19 -19
- data/spec/configuration/tab_spec.rb +165 -165
- data/spec/configuration/tabs_spec.rb +106 -106
- data/spec/controllers/component_helpers_spec.rb +5 -5
- data/spec/controllers/internal_helpers_spec.rb +76 -76
- data/spec/controllers/lolita_rest_nested_resources_spec.rb +33 -33
- data/spec/controllers/lolita_rest_spec.rb +53 -53
- data/spec/dbi/base_spec.rb +44 -44
- data/spec/hooks_spec.rb +257 -257
- data/spec/lolita_spec.rb +13 -13
- data/spec/mapping_spec.rb +29 -29
- data/spec/navigation/branch_spec.rb +81 -81
- data/spec/navigation/tree_spec.rb +73 -73
- data/spec/orm/mongoid.rb +11 -11
- 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 +5 -5
- data/spec/rails_app/app/mongoid/comment.rb +5 -5
- data/spec/rails_app/app/mongoid/post.rb +18 -18
- 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 +26 -26
- data/spec/rails_app/config/boot.rb +13 -13
- data/spec/rails_app/config/environment.rb +5 -5
- data/spec/rails_app/config/environments/development.rb +19 -19
- data/spec/rails_app/config/environments/production.rb +33 -33
- data/spec/rails_app/config/environments/test.rb +33 -33
- 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/lolita/tab.js +40 -40
- 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/routing/routes_spec.rb +15 -15
- data/spec/spec_helper.rb +46 -46
- data/spec/support/factories/category.rb +3 -3
- data/spec/support/factories/post.rb +4 -4
- data/spec/support/factories/tag.rb +2 -2
- data/spec/support/formatter_spec.rb +42 -42
- metadata +31 -31
data/README.rdoc
CHANGED
@@ -1,99 +1,99 @@
|
|
1
|
-
=Lolita
|
2
|
-
|
3
|
-
Great Rails CMS, that turns your business logic into good-looking, fully functional workspace.
|
4
|
-
==Demo
|
5
|
-
See the demo page at Demo[http://lolita-demo.ithouse.lv]
|
6
|
-
|
7
|
-
==Installation
|
8
|
-
|
9
|
-
First install Lolita gem
|
10
|
-
sudo gem install lolita
|
11
|
-
|
12
|
-
Then go to your rails project and
|
13
|
-
rails g lolita:install
|
14
|
-
|
15
|
-
That will create initializer and copy all assets.
|
16
|
-
Also it will call <em>install</em> on all added modules to lolita.
|
17
|
-
So if you in Gemfile have following
|
18
|
-
gem "lolita"
|
19
|
-
gem "lolita-file-upload"
|
20
|
-
It will also call <i>lolita_file_upload:install</i>.
|
21
|
-
==Usage
|
22
|
-
|
23
|
-
To make your model use Lolita do like this
|
24
|
-
class Post < ActiveRecord::Base
|
25
|
-
include Lolita::Configuration
|
26
|
-
lolita
|
27
|
-
end
|
28
|
-
Then in routes.rb file make resources accessable for lolita with
|
29
|
-
lolita_for :posts
|
30
|
-
This will make routes like
|
31
|
-
/lolita/posts
|
32
|
-
/lolita/posts/1/edit
|
33
|
-
/lolita/posts/new
|
34
|
-
|
35
|
-
For more detailed usage read Usage[https://github.com/ithouse/lolita/wiki/Usage] at wiki.
|
36
|
-
|
37
|
-
===Add authorization to Lolita
|
38
|
-
|
39
|
-
Easiest way to add authentication is with Devise. First install Devise as gem, than add it to your project.
|
40
|
-
Make Devise model, lets say, User. After that add these lines in <i>/config/initializers/lolita.rb</i>
|
41
|
-
config.user_classes << User
|
42
|
-
config.authentication = :authenticate_user!
|
43
|
-
This will make before each Lolita requests call before filter, that than will call <em>authenticate_user!</em>
|
44
|
-
that is Devise method for authenticating user. Without it Lolita will be acessable for everyone.
|
45
|
-
You can also add any other authentication method like
|
46
|
-
config.authentication = :authenticate_admin
|
47
|
-
And than put this method for common use in <em>ApplicationController</em> or in some other place that is accessable
|
48
|
-
to all controllers.
|
49
|
-
===Using newer version of Lolita
|
50
|
-
|
51
|
-
If you decide to use some newer version, you most likely should copy new assets to your project.
|
52
|
-
This can be done with
|
53
|
-
rails g lolita:assets
|
54
|
-
===Using hooks
|
55
|
-
|
56
|
-
Lolita define hooks for RestController and for components.
|
57
|
-
====RestController hooks
|
58
|
-
|
59
|
-
There are two kind of hooks for all actions - <em>before_[action name]</em> and <em>after_[action name]</em>.
|
60
|
-
Define callbacks for those hooks outside of controller. This will call User#log_action each time when #destroy
|
61
|
-
action is requested.
|
62
|
-
Lolita::RestController.before_destroy do
|
63
|
-
User.log_action("Going to delete #{params[:id]}")
|
64
|
-
end
|
65
|
-
Also you can define callbacks in your controllers that extend Lolita::RestController. This will call #set_default_params
|
66
|
-
each time #new action is requested.
|
67
|
-
class PostController < Lolita::RestController
|
68
|
-
before_new :set_default_params
|
69
|
-
|
70
|
-
private
|
71
|
-
|
72
|
-
def set_default_params
|
73
|
-
params[:post][:title]="-Your title goes here-"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
====Component hooks
|
77
|
-
|
78
|
-
Components have three hooks - <em>before</em>, <em>after</em> and <em>around</em>.
|
79
|
-
Component hooks are different from controller hooks with names. Each component has it's own name, that is used to
|
80
|
-
call component, like
|
81
|
-
render_component :"lolita/configuration/list/display"
|
82
|
-
#same as
|
83
|
-
render_component :"lolita/configuration/list", :display
|
84
|
-
and this name is used to add callback for component. As components is not related to specific class, then there
|
85
|
-
are only one way to define callback for them.
|
86
|
-
Lolita::Hooks.component(:"lolita/configuration/list/display").before do
|
87
|
-
"<div>My Custom text</div>"
|
88
|
-
end
|
89
|
-
That what are inside of blocks depends on place where you define callback if it is in <i>.rb</i> file, than you
|
90
|
-
should put HTML in quotes, if in <i>.erb</i> and similar files then there is no need for that. Also blocks with
|
91
|
-
Ruby code only return last line, so you should probably define HTML as shown in previous example.
|
92
|
-
For <b>around</b> callback if you pass block, then original content will be replaced with that, but if you want
|
93
|
-
to let original content inside of your block content than it is done like this with #let_content method.
|
94
|
-
Lolita::Hooks.component(:"lolita/configuration/list/display").around do
|
95
|
-
"<div style='color:red'>#{let_content}</div>"
|
96
|
-
end
|
97
|
-
==License
|
98
|
-
|
1
|
+
=Lolita
|
2
|
+
|
3
|
+
Great Rails CMS, that turns your business logic into good-looking, fully functional workspace.
|
4
|
+
==Demo
|
5
|
+
See the demo page at Demo[http://lolita-demo.ithouse.lv]
|
6
|
+
|
7
|
+
==Installation
|
8
|
+
|
9
|
+
First install Lolita gem
|
10
|
+
sudo gem install lolita
|
11
|
+
|
12
|
+
Then go to your rails project and
|
13
|
+
rails g lolita:install
|
14
|
+
|
15
|
+
That will create initializer and copy all assets.
|
16
|
+
Also it will call <em>install</em> on all added modules to lolita.
|
17
|
+
So if you in Gemfile have following
|
18
|
+
gem "lolita"
|
19
|
+
gem "lolita-file-upload"
|
20
|
+
It will also call <i>lolita_file_upload:install</i>.
|
21
|
+
==Usage
|
22
|
+
|
23
|
+
To make your model use Lolita do like this
|
24
|
+
class Post < ActiveRecord::Base
|
25
|
+
include Lolita::Configuration
|
26
|
+
lolita
|
27
|
+
end
|
28
|
+
Then in routes.rb file make resources accessable for lolita with
|
29
|
+
lolita_for :posts
|
30
|
+
This will make routes like
|
31
|
+
/lolita/posts
|
32
|
+
/lolita/posts/1/edit
|
33
|
+
/lolita/posts/new
|
34
|
+
|
35
|
+
For more detailed usage read Usage[https://github.com/ithouse/lolita/wiki/Usage] at wiki.
|
36
|
+
|
37
|
+
===Add authorization to Lolita
|
38
|
+
|
39
|
+
Easiest way to add authentication is with Devise. First install Devise as gem, than add it to your project.
|
40
|
+
Make Devise model, lets say, User. After that add these lines in <i>/config/initializers/lolita.rb</i>
|
41
|
+
config.user_classes << User
|
42
|
+
config.authentication = :authenticate_user!
|
43
|
+
This will make before each Lolita requests call before filter, that than will call <em>authenticate_user!</em>
|
44
|
+
that is Devise method for authenticating user. Without it Lolita will be acessable for everyone.
|
45
|
+
You can also add any other authentication method like
|
46
|
+
config.authentication = :authenticate_admin
|
47
|
+
And than put this method for common use in <em>ApplicationController</em> or in some other place that is accessable
|
48
|
+
to all controllers.
|
49
|
+
===Using newer version of Lolita
|
50
|
+
|
51
|
+
If you decide to use some newer version, you most likely should copy new assets to your project.
|
52
|
+
This can be done with
|
53
|
+
rails g lolita:assets
|
54
|
+
===Using hooks
|
55
|
+
|
56
|
+
Lolita define hooks for RestController and for components.
|
57
|
+
====RestController hooks
|
58
|
+
|
59
|
+
There are two kind of hooks for all actions - <em>before_[action name]</em> and <em>after_[action name]</em>.
|
60
|
+
Define callbacks for those hooks outside of controller. This will call User#log_action each time when #destroy
|
61
|
+
action is requested.
|
62
|
+
Lolita::RestController.before_destroy do
|
63
|
+
User.log_action("Going to delete #{params[:id]}")
|
64
|
+
end
|
65
|
+
Also you can define callbacks in your controllers that extend Lolita::RestController. This will call #set_default_params
|
66
|
+
each time #new action is requested.
|
67
|
+
class PostController < Lolita::RestController
|
68
|
+
before_new :set_default_params
|
69
|
+
|
70
|
+
private
|
71
|
+
|
72
|
+
def set_default_params
|
73
|
+
params[:post][:title]="-Your title goes here-"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
====Component hooks
|
77
|
+
|
78
|
+
Components have three hooks - <em>before</em>, <em>after</em> and <em>around</em>.
|
79
|
+
Component hooks are different from controller hooks with names. Each component has it's own name, that is used to
|
80
|
+
call component, like
|
81
|
+
render_component :"lolita/configuration/list/display"
|
82
|
+
#same as
|
83
|
+
render_component :"lolita/configuration/list", :display
|
84
|
+
and this name is used to add callback for component. As components is not related to specific class, then there
|
85
|
+
are only one way to define callback for them.
|
86
|
+
Lolita::Hooks.component(:"lolita/configuration/list/display").before do
|
87
|
+
"<div>My Custom text</div>"
|
88
|
+
end
|
89
|
+
That what are inside of blocks depends on place where you define callback if it is in <i>.rb</i> file, than you
|
90
|
+
should put HTML in quotes, if in <i>.erb</i> and similar files then there is no need for that. Also blocks with
|
91
|
+
Ruby code only return last line, so you should probably define HTML as shown in previous example.
|
92
|
+
For <b>around</b> callback if you pass block, then original content will be replaced with that, but if you want
|
93
|
+
to let original content inside of your block content than it is done like this with #let_content method.
|
94
|
+
Lolita::Hooks.component(:"lolita/configuration/list/display").around do
|
95
|
+
"<div style='color:red'>#{let_content}</div>"
|
96
|
+
end
|
97
|
+
==License
|
98
|
+
|
99
99
|
Lolita is under MIT license. See LICENSE.txt[https://github.com/ithouse/lolita/blob/master/LICENSE.txt]
|
data/Rakefile
CHANGED
@@ -1,40 +1,40 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'bundler'
|
3
|
-
begin
|
4
|
-
Bundler.setup(:default, :development)
|
5
|
-
rescue Bundler::BundlerError => e
|
6
|
-
$stderr.puts e.message
|
7
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
-
exit e.status_code
|
9
|
-
end
|
10
|
-
require 'rake'
|
11
|
-
|
12
|
-
require 'jeweler'
|
13
|
-
Jeweler::Tasks.new do |gem|
|
14
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
-
gem.name = "lolita"
|
16
|
-
gem.homepage = "http://github.com/ithouse/lolita"
|
17
|
-
gem.license = "MIT"
|
18
|
-
gem.summary = %Q{Great Rails CMS.}
|
19
|
-
gem.description = %Q{Great Rails CMS, that turns your business logic into good-looking, fully functional workspace. }
|
20
|
-
gem.email = "support@ithouse.lv"
|
21
|
-
gem.authors = ["ITHouse (Latvia) and Arturs Meisters"]
|
22
|
-
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
-
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
-
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
-
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
-
end
|
27
|
-
Jeweler::RubygemsDotOrgTasks.new
|
28
|
-
|
29
|
-
|
30
|
-
task :default => :test
|
31
|
-
|
32
|
-
require 'rake/rdoctask'
|
33
|
-
Rake::RDocTask.new do |rdoc|
|
34
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
35
|
-
|
36
|
-
rdoc.rdoc_dir = 'rdoc'
|
37
|
-
rdoc.title = "lolita #{version}"
|
38
|
-
rdoc.rdoc_files.include('README*')
|
39
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
40
|
-
end
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "lolita"
|
16
|
+
gem.homepage = "http://github.com/ithouse/lolita"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = %Q{Great Rails CMS.}
|
19
|
+
gem.description = %Q{Great Rails CMS, that turns your business logic into good-looking, fully functional workspace. }
|
20
|
+
gem.email = "support@ithouse.lv"
|
21
|
+
gem.authors = ["ITHouse (Latvia) and Arturs Meisters"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
|
30
|
+
task :default => :test
|
31
|
+
|
32
|
+
require 'rake/rdoctask'
|
33
|
+
Rake::RDocTask.new do |rdoc|
|
34
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
35
|
+
|
36
|
+
rdoc.rdoc_dir = 'rdoc'
|
37
|
+
rdoc.title = "lolita #{version}"
|
38
|
+
rdoc.rdoc_files.include('README*')
|
39
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
40
|
+
end
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
3.1.
|
1
|
+
3.1.11
|
@@ -1,41 +1,41 @@
|
|
1
|
-
class Lolita::InfoController < ApplicationController
|
2
|
-
@@properties = []
|
3
|
-
|
4
|
-
def index
|
5
|
-
render :layout => false
|
6
|
-
end
|
7
|
-
|
8
|
-
def properties
|
9
|
-
if request.local?
|
10
|
-
render :inline => to_html
|
11
|
-
else
|
12
|
-
render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
private
|
17
|
-
|
18
|
-
def self.property(name, value = nil)
|
19
|
-
value ||= yield
|
20
|
-
@@properties << [name, value] if value
|
21
|
-
rescue Exception
|
22
|
-
end
|
23
|
-
|
24
|
-
def to_html
|
25
|
-
(table = '<table>').tap do
|
26
|
-
@@properties.each do |(name, value)|
|
27
|
-
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
|
28
|
-
formatted_value = if value.kind_of?(Array)
|
29
|
-
"<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
|
30
|
-
else
|
31
|
-
CGI.escapeHTML(value.to_s)
|
32
|
-
end
|
33
|
-
table << %(<td class="value">#{formatted_value}</td></tr>)
|
34
|
-
end
|
35
|
-
table << '</table>'
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
property 'Lolita version', "#{LOLITA_VERSION}"
|
40
|
-
|
41
|
-
end
|
1
|
+
class Lolita::InfoController < ApplicationController
|
2
|
+
@@properties = []
|
3
|
+
|
4
|
+
def index
|
5
|
+
render :layout => false
|
6
|
+
end
|
7
|
+
|
8
|
+
def properties
|
9
|
+
if request.local?
|
10
|
+
render :inline => to_html
|
11
|
+
else
|
12
|
+
render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def self.property(name, value = nil)
|
19
|
+
value ||= yield
|
20
|
+
@@properties << [name, value] if value
|
21
|
+
rescue Exception
|
22
|
+
end
|
23
|
+
|
24
|
+
def to_html
|
25
|
+
(table = '<table>').tap do
|
26
|
+
@@properties.each do |(name, value)|
|
27
|
+
table << %(<tr><td class="name">#{CGI.escapeHTML(name.to_s)}</td>)
|
28
|
+
formatted_value = if value.kind_of?(Array)
|
29
|
+
"<ul>" + value.map { |v| "<li>#{CGI.escapeHTML(v.to_s)}</li>" }.join + "</ul>"
|
30
|
+
else
|
31
|
+
CGI.escapeHTML(value.to_s)
|
32
|
+
end
|
33
|
+
table << %(<td class="value">#{formatted_value}</td></tr>)
|
34
|
+
end
|
35
|
+
table << '</table>'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
property 'Lolita version', "#{LOLITA_VERSION}"
|
40
|
+
|
41
|
+
end
|
@@ -1,130 +1,130 @@
|
|
1
|
-
class Lolita::RestController < ApplicationController
|
2
|
-
include Lolita::Controllers::UserHelpers
|
3
|
-
include Lolita::Controllers::InternalHelpers
|
4
|
-
|
5
|
-
include Lolita::Hooks
|
6
|
-
add_hook :before_new, :after_new, :before_create,:after_create,:before_edit,:after_edit
|
7
|
-
add_hook :before_update,:after_update,:before_destroy,:after_destroy,:before_index,:after_index
|
8
|
-
add_hook :before_build_resource, :after_build_resource
|
9
|
-
|
10
|
-
before_filter :authenticate_lolita_user!
|
11
|
-
layout "lolita/application"
|
12
|
-
|
13
|
-
def new
|
14
|
-
self.run(:before_new)
|
15
|
-
build_resource
|
16
|
-
show_form
|
17
|
-
end
|
18
|
-
|
19
|
-
def create
|
20
|
-
self.run(:before_create)
|
21
|
-
build_resource
|
22
|
-
save_and_redirect
|
23
|
-
end
|
24
|
-
|
25
|
-
def edit
|
26
|
-
self.run(:before_edit)
|
27
|
-
get_resource
|
28
|
-
show_form
|
29
|
-
end
|
30
|
-
|
31
|
-
def update
|
32
|
-
self.run(:before_update)
|
33
|
-
get_resource
|
34
|
-
if self.resource
|
35
|
-
self.resource=resource_with_attributes(self.resource,resource_attributes)
|
36
|
-
save_and_redirect
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
def destroy
|
42
|
-
self.run(:before_destroy)
|
43
|
-
get_resource
|
44
|
-
if self.resource && self.resource.destroy
|
45
|
-
flash[:notice] = ::I18n.t "lolita.shared.destroy_notice"
|
46
|
-
else
|
47
|
-
flash[:alert] = ::I18n.t "lolita.shared.destroy_alert"
|
48
|
-
end
|
49
|
-
self.run(:after_destroy)
|
50
|
-
redirect_to lolita_resources_path
|
51
|
-
end
|
52
|
-
|
53
|
-
def index
|
54
|
-
self.run(:before_index)
|
55
|
-
respond_to do |format|
|
56
|
-
format.html do
|
57
|
-
build_response_for(:list,:page=>page)
|
58
|
-
show_index
|
59
|
-
end
|
60
|
-
format.json do
|
61
|
-
render :json=>page
|
62
|
-
end
|
63
|
-
end
|
64
|
-
self.run(:after_index)
|
65
|
-
end
|
66
|
-
|
67
|
-
private
|
68
|
-
|
69
|
-
def show_form
|
70
|
-
build_response_for(:tabs)
|
71
|
-
self.run(:"after_#{params[:action]}")
|
72
|
-
if request.xhr?
|
73
|
-
render "/lolita/rest/form", :layout => false
|
74
|
-
else
|
75
|
-
render "/lolita/rest/form"
|
76
|
-
end
|
77
|
-
end
|
78
|
-
|
79
|
-
def show_index
|
80
|
-
render "/lolita/rest/index"
|
81
|
-
end
|
82
|
-
|
83
|
-
def save_and_redirect
|
84
|
-
respond_to do |format|
|
85
|
-
if self.resource.save
|
86
|
-
self.resource.reload
|
87
|
-
format.html{ respond_html_200}
|
88
|
-
format.json{ respond_json_200}
|
89
|
-
else
|
90
|
-
format.html{ respond_html_400 }
|
91
|
-
format.json{ respond_json_400 }
|
92
|
-
end
|
93
|
-
end
|
94
|
-
end
|
95
|
-
|
96
|
-
def respond_html_200
|
97
|
-
response.headers["Validation"] = 'true'
|
98
|
-
response.headers["Lolita-Notice"] = ::I18n.t "lolita.shared.save_notice"
|
99
|
-
show_form
|
100
|
-
end
|
101
|
-
|
102
|
-
def respond_html_400
|
103
|
-
response.headers["Validation"] = 'false'
|
104
|
-
response.headers["Lolita-Alert"] = ::I18n.t "lolita.shared.save_alert"
|
105
|
-
show_form
|
106
|
-
end
|
107
|
-
|
108
|
-
def respond_json_200
|
109
|
-
respond_json(200)
|
110
|
-
end
|
111
|
-
|
112
|
-
def respond_json_400
|
113
|
-
respond_json(400)
|
114
|
-
end
|
115
|
-
|
116
|
-
def respond_json(status)
|
117
|
-
self.run(:"after_#{params[:action]}")
|
118
|
-
render :status=>status, :json=>self.resource
|
119
|
-
end
|
120
|
-
|
121
|
-
def to_list
|
122
|
-
builder=build_response_for(:list,:page=>page)
|
123
|
-
render :index
|
124
|
-
#render_component *builder
|
125
|
-
end
|
126
|
-
|
127
|
-
def page
|
128
|
-
resource_class.lolita.list.paginate(params[:page], :params => params)
|
129
|
-
end
|
130
|
-
end
|
1
|
+
class Lolita::RestController < ApplicationController
|
2
|
+
include Lolita::Controllers::UserHelpers
|
3
|
+
include Lolita::Controllers::InternalHelpers
|
4
|
+
|
5
|
+
include Lolita::Hooks
|
6
|
+
add_hook :before_new, :after_new, :before_create,:after_create,:before_edit,:after_edit
|
7
|
+
add_hook :before_update,:after_update,:before_destroy,:after_destroy,:before_index,:after_index
|
8
|
+
add_hook :before_build_resource, :after_build_resource
|
9
|
+
|
10
|
+
before_filter :authenticate_lolita_user!
|
11
|
+
layout "lolita/application"
|
12
|
+
|
13
|
+
def new
|
14
|
+
self.run(:before_new)
|
15
|
+
build_resource
|
16
|
+
show_form
|
17
|
+
end
|
18
|
+
|
19
|
+
def create
|
20
|
+
self.run(:before_create)
|
21
|
+
build_resource
|
22
|
+
save_and_redirect
|
23
|
+
end
|
24
|
+
|
25
|
+
def edit
|
26
|
+
self.run(:before_edit)
|
27
|
+
get_resource
|
28
|
+
show_form
|
29
|
+
end
|
30
|
+
|
31
|
+
def update
|
32
|
+
self.run(:before_update)
|
33
|
+
get_resource
|
34
|
+
if self.resource
|
35
|
+
self.resource=resource_with_attributes(self.resource,resource_attributes)
|
36
|
+
save_and_redirect
|
37
|
+
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def destroy
|
42
|
+
self.run(:before_destroy)
|
43
|
+
get_resource
|
44
|
+
if self.resource && self.resource.destroy
|
45
|
+
flash[:notice] = ::I18n.t "lolita.shared.destroy_notice"
|
46
|
+
else
|
47
|
+
flash[:alert] = ::I18n.t "lolita.shared.destroy_alert"
|
48
|
+
end
|
49
|
+
self.run(:after_destroy)
|
50
|
+
redirect_to lolita_resources_path
|
51
|
+
end
|
52
|
+
|
53
|
+
def index
|
54
|
+
self.run(:before_index)
|
55
|
+
respond_to do |format|
|
56
|
+
format.html do
|
57
|
+
build_response_for(:list,:page=>page)
|
58
|
+
show_index
|
59
|
+
end
|
60
|
+
format.json do
|
61
|
+
render :json=>page
|
62
|
+
end
|
63
|
+
end
|
64
|
+
self.run(:after_index)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
|
69
|
+
def show_form
|
70
|
+
build_response_for(:tabs)
|
71
|
+
self.run(:"after_#{params[:action]}")
|
72
|
+
if request.xhr?
|
73
|
+
render "/lolita/rest/form", :layout => false
|
74
|
+
else
|
75
|
+
render "/lolita/rest/form"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def show_index
|
80
|
+
render "/lolita/rest/index"
|
81
|
+
end
|
82
|
+
|
83
|
+
def save_and_redirect
|
84
|
+
respond_to do |format|
|
85
|
+
if self.resource.save
|
86
|
+
self.resource.reload
|
87
|
+
format.html{ respond_html_200}
|
88
|
+
format.json{ respond_json_200}
|
89
|
+
else
|
90
|
+
format.html{ respond_html_400 }
|
91
|
+
format.json{ respond_json_400 }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
def respond_html_200
|
97
|
+
response.headers["Validation"] = 'true'
|
98
|
+
response.headers["Lolita-Notice"] = ::I18n.t "lolita.shared.save_notice"
|
99
|
+
show_form
|
100
|
+
end
|
101
|
+
|
102
|
+
def respond_html_400
|
103
|
+
response.headers["Validation"] = 'false'
|
104
|
+
response.headers["Lolita-Alert"] = ::I18n.t "lolita.shared.save_alert"
|
105
|
+
show_form
|
106
|
+
end
|
107
|
+
|
108
|
+
def respond_json_200
|
109
|
+
respond_json(200)
|
110
|
+
end
|
111
|
+
|
112
|
+
def respond_json_400
|
113
|
+
respond_json(400)
|
114
|
+
end
|
115
|
+
|
116
|
+
def respond_json(status)
|
117
|
+
self.run(:"after_#{params[:action]}")
|
118
|
+
render :status=>status, :json=>self.resource
|
119
|
+
end
|
120
|
+
|
121
|
+
def to_list
|
122
|
+
builder=build_response_for(:list,:page=>page)
|
123
|
+
render :index
|
124
|
+
#render_component *builder
|
125
|
+
end
|
126
|
+
|
127
|
+
def page
|
128
|
+
resource_class.lolita.list.paginate(params[:page], :params => params)
|
129
|
+
end
|
130
|
+
end
|