lipsiadmin 2.9
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +90 -0
- data/MIT-LICENSE +20 -0
- data/README +60 -0
- data/Rakefile +90 -0
- data/init.rb +1 -0
- data/lib/access_control/authentication.rb +105 -0
- data/lib/access_control/base.rb +227 -0
- data/lib/controller/ext.rb +168 -0
- data/lib/controller/lipsiadmin_controller.rb +18 -0
- data/lib/controller/pdf_builder.rb +67 -0
- data/lib/controller/rescue.rb +72 -0
- data/lib/controller/responds_to_parent.rb +56 -0
- data/lib/data_base/attachment.rb +351 -0
- data/lib/data_base/attachment/attach.rb +515 -0
- data/lib/data_base/attachment/geometry.rb +117 -0
- data/lib/data_base/attachment/iostream.rb +62 -0
- data/lib/data_base/attachment/processor.rb +49 -0
- data/lib/data_base/attachment/storage.rb +223 -0
- data/lib/data_base/attachment/thumbnail.rb +72 -0
- data/lib/data_base/attachment/upfile.rb +45 -0
- data/lib/data_base/attachment_table.rb +142 -0
- data/lib/data_base/translate_attributes.rb +30 -0
- data/lib/data_base/utility_scopes.rb +40 -0
- data/lib/data_base/without_table.rb +62 -0
- data/lib/generator.rb +114 -0
- data/lib/lipsiadmin.rb +77 -0
- data/lib/lipsiadmin_tasks.rb +3 -0
- data/lib/locale/en.yml +16 -0
- data/lib/locale/it.yml +16 -0
- data/lib/mailer/exception/exception.html.erb +11 -0
- data/lib/mailer/exception_notifier.rb +46 -0
- data/lib/mailer/pdf_builder.rb +66 -0
- data/lib/utils/html_entities.rb +63 -0
- data/lib/utils/literal.rb +20 -0
- data/lib/version.rb +9 -0
- data/lib/view/helpers/active_record_helper.rb +11 -0
- data/lib/view/helpers/backend_helper.rb +132 -0
- data/lib/view/helpers/ext/column_model.rb +73 -0
- data/lib/view/helpers/ext/component.rb +163 -0
- data/lib/view/helpers/ext/configuration.rb +36 -0
- data/lib/view/helpers/ext/grid.rb +281 -0
- data/lib/view/helpers/ext/store.rb +103 -0
- data/lib/view/helpers/ext/templates/grid_functions.js.erb +51 -0
- data/lib/view/helpers/ext/tool_bar.rb +40 -0
- data/lib/view/helpers/ext_helper.rb +150 -0
- data/lib/view/helpers/view_helper.rb +222 -0
- data/lipsiadmin_generators/attachment/REMEMBER +21 -0
- data/lipsiadmin_generators/attachment/attachment_generator.rb +27 -0
- data/lipsiadmin_generators/attachment/templates/migration.rb +14 -0
- data/lipsiadmin_generators/attachment/templates/model.rb +4 -0
- data/lipsiadmin_generators/backend/REMEMBER +18 -0
- data/lipsiadmin_generators/backend/backend_generator.rb +58 -0
- data/lipsiadmin_generators/backend/templates/config/config.yml +14 -0
- data/lipsiadmin_generators/backend/templates/config/initializers/config.rb +7 -0
- data/lipsiadmin_generators/backend/templates/config/initializers/emails.rb +2 -0
- data/lipsiadmin_generators/backend/templates/config/initializers/exception_notifier.rb +7 -0
- data/lipsiadmin_generators/backend/templates/config/locales/backend/en.yml +204 -0
- data/lipsiadmin_generators/backend/templates/config/locales/backend/it.yml +203 -0
- data/lipsiadmin_generators/backend/templates/config/locales/frontend/en.yml +5 -0
- data/lipsiadmin_generators/backend/templates/config/locales/frontend/it.yml +5 -0
- data/lipsiadmin_generators/backend/templates/config/locales/models/en.yml +31 -0
- data/lipsiadmin_generators/backend/templates/config/locales/models/it.yml +23 -0
- data/lipsiadmin_generators/backend/templates/config/locales/rails/en.yml +148 -0
- data/lipsiadmin_generators/backend/templates/config/locales/rails/it.yml +109 -0
- data/lipsiadmin_generators/backend/templates/controllers/backend/accounts_controller.rb +53 -0
- data/lipsiadmin_generators/backend/templates/controllers/backend/base_controller.rb +8 -0
- data/lipsiadmin_generators/backend/templates/controllers/backend/sessions_controller.rb +21 -0
- data/lipsiadmin_generators/backend/templates/controllers/backend_controller.rb +2 -0
- data/lipsiadmin_generators/backend/templates/controllers/frontend_controller.rb +4 -0
- data/lipsiadmin_generators/backend/templates/controllers/javascripts_controller.rb +17 -0
- data/lipsiadmin_generators/backend/templates/exceptions/template.html.haml +5 -0
- data/lipsiadmin_generators/backend/templates/helpers/backend_helper.rb +2 -0
- data/lipsiadmin_generators/backend/templates/helpers/frontend_helper.rb +2 -0
- data/lipsiadmin_generators/backend/templates/images/backend/back.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/background.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/bg-content.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/bg-hd-slate.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/bg-hd.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/bg-intro.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/bg-login.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/bg-menu-slate.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/bg-menu.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/bg.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/btn-login.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/delete.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/download.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/duplicate.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/edit.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/hd-bg-slate.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/hd-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/it.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/loader.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/logo-loader.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/logo-small.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/new.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/no-image.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/preview.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/print.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/save.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/support.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/backend/us.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/box/corners-blue.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/box/corners.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/box/l-blue.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/box/l.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/box/r-blue.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/box/r.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/box/tb-blue.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/box/tb-slate.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/box/tb.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/button/btn-arrow.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/button/btn-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/dd/drop-add.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/dd/drop-no.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/dd/drop-yes.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/editor/tb-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/clear-trigger.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/clear-trigger.psd +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/date-trigger.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/date-trigger.psd +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/error-tip-corners.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/exclamation.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/search-trigger.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/search-trigger.psd +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/text-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/trigger-tpl.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/trigger.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/form/trigger.psd +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/gradient-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/Thumbs.db +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/arrow-left-white.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/arrow-right-white.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/col-move-bottom.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/col-move-top.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/columns.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/dirty.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/done.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/drop-no.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/drop-yes.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/footer-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-blue-hd.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-blue-split.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-hrow.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-loading.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-split.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid-vista-hd.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-hd-btn.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-hrow-over.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-hrow.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-special-col-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/grid3-special-col-sel-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/group-by.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/group-expand-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hd-pop.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-asc.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-desc.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-lock.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-lock.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-unlock.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/hmenu-unlock.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/invalid_line.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/loading.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/mso-hd.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/nowait.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-first-disabled.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-first.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-last-disabled.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-last.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-next-disabled.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-next.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-prev-disabled.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/page-prev.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/pick-button.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/refresh.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/row-check-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/row-expand-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/row-over.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/row-sel.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/sort_asc.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/sort_desc.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/grid/wait.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/collapse.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/expand.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/gradient-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/mini-bottom.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/mini-left.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/mini-right.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/mini-top.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/ns-collapse.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/ns-expand.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/panel-close.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/panel-title-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/panel-title-light-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/stick.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/stuck.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/tab-close-on.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/layout/tab-close.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/menu/checked.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/menu/group-checked.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/menu/item-over.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/menu/menu-parent.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/menu/menu.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/menu/unchecked.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/corners-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/left-right.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/light-hd.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/tool-sprite-tpl.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/tool-sprites.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/tools-sprites-trans.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/top-bottom.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/top-bottom.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/white-corners-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/white-left-right.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/panel/white-top-bottom.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/progress/progress-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/qtip/bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/qtip/close.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/qtip/tip-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/s.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shadow-c.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shadow-lr.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shadow.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shared/blue-loading.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shared/calendar.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shared/glass-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shared/hd-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shared/large-loading.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shared/left-btn.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shared/loading-balls.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shared/right-btn.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/shared/warning.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/e-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/e-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/ne-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/ne-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/nw-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/nw-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/s-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/s-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/se-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/se-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/square.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/sw-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/sizer/sw-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-bg.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-thumb.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-v-bg.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/slider/slider-v-thumb.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/scroll-left.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/scroll-right.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/scroller-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-btm-inactive-left-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-btm-inactive-right-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-btm-left-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-btm-right-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-close.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-strip-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-strip-bg.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tab-strip-btm-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tabs/tabs-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/btn-arrow-light.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/btn-arrow.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/btn-over-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/gray-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/tb-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/toolbar/tb-btn-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/arrows.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-add.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-between.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-no.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-over.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-under.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/drop-yes.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end-minus-nl.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end-minus.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end-plus-nl.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end-plus.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-end.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-line.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-minus-nl.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-minus.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-plus-nl.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow-plus.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/elbow.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/folder-open.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/folder.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/leaf.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/loading.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/tree/s.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/icon-error.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/icon-info.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/icon-question.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/icon-warning.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-corners.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-corners.psd +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-right.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/left-right.psd +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/right-corners.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/right-corners.psd +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/top-bottom.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/default/window/top-bottom.psd +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/button/btn-arrow.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/button/btn-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/editor/tb-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/form/checkbox.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/form/clear-trigger.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/form/date-trigger.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/form/radio.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/form/search-trigger.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/form/trigger-tpl.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/form/trigger.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/gradient-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/arrow-left-white.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/arrow-right-white.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/col-move-bottom.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/col-move-top.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/footer-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-blue-hd.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-blue-split.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-hrow.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-split.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid-vista-hd.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-hd-btn.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-hrow-over.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-hrow.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-special-col-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/grid3-special-col-sel-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/group-expand-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/mso-hd.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-first-disabled.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-first.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-last-disabled.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-last.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-next-disabled.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-next.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-prev-disabled.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/page-prev.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/refresh.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/row-over.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/row-sel.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/sort_asc.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/grid/sort_desc.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/checked.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/group-checked.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/item-over - Copy.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/item-over.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/menu-parent.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/menu.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/menu/unchecked.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/corners-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/left-right.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/light-hd.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/tool-sprite-tpl.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/tool-sprites.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/tools-sprites-trans.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/top-bottom.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/top-bottom.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/white-corners-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/white-left-right.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/panel/white-top-bottom.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/progress/progress-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/qtip/bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/qtip/close.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/qtip/tip-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/s.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/glass-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/hd-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/left-btn.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/shared/right-btn.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/e-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/e-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/ne-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/ne-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/nw-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/nw-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/s-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/s-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/se-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/se-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/square.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/sw-handle-dark.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/sizer/sw-handle.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-bg.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-thumb.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-v-bg.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/slider/slider-v-thumb.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/scroll-left.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/scroll-right.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/scroller-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-inactive-left-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-inactive-right-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-left-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-btm-right-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-close.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-strip-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-strip-bg.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tab-strip-btm-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tabs/tabs-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/bg-menu.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/btn-arrow-light.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/btn-arrow.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/btn-over-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/gray-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/tb-bg.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/toolbar/tb-btn-sprite.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/tree/arrows.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-error.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-info.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-question.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/window/icon-warning.gif +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/window/left-corners.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/window/left-right.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/window/right-corners.png +0 -0
- data/lipsiadmin_generators/backend/templates/images/ext/slate/window/top-bottom.png +0 -0
- data/lipsiadmin_generators/backend/templates/javascripts/controls.js +3 -0
- data/lipsiadmin_generators/backend/templates/javascripts/dragdrop.js +3 -0
- data/lipsiadmin_generators/backend/templates/javascripts/effects.js +4 -0
- data/lipsiadmin_generators/backend/templates/javascripts/ext.js +76 -0
- data/lipsiadmin_generators/backend/templates/javascripts/prototype.js +12 -0
- data/lipsiadmin_generators/backend/templates/layouts/backend.html.haml +12 -0
- data/lipsiadmin_generators/backend/templates/layouts/frontend.html.haml +7 -0
- data/lipsiadmin_generators/backend/templates/migrations/create_accounts.rb +20 -0
- data/lipsiadmin_generators/backend/templates/models/account.rb +116 -0
- data/lipsiadmin_generators/backend/templates/models/account_access.rb +17 -0
- data/lipsiadmin_generators/backend/templates/models/notifier.rb +15 -0
- data/lipsiadmin_generators/backend/templates/stylesheets/backend-slate.css +105 -0
- data/lipsiadmin_generators/backend/templates/stylesheets/backend.css +74 -0
- data/lipsiadmin_generators/backend/templates/stylesheets/ext-slate.css +241 -0
- data/lipsiadmin_generators/backend/templates/stylesheets/ext.css +904 -0
- data/lipsiadmin_generators/backend/templates/stylesheets/login.css +22 -0
- data/lipsiadmin_generators/backend/templates/stylesheets/print.css +11 -0
- data/lipsiadmin_generators/backend/templates/stylesheets/standard.css +62 -0
- data/lipsiadmin_generators/backend/templates/views/backend/accounts/_form.html.haml +21 -0
- data/lipsiadmin_generators/backend/templates/views/backend/accounts/edit.html.haml +3 -0
- data/lipsiadmin_generators/backend/templates/views/backend/accounts/index.rjs +16 -0
- data/lipsiadmin_generators/backend/templates/views/backend/accounts/new.html.haml +3 -0
- data/lipsiadmin_generators/backend/templates/views/backend/base/index.html.haml +17 -0
- data/lipsiadmin_generators/backend/templates/views/backend/base/welcome.html.haml +2 -0
- data/lipsiadmin_generators/backend/templates/views/backend/sessions/new.html.haml +12 -0
- data/lipsiadmin_generators/backend/templates/views/javascripts/backend.js.erb +346 -0
- data/lipsiadmin_generators/backend/templates/views/javascripts/locale.js.erb +135 -0
- data/lipsiadmin_generators/backend/templates/views/notifier/registration.html.erb +2 -0
- data/lipsiadmin_generators/backend/templates/views/notifier/support_request.html.erb +1 -0
- data/lipsiadmin_generators/backend_page/REMEMBER +7 -0
- data/lipsiadmin_generators/backend_page/backend_page_generator.rb +212 -0
- data/lipsiadmin_generators/backend_page/templates/controller.rb +61 -0
- data/lipsiadmin_generators/backend_page/templates/form.html.haml +5 -0
- data/lipsiadmin_generators/backend_page/templates/form_scaffolding.html.haml +1 -0
- data/lipsiadmin_generators/backend_page/templates/functional_test.rb +45 -0
- data/lipsiadmin_generators/backend_page/templates/helper.rb +2 -0
- data/lipsiadmin_generators/backend_page/templates/view_edit.html.haml +3 -0
- data/lipsiadmin_generators/backend_page/templates/view_index.rjs.erb +16 -0
- data/lipsiadmin_generators/backend_page/templates/view_new.html.haml +3 -0
- data/lipsiadmin_generators/pdf/pdf_generator.rb +50 -0
- data/lipsiadmin_generators/pdf/templates/layout.html.erb +18 -0
- data/lipsiadmin_generators/pdf/templates/stylesheets/print.css +11 -0
- data/lipsiadmin_generators/pdf/templates/view.html.haml +7 -0
- data/resources/Pd4Ruby.class +0 -0
- data/resources/Pd4Ruby.java +52 -0
- data/resources/javascripts/ux.js +1102 -0
- data/resources/pd4ml.jar +0 -0
- data/resources/rdoc/horo.rb +613 -0
- data/resources/ss_css2.jar +0 -0
- data/tasks/lipsiadmin_tasks.rake +14 -0
- metadata +604 -0
@@ -0,0 +1,168 @@
|
|
1
|
+
module Lipsiadmin
|
2
|
+
module Controller
|
3
|
+
module Ext
|
4
|
+
# Return column config, and store config/data for ExtJS ColumnModel and Store
|
5
|
+
#
|
6
|
+
# Examples:
|
7
|
+
#
|
8
|
+
# # app/controllers/backend/debtors_controller.rb
|
9
|
+
# def index
|
10
|
+
# @column_store = column_store_for Debtor do |cm|
|
11
|
+
# cm.add :id
|
12
|
+
# cm.add "full_name_or_company.upcase", "Full Name", :sortable => true, :dataIndex => :company
|
13
|
+
# cm.add :email, "Email", :sortable => true
|
14
|
+
# cm.add :piva, "Piva", :sortable => true
|
15
|
+
# cm.add :created_at, "Creato il", :sortable => true, :renderer => :date, :align => :right
|
16
|
+
# cm.add :updated_at, "Aggiornato il", :sortable => true, :renderer => :datetime, :align => :right
|
17
|
+
# end
|
18
|
+
#
|
19
|
+
# respond_to do |format|
|
20
|
+
# format.js
|
21
|
+
# format.json do
|
22
|
+
# render :json => @column_store.store_data(params)
|
23
|
+
#
|
24
|
+
# # or you can manually do:
|
25
|
+
# # debtors = Debtor.search(params)
|
26
|
+
# # debtors_count = debtors.size
|
27
|
+
# # debtors_paginated = debtors.paginate(params)
|
28
|
+
# # render :json => { :results => @column_store.store_data_from(debtors_paginated), :count => debtors_count }
|
29
|
+
# end
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
#
|
33
|
+
# # app/views/backend/index.rjs
|
34
|
+
# page.grid do |grid|
|
35
|
+
# grid.id "debtors-grid" # If you don't set this columns are not saved in cookies
|
36
|
+
# grid.title "List al debtors"
|
37
|
+
# grid.base_path "/backend/debtors"
|
38
|
+
# grid.forgery_protection_token request_forgery_protection_token
|
39
|
+
# grid.authenticity_token form_authenticity_token
|
40
|
+
# grid.tbar :default
|
41
|
+
# grid.store do |store|
|
42
|
+
# store.url "/backend/debtors.json"
|
43
|
+
# store.fields @column_store.store_fields
|
44
|
+
# end
|
45
|
+
# grid.columns do |columns|
|
46
|
+
# columns.fields @column_store.column_fields
|
47
|
+
# end
|
48
|
+
# grid.bbar :store => grid.get_store, :pageSize => params[:limit] # Remember to add after defining store!
|
49
|
+
# end
|
50
|
+
#
|
51
|
+
def column_store_for(model, &block)
|
52
|
+
ColumnStore.new(model, &block)
|
53
|
+
end
|
54
|
+
|
55
|
+
class ColumnStore#:nodoc:
|
56
|
+
attr_reader :data
|
57
|
+
|
58
|
+
def initialize(model, &block)#:nodoc
|
59
|
+
@model = model
|
60
|
+
@data = []
|
61
|
+
yield self
|
62
|
+
end
|
63
|
+
|
64
|
+
# Method for add columns to the Column Model
|
65
|
+
def add(method, header=nil, options={})
|
66
|
+
options[:method] = method
|
67
|
+
# Setting hidden and removing query for
|
68
|
+
# items that don't have headers
|
69
|
+
if header.blank?
|
70
|
+
options[:hidden] = true
|
71
|
+
options[:query] = false
|
72
|
+
end
|
73
|
+
|
74
|
+
# Reforma DataIndex
|
75
|
+
if options[:dataIndex].is_a?(Array)
|
76
|
+
options[:dataIndex] = options[:dataIndex].collect do |f|
|
77
|
+
f.is_a?(Symbol) ? "#{@model.table_name}.#{f}" : f
|
78
|
+
end.join(",")
|
79
|
+
end
|
80
|
+
|
81
|
+
# Reformat query
|
82
|
+
if options[:method].is_a?(Symbol)
|
83
|
+
options[:dataIndex] ||= "#{@model.table_name}.#{options[:method]}"
|
84
|
+
else
|
85
|
+
# if we have eg. prodcedure.category.name we need to build
|
86
|
+
# a sql finder action so we need to generate
|
87
|
+
# procedures.categories.name
|
88
|
+
columns = options[:method].split(".")
|
89
|
+
if columns.empty?
|
90
|
+
options[:dataIndex] ||= "#{@model.table_name}.#{options[:method]}"
|
91
|
+
else
|
92
|
+
options[:dataIndex] ||= columns[0..columns.length-2].collect(&:pluralize).join(".") + "." + columns.at(columns.size-1)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
# Reformat dataIndex
|
97
|
+
options[:mapping] ||= options[:dataIndex].to_s.downcase.gsub(/[^a-z0-9]+/, '_').
|
98
|
+
gsub(/-+$/, '_').
|
99
|
+
gsub(/^-+$/, '_')
|
100
|
+
|
101
|
+
# Reformat header
|
102
|
+
options[:header] = header || options[:dataIndex].to_s.humanize
|
103
|
+
|
104
|
+
@data << options
|
105
|
+
end
|
106
|
+
|
107
|
+
# Return an array config for build an Ext.grid.ColumnModel() config
|
108
|
+
def column_fields
|
109
|
+
@data.clone.inject([]) do |fields, data|
|
110
|
+
# Prevent to removing in the original Hash
|
111
|
+
field = data.clone
|
112
|
+
field.delete(:method)
|
113
|
+
field.delete(:mapping)
|
114
|
+
fields << field
|
115
|
+
fields
|
116
|
+
end
|
117
|
+
end
|
118
|
+
|
119
|
+
# Return an array config for build an Ext.data.GroupingStore()
|
120
|
+
def store_fields
|
121
|
+
@data.inject([]) do |fields, data|
|
122
|
+
hash = { :name => data[:dataIndex], :mapping => data[:mapping] }
|
123
|
+
hash.merge!(:type => data[:renderer]) if data[:renderer] &&
|
124
|
+
(data[:renderer] == :date || data[:renderer] == :datetime)
|
125
|
+
fields << hash
|
126
|
+
fields
|
127
|
+
end
|
128
|
+
end
|
129
|
+
|
130
|
+
# Return data for a custom collection for the ExtJS Ext.data.GroupingStore() json
|
131
|
+
def store_data_from(collection)
|
132
|
+
collection.inject([]) do |store, c|
|
133
|
+
store << @data.inject({ :id => c.id }) do |options, data|
|
134
|
+
options[data[:mapping]] = (c.instance_eval(data[:method].to_s) rescue I18n.t("lipsiadmin.labels.not_found"))
|
135
|
+
options
|
136
|
+
end
|
137
|
+
store
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
# Return a searched and paginated data collection for the ExtJS Ext.data.GroupingStore() json
|
142
|
+
# You can pass options like:
|
143
|
+
#
|
144
|
+
# Examples
|
145
|
+
#
|
146
|
+
# store_data(params, :conditions => "found = 1")
|
147
|
+
# store_data(params, :include => :posts)
|
148
|
+
#
|
149
|
+
def store_data(params, options={})
|
150
|
+
@model.send(:with_scope, :find => options) do
|
151
|
+
collection = @model.search(params)
|
152
|
+
collection_count = collection.size
|
153
|
+
collection_paginated = collection.paginate(params)
|
154
|
+
{ :results => store_data_from(collection_paginated), :count => collection_count }
|
155
|
+
end
|
156
|
+
end
|
157
|
+
|
158
|
+
# Returns an object whose <tt>to_json</tt> evaluates to +code+. Use this to pass a literal JavaScript
|
159
|
+
# expression as an argument to another JavaScriptGenerator method.
|
160
|
+
#
|
161
|
+
def literal(code)
|
162
|
+
ActiveSupport::JSON::Variable.new(code.to_s)
|
163
|
+
end
|
164
|
+
alias_method :l, :literal
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Lipsiadmin#:nodoc:
|
2
|
+
module Controller#:nodoc:
|
3
|
+
# Base Backend Controller that define:
|
4
|
+
#
|
5
|
+
# layout false
|
6
|
+
# before_filter :backend_login_required
|
7
|
+
# helper Lipsiadmin::View::Helpers::BackendHelper
|
8
|
+
#
|
9
|
+
class Base < ActionController::Base
|
10
|
+
def self.inherited(subclass)#:nodoc:
|
11
|
+
super
|
12
|
+
subclass.layout false
|
13
|
+
subclass.before_filter :backend_login_required
|
14
|
+
subclass.helper Lipsiadmin::View::Helpers::BackendHelper
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
module Lipsiadmin
|
2
|
+
module Controller
|
3
|
+
# This module convert a string/controller to a pdf through Pd4ml java library (included in this plugin)
|
4
|
+
#
|
5
|
+
# For generate a pdf you can simply do
|
6
|
+
#
|
7
|
+
# script/generate pdf invoice
|
8
|
+
#
|
9
|
+
# then edit your template /app/views/pdf/invoice.html.haml
|
10
|
+
#
|
11
|
+
# Then in any of your controllers add some like this:
|
12
|
+
#
|
13
|
+
# def generate_pdf_invoice
|
14
|
+
# render_pdf :invoice, 'invoice_file.pdf'
|
15
|
+
# end
|
16
|
+
#
|
17
|
+
# Possible options are:
|
18
|
+
#
|
19
|
+
# * landescape, default it's false
|
20
|
+
# * send_data, default it's true
|
21
|
+
#
|
22
|
+
module PdfBuilder
|
23
|
+
include Lipsiadmin::Utils::HtmlEntities
|
24
|
+
|
25
|
+
# Path to the pd4ml jarfile
|
26
|
+
JARPATH = "../../resources"
|
27
|
+
|
28
|
+
# Convert a stream to pdf, the template must be located in app/view/pdf/yourtemplate.pdf.erb
|
29
|
+
def render_pdf(template, filename=nil, options={})
|
30
|
+
|
31
|
+
options[:landescape] ||= true
|
32
|
+
options[:send_data] ||= !filename.blank?
|
33
|
+
# encode the template
|
34
|
+
input = encode_entities(render(:template => "/pdf/#{template}.html.haml", :layout => "print"))
|
35
|
+
|
36
|
+
# search for stylesheet links and make their paths absolute.
|
37
|
+
input.gsub!('<link href="/javascripts', '<link href="' + RAILS_ROOT + '/public/javascripts')
|
38
|
+
input.gsub!('<link href="/stylesheets', '<link href="' + RAILS_ROOT + '/public/stylesheets')
|
39
|
+
|
40
|
+
# search for images src, append full-path.
|
41
|
+
input.gsub!('src="/', 'src="' + RAILS_ROOT + '/public/')
|
42
|
+
input.gsub!('url(','url('+RAILS_ROOT+'/public')
|
43
|
+
|
44
|
+
cmd = "java -Xmx512m -Djava.awt.headless=true -cp pd4ml.jar:.:#{File.dirname(__FILE__)}/#{JARPATH} Pd4Ruby '#{input}' 950 A4 #{options[:landescape]}"
|
45
|
+
|
46
|
+
output = %x[cd #{File.dirname(__FILE__)}/#{JARPATH} \n #{cmd}]
|
47
|
+
|
48
|
+
# raise error if process returned false (ie: a java error)
|
49
|
+
raise PdfError, "An unknonwn error occurred while generating pdf: cd #{File.dirname(__FILE__)}/#{JARPATH} #{cmd}" if $?.success? === false
|
50
|
+
|
51
|
+
# return raw pdf binary-stream
|
52
|
+
if options[:send_data]
|
53
|
+
pdf_options = { :filename => filename, :type => 'application/pdf' }
|
54
|
+
pdf_options[:disposition] = "inline" if Rails.env == "development"
|
55
|
+
send_data(output, pdf_options)
|
56
|
+
else
|
57
|
+
erase_results
|
58
|
+
output
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# Errors For PDF
|
63
|
+
class PdfError < StandardError#:nodoc:
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
module Lipsiadmin
|
2
|
+
module Controller
|
3
|
+
# This module are raised when an exception fire up in controllers.
|
4
|
+
#
|
5
|
+
# Now you can personalize exception and simplify the layout using templates in:
|
6
|
+
#
|
7
|
+
# app/views/exception
|
8
|
+
#
|
9
|
+
# when an exception is raised it try to send an email, and for send an email
|
10
|
+
# you need to configure in enviroment or in an initializer some like this:
|
11
|
+
#
|
12
|
+
# Examples:
|
13
|
+
#
|
14
|
+
# Lipsiadmin::Mailer::ExceptionNotifier.sender_address = %("Exception Notifier" <server1@lipsiasoft.com>)
|
15
|
+
# Lipsiadmin::Mailer::ExceptionNotifier.recipients_addresses = %(info@lipsiasoft.com)
|
16
|
+
# Lipsiadmin::Mailer::ExceptionNotifier.email_prefix = "[Your Project]"
|
17
|
+
#
|
18
|
+
module Rescue
|
19
|
+
|
20
|
+
def self.included(base)#:nodoc:
|
21
|
+
base.class_eval do
|
22
|
+
alias_method_chain :rescue_action_in_public, :notifier
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
# Overwrite to implement public exception handling (for requests answering false to <tt>local_request?</tt>). By
|
27
|
+
# default will call render_optional_error_file. Override this method to provide more user friendly error messages.
|
28
|
+
def rescue_action_in_public_with_notifier(exception) #:doc:
|
29
|
+
response_code = response_code_for_rescue(exception)
|
30
|
+
status = interpret_status(response_code)[0,3]
|
31
|
+
respond_to do |format|
|
32
|
+
# Personalize rescue rules for backend
|
33
|
+
if controller_path =~ /^backend\//
|
34
|
+
# Usually when we made a post we submit the form
|
35
|
+
# to a target iframe, so we need to respond to the parent.
|
36
|
+
if request.post?
|
37
|
+
responds_to_parent do
|
38
|
+
render :update do |page|
|
39
|
+
page.unmask
|
40
|
+
page.ext_alert I18n.t("lipsiadmin.exceptions.#{status}.title"), I18n.t("lipsiadmin.exceptions.#{status}.description")
|
41
|
+
end
|
42
|
+
end
|
43
|
+
else
|
44
|
+
# We can't use status, because Backend.app.load don't permit load 500, 404 pages
|
45
|
+
format.html { render :template => "/exceptions/#{status}" }
|
46
|
+
format.js do
|
47
|
+
render :update do |page|
|
48
|
+
page.unmask
|
49
|
+
page.ext_alert I18n.t("lipsiadmin.exceptions.#{status}.title"), I18n.t("lipsiadmin.exceptions.#{status}.description")
|
50
|
+
end
|
51
|
+
end
|
52
|
+
format.all { render :nothing => true, :status => status }
|
53
|
+
end
|
54
|
+
else
|
55
|
+
format.html { render :template => "/exceptions/#{status}", :status => status }
|
56
|
+
format.all { render :nothing => true, :status => status }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
rescue Exception => e
|
60
|
+
logger.error e.message
|
61
|
+
erase_results
|
62
|
+
rescue_action_in_public_without_notifier(exception)
|
63
|
+
ensure
|
64
|
+
if response_code != :not_found && Lipsiadmin::Mailer::ExceptionNotifier.send_mail
|
65
|
+
Lipsiadmin::Mailer::ExceptionNotifier.deliver_exception(exception, self, request)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
70
|
+
|
71
|
+
end
|
72
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
module Lipsiadmin
|
2
|
+
module Controller
|
3
|
+
# Executes the response body as JavaScript in the context of the parent window.
|
4
|
+
#
|
5
|
+
# Use this method of you are posting a form to a hidden IFRAME or if you would like
|
6
|
+
# to use IFRAME base RPC.
|
7
|
+
module RespondsToParent
|
8
|
+
# Render an action to parent
|
9
|
+
def render_to_parent(*options_for_render)
|
10
|
+
responds_to_parent do
|
11
|
+
# I don't use page.update for prevent dobule rendering
|
12
|
+
# and so we can save rendering time!
|
13
|
+
source = render_to_string(*options_for_render)
|
14
|
+
render :update do |page|
|
15
|
+
page.call "Backend.app.update", source
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
# Redirect parent to a new url
|
20
|
+
def redirect_parent_to(location)
|
21
|
+
responds_to_parent do
|
22
|
+
render :update do |page|
|
23
|
+
page.load location, true
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
def responds_to_parent(&block)
|
30
|
+
yield
|
31
|
+
# We're returning HTML instead of JS or XML now
|
32
|
+
response.headers['Content-Type'] = 'text/html; charset=UTF-8'
|
33
|
+
# Either pull out a redirect or the request body
|
34
|
+
script = location = erase_redirect_results ? "document.location.href = #{location.to_s.inspect}" : response.body
|
35
|
+
# Escape quotes, linebreaks and slashes, maintaining previously escaped slashes
|
36
|
+
# Suggestions for improvement?
|
37
|
+
script = (script || '').
|
38
|
+
gsub('\\', '\\\\\\').
|
39
|
+
gsub(/\r\n|\r|\n/, '\\n').
|
40
|
+
gsub(/['"]/, '\\\\\&').
|
41
|
+
gsub('</script>','</scr"+"ipt>')
|
42
|
+
# Clear out the previous render to prevent double render
|
43
|
+
erase_results
|
44
|
+
# Eval in parent scope and replace document location of this frame
|
45
|
+
# so back button doesn't replay action on targeted forms
|
46
|
+
# loc = document.location to be set after parent is updated for IE
|
47
|
+
# setTimeout - scope the execution in the windows parent for safari
|
48
|
+
# window.eval - legal eval for Opera
|
49
|
+
render :text => "<html><body><script type='text/javascript' charset='utf-8'>
|
50
|
+
window.parent.eval('#{script}');
|
51
|
+
document.location.replace('about:blank');
|
52
|
+
</script></body></html>"
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,351 @@
|
|
1
|
+
require 'tempfile'
|
2
|
+
require 'data_base/attachment/upfile'
|
3
|
+
require 'data_base/attachment/iostream'
|
4
|
+
require 'data_base/attachment/geometry'
|
5
|
+
require 'data_base/attachment/processor'
|
6
|
+
require 'data_base/attachment/thumbnail'
|
7
|
+
require 'data_base/attachment/storage'
|
8
|
+
require 'data_base/attachment/attach'
|
9
|
+
|
10
|
+
if defined? RAILS_ROOT
|
11
|
+
Dir.glob(File.join(File.expand_path(RAILS_ROOT), "lib", "attachment_processors", "*.rb")).each do |processor|
|
12
|
+
require processor
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Lipsiadmin
|
17
|
+
module DataBase
|
18
|
+
module Attachment
|
19
|
+
|
20
|
+
class << self#:nodoc:
|
21
|
+
def included(base) #:nodoc:
|
22
|
+
base.extend(ClassMethods)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
module ClassMethods
|
27
|
+
|
28
|
+
# Attach a single file/image to your model.
|
29
|
+
#
|
30
|
+
# Examples:
|
31
|
+
#
|
32
|
+
# has_one_attachment :image
|
33
|
+
# attachment_styles_for :image, :normal, "128x128!"
|
34
|
+
# validates_attachment_presence_for :image
|
35
|
+
# validates_attachment_size_for :image, :greater_than => 10.megabytes
|
36
|
+
# validates_attachment_content_type_for :image, "image/png"
|
37
|
+
#
|
38
|
+
# Then in your form (with multipart) you can simply add:
|
39
|
+
#
|
40
|
+
# =file_field :mymodel, :image_attributes
|
41
|
+
#
|
42
|
+
def has_one_attachment(name, options={})
|
43
|
+
options[:as] ||= :attacher
|
44
|
+
options[:class_name] ||= "Attachment"
|
45
|
+
has_one name, options
|
46
|
+
before_save "before_save_for_#{name}"
|
47
|
+
attr_accessor "#{name}_attributes"
|
48
|
+
|
49
|
+
write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil?
|
50
|
+
attachment_definitions[name] = {:validations => {}}.merge(reflections[name].class_name.constantize.attachment_definitions)
|
51
|
+
|
52
|
+
validates_each(name) do |record, attr, value|
|
53
|
+
attributes = record.send("#{name}_attributes")
|
54
|
+
attributes ||= {}
|
55
|
+
|
56
|
+
attributes.merge!(:attachment_definitions => record.class.attachment_definitions[name])
|
57
|
+
file_column = reflections[name].class_name.constantize.new(attributes)
|
58
|
+
unless file_column.valid?
|
59
|
+
file_column.errors.each do |error, message|
|
60
|
+
record.errors.add(name, message) if message
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
|
65
|
+
define_method "before_save_for_#{name}" do
|
66
|
+
attributes = send("#{name}_attributes")
|
67
|
+
attributes ||= {}
|
68
|
+
|
69
|
+
return if attributes[:file].blank?
|
70
|
+
|
71
|
+
attributes.merge!(:attachment_definitions => self.class.attachment_definitions[name])
|
72
|
+
|
73
|
+
if file_column = self.send(name)
|
74
|
+
file_column.update_attributes(attributes)
|
75
|
+
else
|
76
|
+
self.send(name).build(attributes)
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
# Attach a many files/images to your model.
|
83
|
+
#
|
84
|
+
# Examples:
|
85
|
+
#
|
86
|
+
# has_one_attachment :images
|
87
|
+
# attachment_styles_for :images, :normal, "128x128!"
|
88
|
+
# validates_attachment_presence_for :images
|
89
|
+
# validates_attachment_size_for :images, :greater_than => 10.megabytes
|
90
|
+
# validates_attachment_content_type_for :images, "image/png"
|
91
|
+
#
|
92
|
+
# Then in your form (with multipart) you can simply add:
|
93
|
+
#
|
94
|
+
# =fields_for "yourmodel[attachments_attributes][]", @yourmodel.images.build do |image|
|
95
|
+
# =image.file_field :file
|
96
|
+
#
|
97
|
+
def has_many_attachments(name, options = {})
|
98
|
+
options[:as] ||= :attacher
|
99
|
+
options[:class_name] ||= "Attachment"
|
100
|
+
|
101
|
+
has_many name, options
|
102
|
+
before_save "before_save_for_#{name}"
|
103
|
+
attr_accessor "#{name}_attributes"
|
104
|
+
|
105
|
+
write_inheritable_attribute(:attachment_definitions, {}) if attachment_definitions.nil?
|
106
|
+
attachment_definitions[name] = {:validations => {}}.merge(reflections[name].class_name.constantize.attachment_definitions)
|
107
|
+
|
108
|
+
validates_each(name) do |record, attr, value|
|
109
|
+
attributes = record.send("#{name}_attributes")
|
110
|
+
attributes ||= {}
|
111
|
+
|
112
|
+
file_column = nil
|
113
|
+
for attribute in attributes
|
114
|
+
attribute.merge!(:attachment_definitions => record.class.attachment_definitions[name])
|
115
|
+
file_column = reflections[name].class_name.constantize.new(attribute)
|
116
|
+
unless file_column.valid?
|
117
|
+
file_column.errors.each do |error, message|
|
118
|
+
record.errors.add(name, message) if message
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
define_method "before_save_for_#{name}" do
|
125
|
+
attributes = send("#{name}_attributes")
|
126
|
+
attributes ||= {}
|
127
|
+
|
128
|
+
file_column = nil
|
129
|
+
|
130
|
+
for attribute in attributes
|
131
|
+
next if attribute["file"].blank?
|
132
|
+
attribute.merge!(:attachment_definitions => self.class.attachment_definitions[name])
|
133
|
+
self.send(name).build(attribute)
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
138
|
+
|
139
|
+
# The full URL of where the attachment is publically accessible. This can just
|
140
|
+
# as easily point to a directory served directly through Apache as it can to an action
|
141
|
+
# that can control permissions. You can specify the full domain and path, but usually
|
142
|
+
# just an absolute path is sufficient. The leading slash *must* be included manually for
|
143
|
+
# absolute paths. The default value is
|
144
|
+
# "/uploads/:id_:attachment_:style_:basename.:extension". See
|
145
|
+
# Lipsiadmin::Attachment::Attach#interpolate for more information on variable interpolaton.
|
146
|
+
# :url => "/:class/:attachment/:id/:style_:basename.:extension"
|
147
|
+
# :url => "http://some.other.host/stuff/:class/:id_:extension"
|
148
|
+
def attachment_url_for(name, url)
|
149
|
+
attachment_definitions[name][:url] = url
|
150
|
+
end
|
151
|
+
|
152
|
+
# The URL that will be returned if there is no attachment assigned.
|
153
|
+
# This field is interpolated just as the url is. The default value is
|
154
|
+
# "/images/backend/no-image.png"
|
155
|
+
# has_one_attached_file :avatar
|
156
|
+
# attachment_default_url :avatar, "/images/backend/no-image.png"
|
157
|
+
# User.new.avatar.url(:small) # => "/images/backend/no-image.png"
|
158
|
+
def attachment_default_url_for(name, url)
|
159
|
+
attachment_definitions[name][:default_url]
|
160
|
+
end
|
161
|
+
|
162
|
+
# The path were the attachment are stored.
|
163
|
+
# The default value is
|
164
|
+
# :rails_root/public/uploads/:id_:attachment_:style_:basename.:extension
|
165
|
+
# This value must be in consistency with <tt>url</tt>
|
166
|
+
def attachment_path_for(name, path)
|
167
|
+
attachment_definitions[name][:path] = path
|
168
|
+
end
|
169
|
+
|
170
|
+
# A hash of thumbnail styles and their geometries. You can find more about
|
171
|
+
# geometry strings at the ImageMagick website
|
172
|
+
# (http://www.imagemagick.org/script/command-line-options.php#resize). Attachment
|
173
|
+
# also adds the "#" option (e.g. "50x50#"), which will resize the image to fit maximally
|
174
|
+
# inside the dimensions and then crop the rest off (weighted at the center). The
|
175
|
+
# default value is to generate no thumbnails.
|
176
|
+
def attachment_styles_for(name, style_name, styles)
|
177
|
+
attachment_definitions[name][:styles] = { style_name => styles }
|
178
|
+
end
|
179
|
+
|
180
|
+
# The thumbnail style that will be used by default URLs.
|
181
|
+
# Defaults to +original+.
|
182
|
+
# attachment_styles :avatar, :normal, "100x100#"
|
183
|
+
# attachment_default_style :normal
|
184
|
+
# user.avatar.url # => "/avatars/23/normal_me.png"
|
185
|
+
def attachment_default_style_for(name, default_style)
|
186
|
+
attachment_definitions[name][:default_style] = default_style
|
187
|
+
end
|
188
|
+
|
189
|
+
# Will raise an error if Attachment cannot post_process an uploaded file due
|
190
|
+
# to a command line error. This will override the global setting for this attachment.
|
191
|
+
# Defaults to false.
|
192
|
+
def attachment_whiny_for(name, whiny_thumbnails)
|
193
|
+
attachment_definitions[name][:whiny_thumbnails] = whiny_thumbnails
|
194
|
+
end
|
195
|
+
|
196
|
+
# Chooses the storage backend where the files will be stored. The current
|
197
|
+
# choices are :filesystem and :s3. The default is :filesystem. Make sure you read the
|
198
|
+
# documentation for Lipsiadmin::Attachment::Storage::Filesystem and Lipsiadmin::Attachment::Storage::S3
|
199
|
+
# for backend-specific options.
|
200
|
+
def attachment_storage_for(name, storage)
|
201
|
+
attachment_definitions[name][:storage] = storage
|
202
|
+
end
|
203
|
+
|
204
|
+
# When creating thumbnails, use this free-form options
|
205
|
+
# field to pass in various convert command options. Typical options are "-strip" to
|
206
|
+
# remove all Exif data from the image (save space for thumbnails and avatars) or
|
207
|
+
# "-depth 8" to specify the bit depth of the resulting conversion. See ImageMagick
|
208
|
+
# convert documentation for more options: (http://www.imagemagick.org/script/convert.php)
|
209
|
+
# Note that this option takes a hash of options, each of which correspond to the style
|
210
|
+
# of thumbnail being generated. You can also specify :all as a key, which will apply
|
211
|
+
# to all of the thumbnails being generated. If you specify options for the :original,
|
212
|
+
# it would be best if you did not specify destructive options, as the intent of keeping
|
213
|
+
# the original around is to regenerate all the thumbnails when requirements change.
|
214
|
+
# attachment_styles :avatar, :large, "300x300"
|
215
|
+
# attachment_styles :avatar, :negative, "100x100"
|
216
|
+
# attachment_convert_options :avatar, :all, "-strip"
|
217
|
+
# attachment_convert_options :avatar, :negative, "-negate"
|
218
|
+
def attachment_convert_options_for(name, convert_name, convert_options)
|
219
|
+
attachment_definitions[name][:convert_options] = { convert_name => convert_options}
|
220
|
+
end
|
221
|
+
|
222
|
+
# When processing, if the spawn plugin is installed, processing can be done in
|
223
|
+
# a background fork or thread if desired.
|
224
|
+
def attachment_background_for(name, background)
|
225
|
+
attachment_definitions[name][:background] = background
|
226
|
+
end
|
227
|
+
|
228
|
+
# Attachment supports an extendible selection of post-processors. When you define
|
229
|
+
# a set of styles for an attachment, by default it is expected that those
|
230
|
+
# "styles" are actually "thumbnails". However, you can do more than just
|
231
|
+
# thumbnail images. By defining a subclass of Lipsiadmin::Attachment::Processor, you can
|
232
|
+
# perform any processing you want on the files that are attached. Any file in
|
233
|
+
# your Rails app's lib/attachment_processors directory is automatically loaded by
|
234
|
+
# Attachment, allowing you to easily define custom processors. You can specify a
|
235
|
+
# processor with the :processors option to has_attached_file:
|
236
|
+
#
|
237
|
+
# attachment_styles :avatar, :text, { :quality => :better }
|
238
|
+
# attachment_processors :avatar, :ocr
|
239
|
+
#
|
240
|
+
# This would load the hypothetical class Lipsiadmin::Ocr, which would have the
|
241
|
+
# hash "{ :quality => :better }" passed to it along with the uploaded file. For
|
242
|
+
# more information about defining processors, see Lipsiadmin::Attachment::Processor.
|
243
|
+
#
|
244
|
+
# The default processor is Lipsiadmin::Attachment::Thumbnail. For backwards compatability
|
245
|
+
# reasons, you can pass a single geometry string or an array containing a
|
246
|
+
# geometry and a format, which the file will be converted to, like so:
|
247
|
+
#
|
248
|
+
# attachment_styles :avatar, :thumb, ["32x32#", :png]
|
249
|
+
#
|
250
|
+
# This will convert the "thumb" style to a 32x32 square in png format, regardless
|
251
|
+
# of what was uploaded. If the format is not specified, it is kept the same (i.e.
|
252
|
+
# jpgs will remain jpgs).
|
253
|
+
#
|
254
|
+
# Multiple processors can be specified, and they will be invoked in the order
|
255
|
+
# they are defined in the :processors array. Each successive processor will
|
256
|
+
# be given the result of the previous processor's execution. All processors will
|
257
|
+
# receive the same parameters, which are what you define in the :styles hash.
|
258
|
+
# For example, assuming we had this definition:
|
259
|
+
#
|
260
|
+
# attachment_styles :avatar, :text, { :quality => :better }
|
261
|
+
# attachment_processors :avatar, :rotator
|
262
|
+
# attachment_processors :avatar, :ocr
|
263
|
+
#
|
264
|
+
# then both the :rotator processor and the :ocr processor would receive the
|
265
|
+
# options "{ :quality => :better }". This parameter may not mean anything to one
|
266
|
+
# or more or the processors, and they are free to ignore it.
|
267
|
+
def attachment_processors_for(name, processor_name, processors)
|
268
|
+
attachment_definitions[name][:processors] = { processor_name => processor_processors }
|
269
|
+
end
|
270
|
+
|
271
|
+
# Places ActiveRecord-style validations on the size of the file assigned. The
|
272
|
+
# possible options are:
|
273
|
+
# * +in+: a Range of bytes (i.e. +1..1.megabyte+),
|
274
|
+
# * +less_than+: equivalent to :in => 0..options[:less_than]
|
275
|
+
# * +greater_than+: equivalent to :in => options[:greater_than]..Infinity
|
276
|
+
# * +message+: error message to display, use :min and :max as replacements
|
277
|
+
def validates_attachment_size_for(name, options = {})
|
278
|
+
min = options[:greater_than] || (options[:in] && options[:in].first) || 0
|
279
|
+
max = options[:less_than] || (options[:in] && options[:in].last) || (1.0/0)
|
280
|
+
range = (min..max)
|
281
|
+
helper = ActionController::Base.helpers
|
282
|
+
|
283
|
+
if options[:message].blank?
|
284
|
+
message = ""
|
285
|
+
message << I18n.t("activerecord.errors.messages.greater_than", :count => helper.number_to_human_size(min)) if min > 0
|
286
|
+
message << " " + I18n.t("activerecord.errors.messages.less_than", :count => helper.number_to_human_size(max)) if max.to_f.infinite? != 1
|
287
|
+
else
|
288
|
+
message = options[:message]
|
289
|
+
end
|
290
|
+
|
291
|
+
attachment_definitions[name][:validations][:size] = lambda do |attachment, instance|
|
292
|
+
if attachment.exist? && !range.include?(attachment.size.to_i)
|
293
|
+
message
|
294
|
+
end
|
295
|
+
end
|
296
|
+
end
|
297
|
+
|
298
|
+
# Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true.
|
299
|
+
def validates_attachment_thumbnails_for(name, options = {})
|
300
|
+
attachment_definitions[name][:whiny_thumbnails] = true
|
301
|
+
end
|
302
|
+
|
303
|
+
# Places ActiveRecord-style validations on the presence of a file.
|
304
|
+
def validates_attachment_presence_for(name, options = {})
|
305
|
+
message = options[:message] || I18n.t("activerecord.errors.messages.blank")
|
306
|
+
attachment_definitions[name][:validations][:presence] = lambda do |attachment, instance|
|
307
|
+
message unless attachment.exist?
|
308
|
+
end
|
309
|
+
end
|
310
|
+
|
311
|
+
# Places ActiveRecord-style validations on the content type of the file
|
312
|
+
# assigned. The possible options are:
|
313
|
+
# * +content_type+: Allowed content types. Can be a single content type
|
314
|
+
# or an array. Each type can be a String or a Regexp. It should be
|
315
|
+
# noted that Internet Explorer upload files with content_types that you
|
316
|
+
# may not expect. For example, JPEG images are given image/pjpeg and
|
317
|
+
# PNGs are image/x-png, so keep that in mind when determining how you
|
318
|
+
# match. Allows all by default.
|
319
|
+
# * +message+: The message to display when the uploaded file has an invalid
|
320
|
+
# content type.
|
321
|
+
def validates_attachment_content_type_for(name, *args)
|
322
|
+
options = {}
|
323
|
+
valid_types = []
|
324
|
+
args.each do |variable|
|
325
|
+
case variable
|
326
|
+
when String then valid_types << variable
|
327
|
+
when Hash then options.merge!(variable)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
attachment_definitions[name][:validations][:content_type] = lambda do |attachment, instance|
|
331
|
+
unless attachment.original_filename.blank?
|
332
|
+
content_type = attachment.instance_read(:content_type)
|
333
|
+
unless valid_types.any?{ |t| t === content_type }
|
334
|
+
options[:message] || I18n.t("activerecord.errors.messages.content_type")
|
335
|
+
end
|
336
|
+
end
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
# Returns the attachment definitions defined by each call to
|
341
|
+
# has_attached_file.
|
342
|
+
def attachment_definitions
|
343
|
+
read_inheritable_attribute(:attachment_definitions)
|
344
|
+
end
|
345
|
+
|
346
|
+
end
|
347
|
+
|
348
|
+
end
|
349
|
+
|
350
|
+
end
|
351
|
+
end
|