lolita 3.2.0.rc.7 → 3.2.0.rc.9
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +31 -0
- data/Gemfile +15 -36
- data/History.rdoc +9 -3
- data/README.md +57 -30
- data/Rakefile +1 -44
- data/app/assets/javascripts/lolita/list.js +28 -0
- data/app/assets/javascripts/lolita/main.js +81 -12
- data/app/assets/javascripts/lolita/tab.js +37 -32
- data/app/assets/stylesheets/lolita/style.css.erb +58 -18
- data/app/controllers/lolita/field_data_controller.rb +13 -9
- data/app/controllers/lolita/info_controller.rb +3 -5
- data/app/controllers/lolita/rest_controller.rb +53 -24
- data/app/helpers/components/lolita/configuration_component.rb +1 -1
- data/app/views/components/lolita/configuration/action/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/column/_display.html.haml +4 -0
- data/app/views/components/lolita/configuration/column/_first.html.haml +2 -0
- data/app/views/components/lolita/configuration/column/_last.html.haml +5 -0
- data/app/views/components/lolita/configuration/column/header/_display.html.haml +5 -0
- data/app/views/components/lolita/configuration/column/header/_first.html.haml +1 -0
- data/app/views/components/lolita/configuration/column/header/_last.html.haml +1 -0
- data/app/views/components/lolita/configuration/column/header/_sort.html.haml +6 -0
- data/app/views/components/lolita/configuration/columns/_display.html.haml +2 -0
- data/app/views/components/lolita/configuration/columns/body/_display.html.haml +3 -0
- data/app/views/components/lolita/configuration/columns/body/row/_display.html.haml +5 -0
- data/app/views/components/lolita/configuration/columns/header/_display.html.haml +5 -0
- data/app/views/components/lolita/configuration/field/_display.html.haml +7 -0
- data/app/views/components/lolita/configuration/field/_label.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/_object.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/array/_display.html.haml +5 -0
- data/app/views/components/lolita/configuration/field/array/autocomplete/_display.html.haml +1 -1
- data/app/views/components/lolita/configuration/field/array/autocomplete/_input.html.haml +2 -2
- data/app/views/components/lolita/configuration/field/array/polymorphic/_display.html.haml +3 -3
- data/app/views/components/lolita/configuration/field/array/select/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/big_decimal/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/boolean/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/date/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/date_time/_display.html.haml +2 -0
- data/app/views/components/lolita/configuration/field/date_time/date/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/date_time/time/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/float/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/integer/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/string/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/string/disabled/_display.html.haml +2 -0
- data/app/views/components/lolita/configuration/field/string/hidden/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/string/password/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field/string/text/_display.html.haml +7 -0
- data/app/views/components/lolita/configuration/field/time/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/field_set/_display.html.haml +3 -0
- data/app/views/components/lolita/configuration/filter/_display.html.haml +9 -0
- data/app/views/components/lolita/configuration/list/_display.html.haml +9 -0
- data/app/views/components/lolita/configuration/list/_new_resource.html.haml +4 -0
- data/app/views/components/lolita/configuration/list/_paginator.html.haml +1 -0
- data/app/views/components/lolita/configuration/list/_title.html.haml +6 -0
- data/app/views/components/lolita/configuration/nested_form/_display.html.haml +12 -0
- data/app/views/components/lolita/configuration/nested_form/_fields.html.haml +8 -0
- data/app/views/components/lolita/configuration/nested_list/_display.html.haml +7 -0
- data/app/views/components/lolita/configuration/nested_list/_paginator.html.haml +2 -0
- data/app/views/components/lolita/configuration/tab/_display.html.haml +4 -0
- data/app/views/components/lolita/configuration/tab/_error_msg.html.haml +14 -0
- data/app/views/components/lolita/configuration/tab/_fields.html.haml +6 -0
- data/app/views/components/lolita/configuration/tab/_form.html.haml +4 -0
- data/app/views/components/lolita/configuration/tab/_title.html.haml +3 -0
- data/app/views/components/lolita/configuration/tab/content/_display.html.haml +1 -0
- data/app/views/components/lolita/configuration/tab/default/_display.html.haml +2 -0
- data/app/views/components/lolita/configuration/tabs/_display.html.haml +10 -0
- data/app/views/components/lolita/configuration/tabs/_form.html.haml +7 -0
- data/app/views/components/lolita/navigation/_display.html.haml +2 -0
- data/app/views/components/lolita/navigation/_tree.html.haml +14 -0
- data/app/views/components/lolita/shared/_buttons.html.haml +6 -0
- data/app/views/components/lolita/shared/_flash.html.haml +3 -0
- data/app/views/components/lolita/shared/_header.html.haml +7 -0
- data/app/views/components/lolita/shared/_languages.html.haml +11 -0
- data/app/views/components/lolita/shared/_right_sidebar.html.haml +6 -0
- data/app/views/components/lolita/shared/_save_button.html.haml +1 -0
- data/app/views/layouts/lolita/application.html.haml +36 -0
- data/app/views/lolita/rest/form.html.haml +1 -0
- data/app/views/lolita/rest/index.html.haml +1 -0
- data/app/views/lolita/rest/index.js.erb +1 -0
- data/config/locales/en.yml +4 -0
- data/config/locales/lv.yml +5 -2
- data/lib/generators/lolita/uninstall_generator.rb +76 -0
- data/lib/lolita.rb +104 -170
- data/lib/lolita/adapter/abstract_adapter.rb +1 -0
- data/lib/lolita/adapter/active_record.rb +22 -55
- data/lib/lolita/adapter/common_helper.rb +252 -0
- data/lib/lolita/adapter/mongoid.rb +11 -55
- data/lib/lolita/base.rb +5 -0
- data/lib/lolita/builder.rb +3 -3
- data/lib/lolita/components/base.rb +12 -0
- data/lib/lolita/components/configuration/column_component.rb +31 -0
- data/lib/lolita/components/configuration/list_component.rb +11 -0
- data/lib/lolita/configuration.rb +61 -0
- data/lib/lolita/configuration/action.rb +53 -0
- data/lib/lolita/configuration/base.rb +23 -71
- data/lib/lolita/configuration/column.rb +50 -16
- data/lib/lolita/configuration/columns.rb +51 -23
- data/lib/lolita/configuration/core.rb +80 -0
- data/lib/lolita/configuration/factory/field.rb +8 -3
- data/lib/lolita/configuration/factory/tab.rb +12 -6
- data/lib/lolita/configuration/field.rb +8 -11
- data/lib/lolita/configuration/field/array.rb +7 -9
- data/lib/lolita/configuration/fields.rb +1 -1
- data/lib/lolita/configuration/filter.rb +26 -19
- data/lib/lolita/configuration/list.rb +143 -80
- data/lib/lolita/configuration/nested_list.rb +102 -0
- data/lib/lolita/configuration/search.rb +14 -0
- data/lib/lolita/configuration/tab.rb +13 -9
- data/lib/lolita/configuration/tab/content.rb +6 -0
- data/lib/lolita/configuration/tab/default.rb +2 -2
- data/lib/lolita/configuration/tabs.rb +35 -82
- data/lib/lolita/controller_additions.rb +4 -3
- data/lib/lolita/controllers.rb +13 -0
- data/lib/lolita/controllers/authentication_helpers.rb +17 -0
- data/lib/lolita/controllers/component_helpers.rb +9 -5
- data/lib/lolita/controllers/internal_helpers.rb +22 -97
- data/lib/lolita/controllers/rails_helpers.rb +132 -0
- data/lib/lolita/controllers/url_helpers.rb +1 -1
- data/lib/lolita/errors.rb +3 -0
- data/lib/lolita/extensions/authentication/default_adapter.rb +24 -0
- data/lib/lolita/extensions/authentication/devise_adapter.rb +58 -0
- data/lib/lolita/extensions/authentication/proxy.rb +60 -0
- data/lib/lolita/extensions/authorization/cancan_adapter.rb +45 -0
- data/lib/lolita/extensions/authorization/default_adapter.rb +29 -0
- data/lib/lolita/extensions/authorization/proxy.rb +48 -0
- data/lib/lolita/extensions/extensions.rb +66 -0
- data/lib/lolita/helpers.rb +12 -0
- data/lib/lolita/lazy_loader.rb +15 -10
- data/lib/lolita/mapping.rb +25 -19
- data/lib/lolita/navigation/branch.rb +29 -2
- data/lib/lolita/navigation/tree.rb +6 -0
- data/lib/lolita/observed_array.rb +1 -1
- data/lib/lolita/orm.rb +7 -0
- data/lib/lolita/processors/request_processor.rb +38 -0
- data/lib/lolita/rails/engine.rb +24 -0
- data/lib/lolita/{modules/rest.rb → rails/railtie.rb} +8 -2
- data/lib/lolita/rails/routes.rb +26 -29
- data/lib/lolita/register.rb +48 -0
- data/lib/lolita/ruby_ext/lolita_model_name.rb +37 -0
- data/lib/lolita/system_configuration/application.rb +1 -0
- data/lib/lolita/system_configuration/base.rb +12 -5
- data/lib/lolita/utils.rb +14 -0
- data/lib/lolita/version.rb +30 -0
- data/lolita.gemspec +26 -398
- data/spec/configuration/base_spec.rb +14 -35
- data/spec/configuration/column_spec.rb +51 -2
- data/spec/configuration/columns_spec.rb +13 -19
- data/spec/configuration/core_spec.rb +89 -0
- data/spec/configuration/field_spec.rb +17 -5
- data/spec/configuration/filter_spec.rb +76 -61
- data/spec/configuration/list_spec.rb +339 -45
- data/spec/configuration/nested_list_spec.rb +111 -0
- data/spec/configuration/search_spec.rb +1 -1
- data/spec/configuration/tabs_spec.rb +89 -74
- data/spec/controllers/configuration_spec.rb +15 -0
- data/spec/controllers/internal_helpers_spec.rb +1 -1
- data/spec/controllers/lolita_rest_spec.rb +31 -2
- data/spec/coverage_helper.rb +33 -0
- data/spec/extensions/authentication/default_adapter_spec.rb +34 -0
- data/spec/extensions/authentication/devise_adapter_spec.rb +94 -0
- data/spec/extensions/authentication/proxy_spec.rb +55 -0
- data/spec/extensions/authorization/cancan_adapter_spec.rb +94 -0
- data/spec/extensions/authorization/default_adapter_spec.rb +43 -0
- data/spec/extensions/authorization/proxy_spec.rb +60 -0
- data/spec/extensions/extensions_spec.rb +45 -0
- data/spec/fabricators/category_fabricator.rb +3 -0
- data/spec/fabricators/post_fabricator.rb +4 -0
- data/spec/fabricators/tag_fabricator.rb +3 -0
- data/spec/lolita_spec.rb +1 -0
- data/spec/orm/mongoid.rb +1 -0
- data/spec/rails_app/app/mongoid/category.rb +14 -1
- data/spec/rails_app/app/mongoid/post.rb +9 -1
- data/spec/rails_app/config/application.rb +0 -4
- data/spec/rails_app/config/boot.rb +1 -2
- data/spec/register_spec.rb +50 -0
- data/spec/search/simple_spec.rb +4 -4
- data/spec/simple_spec_helper.rb +2 -1
- data/spec/spec_helper.rb +22 -35
- data/vendor/assets/javascripts/tinymce_config.js +5 -3
- metadata +202 -180
- data/.document +0 -5
- data/GUIDELINES.rdoc +0 -22
- data/VERSION +0 -1
- data/app/helpers/lolita_helper.rb +0 -23
- data/app/views/components/lolita/configuration/column/_display.html.erb +0 -4
- data/app/views/components/lolita/configuration/column/_header.html.erb +0 -7
- data/app/views/components/lolita/configuration/column/_sort.html.erb +0 -7
- data/app/views/components/lolita/configuration/columns/_body.html.erb +0 -5
- data/app/views/components/lolita/configuration/columns/_display.html.erb +0 -2
- data/app/views/components/lolita/configuration/columns/_first.html.erb +0 -3
- data/app/views/components/lolita/configuration/columns/_first_column_header.html.erb +0 -3
- data/app/views/components/lolita/configuration/columns/_header.html.erb +0 -9
- data/app/views/components/lolita/configuration/columns/_last.html.erb +0 -4
- data/app/views/components/lolita/configuration/columns/_last_column_header.html.erb +0 -3
- data/app/views/components/lolita/configuration/columns/_row.html.erb +0 -7
- data/app/views/components/lolita/configuration/field/_display.html.erb +0 -13
- data/app/views/components/lolita/configuration/field/_label.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/_object.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/array/_display.html.erb +0 -5
- data/app/views/components/lolita/configuration/field/array/filter/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/array/select/_display.html.erb +0 -4
- data/app/views/components/lolita/configuration/field/big_decimal/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/boolean/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/boolean/filter/_display.html.erb +0 -2
- data/app/views/components/lolita/configuration/field/date/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/date_time/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/date_time/date/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/date_time/time/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/float/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/hidden/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/integer/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/string/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/string/disabled/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field/string/password/_display.html.erb +0 -3
- data/app/views/components/lolita/configuration/field/string/text/_display.html.erb +0 -11
- data/app/views/components/lolita/configuration/field/time/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/field_set/_display.html.erb +0 -5
- data/app/views/components/lolita/configuration/list/_display.html.erb +0 -11
- data/app/views/components/lolita/configuration/list/_filter.html.erb +0 -8
- data/app/views/components/lolita/configuration/list/_new_resource.html.erb +0 -6
- data/app/views/components/lolita/configuration/list/_paginator.html.erb +0 -1
- data/app/views/components/lolita/configuration/list/_title.html.erb +0 -10
- data/app/views/components/lolita/configuration/nested_form/_display.html.erb +0 -15
- data/app/views/components/lolita/configuration/nested_form/_fields.html.erb +0 -13
- data/app/views/components/lolita/configuration/tab/_display.html.erb +0 -8
- data/app/views/components/lolita/configuration/tab/_error_msg.html.erb +0 -20
- data/app/views/components/lolita/configuration/tab/_fields.html.erb +0 -9
- data/app/views/components/lolita/configuration/tab/_form.html.erb +0 -8
- data/app/views/components/lolita/configuration/tab/content/_display.html.erb +0 -1
- data/app/views/components/lolita/configuration/tab/default/_display.html.erb +0 -3
- data/app/views/components/lolita/configuration/tabs/_display.html.erb +0 -11
- data/app/views/components/lolita/navigation/_display.html.erb +0 -3
- data/app/views/components/lolita/navigation/_tree.html.erb +0 -32
- data/app/views/components/lolita/shared/_flash.html.erb +0 -5
- data/app/views/components/lolita/shared/_header.html.erb +0 -9
- data/app/views/components/lolita/shared/_right_sidebar.html.erb +0 -9
- data/app/views/components/lolita/shared/_save_button.html.erb +0 -6
- data/app/views/layouts/lolita/application.html.erb +0 -37
- data/app/views/lolita/rest/form.html.erb +0 -1
- data/app/views/lolita/rest/index.html.erb +0 -1
- data/config/locales/default/lv.yml +0 -181
- data/db/seed.rb +0 -1
- data/features/create_page.feature +0 -20
- data/features/step_definitions/lolita_steps.rb +0 -7
- data/features/step_definitions/web_steps.rb +0 -219
- data/features/support/env.rb +0 -73
- data/features/support/paths.rb +0 -35
- data/lib/lolita/controllers/authorization_helpers.rb +0 -56
- data/lib/lolita/controllers/user_helpers.rb +0 -44
- data/lib/lolita/modules.rb +0 -6
- data/lib/lolita/rails.rb +0 -23
- data/lib/lolita/rails/all.rb +0 -11
- data/spec/support/factories/category.rb +0 -3
- data/spec/support/factories/post.rb +0 -4
- data/spec/support/factories/tag.rb +0 -3
data/.gitignore
ADDED
@@ -0,0 +1,31 @@
|
|
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
|
data/Gemfile
CHANGED
@@ -1,42 +1,21 @@
|
|
1
|
-
source
|
1
|
+
source 'http://rubygems.org'
|
2
2
|
|
3
|
-
|
4
|
-
gem "rails", "~>3.1.1"
|
5
|
-
gem "kaminari", "~>0.12.4"
|
6
|
-
gem "abstract"
|
3
|
+
gemspec
|
7
4
|
|
8
|
-
|
9
|
-
|
10
|
-
gem "haml", "~> 3.1.2"
|
11
|
-
gem 'jquery-rails'
|
12
|
-
gem 'tinymce-rails', :require => 'tinymce-rails'
|
13
|
-
|
14
|
-
group :mongoid do
|
15
|
-
gem "mongo", "~> 1.4.0"
|
16
|
-
gem "mongoid", "~> 2.3.0"
|
17
|
-
gem "bson_ext", "~> 1.4.0"
|
5
|
+
group :test, :development do
|
6
|
+
gem "debugger"
|
18
7
|
end
|
19
8
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
gem
|
24
|
-
gem
|
9
|
+
group :rails do
|
10
|
+
gem "rails" , "~> 3.2.0"
|
11
|
+
gem "rspec-rails", "~> 2.9.0"
|
12
|
+
gem "jquery-rails"
|
13
|
+
gem "tinymce-rails", "~>3.4.8"
|
25
14
|
end
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
gem
|
30
|
-
gem
|
31
|
-
gem "arrayfields"
|
32
|
-
gem "map"
|
33
|
-
gem "rspec", "~>2.6.0"
|
34
|
-
gem "rspec-rails","~>2.6.1"
|
35
|
-
gem "factory_girl"
|
36
|
-
gem 'ffaker'
|
37
|
-
gem "ruby-debug19"
|
38
|
-
# gem "cucumber-rails"
|
39
|
-
# gem "capybara"
|
40
|
-
gem "database_cleaner"
|
41
|
-
# gem "akephalos"
|
15
|
+
|
16
|
+
group :mongoid do
|
17
|
+
gem 'mongo', '~> 1.4.0'
|
18
|
+
gem 'mongoid', '~> 2.3.0'
|
19
|
+
gem 'bson_ext', '~> 1.4.0'
|
42
20
|
end
|
21
|
+
|
data/History.rdoc
CHANGED
@@ -17,12 +17,17 @@
|
|
17
17
|
* :once options added to hook #run
|
18
18
|
* #use_mapping added in InternalHelpers, switch block to given mapping
|
19
19
|
* :on option added to fields, that allow to determine when to show field
|
20
|
+
* Sublists for columns and list itself for 1-to-many, many-to-many and 1-to-many throught for AR
|
21
|
+
* Version class added in Support
|
22
|
+
* #skip_routes added for Lolita.application, that allow to add specific behaviour for application when rake or rails or other commands is called
|
23
|
+
* #action added to list
|
20
24
|
|
21
25
|
* Changes
|
22
|
-
*
|
26
|
+
* using rails 3.1.x
|
23
27
|
* #value, #value=, #record_value removed from Lolita::Configuration::Field
|
24
28
|
* Created pagination in list and in adapters; its possible to customize it for model.
|
25
29
|
* All fields must have name as well as tabs must have type
|
30
|
+
* List #per renamed to #per_page
|
26
31
|
|
27
32
|
* Removed
|
28
33
|
* Lolita::Generator::FileHelper from generators removed
|
@@ -34,6 +39,7 @@
|
|
34
39
|
* All classes fixed to work with both mongoid and AR
|
35
40
|
* String disabled builder fixed to use form object
|
36
41
|
* Error msg list is visible in all tabs even there is no field that failed validation (fixed)
|
42
|
+
* only run #lolita_for when <em>rails console</em> or <em>rails server</em> is running
|
37
43
|
|
38
44
|
=== Version 3.1.18
|
39
45
|
* Bug fixes
|
@@ -59,7 +65,7 @@
|
|
59
65
|
* Enhancements
|
60
66
|
* By default content tab excludes technical columns, like created_at, updated_at etc.
|
61
67
|
* It's possible to define and lolita uses nested fields in each tab through nested_fields_for.
|
62
|
-
* All fields (except array/habtm) uses #
|
68
|
+
* All fields (except array/habtm) uses #current_form for field generation, that is current tab form.
|
63
69
|
* Lolita know how to vizualize habtm relation
|
64
70
|
* Added #component_locals method for views, so it is possible to access next component locals.
|
65
71
|
* Hidden field type added
|
@@ -80,7 +86,7 @@
|
|
80
86
|
=== Version 3.1.13 / 2011-08-16
|
81
87
|
* Enhancements
|
82
88
|
* Color for Lolita-Alert popup changed
|
83
|
-
* #
|
89
|
+
* #current_form method added in lolita helpers
|
84
90
|
* Bug fixes
|
85
91
|
* DBI for AR - method names fixed
|
86
92
|
* Messages encoding bug fixed
|
data/README.md
CHANGED
@@ -18,18 +18,24 @@ Then go to your rails project and
|
|
18
18
|
That will create initializer and copy all assets.
|
19
19
|
Also it will call *install* on all added modules to lolita.
|
20
20
|
So if you in Gemfile have following
|
21
|
-
|
22
|
-
|
23
|
-
|
21
|
+
|
22
|
+
```ruby
|
23
|
+
gem "lolita"
|
24
|
+
gem "lolita-file-upload"
|
25
|
+
```
|
26
|
+
|
24
27
|
It will also call *lolita_file_upload:install*.
|
25
28
|
##Usage
|
26
29
|
|
27
30
|
To make your model use Lolita do like this
|
28
31
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
32
|
+
```ruby
|
33
|
+
class Post < ActiveRecord::Base
|
34
|
+
include Lolita::Configuration
|
35
|
+
lolita
|
36
|
+
end
|
37
|
+
```
|
38
|
+
|
33
39
|
Then in routes.rb file make resources accessable for lolita with
|
34
40
|
|
35
41
|
lolita_for :posts
|
@@ -46,13 +52,19 @@ For more detailed usage read [Usage](https://github.com/ithouse/lolita/wiki/Usag
|
|
46
52
|
Easiest way to add authentication is with Devise. First install Devise as gem, than add it to your project.
|
47
53
|
Make Devise model, lets say, *User*. After that add these lines in */config/initializers/lolita.rb*
|
48
54
|
|
49
|
-
|
50
|
-
|
55
|
+
```ruby
|
56
|
+
config.user_classes << User
|
57
|
+
config.authentication = :authenticate_user!
|
58
|
+
```
|
59
|
+
|
51
60
|
This will make before each Lolita requests call before filter, that than will call *authenticate_user!*
|
52
61
|
that is Devise method for authenticating user. Without it Lolita will be acessable for everyone.
|
53
62
|
You can also add any other authentication method like
|
54
|
-
|
55
|
-
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
config.authentication = :authenticate_admin
|
66
|
+
```
|
67
|
+
|
56
68
|
And than put this method for common use in *ApplicationController* or in some other place that is accessable
|
57
69
|
to all controllers.
|
58
70
|
|
@@ -65,45 +77,60 @@ There are two kind of hooks for all actions - *before_[action name]* and *after_
|
|
65
77
|
Define callbacks for those hooks outside of controller. This will call User#log_action each time when #destroy
|
66
78
|
action is requested.
|
67
79
|
|
68
|
-
|
69
|
-
|
70
|
-
|
80
|
+
```ruby
|
81
|
+
Lolita::RestController.before_destroy do
|
82
|
+
User.log_action("Going to delete #{params[:id]}")
|
83
|
+
end
|
84
|
+
```
|
85
|
+
|
71
86
|
Also you can define callbacks in your controllers that extend Lolita::RestController. This will call #set\_default\_params
|
72
87
|
each time #new action is requested.
|
73
88
|
|
74
|
-
|
75
|
-
|
89
|
+
```ruby
|
90
|
+
class PostController < Lolita::RestController
|
91
|
+
before_new :set_default_params
|
92
|
+
|
93
|
+
private
|
76
94
|
|
77
|
-
|
95
|
+
def set_default_params
|
96
|
+
params[:post][:title]="-Your title goes here-"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
```
|
78
100
|
|
79
|
-
def set_default_params
|
80
|
-
params[:post][:title]="-Your title goes here-"
|
81
|
-
end
|
82
|
-
end
|
83
101
|
####Component hooks
|
84
102
|
|
85
103
|
Components have three hooks - *before*, *after* and *around*.
|
86
104
|
Component hooks are different from controller hooks with names. Each component has it's own name, that is used to
|
87
105
|
call component, like
|
88
106
|
|
89
|
-
|
90
|
-
|
91
|
-
|
107
|
+
```ruby
|
108
|
+
render_component :"lolita/configuration/list/display"
|
109
|
+
#same as
|
110
|
+
render_component :"lolita/configuration/list", :display
|
111
|
+
```
|
112
|
+
|
92
113
|
and this name is used to add callback for component. As components is not related to specific class, then there
|
93
114
|
are only one way to define callback for them.
|
94
115
|
|
95
|
-
|
96
|
-
|
97
|
-
|
116
|
+
```ruby
|
117
|
+
Lolita::Hooks.component(:"/lolita/configuration/list/display").before do
|
118
|
+
"<div>My Custom text</div>"
|
119
|
+
end
|
120
|
+
```
|
121
|
+
|
98
122
|
That what are inside of blocks depends on place where you define callback if it is in _.rb_ file, than you
|
99
123
|
should put HTML in quotes, if in _.erb_ and similar files then there is no need for that. Also blocks with
|
100
124
|
Ruby code only return last line, so you should probably define HTML as shown in previous example.
|
101
125
|
For _around_ callback if you pass block, then original content will be replaced with that, but if you want
|
102
126
|
to let original content inside of your block content than it is done like this with #let_content method.
|
103
127
|
|
104
|
-
|
105
|
-
|
106
|
-
|
128
|
+
```ruby
|
129
|
+
Lolita::Hooks.component(:"/lolita/configuration/list/display").around do
|
130
|
+
"<div style='color:red'>#{let_content}</div>"
|
131
|
+
end
|
132
|
+
```
|
133
|
+
|
107
134
|
##License
|
108
135
|
|
109
136
|
Lolita is under MIT license. See [LICENSE.txt](https://github.com/ithouse/lolita/blob/master/LICENSE.txt)
|
data/Rakefile
CHANGED
@@ -1,47 +1,4 @@
|
|
1
1
|
require 'rubygems'
|
2
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
3
|
|
12
|
-
|
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
|
41
|
-
|
42
|
-
require 'metric_fu'
|
43
|
-
MetricFu::Configuration.run do |config|
|
44
|
-
config.rcov[:test_files] = ['spec/**/*_spec.rb']
|
45
|
-
config.rcov[:rcov_opts] << "-Ispec" # Needed to find spec_helper
|
46
|
-
config.metrics -= [:flog]
|
47
|
-
end
|
4
|
+
Bundler::GemHelper.install_tasks
|
@@ -0,0 +1,28 @@
|
|
1
|
+
$(function(){
|
2
|
+
$("td.with-nested-list a, tr.with-nested-list").live("click",function(event){
|
3
|
+
event.preventDefault()
|
4
|
+
var was_active = $(this).data("active")
|
5
|
+
$("td.with-nested-list a, tr.with-nested-list").data("active",false)
|
6
|
+
$(this).data("active",true)
|
7
|
+
|
8
|
+
if($(this).prop("tagName") == "A"){
|
9
|
+
var $tr = $(this).parents("tr").eq(0)
|
10
|
+
var url = $(this).parent().data("nested-list-url")
|
11
|
+
}else{
|
12
|
+
$tr = $(this)
|
13
|
+
url = $(this).data("nested-list-url")
|
14
|
+
}
|
15
|
+
if(was_active && $tr.next().hasClass("nested-list")){
|
16
|
+
$tr.next().remove()
|
17
|
+
$(this).data("active",false)
|
18
|
+
}else{
|
19
|
+
$.get(url,function(data){
|
20
|
+
if($tr.next().hasClass("nested-list")){
|
21
|
+
$tr.next().replaceWith(data)
|
22
|
+
}else{
|
23
|
+
$tr.after(data)
|
24
|
+
}
|
25
|
+
})
|
26
|
+
}
|
27
|
+
})
|
28
|
+
})
|
@@ -12,22 +12,91 @@ $(function(){
|
|
12
12
|
})
|
13
13
|
|
14
14
|
$("#flash").ajaxComplete(function(e,request){
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
15
|
+
show_lolita_messages(request)
|
16
|
+
})
|
17
|
+
})
|
18
|
+
|
19
|
+
function show_lolita_messages(request){
|
20
|
+
var notice=request.getResponseHeader("Lolita-Notice");
|
21
|
+
var error=request.getResponseHeader("Lolita-Error");
|
22
|
+
var alert_msg=request.getResponseHeader("Lolita-Alert");
|
23
|
+
if(notice){
|
24
|
+
show_notice_msg(Base64.decode(notice))
|
25
|
+
}else{
|
26
|
+
if(error){
|
27
|
+
show_error_msg(Base64.decode(error))
|
20
28
|
}else{
|
21
|
-
if(
|
22
|
-
|
23
|
-
}else{
|
24
|
-
if(alert_msg){
|
25
|
-
show_flash("<span style='color:#ea7c15'>"+Base64.decode(alert_msg)+"</span>");
|
26
|
-
}
|
29
|
+
if(alert_msg){
|
30
|
+
show_alert_msg(Base64.decode(alert_msg))
|
27
31
|
}
|
28
32
|
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
|
37
|
+
function resize_all_tinymce_editors(){
|
38
|
+
$("textarea").each(function(item,index){
|
39
|
+
try{
|
40
|
+
tinymce_id = $(this).tinymce().editorId
|
41
|
+
}catch(err){
|
42
|
+
tinymce_id = false
|
43
|
+
}
|
44
|
+
if(tinymce_id){
|
45
|
+
var $textarea = $("#"+tinymce_id)
|
46
|
+
var $parent = $textarea.parent()
|
47
|
+
var h = $textarea.height();
|
48
|
+
$parent.find('.mceEditor').css('width','100%').css('minHeight',h + "px");
|
49
|
+
$parent.find('.mceLayout').css('width','100%').css('minHeight',h + "px");
|
50
|
+
$parent.find('.mceIframeContainer').css('width','100%').css('minHeight',h + "px");
|
51
|
+
$parent.find("iframe").css("width","100%").css("minHeight",h + "px")
|
52
|
+
}
|
29
53
|
})
|
30
|
-
}
|
54
|
+
}
|
55
|
+
|
56
|
+
function params(object_or_name,new_value){
|
57
|
+
var url = window.location.href
|
58
|
+
if(typeof(object_or_name) && object_or_name.constructor.toString().match(/Object/)){
|
59
|
+
for(var name in object_or_name){
|
60
|
+
var value = object_or_name[name]
|
61
|
+
url = apply_param_to_url(name,value,url)
|
62
|
+
}
|
63
|
+
}else{
|
64
|
+
url = apply_param_to_url(object_or_name,new_value,url)
|
65
|
+
}
|
66
|
+
window.location.href = url.replace(/&{2,}/,"&")
|
67
|
+
}
|
68
|
+
|
69
|
+
function apply_param_to_url(name,new_value,url){
|
70
|
+
var value = (url.match(RegExp(name+"=([^&]*)(&|$)")) || [])
|
71
|
+
if(new_value){
|
72
|
+
if(value[0]){
|
73
|
+
replace_value = !new_value ? "" : (name + "=" + new_value + value[2])
|
74
|
+
url = url.replace(RegExp(name+"=([^&]*)(&|$)"),replace_value)
|
75
|
+
}else{
|
76
|
+
start_sym = url.match(/\?/) ? "&" : "?"
|
77
|
+
url = url + (start_sym+name+"="+new_value)
|
78
|
+
}
|
79
|
+
}else{
|
80
|
+
url = url.replace(RegExp(name+"=([^&]*)(&|$)"),"")
|
81
|
+
}
|
82
|
+
return encodeURI(url)
|
83
|
+
}
|
84
|
+
|
85
|
+
function show_notice_msg(msg){
|
86
|
+
show_msg("green",msg)
|
87
|
+
}
|
88
|
+
|
89
|
+
function show_error_msg(msg){
|
90
|
+
show_msg("red",msg)
|
91
|
+
}
|
92
|
+
|
93
|
+
function show_alert_msg(msg){
|
94
|
+
show_msg("#ea7c15",msg)
|
95
|
+
}
|
96
|
+
|
97
|
+
function show_msg(color,msg){
|
98
|
+
show_flash("<span style='color:"+color+"'>"+msg+"</span>");
|
99
|
+
}
|
31
100
|
|
32
101
|
function show_flash(html){
|
33
102
|
var flash=$("#flash")
|