optimacms 0.1.54 → 0.1.55
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/optimacms/admin.js +4 -4
- data/app/assets/stylesheets/optimacms/admin.css.scss +6 -6
- data/app/assets/stylesheets/optimacms/admin_tpl.css.scss +15 -15
- data/app/assets/stylesheets/optimacms/bootstrap_and_overrides.css.scss +52 -52
- data/app/assets/stylesheets/optimacms/bootstrap_custom.css.scss +49 -49
- data/app/assets/stylesheets/optimacms/bootstrap_variables.css.scss +860 -860
- data/app/assets/stylesheets/optimacms/colors.css.scss +68 -68
- data/app/assets/stylesheets/optimacms/skins/noskin.css.scss +95 -95
- data/app/assets/stylesheets/optimacms/tinymce.css.scss +54 -54
- data/app/assets/stylesheets/optimacms/tpl.css.scss +309 -309
- data/app/controllers/optimacms/admin/admin_base_controller.rb +44 -44
- data/app/controllers/optimacms/admin/dashboard_controller.rb +6 -6
- data/app/controllers/optimacms/admin/layouts_controller.rb +76 -76
- data/app/controllers/optimacms/admin/pages_controller.rb +229 -229
- data/app/controllers/optimacms/admin/templates_controller.rb +315 -315
- data/app/controllers/optimacms/dev_controller.rb +40 -40
- data/app/controllers/optimacms/elfinder_controller.rb +39 -39
- data/app/controllers/optimacms/page_base_controller.rb +6 -6
- data/app/controllers/optimacms/pages_controller.rb +170 -167
- data/app/controllers/optimacms/tinymce_assets_controller.rb +20 -20
- data/app/helpers/optimacms/application_helper.rb +20 -3
- data/app/helpers/optimacms/forms_helper.rb +75 -75
- data/app/inputs/textarea_tinymce_input.rb +27 -27
- data/app/models/concerns/optimacms/meta_content.rb +63 -63
- data/app/models/optimacms/language.rb +14 -14
- data/app/models/optimacms/layout.rb +53 -53
- data/app/models/optimacms/mediafile.rb +17 -17
- data/app/models/optimacms/page.rb +171 -171
- data/app/models/optimacms/page_translation.rb +10 -10
- data/app/models/optimacms/template.rb +390 -390
- data/app/models/optimacms/template_type.rb +20 -20
- data/app/views/optimacms/admin/common/_js_tinymce.html.haml +49 -49
- data/app/views/optimacms/admin/common/_modal_div.html.haml +16 -16
- data/app/views/optimacms/admin/dashboard/index.html.haml +18 -18
- data/app/views/optimacms/admin/layouts/_form.html.haml +22 -22
- data/app/views/optimacms/admin/layouts/edit.html.haml +5 -5
- data/app/views/optimacms/admin/layouts/index.html.haml +25 -25
- data/app/views/optimacms/admin/layouts/main.html.haml +6 -6
- data/app/views/optimacms/admin/layouts/new.html.haml +5 -5
- data/app/views/optimacms/admin/pages/_form.html.haml +78 -78
- data/app/views/optimacms/admin/pages/_form_folder.html.haml +14 -14
- data/app/views/optimacms/admin/pages/_form_old.html.haml +107 -107
- data/app/views/optimacms/admin/pages/_meta.html.haml +48 -48
- data/app/views/optimacms/admin/pages/edit.html.haml +5 -5
- data/app/views/optimacms/admin/pages/editfolder.html.haml +15 -15
- data/app/views/optimacms/admin/pages/index.html.haml +58 -58
- data/app/views/optimacms/admin/pages/new.html.haml +5 -5
- data/app/views/optimacms/admin/pages/newfolder.html.haml +15 -15
- data/app/views/optimacms/admin/shared/_breadcrumbs.html.haml +7 -7
- data/app/views/optimacms/admin/shared/_flash.html.haml +23 -23
- data/app/views/optimacms/admin/shared/_footer.html.haml +5 -5
- data/app/views/optimacms/admin/shared/_form_errors.html.haml +11 -11
- data/app/views/optimacms/admin/shared/_leftmenu.html.haml +49 -49
- data/app/views/optimacms/admin/shared/_top.html.haml +33 -33
- data/app/views/optimacms/admin/templates/_form.html.haml +61 -61
- data/app/views/optimacms/admin/templates/_js_form_modal.html.haml +43 -43
- data/app/views/optimacms/admin/templates/create.js.haml +3 -3
- data/app/views/optimacms/admin/templates/edit.html.haml +5 -5
- data/app/views/optimacms/admin/templates/editfolder.html.haml +31 -31
- data/app/views/optimacms/admin/templates/index.html.haml +48 -48
- data/app/views/optimacms/admin/templates/new.html.haml +37 -37
- data/app/views/optimacms/admin/templates/newattach.html.haml +32 -32
- data/app/views/optimacms/admin/templates/newfolder.html.haml +28 -28
- data/app/views/optimacms/elfinder/index.html.erb +54 -54
- data/config/initializers/assets.rb +2 -2
- data/config/initializers/kaminari.rb +10 -10
- data/config/initializers/paperclip.rb +11 -11
- data/config/initializers/paperclip_media_type_spoof_detector_override.rb +7 -7
- data/config/initializers/simple_form.rb +166 -166
- data/config/initializers/simple_form_bootstrap.rb +146 -146
- data/config/locales/simple_form.en.yml +3 -3
- data/config/locales/simple_form.ru.yml +3 -3
- data/config/tinymce.yml +6 -6
- data/lib/optimacms/fileutils/fileutils.rb +39 -39
- data/lib/optimacms/filters/form_filter.rb +226 -226
- data/lib/optimacms/mycontroller.rb +82 -69
- data/lib/optimacms/page_services/page_data.rb +97 -97
- data/lib/optimacms/page_services/page_process_service.rb +32 -32
- data/lib/optimacms/page_services/page_route_service.rb +156 -156
- data/lib/optimacms/simple_form_extensions/button_components.rb +33 -33
- data/lib/optimacms/version.rb +3 -3
- data/spec/dummy/app/assets/stylesheets/application.css.scss +11 -11
- data/spec/dummy/app/assets/stylesheets/bootstrap_and_overrides.css.scss +3 -3
- data/spec/dummy/app/assets/stylesheets/bootstrap_custom.css.scss +49 -49
- data/spec/dummy/app/assets/stylesheets/tpl.css.scss +62 -62
- data/spec/dummy/app/controllers/home_controller.rb +6 -6
- data/spec/dummy/app/controllers/my_controller.rb +6 -6
- data/spec/dummy/app/controllers/news_controller.rb +46 -46
- data/spec/dummy/app/models/news.rb +7 -7
- data/spec/dummy/app/views/home/index.html.haml +18 -18
- data/spec/dummy/app/views/my/hello.html.haml +4 -4
- data/spec/dummy/app/views/news/index.html.haml +13 -13
- data/spec/dummy/app/views/news/show.html.haml +6 -6
- data/spec/dummy/app/views/pages/1.html.erb +16 -16
- data/spec/dummy/app/views/pages/about.html.erb +12 -12
- data/spec/dummy/app/views/pages/text1.html +1 -1
- data/spec/dummy/app/views/services/index.html.haml +9 -9
- data/spec/dummy/app/views/services/service.html.haml +2 -2
- data/spec/dummy/app/views/temp/html1.html +1 -1
- data/spec/dummy/app/views/temp/p1.html.haml +6 -6
- data/spec/dummy/app/views/temp/t1.html.haml +13 -13
- data/spec/dummy/app/views/temp9/t2.html +8 -8
- data/spec/dummy/app/views/workers/_breadcrumb_worker.html.haml +11 -11
- data/spec/dummy/app/views/workers/_breadcrumb_workers.html.haml +9 -9
- data/spec/dummy/app/views/workers/_contacts_our.html.haml +3 -3
- data/spec/dummy/app/views/workers/_list_worker.html.haml +46 -46
- data/spec/dummy/app/views/workers/_list_workers.html.haml +6 -6
- data/spec/dummy/app/views/workers/_share_js.html.haml +22 -22
- data/spec/dummy/app/views/workers/_share_worker.html.haml +11 -11
- data/spec/dummy/app/views/workers/_show_info.html.haml +53 -53
- data/spec/dummy/app/views/workers/_tabs.html.haml +11 -11
- data/spec/dummy/app/views/workers/contacts.html.haml +19 -19
- data/spec/dummy/app/views/workers/index.html.haml +49 -49
- data/spec/dummy/app/views/workers/portfolio.html.haml +20 -20
- data/spec/dummy/app/views/workers/services.html.haml +11 -11
- data/spec/dummy/app/views/workers/show.html.haml +53 -53
- data/spec/dummy/app/views/workers/show_notfound.html.haml +8 -8
- data/spec/dummy/app/views/workers/t2.html.haml +1 -1
- data/spec/dummy/app/views/workers/work.html.haml +43 -43
- data/spec/dummy/config/tinymce.yml +5 -5
- data/spec/dummy/db/schema.rb +164 -164
- data/spec/dummy/log/development.log +0 -20396
- data/spec/factories/page.rb +25 -25
- data/spec/models/page_spec.rb +92 -92
- data/spec/spec_helper.rb +89 -89
- data/spec/support/factory_girl.rb +15 -15
- metadata +1431 -1817
- data/spec/dummy/app/views/temp/_part2.html.haml +0 -1
- data/spec/dummy/log/test.log +0 -203
- data/spec/dummy/tmp/cache/assets/development/sass/0abc660c880b2e10d695d713e519e6a4257cd348/application.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/0abc660c880b2e10d695d713e519e6a4257cd348/bootstrap_and_overrides.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/0abc660c880b2e10d695d713e519e6a4257cd348/bootstrap_custom.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/0abc660c880b2e10d695d713e519e6a4257cd348/bootstrap_variables.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/0abc660c880b2e10d695d713e519e6a4257cd348/tpl.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/18577b7353d72dbc7e81d46af07240af8557f987/_hacks.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/255a203cf5ecbb5470dfd267d6d4b923c8f1e5f0/_css3.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/255a203cf5ecbb5470dfd267d6d4b923c8f1e5f0/_support.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/4b8b59c3cee3225b46cdcaa54f7d0474421be9c6/_bootstrap-sprockets.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/7f871ea7e3a8127767d5a5868622ef2909611f26/noskin.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/admin.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/admin_tpl.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/bootstrap_and_overrides.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/bootstrap_custom.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/bootstrap_variables.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/colors.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/tinymce.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/a1b4b92b7663fe8c3e3678ca845c8a0566c3ca13/tpl.css.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_alerts.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_background-variant.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_border-radius.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_buttons.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_center-block.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_clearfix.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_forms.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_gradients.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_grid-framework.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_grid.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_hide-text.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_image.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_labels.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_list-group.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_nav-divider.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_nav-vertical-align.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_opacity.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_pagination.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_panels.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_progress-bar.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_reset-filter.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_resize.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_responsive-visibility.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_size.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_tab-focus.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_table-row.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_text-emphasis.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_text-overflow.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/bfa17faa2a4aa370d46a5900b72c48f05b4837d1/_vendor-prefixes.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_appearance.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_background-clip.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_background-origin.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_background-size.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_border-radius.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_box-shadow.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_box-sizing.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_box.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_columns.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_filter.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_font-face.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_hyphenation.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_images.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_inline-block.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_opacity.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_regions.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_shared.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_text-shadow.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_transform.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_transition.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e04ca948242d213270bfe676c8b96e7b33226468/_user-interface.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_alerts.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_badges.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_breadcrumbs.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_button-groups.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_buttons.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_carousel.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_close.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_code.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_component-animations.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_dropdowns.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_forms.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_glyphicons.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_grid.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_input-groups.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_jumbotron.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_labels.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_list-group.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_media.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_mixins.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_modals.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_navbar.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_navs.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_normalize.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_pager.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_pagination.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_panels.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_popovers.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_print.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_progress-bars.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_responsive-embed.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_responsive-utilities.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_scaffolding.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_tables.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_thumbnails.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_tooltip.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_type.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_utilities.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_variables.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/e541a95436c6e387d69ff457c2fe7f7bd11c2069/_wells.scssc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sass/fc41a79de5ec40d34c8a83221f3f3da2c64f4153/font-awesome.css.erbc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/002bd8f28c62a795a10ce5716ceffc21 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/053f826d1ea01a2fac355de0755e5c40 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/05e27d4921b00a0fdddb47a737a64494 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0a470277dd21c166b9dfb68b03d34d5c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0b1671e1bffda60e6a95f72b9176d628 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0c01383de62960e3667c7bf3788ecdb6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/0d2f255829ff9f72d98dead4f35ddf02 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/11f54468370774efca0fe1afb2ebf1d9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/1c0ef71c34dc1d573e1b4b527116e3cc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2168c08c151d642aa46ea4bc6283929c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2a9369c8d28de014045a120b692e8139 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/2f7d38a264678a2db4a0d569a3313cb1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3240ef40c1dc9d13156bbd790ec2651a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/332dfe4887cbad3adbd20e6609fa4960 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3347cc312918facec5bbac684ea65715 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/3cd4037d8c32ad8fcdd5e3bbb8dfc35a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/4016d2fd0b776ceb82fcbfbc5d2e26b1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/43dc3e92cd09deb0fc54dd97b46935e9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/452d7e35d5a012ae12fa7346fcf2239b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/49c7cb5dd916ffc9e87ce3b989c92062 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/529a74a4530de52f6c3ebbf107ffe9f2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/55a2847335c39261e1efe764deb18592 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/56c7eb172a7423728c45d0a751d198e3 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6789fe765d536063c998330523bb12b9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/678a2e392e656b8132f0420e4ec28ed6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6843f0414f73089579ae0f9fddf7b38f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6c7c58744c14732af9bf574870fdf07e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6cdbd6f171a27a578bcb07dd5bfa83a2 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6e431ed1dfb5bbcbd33a5f9e069dd3ab +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/6f943f22c610e6417422e4a13e0bcc0d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/73fbaa501dc0b072cf2c27fa7dfe0d91 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/7c886717bced4d59ab89e012b52f40de +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/821470da3272c8b99070972d4f4f58ca +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/88d843fcb07453d1057fac1e254fde0d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8956737a82f17db48d50e13f133aeefc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8ab512c9b33ac90e699b73469d71f061 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8b5a7992567ebbeb9a882d074778f8c8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8d71fe4f0e2910900097bdc07bf2d6af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/8e1785ddbfab42cd2df0416eb3932253 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9024d024c62c2668836b1e1b7b3b78cc +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/928ed298f875a25727ca516f5c03f344 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/97c1e12a09973e0fb97f23a1dc496443 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/991576185140a77411185839fd0533f1 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/99e8d6370ba85ec4a61d953f5ed261af +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/9ee80730ab26986d507820ac7a288d5c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a3faca31eb11ba1a981535f9c8408282 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a5c68a2aec806face32c749f380f1e14 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a64dbcf0e4afe0985b1abd3e209d17cd +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/a6d357fbe03dae6f590180f6c5e0e148 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/aa58fb159780a7200a1bc4c6844cc5c4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/aaba73a43e02d8c6550bae851f17e7a0 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/af26c017afcf68f1edd44a4c9bb942e4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b3defd466aec80b128284b8d85324630 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/b48ed8a3de3ca66055ee4fd18b16421f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ba9859d0d2b7d4d7d5b03ff3a71ed478 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/bcca522c6302f184f12fe0e8a7d7e71a +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/be8a0cd6c3605b9d7c22642609316a9f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c11c6d97cfc7ef7945fa87f14b44445c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c13fc73ceafa45876a901b3e775b83ae +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c5f3450b5366b6fbdc4172ce089fba48 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/c982bb1e71844744a60dc9b4afcb2f49 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cf24c3f1bb8adb1f168758f2bd9775c9 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d3e5a199890ba7c706fc62c2b891714d +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d584baf83d8a779d945f9668f902fa7c +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d71b820ce5f8b310e466f517bd3a8e4b +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/d8dab59d17daf5a5081153e2ad7d09b4 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/dd4a8658311b7a2cd8effa6479827559 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e11970a225a09526aac3f76d7ee91822 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e3dd086dd858b5bff9cfd60a031c2091 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e43bcf201d76cdf6e1fe345195c1cd9e +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/e945ca604ee0240455a5652953b3e495 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ec33505f0e2ed4dd12951ecceffa3695 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ee287313e28f341f83628dec0a353fa6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ee9a23832dc2a49ee6ec6d3f1d6a0e1f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ef2d6862f5fd690c5387cafd88944a9f +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ef8c3824b85ed745cad651aadda4f2b8 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f557612d05bb9fea499dce8352b3f0ca +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f7f3056583a2454471a4a5f7200dcefa +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/f9c51fa87975943d31bc1bfd7cb684c6 +0 -0
- data/spec/dummy/tmp/cache/assets/development/sprockets/ff9ed89418a3f78032b8f8184dd98e80 +0 -0
@@ -1,315 +1,315 @@
|
|
1
|
-
module Optimacms
|
2
|
-
class Admin::TemplatesController < Admin::AdminBaseController
|
3
|
-
|
4
|
-
before_action :set_item, only: [:show, :edit, :update, :destroy]
|
5
|
-
before_action :init_common
|
6
|
-
before_action :init_data_form, only: [:new, :edit, :newfolder, :editfolder, :newattach]
|
7
|
-
#before_action :set_layout_modal
|
8
|
-
|
9
|
-
|
10
|
-
def init_common
|
11
|
-
@modal = (params[:modal] || 0).to_i
|
12
|
-
set_layout_modal(@modal)
|
13
|
-
|
14
|
-
end
|
15
|
-
|
16
|
-
def set_layout_modal(modal)
|
17
|
-
if modal.to_i==1
|
18
|
-
#self.class.layout false
|
19
|
-
end
|
20
|
-
|
21
|
-
end
|
22
|
-
|
23
|
-
|
24
|
-
def index
|
25
|
-
#@filter.clear_data
|
26
|
-
|
27
|
-
#
|
28
|
-
@parent_id = @filter.v('parent_id').to_i
|
29
|
-
@parent = Template.find(@parent_id) rescue nil
|
30
|
-
|
31
|
-
if @parent.nil? && @parent_id>0
|
32
|
-
redirect_to templates_path(:parent_id=>0) and return
|
33
|
-
end
|
34
|
-
|
35
|
-
#
|
36
|
-
@items = model.by_filter(@filter)
|
37
|
-
#@items = model.where(@filter.where).order(@filter.order_string).page(@filter.page)
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
42
|
-
#include SimpleFilter::Controller
|
43
|
-
search_filter :index, {save_session: true, search_method: :post_and_redirect, url: :templates_url, search_url: :search_templates_url, search_action: :search} do
|
44
|
-
# define filter
|
45
|
-
default_order "title", 'asc'
|
46
|
-
|
47
|
-
# fields
|
48
|
-
field :title, :string, :text, {label: '', default_value: '', condition: :like_full}
|
49
|
-
#field :parent_id, :int, :hidden, {label: '', default_value: 0, ignore_value: 0, condition: :empty}
|
50
|
-
field :parent_id, :int, :hidden, {label: '', default_value: 0, ignore_value: -1, condition: :custom, condition_scope: :of_parent}
|
51
|
-
|
52
|
-
#field :category_id, :int, :select, {collection: [['UGX- Uganda Shillings',1],['USD- US Dollars',2]], label_method: :first, value_method: :last}
|
53
|
-
#field :type_id, :int, :select, {label: 'Type', default_value: 0, collection: TemplateType.all, label_method: :title, value_method: :id}
|
54
|
-
#field :type, :string, :autocomplete, {label: 'Type', default_value: '', :source_query => :autocomplete_templates_url}
|
55
|
-
|
56
|
-
end
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
def autocomplete
|
61
|
-
q = params[:q]
|
62
|
-
type_id = (params[:t] || TemplateType::TYPE_PAGE).to_i
|
63
|
-
|
64
|
-
rows = Template.where("type_id=#{type_id} AND (basepath LIKE ? OR title like ?)", "%#{q}%", "%#{q}%").order('basepath asc').limit(20)
|
65
|
-
|
66
|
-
data = rows.map{|r| [r.id, "#{r.title} (#{r.basepath})"]}
|
67
|
-
render :json => data
|
68
|
-
end
|
69
|
-
|
70
|
-
def show
|
71
|
-
end
|
72
|
-
|
73
|
-
def new
|
74
|
-
@item = model.new({:tpl_format=>Optimacms::Template::EXTENSION_DEFAULT, :type_id=>TemplateType::TYPE_PAGE})
|
75
|
-
item_init_parent
|
76
|
-
@item.set_basedirpath_from_parent
|
77
|
-
|
78
|
-
@url_back = url_list
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
def create
|
83
|
-
@item = model.new(item_params)
|
84
|
-
@res = @item.save
|
85
|
-
|
86
|
-
respond_to do |format|
|
87
|
-
if @res
|
88
|
-
format.html { redirect_to edit_template_path(@item), success: 'Successfully created' }
|
89
|
-
#format.json { render json: @item, status: :created, location: user_clients_url(:action => 'index') }
|
90
|
-
format.js {}
|
91
|
-
else
|
92
|
-
format.html { render :new }
|
93
|
-
#format.json { render json: @item.errors, status: :unprocessable_entity }
|
94
|
-
format.js {}
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
|
100
|
-
def edit
|
101
|
-
end
|
102
|
-
|
103
|
-
|
104
|
-
def update
|
105
|
-
|
106
|
-
# fix line breaks
|
107
|
-
content = item_params[:content]
|
108
|
-
content.gsub! /\r\n/, "\n"
|
109
|
-
|
110
|
-
@res = @item.update(item_params)
|
111
|
-
|
112
|
-
if @res
|
113
|
-
redirect_to url_list, success: 'Successfully updated'
|
114
|
-
else
|
115
|
-
render :edit
|
116
|
-
end
|
117
|
-
end
|
118
|
-
|
119
|
-
|
120
|
-
def destroy
|
121
|
-
@res = @item.destroy
|
122
|
-
|
123
|
-
if @res
|
124
|
-
redirect_to url_list, success: 'Successfully deleted'
|
125
|
-
else
|
126
|
-
redirect_to url_list, error: 'Cannot delete'
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
def newattach
|
133
|
-
@item = model.new({:tpl_format=>Optimacms::Template::EXTENSION_DEFAULT})
|
134
|
-
item_init_parent
|
135
|
-
@item.set_basedirpath_from_parent
|
136
|
-
|
137
|
-
@url_back = url_list
|
138
|
-
end
|
139
|
-
|
140
|
-
def attach
|
141
|
-
item_params = params.require(model_name).permit!
|
142
|
-
#(:title, :basepath, :parent_id, :tpl_format)
|
143
|
-
item_params[:type_id] = TemplateType::TYPE_PAGE
|
144
|
-
@item = model.new(item_params)
|
145
|
-
@res = @item.attach
|
146
|
-
|
147
|
-
respond_to do |format|
|
148
|
-
if @res
|
149
|
-
format.html { redirect_to edit_template_path(@item), success: 'Successfully attached' }
|
150
|
-
#format.json { render json: @item, status: :created, location: user_clients_url(:action => 'index') }
|
151
|
-
format.js {}
|
152
|
-
else
|
153
|
-
format.html { render :newattach }
|
154
|
-
#format.json { render json: @item.errors, status: :unprocessable_entity }
|
155
|
-
format.js {}
|
156
|
-
end
|
157
|
-
end
|
158
|
-
end
|
159
|
-
|
160
|
-
|
161
|
-
#### folders
|
162
|
-
|
163
|
-
|
164
|
-
def newfolder
|
165
|
-
@item = model.new(:is_folder=>true)
|
166
|
-
item_init_parent
|
167
|
-
@item.basedirpath = @item.parent.basepath+'/' unless @item.parent_id.nil?
|
168
|
-
|
169
|
-
end
|
170
|
-
|
171
|
-
def createfolder
|
172
|
-
item_params = params.require(model_name).permit(:title, :basename, :parent_id, :is_folder)
|
173
|
-
|
174
|
-
@item = model.new(item_params)
|
175
|
-
@res = @item.save
|
176
|
-
|
177
|
-
if @res
|
178
|
-
redirect_to url_list, success: 'Successfully created'
|
179
|
-
else
|
180
|
-
render :newfolder
|
181
|
-
end
|
182
|
-
end
|
183
|
-
|
184
|
-
|
185
|
-
def editfolder
|
186
|
-
@item = Template.folders.find(params[:id])
|
187
|
-
|
188
|
-
return url_list if @item.nil?
|
189
|
-
|
190
|
-
end
|
191
|
-
|
192
|
-
def updatefolder
|
193
|
-
@item = Template.folders.find(params[:id])
|
194
|
-
item_params = params.require(model_name).permit(:title, :basename, :parent_id, :is_folder)
|
195
|
-
@res = @item.update_attributes(item_params)
|
196
|
-
|
197
|
-
if @res
|
198
|
-
redirect_to url_list, success: 'Successfully updated'
|
199
|
-
else
|
200
|
-
render :editfolder
|
201
|
-
end
|
202
|
-
end
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
private
|
207
|
-
|
208
|
-
def init_data_form
|
209
|
-
@url_back = url_list
|
210
|
-
|
211
|
-
end
|
212
|
-
|
213
|
-
|
214
|
-
def model
|
215
|
-
Template
|
216
|
-
end
|
217
|
-
def model_name
|
218
|
-
:template
|
219
|
-
end
|
220
|
-
|
221
|
-
def url_list
|
222
|
-
templates_url
|
223
|
-
end
|
224
|
-
|
225
|
-
# Use callbacks to share common setup or constraints between actions.
|
226
|
-
def set_item
|
227
|
-
@item = model.find(params[:id])
|
228
|
-
|
229
|
-
@url_back = url_list
|
230
|
-
end
|
231
|
-
|
232
|
-
def item_init_parent
|
233
|
-
parent_id = params[:parent_id]
|
234
|
-
parent_id = parent_id.to_i unless parent_id.nil?
|
235
|
-
parent_id = nil if parent_id==0
|
236
|
-
|
237
|
-
@item.parent_id = parent_id
|
238
|
-
end
|
239
|
-
|
240
|
-
def item_params
|
241
|
-
#params.require(model_name).permit(:title)
|
242
|
-
params.require(model_name).permit!
|
243
|
-
end
|
244
|
-
|
245
|
-
|
246
|
-
# filter
|
247
|
-
|
248
|
-
def filter_prefix
|
249
|
-
'admin_templates_index_'
|
250
|
-
end
|
251
|
-
|
252
|
-
def init_tabledata
|
253
|
-
init_filter
|
254
|
-
end
|
255
|
-
|
256
|
-
def init_filter
|
257
|
-
# input
|
258
|
-
@pg = params[:pg].to_i || 1
|
259
|
-
|
260
|
-
#
|
261
|
-
@filter = Filters::FormFilter.new(session, filter_prefix)
|
262
|
-
|
263
|
-
# set filter fields
|
264
|
-
@filter.add_fields_from_array(
|
265
|
-
[
|
266
|
-
{name: 'title', type: 'text', dbtype: Filters::FormFilter::DBTYPE_STRING, title: 'Title', def: '', opt: {width: 120}},
|
267
|
-
{name: 'parent_id', type: 'int', dbtype: Filters::FormFilter::FIELD_TYPE_HIDDEN, title: '', def: 0},
|
268
|
-
]
|
269
|
-
)
|
270
|
-
|
271
|
-
#
|
272
|
-
if params.has_key? :parent_id
|
273
|
-
@filter.set 'parent_id', params[:parent_id]
|
274
|
-
end
|
275
|
-
#@filter.set 'owner_id', current_user.owner_id
|
276
|
-
|
277
|
-
#
|
278
|
-
@cmd = params[:cmd] || ''
|
279
|
-
|
280
|
-
|
281
|
-
# post
|
282
|
-
if request.post? && params[:filter]
|
283
|
-
if params[:cmd]=='clear'
|
284
|
-
@filter.clear_data
|
285
|
-
|
286
|
-
redirect_to url_list and return
|
287
|
-
else
|
288
|
-
@filter.set_data_from_form(params[:filter] || [])
|
289
|
-
redirect_to url_list and return
|
290
|
-
end
|
291
|
-
|
292
|
-
end
|
293
|
-
|
294
|
-
# order
|
295
|
-
@filter.set_order_default('created_at' ,'desc')
|
296
|
-
#@filter.set_order('created_at' ,'desc')
|
297
|
-
|
298
|
-
if @cmd=='order'
|
299
|
-
@filter.set_order params[:orderby], params[:orderdir]
|
300
|
-
redirect_to url_list and return
|
301
|
-
end
|
302
|
-
|
303
|
-
|
304
|
-
end
|
305
|
-
|
306
|
-
|
307
|
-
def table_columns
|
308
|
-
@table_columns = [
|
309
|
-
{name: "id", title: "##"},
|
310
|
-
{name: "title", title: "title"},
|
311
|
-
]
|
312
|
-
end
|
313
|
-
|
314
|
-
end
|
315
|
-
end
|
1
|
+
module Optimacms
|
2
|
+
class Admin::TemplatesController < Admin::AdminBaseController
|
3
|
+
|
4
|
+
before_action :set_item, only: [:show, :edit, :update, :destroy]
|
5
|
+
before_action :init_common
|
6
|
+
before_action :init_data_form, only: [:new, :edit, :newfolder, :editfolder, :newattach]
|
7
|
+
#before_action :set_layout_modal
|
8
|
+
|
9
|
+
|
10
|
+
def init_common
|
11
|
+
@modal = (params[:modal] || 0).to_i
|
12
|
+
set_layout_modal(@modal)
|
13
|
+
|
14
|
+
end
|
15
|
+
|
16
|
+
def set_layout_modal(modal)
|
17
|
+
if modal.to_i==1
|
18
|
+
#self.class.layout false
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
23
|
+
|
24
|
+
def index
|
25
|
+
#@filter.clear_data
|
26
|
+
|
27
|
+
#
|
28
|
+
@parent_id = @filter.v('parent_id').to_i
|
29
|
+
@parent = Template.find(@parent_id) rescue nil
|
30
|
+
|
31
|
+
if @parent.nil? && @parent_id>0
|
32
|
+
redirect_to templates_path(:parent_id=>0) and return
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
@items = model.by_filter(@filter)
|
37
|
+
#@items = model.where(@filter.where).order(@filter.order_string).page(@filter.page)
|
38
|
+
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
#include SimpleFilter::Controller
|
43
|
+
search_filter :index, {save_session: true, search_method: :post_and_redirect, url: :templates_url, search_url: :search_templates_url, search_action: :search} do
|
44
|
+
# define filter
|
45
|
+
default_order "title", 'asc'
|
46
|
+
|
47
|
+
# fields
|
48
|
+
field :title, :string, :text, {label: '', default_value: '', condition: :like_full}
|
49
|
+
#field :parent_id, :int, :hidden, {label: '', default_value: 0, ignore_value: 0, condition: :empty}
|
50
|
+
field :parent_id, :int, :hidden, {label: '', default_value: 0, ignore_value: -1, condition: :custom, condition_scope: :of_parent}
|
51
|
+
|
52
|
+
#field :category_id, :int, :select, {collection: [['UGX- Uganda Shillings',1],['USD- US Dollars',2]], label_method: :first, value_method: :last}
|
53
|
+
#field :type_id, :int, :select, {label: 'Type', default_value: 0, collection: TemplateType.all, label_method: :title, value_method: :id}
|
54
|
+
#field :type, :string, :autocomplete, {label: 'Type', default_value: '', :source_query => :autocomplete_templates_url}
|
55
|
+
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
def autocomplete
|
61
|
+
q = params[:q]
|
62
|
+
type_id = (params[:t] || TemplateType::TYPE_PAGE).to_i
|
63
|
+
|
64
|
+
rows = Template.where("type_id=#{type_id} AND (basepath LIKE ? OR title like ?)", "%#{q}%", "%#{q}%").order('basepath asc').limit(20)
|
65
|
+
|
66
|
+
data = rows.map{|r| [r.id, "#{r.title} (#{r.basepath})"]}
|
67
|
+
render :json => data
|
68
|
+
end
|
69
|
+
|
70
|
+
def show
|
71
|
+
end
|
72
|
+
|
73
|
+
def new
|
74
|
+
@item = model.new({:tpl_format=>Optimacms::Template::EXTENSION_DEFAULT, :type_id=>TemplateType::TYPE_PAGE})
|
75
|
+
item_init_parent
|
76
|
+
@item.set_basedirpath_from_parent
|
77
|
+
|
78
|
+
@url_back = url_list
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
def create
|
83
|
+
@item = model.new(item_params)
|
84
|
+
@res = @item.save
|
85
|
+
|
86
|
+
respond_to do |format|
|
87
|
+
if @res
|
88
|
+
format.html { redirect_to edit_template_path(@item), success: 'Successfully created' }
|
89
|
+
#format.json { render json: @item, status: :created, location: user_clients_url(:action => 'index') }
|
90
|
+
format.js {}
|
91
|
+
else
|
92
|
+
format.html { render :new }
|
93
|
+
#format.json { render json: @item.errors, status: :unprocessable_entity }
|
94
|
+
format.js {}
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def edit
|
101
|
+
end
|
102
|
+
|
103
|
+
|
104
|
+
def update
|
105
|
+
|
106
|
+
# fix line breaks
|
107
|
+
content = item_params[:content]
|
108
|
+
content.gsub! /\r\n/, "\n"
|
109
|
+
|
110
|
+
@res = @item.update(item_params)
|
111
|
+
|
112
|
+
if @res
|
113
|
+
redirect_to url_list, success: 'Successfully updated'
|
114
|
+
else
|
115
|
+
render :edit
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
|
120
|
+
def destroy
|
121
|
+
@res = @item.destroy
|
122
|
+
|
123
|
+
if @res
|
124
|
+
redirect_to url_list, success: 'Successfully deleted'
|
125
|
+
else
|
126
|
+
redirect_to url_list, error: 'Cannot delete'
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
def newattach
|
133
|
+
@item = model.new({:tpl_format=>Optimacms::Template::EXTENSION_DEFAULT})
|
134
|
+
item_init_parent
|
135
|
+
@item.set_basedirpath_from_parent
|
136
|
+
|
137
|
+
@url_back = url_list
|
138
|
+
end
|
139
|
+
|
140
|
+
def attach
|
141
|
+
item_params = params.require(model_name).permit!
|
142
|
+
#(:title, :basepath, :parent_id, :tpl_format)
|
143
|
+
item_params[:type_id] = TemplateType::TYPE_PAGE
|
144
|
+
@item = model.new(item_params)
|
145
|
+
@res = @item.attach
|
146
|
+
|
147
|
+
respond_to do |format|
|
148
|
+
if @res
|
149
|
+
format.html { redirect_to edit_template_path(@item), success: 'Successfully attached' }
|
150
|
+
#format.json { render json: @item, status: :created, location: user_clients_url(:action => 'index') }
|
151
|
+
format.js {}
|
152
|
+
else
|
153
|
+
format.html { render :newattach }
|
154
|
+
#format.json { render json: @item.errors, status: :unprocessable_entity }
|
155
|
+
format.js {}
|
156
|
+
end
|
157
|
+
end
|
158
|
+
end
|
159
|
+
|
160
|
+
|
161
|
+
#### folders
|
162
|
+
|
163
|
+
|
164
|
+
def newfolder
|
165
|
+
@item = model.new(:is_folder=>true)
|
166
|
+
item_init_parent
|
167
|
+
@item.basedirpath = @item.parent.basepath+'/' unless @item.parent_id.nil?
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
def createfolder
|
172
|
+
item_params = params.require(model_name).permit(:title, :basename, :parent_id, :is_folder)
|
173
|
+
|
174
|
+
@item = model.new(item_params)
|
175
|
+
@res = @item.save
|
176
|
+
|
177
|
+
if @res
|
178
|
+
redirect_to url_list, success: 'Successfully created'
|
179
|
+
else
|
180
|
+
render :newfolder
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
|
185
|
+
def editfolder
|
186
|
+
@item = Template.folders.find(params[:id])
|
187
|
+
|
188
|
+
return url_list if @item.nil?
|
189
|
+
|
190
|
+
end
|
191
|
+
|
192
|
+
def updatefolder
|
193
|
+
@item = Template.folders.find(params[:id])
|
194
|
+
item_params = params.require(model_name).permit(:title, :basename, :parent_id, :is_folder)
|
195
|
+
@res = @item.update_attributes(item_params)
|
196
|
+
|
197
|
+
if @res
|
198
|
+
redirect_to url_list, success: 'Successfully updated'
|
199
|
+
else
|
200
|
+
render :editfolder
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
private
|
207
|
+
|
208
|
+
def init_data_form
|
209
|
+
@url_back = url_list
|
210
|
+
|
211
|
+
end
|
212
|
+
|
213
|
+
|
214
|
+
def model
|
215
|
+
Template
|
216
|
+
end
|
217
|
+
def model_name
|
218
|
+
:template
|
219
|
+
end
|
220
|
+
|
221
|
+
def url_list
|
222
|
+
templates_url
|
223
|
+
end
|
224
|
+
|
225
|
+
# Use callbacks to share common setup or constraints between actions.
|
226
|
+
def set_item
|
227
|
+
@item = model.find(params[:id])
|
228
|
+
|
229
|
+
@url_back = url_list
|
230
|
+
end
|
231
|
+
|
232
|
+
def item_init_parent
|
233
|
+
parent_id = params[:parent_id]
|
234
|
+
parent_id = parent_id.to_i unless parent_id.nil?
|
235
|
+
parent_id = nil if parent_id==0
|
236
|
+
|
237
|
+
@item.parent_id = parent_id
|
238
|
+
end
|
239
|
+
|
240
|
+
def item_params
|
241
|
+
#params.require(model_name).permit(:title)
|
242
|
+
params.require(model_name).permit!
|
243
|
+
end
|
244
|
+
|
245
|
+
|
246
|
+
# filter
|
247
|
+
|
248
|
+
def filter_prefix
|
249
|
+
'admin_templates_index_'
|
250
|
+
end
|
251
|
+
|
252
|
+
def init_tabledata
|
253
|
+
init_filter
|
254
|
+
end
|
255
|
+
|
256
|
+
def init_filter
|
257
|
+
# input
|
258
|
+
@pg = params[:pg].to_i || 1
|
259
|
+
|
260
|
+
#
|
261
|
+
@filter = Filters::FormFilter.new(session, filter_prefix)
|
262
|
+
|
263
|
+
# set filter fields
|
264
|
+
@filter.add_fields_from_array(
|
265
|
+
[
|
266
|
+
{name: 'title', type: 'text', dbtype: Filters::FormFilter::DBTYPE_STRING, title: 'Title', def: '', opt: {width: 120}},
|
267
|
+
{name: 'parent_id', type: 'int', dbtype: Filters::FormFilter::FIELD_TYPE_HIDDEN, title: '', def: 0},
|
268
|
+
]
|
269
|
+
)
|
270
|
+
|
271
|
+
#
|
272
|
+
if params.has_key? :parent_id
|
273
|
+
@filter.set 'parent_id', params[:parent_id]
|
274
|
+
end
|
275
|
+
#@filter.set 'owner_id', current_user.owner_id
|
276
|
+
|
277
|
+
#
|
278
|
+
@cmd = params[:cmd] || ''
|
279
|
+
|
280
|
+
|
281
|
+
# post
|
282
|
+
if request.post? && params[:filter]
|
283
|
+
if params[:cmd]=='clear'
|
284
|
+
@filter.clear_data
|
285
|
+
|
286
|
+
redirect_to url_list and return
|
287
|
+
else
|
288
|
+
@filter.set_data_from_form(params[:filter] || [])
|
289
|
+
redirect_to url_list and return
|
290
|
+
end
|
291
|
+
|
292
|
+
end
|
293
|
+
|
294
|
+
# order
|
295
|
+
@filter.set_order_default('created_at' ,'desc')
|
296
|
+
#@filter.set_order('created_at' ,'desc')
|
297
|
+
|
298
|
+
if @cmd=='order'
|
299
|
+
@filter.set_order params[:orderby], params[:orderdir]
|
300
|
+
redirect_to url_list and return
|
301
|
+
end
|
302
|
+
|
303
|
+
|
304
|
+
end
|
305
|
+
|
306
|
+
|
307
|
+
def table_columns
|
308
|
+
@table_columns = [
|
309
|
+
{name: "id", title: "##"},
|
310
|
+
{name: "title", title: "title"},
|
311
|
+
]
|
312
|
+
end
|
313
|
+
|
314
|
+
end
|
315
|
+
end
|