padrino-admin 0.8.5 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +40 -84
- data/VERSION +1 -1
- data/lib/padrino-admin.rb +3 -20
- data/lib/padrino-admin/access_control.rb +78 -326
- data/lib/padrino-admin/generators/actions.rb +6 -26
- data/lib/padrino-admin/generators/admin_app.rb +40 -11
- data/lib/padrino-admin/generators/admin_page.rb +11 -17
- data/lib/padrino-admin/generators/orm.rb +85 -0
- data/lib/padrino-admin/generators/templates/account/activerecord.rb.tt +43 -0
- data/lib/padrino-admin/generators/templates/account/datamapper.rb.tt +54 -0
- data/lib/padrino-admin/generators/templates/{page/db → account}/seeds.rb.tt +5 -6
- data/lib/padrino-admin/generators/{app/app.rb.tt → templates/app/app.rb} +2 -10
- data/lib/padrino-admin/generators/templates/app/controllers/base.rb +7 -0
- data/lib/padrino-admin/generators/{app → templates/app}/controllers/sessions.rb +6 -6
- data/lib/padrino-admin/generators/templates/assets/stylesheets/base.css +370 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/amro/style.css +364 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec-green/style.css +290 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/bec/style.css +301 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/blue/style.css +287 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/default/style.css +373 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/djime-cerulean/style.css +305 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/kathleene/style.css +279 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/olive/style.css +345 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/orange/style.css +269 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/reidb-greenish/style.css +302 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/ruby/style.css +281 -0
- data/lib/padrino-admin/generators/templates/assets/stylesheets/themes/warehouse/style.css +391 -0
- data/lib/padrino-admin/generators/templates/erb/app/base/_sidebar.erb.tt +13 -0
- data/lib/padrino-admin/generators/templates/erb/app/base/index.erb.tt +17 -0
- data/lib/padrino-admin/generators/templates/erb/app/layouts/application.erb.tt +44 -0
- data/lib/padrino-admin/generators/templates/erb/app/sessions/new.erb.tt +46 -0
- data/lib/padrino-admin/generators/templates/erb/page/_form.erb.tt +11 -0
- data/lib/padrino-admin/generators/templates/erb/page/edit.erb.tt +18 -0
- data/lib/padrino-admin/generators/templates/erb/page/index.erb.tt +36 -0
- data/lib/padrino-admin/generators/templates/erb/page/new.erb.tt +17 -0
- data/lib/padrino-admin/generators/templates/page/controller.rb.tt +32 -22
- data/lib/padrino-admin/helpers/authentication_helpers.rb +8 -9
- data/lib/padrino-admin/helpers/view_helpers.rb +20 -338
- data/lib/padrino-admin/locale/admin/de.yml +15 -49
- data/lib/padrino-admin/locale/admin/en.yml +12 -50
- data/lib/padrino-admin/locale/admin/it.yml +15 -50
- data/padrino-admin.gemspec +40 -321
- data/test/fixtures/data_mapper.rb +56 -7
- data/test/generators/test_admin_app_generator.rb +17 -16
- data/test/generators/test_admin_page_generator.rb +12 -16
- data/test/test_admin_application.rb +193 -12
- metadata +33 -314
- data/lib/padrino-admin/column_store.rb +0 -156
- data/lib/padrino-admin/config.rb +0 -36
- data/lib/padrino-admin/generators/admin_uploader.rb +0 -88
- data/lib/padrino-admin/generators/app/controllers/accounts.rb +0 -37
- data/lib/padrino-admin/generators/app/controllers/base.rb +0 -11
- data/lib/padrino-admin/generators/app/controllers/javascripts.rb +0 -10
- data/lib/padrino-admin/generators/app/views/accounts/_form.haml +0 -24
- data/lib/padrino-admin/generators/app/views/accounts/edit.haml +0 -3
- data/lib/padrino-admin/generators/app/views/accounts/grid.js.erb +0 -9
- data/lib/padrino-admin/generators/app/views/accounts/new.haml +0 -3
- data/lib/padrino-admin/generators/app/views/accounts/store.jml +0 -7
- data/lib/padrino-admin/generators/app/views/base/dashboard.haml +0 -3
- data/lib/padrino-admin/generators/app/views/base/index.haml +0 -19
- data/lib/padrino-admin/generators/app/views/javascripts/admin.js.erb +0 -490
- data/lib/padrino-admin/generators/app/views/javascripts/locale.js.erb +0 -135
- data/lib/padrino-admin/generators/app/views/sessions/new.haml +0 -26
- data/lib/padrino-admin/generators/assets/flash/charts.swf +0 -0
- data/lib/padrino-admin/generators/assets/flash/clippy.swf +0 -0
- data/lib/padrino-admin/generators/assets/flash/expressinstall.swf +0 -0
- data/lib/padrino-admin/generators/assets/flash/swfupload.swf +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/back.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/background.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-content.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-hd-slate.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-hd.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-intro.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-login.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-menu-slate.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg-menu.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/bg.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/btn-login.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/cancel.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/categories.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/close.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/delete.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/download.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/duplicate.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/edit.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/export.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/hd-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/image.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/loader.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/logo-loader.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/logo-small.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/new.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/no-image.png +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/preview.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/print.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/save.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/support.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/admin/up.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/corners-blue.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/corners.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/l-blue.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/l.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/r-blue.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/r.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/tb-blue.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/box/tb.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/arrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/btn.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/group-cs.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/group-lr.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/group-tb.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-b-noline.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-b.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-bo.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-noline.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow-o.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/button/s-arrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/dd/drop-add.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/dd/drop-no.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/dd/drop-yes.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/editor/tb-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/checkbox.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/clear-trigger.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/clear-trigger.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/date-trigger.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/date-trigger.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/error-tip-corners.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/exclamation.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/radio.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/search-trigger.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/search-trigger.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/text-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/trigger-tpl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/trigger.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/form/trigger.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/gradient-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/Thumbs.db +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/arrow-left-white.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/arrow-right-white.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/col-move-bottom.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/col-move-top.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/columns.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/dirty.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/done.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/drop-no.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/drop-yes.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/footer-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-blue-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-blue-split.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-hrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-split.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid-vista-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-hd-btn.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-hrow-over.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-hrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-special-col-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/grid3-special-col-sel-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/group-by.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/group-expand-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hd-pop.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-asc.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-desc.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-lock.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-lock.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-unlock.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/hmenu-unlock.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/invalid_line.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/mso-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/nowait.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-first-disabled.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-first.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-last-disabled.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-last.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-next-disabled.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-next.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-prev-disabled.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/page-prev.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/pick-button.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/refresh.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-check-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-expand-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-over.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/row-sel.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/sort-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/sort_asc.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/sort_desc.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/grid/wait.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/collapse.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/expand.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/gradient-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-bottom.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-left.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-right.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/mini-top.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/ns-collapse.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/ns-expand.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/panel-close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/panel-title-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/panel-title-light-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/stick.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/stuck.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/tab-close-on.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/layout/tab-close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/checked.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/group-checked.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/item-over.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/menu-parent.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/menu.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/menu/unchecked.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/corners-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/left-right.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/light-hd.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/tool-sprite-tpl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/tool-sprites.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/tools-sprites-trans.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/top-bottom.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/top-bottom.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/white-corners-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/white-left-right.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/panel/white-top-bottom.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/progress/progress-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/qtip/bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/qtip/close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/qtip/tip-anchor-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/qtip/tip-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/s.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shadow-c.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shadow-lr.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shadow.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/blue-loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/calendar.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/glass-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/hd-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/large-loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/left-btn.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/loading-balls.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/right-btn.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/shared/warning.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/e-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/e-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/ne-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/ne-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/nw-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/nw-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/s-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/s-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/se-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/se-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/square.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/sw-handle-dark.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/sizer/sw-handle.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-bg.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-thumb.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-v-bg.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/slider/slider-v-thumb.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/scroll-left.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/scroll-right.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/scroller-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-inactive-left-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-inactive-right-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-left-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-btm-right-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-close.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-strip-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-strip-bg.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tab-strip-btm-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tabs/tabs-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/btn-arrow-light.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/btn-arrow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/btn-over-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/gray-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/more.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-bg.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-btn-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-xl-btn-sprite.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/toolbar/tb-xl-sep.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/arrows.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-add.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-between.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-no.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-over.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-under.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/drop-yes.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-minus-nl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-minus.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-plus-nl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end-plus.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-end.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-line.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-minus-nl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-minus.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-plus-nl.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow-plus.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/elbow.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/folder-open.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/folder.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/leaf.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/loading.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/tree/s.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-error.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-info.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-question.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/icon-warning.gif +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/left-corners.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/left-corners.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/left-right.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/left-right.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/right-corners.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/right-corners.psd +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/top-bottom.png +0 -0
- data/lib/padrino-admin/generators/assets/images/ext/default/window/top-bottom.psd +0 -0
- data/lib/padrino-admin/generators/assets/javascripts/controls.js +0 -3
- data/lib/padrino-admin/generators/assets/javascripts/dragdrop.js +0 -3
- data/lib/padrino-admin/generators/assets/javascripts/effects.js +0 -4
- data/lib/padrino-admin/generators/assets/javascripts/ext.js +0 -29
- data/lib/padrino-admin/generators/assets/javascripts/prototype.js +0 -14
- data/lib/padrino-admin/generators/assets/javascripts/swfupload.js +0 -4
- data/lib/padrino-admin/generators/assets/stylesheets/admin.css +0 -60
- data/lib/padrino-admin/generators/assets/stylesheets/ext.css +0 -1543
- data/lib/padrino-admin/generators/assets/stylesheets/login.css +0 -17
- data/lib/padrino-admin/generators/assets/stylesheets/standard.css +0 -62
- data/lib/padrino-admin/generators/templates/page/views/_form.haml.tt +0 -9
- data/lib/padrino-admin/generators/templates/page/views/edit.haml.tt +0 -3
- data/lib/padrino-admin/generators/templates/page/views/grid.js.erb.tt +0 -9
- data/lib/padrino-admin/generators/templates/page/views/new.haml.tt +0 -3
- data/lib/padrino-admin/generators/templates/page/views/store.jml.tt +0 -6
- data/lib/padrino-admin/generators/templates/uploader/controller.rb +0 -24
- data/lib/padrino-admin/generators/templates/uploader/lib/uploader.rb +0 -66
- data/lib/padrino-admin/generators/templates/uploader/views/grid.js.erb +0 -57
- data/lib/padrino-admin/generators/templates/uploader/views/store.jml +0 -10
- data/lib/padrino-admin/locale/extjs/de.yml +0 -147
- data/lib/padrino-admin/locale/extjs/en.yml +0 -147
- data/lib/padrino-admin/locale/extjs/it.yml +0 -147
- data/lib/padrino-admin/orm.rb +0 -48
- data/lib/padrino-admin/orm/abstract.rb +0 -95
- data/lib/padrino-admin/orm/activerecord.rb +0 -144
- data/lib/padrino-admin/orm/datamapper.rb +0 -229
- data/lib/padrino-admin/orm/mongomapper.rb +0 -65
- data/lib/padrino-admin/utils/literal.rb +0 -13
- data/test/fixtures/active_record.rb +0 -29
- data/test/fixtures/mongo_mapper.rb +0 -12
- data/test/fixtures/test_column_store.jml +0 -11
- data/test/generators/test_admin_uploader_generator.rb +0 -56
- data/test/test_access_control.rb +0 -99
- data/test/test_active_record.rb +0 -96
- data/test/test_column_store.rb +0 -87
- data/test/test_config.rb +0 -13
- data/test/test_data_mapper.rb +0 -114
- data/test/test_mongo_mapper.rb +0 -30
@@ -8,6 +8,7 @@ module Padrino
|
|
8
8
|
def orm
|
9
9
|
fetch_component_choice(:orm).to_sym rescue :datamapper
|
10
10
|
end
|
11
|
+
alias :adapter :orm
|
11
12
|
|
12
13
|
##
|
13
14
|
# Tell us for now wich orm we support
|
@@ -19,16 +20,9 @@ module Padrino
|
|
19
20
|
##
|
20
21
|
# Add access_control permission in our app.rb
|
21
22
|
#
|
22
|
-
def
|
23
|
-
permission = indent(6,
|
24
|
-
inject_into_file destination_root("
|
25
|
-
end
|
26
|
-
|
27
|
-
##
|
28
|
-
# Add a simple permission (allow/deny) to our app.rb
|
29
|
-
#
|
30
|
-
def add_permission(admin, permission)
|
31
|
-
inject_into_file destination_root("#{admin}/app.rb"), indent(6, "\n#{permission}\n"), :after => "access_control.roles_for :admin do |role, account|\n"
|
23
|
+
def add_project_module(controller)
|
24
|
+
permission = indent(6, "role.project_module :#{controller}, \"/#{controller}\"\n")
|
25
|
+
inject_into_file destination_root("/admin/app.rb"), permission, :after => "access_control.roles_for :admin do |role, account|\n"
|
32
26
|
end
|
33
27
|
|
34
28
|
##
|
@@ -38,21 +32,7 @@ module Padrino
|
|
38
32
|
indent = ' ' * count
|
39
33
|
content.lines.map { |line| line != "\n" ? indent+line : "\n" }.join
|
40
34
|
end
|
41
|
-
|
42
|
-
|
43
|
-
##
|
44
|
-
# For access control permissions
|
45
|
-
#
|
46
|
-
def access_control(controller)
|
47
|
-
(<<-RUBY).gsub(/ {14}/,'')
|
48
|
-
|
49
|
-
role.project_module :#{controller} do |project|
|
50
|
-
project.menu :list, "/admin/#{controller}.js"
|
51
|
-
project.menu :new, "/admin/#{controller}/new"
|
52
|
-
end
|
53
|
-
RUBY
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
35
|
+
end # Actions
|
36
|
+
end # Admin
|
57
37
|
end # Generators
|
58
38
|
end # Padrino
|
@@ -6,9 +6,10 @@ module Padrino
|
|
6
6
|
# Add this generator to our padrino-gen
|
7
7
|
Padrino::Generators.add_generator(:admin, self)
|
8
8
|
|
9
|
-
# Define the source template root
|
9
|
+
# Define the source template root and themes
|
10
10
|
def self.source_root; File.expand_path(File.dirname(__FILE__)); end
|
11
11
|
def self.banner; "padrino-gen admin"; end
|
12
|
+
def self.themes; Dir[File.dirname(__FILE__) + "/templates/assets/stylesheets/themes/*"].map { |t| File.basename(t) }; end
|
12
13
|
|
13
14
|
# Include related modules
|
14
15
|
include Thor::Actions
|
@@ -20,6 +21,8 @@ module Padrino
|
|
20
21
|
class_option :skip_migration, :aliases => "-s", :default => false, :type => :boolean
|
21
22
|
class_option :root, :desc => "The root destination", :aliases => '-r', :default => ".", :type => :string
|
22
23
|
class_option :destroy, :aliases => '-d', :default => false, :type => :boolean
|
24
|
+
class_option :name, :desc => "The app name", :aliases => '-a', :default => "Padrino Admin", :type => :string
|
25
|
+
class_option :theme, :desc => "Your admin theme: (#{self.themes.join(", ")})", :default => "default", :type => :string
|
23
26
|
|
24
27
|
# Copies over the Padrino base admin application
|
25
28
|
def create_admin
|
@@ -31,18 +34,46 @@ module Padrino
|
|
31
34
|
raise SystemExit
|
32
35
|
end
|
33
36
|
|
37
|
+
unless self.class.themes.include?(options[:theme])
|
38
|
+
say "<= You need to choose a theme from: #{self.class.themes.join(", ")}"
|
39
|
+
raise SystemExit
|
40
|
+
end
|
41
|
+
|
34
42
|
self.behavior = :revoke if options[:destroy]
|
35
|
-
|
36
|
-
directory
|
43
|
+
|
44
|
+
directory "templates/app", destination_root("admin")
|
45
|
+
directory "templates/assets", destination_root("public", "admin")
|
37
46
|
|
38
47
|
Padrino::Generators::Model.dup.start([
|
39
48
|
"account", "name:string", "surname:string", "email:string", "crypted_password:string", "salt:string", "role:string",
|
40
49
|
"-r=#{options[:root]}", "-s=#{options[:skip_migration]}", "-d=#{options[:destroy]}"
|
41
50
|
])
|
42
51
|
|
43
|
-
|
44
|
-
|
52
|
+
column = Struct.new(:name, :type)
|
53
|
+
columns = [:id, :name, :surname, :email].map { |col| column.new(col) }
|
54
|
+
column_fields = [
|
55
|
+
{ :name => :name, :field_type => :text_field },
|
56
|
+
{ :name => :surname, :field_type => :text_field },
|
57
|
+
{ :name => :email, :field_type => :text_field },
|
58
|
+
{ :name => :password, :field_type => :text_field },
|
59
|
+
{ :name => :password_confirmation, :field_type => :text_field },
|
60
|
+
{ :name => :role, :field_type => :text_field }
|
61
|
+
]
|
62
|
+
|
63
|
+
admin_app = Padrino::Generators::AdminPage.new(["account"], :root => options[:root])
|
64
|
+
admin_app.orm = Padrino::Admin::Generators::Orm.new(:account, orm, columns, column_fields)
|
65
|
+
admin_app.invoke
|
66
|
+
|
67
|
+
template "templates/account/#{orm}.rb.tt", destination_root("app", "models", "account.rb"), :force => true
|
68
|
+
template "templates/account/seeds.rb.tt", destination_root("db/seeds.rb")
|
69
|
+
template "templates/erb/app/base/_sidebar.erb.tt", destination_root("admin/views/base/_sidebar.erb")
|
70
|
+
template "templates/erb/app/base/index.erb.tt", destination_root("admin/views/base/index.erb")
|
71
|
+
template "templates/erb/app/layouts/application.erb.tt", destination_root("admin/views/layouts/application.erb")
|
72
|
+
template "templates/erb/app/sessions/new.erb.tt", destination_root("admin/views/sessions/new.erb")
|
73
|
+
|
74
|
+
add_project_module :accounts
|
45
75
|
append_file destination_root("config/apps.rb"), "\nPadrino.mount(\"Admin\").to(\"/admin\")"
|
76
|
+
gsub_file destination_root("admin/views/accounts/_form.erb"), "f.text_field :role, :class => :text_field", "f.select :role, :options => access_control.roles"
|
46
77
|
|
47
78
|
return if self.behavior == :revoke
|
48
79
|
say (<<-TEXT).gsub(/ {10}/,'')
|
@@ -51,7 +82,7 @@ module Padrino
|
|
51
82
|
Admin has been successfully installed, now follow this steps:
|
52
83
|
=================================================================
|
53
84
|
1) Run migrations
|
54
|
-
2)
|
85
|
+
2) Run padrino rake seed
|
55
86
|
=================================================================
|
56
87
|
|
57
88
|
TEXT
|
@@ -59,8 +90,6 @@ module Padrino
|
|
59
90
|
say "You are not at the root of a Padrino application! (config/boot.rb not found)" and exit unless in_app_root?
|
60
91
|
end
|
61
92
|
end
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
end
|
66
|
-
end
|
93
|
+
end # AdminApp
|
94
|
+
end # Generators
|
95
|
+
end # Padrino
|
@@ -2,6 +2,7 @@ module Padrino
|
|
2
2
|
module Generators
|
3
3
|
|
4
4
|
class AdminPage < Thor::Group
|
5
|
+
attr_accessor :orm
|
5
6
|
|
6
7
|
# Add this generator to our padrino-gen
|
7
8
|
Padrino::Generators.add_generator(:admin_page, self)
|
@@ -28,23 +29,16 @@ module Padrino
|
|
28
29
|
def create_controller
|
29
30
|
self.destination_root = options[:root]
|
30
31
|
if in_app_root?
|
31
|
-
@
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
template "templates/page/
|
38
|
-
template "templates/page/
|
39
|
-
|
40
|
-
|
41
|
-
template "templates/page/views/new.haml.tt", destination_root("/admin/views/#{@model_plural}/new.haml")
|
42
|
-
template "templates/page/views/store.jml.tt", destination_root("/admin/views/#{@model_plural}/store.jml")
|
43
|
-
|
44
|
-
add_access_control_permission("/admin", @model_plural)
|
45
|
-
# TODO: figure how to manage tests for sub apps.
|
46
|
-
# include_component_module_for(:test) if test?
|
47
|
-
# generate_controller_test(model.downcase.pluralize)
|
32
|
+
@orm ||= Padrino::Admin::Generators::Orm.new(model, adapter)
|
33
|
+
self.behavior = :revoke if options[:destroy]
|
34
|
+
|
35
|
+
template "templates/page/controller.rb.tt", destination_root("/admin/controllers/#{@orm.name_plural}.rb")
|
36
|
+
template "templates/erb/page/_form.erb.tt", destination_root("/admin/views/#{@orm.name_plural}/_form.erb")
|
37
|
+
template "templates/erb/page/edit.erb.tt", destination_root("/admin/views/#{@orm.name_plural}/edit.erb")
|
38
|
+
template "templates/erb/page/index.erb.tt", destination_root("/admin/views/#{@orm.name_plural}/index.erb")
|
39
|
+
template "templates/erb/page/new.erb.tt", destination_root("/admin/views/#{@orm.name_plural}/new.erb")
|
40
|
+
|
41
|
+
add_project_module(@orm.name_plural)
|
48
42
|
else
|
49
43
|
say "You are not at the root of a Padrino application! (config/boot.rb not found)" and return unless in_app_root?
|
50
44
|
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Padrino
|
2
|
+
module Admin
|
3
|
+
module Generators
|
4
|
+
class OrmError < StandardError; end
|
5
|
+
class Orm
|
6
|
+
attr_reader :klass_name, :klass, :name_plural, :name_singular, :orm
|
7
|
+
|
8
|
+
def initialize(name, orm, columns=nil, column_fields=nil)
|
9
|
+
name = name.to_s
|
10
|
+
@klass_name = name.classify
|
11
|
+
@klass = name.classify.constantize rescue nil
|
12
|
+
@name_plural = name.underscore.pluralize
|
13
|
+
@name_singular = name.underscore
|
14
|
+
@orm = orm.to_sym
|
15
|
+
@columns = columns
|
16
|
+
@column_fields = column_fields
|
17
|
+
raise OrmError, "Model #{name} not found!" if @columns.nil? && @klass.nil?
|
18
|
+
end
|
19
|
+
|
20
|
+
def field_type(type)
|
21
|
+
case type
|
22
|
+
when :integer, :float, :decimal then :text_field
|
23
|
+
when :string then :text_field
|
24
|
+
when :text then :text_area
|
25
|
+
when :boolean then :check_box
|
26
|
+
else :text_field
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def columns
|
31
|
+
@columns ||= case orm
|
32
|
+
when :activerecord then @klass.columns
|
33
|
+
when :datamapper then @klass.properties
|
34
|
+
else raise OrmError, "Adapter #{orm} not yet supported!"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def column_fields
|
39
|
+
excluded_columns = %w[id created_at updated_at]
|
40
|
+
column_fields = columns.dup
|
41
|
+
column_fields.reject! { |column| excluded_columns.include?(column.name.to_s) }
|
42
|
+
@column_fields ||= column_fields.map do |column|
|
43
|
+
{ :name => column.name, :field_type => field_type(column.type) }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def all
|
48
|
+
"#{klass_name}.all"
|
49
|
+
end
|
50
|
+
|
51
|
+
def find(params=nil)
|
52
|
+
case orm
|
53
|
+
when :activerecord then "#{klass_name}.find(#{params})"
|
54
|
+
when :datamapper then "#{klass_name}.get(#{params})"
|
55
|
+
else raise OrmError, "Adapter #{orm} not yet supported!"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def build(params=nil)
|
60
|
+
if params
|
61
|
+
"#{klass_name}.new(#{params})"
|
62
|
+
else
|
63
|
+
"#{klass_name}.new"
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def save
|
68
|
+
"#{name_singular}.save"
|
69
|
+
end
|
70
|
+
|
71
|
+
def update_attributes(params=nil)
|
72
|
+
case orm
|
73
|
+
when :activerecord then "#{name_singular}.update_attributes(#{params})"
|
74
|
+
when :datamapper then "#{name_singular}.update(#{params})"
|
75
|
+
else raise OrmError, "Adapter #{orm} not yet supported!"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def destroy
|
80
|
+
"#{name_singular}.destroy"
|
81
|
+
end
|
82
|
+
end # Orm
|
83
|
+
end # Generators
|
84
|
+
end # Admin
|
85
|
+
end # Padrino
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class Account < ActiveRecord::Base
|
2
|
+
attr_accessor :password
|
3
|
+
|
4
|
+
# Validations
|
5
|
+
validates_presence_of :email, :role
|
6
|
+
validates_presence_of :password, :if => :password_required
|
7
|
+
validates_presence_of :password_confirmation, :if => :password_required
|
8
|
+
validates_length_of :password, :within => 4..40, :if => :password_required
|
9
|
+
validates_confirmation_of :password, :if => :password_required
|
10
|
+
validates_length_of :email, :within => 3..100
|
11
|
+
validates_uniqueness_of :email, :case_sensitive => false
|
12
|
+
validates_format_of :email, :with => /\A([^@\s]+)@((?:[-a-z0-9]+\.)+[a-z]{2,})\Z/i
|
13
|
+
validates_format_of :role, :with => /[A-Za-z]/
|
14
|
+
|
15
|
+
# Callbacks
|
16
|
+
before_save :generate_password
|
17
|
+
|
18
|
+
##
|
19
|
+
# This method it's for authentication purpose
|
20
|
+
#
|
21
|
+
def self.authenticate(email, password)
|
22
|
+
account = first(:conditions => { :email => email }) if email.present?
|
23
|
+
account && account.password_clean == password ? account : nil
|
24
|
+
end
|
25
|
+
|
26
|
+
##
|
27
|
+
# This method it's used for retrive the original password.
|
28
|
+
#
|
29
|
+
def password_clean
|
30
|
+
crypted_password.decrypt(salt)
|
31
|
+
end
|
32
|
+
|
33
|
+
private
|
34
|
+
def generate_password
|
35
|
+
return if password.blank?
|
36
|
+
self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new_record?
|
37
|
+
self.crypted_password = password.encrypt(self.salt)
|
38
|
+
end
|
39
|
+
|
40
|
+
def password_required
|
41
|
+
crypted_password.blank? || !password.blank?
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
class Account
|
2
|
+
include DataMapper::Resource
|
3
|
+
include DataMapper::Validate
|
4
|
+
attr_accessor :password, :password_confirmation
|
5
|
+
|
6
|
+
# Properties
|
7
|
+
property :id, Serial
|
8
|
+
property :name, String
|
9
|
+
property :surname, String
|
10
|
+
property :email, String
|
11
|
+
property :crypted_password, String
|
12
|
+
property :salt, String
|
13
|
+
property :role, String
|
14
|
+
|
15
|
+
# Validations
|
16
|
+
validates_present :email, :role
|
17
|
+
validates_present :password, :if => :password_required
|
18
|
+
validates_present :password_confirmation, :if => :password_required
|
19
|
+
validates_length :password, :min => 4, :max => 40, :if => :password_required
|
20
|
+
validates_is_confirmed :password, :if => :password_required
|
21
|
+
validates_length :email, :min => 3, :max => 100
|
22
|
+
validates_is_unique :email, :case_sensitive => false
|
23
|
+
validates_format :email, :with => :email_address
|
24
|
+
validates_format :role, :with => /[A-Za-z]/
|
25
|
+
|
26
|
+
# Callbacks
|
27
|
+
before :save, :generate_password
|
28
|
+
|
29
|
+
##
|
30
|
+
# This method it's for authentication purpose
|
31
|
+
#
|
32
|
+
def self.authenticate(email, password)
|
33
|
+
account = first(:conditions => { :email => email }) if email.present?
|
34
|
+
account && account.password_clean == password ? account : nil
|
35
|
+
end
|
36
|
+
|
37
|
+
##
|
38
|
+
# This method it's used for retrive the original password.
|
39
|
+
#
|
40
|
+
def password_clean
|
41
|
+
crypted_password.decrypt(salt)
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def generate_password
|
46
|
+
return if password.blank?
|
47
|
+
self.salt = Digest::SHA1.hexdigest("--#{Time.now.to_s}--#{email}--") if new?
|
48
|
+
self.crypted_password = password.encrypt(self.salt)
|
49
|
+
end
|
50
|
+
|
51
|
+
def password_required
|
52
|
+
crypted_password.blank? || !password.blank?
|
53
|
+
end
|
54
|
+
end
|
@@ -10,16 +10,15 @@ password = shell.ask "Tell me the password to use:"
|
|
10
10
|
|
11
11
|
shell.say ""
|
12
12
|
|
13
|
-
account = Account.create(:email => email, :password => password, :password_confirmation => password, :role => "admin")
|
13
|
+
account = Account.create(:email => email, :name => "Foo", :surname => "Bar", :password => password, :password_confirmation => password, :role => "admin")
|
14
14
|
|
15
15
|
if account.valid?
|
16
|
-
shell.say "
|
17
|
-
shell.say ""
|
18
|
-
shell.say "
|
16
|
+
shell.say "================================================================="
|
17
|
+
shell.say "Account has been successfully created, now you can login with:"
|
18
|
+
shell.say "================================================================="
|
19
19
|
shell.say " email: #{email}"
|
20
20
|
shell.say " password: #{password}"
|
21
|
-
shell.say ""
|
22
|
-
shell.say "That's all!"
|
21
|
+
shell.say "================================================================="
|
23
22
|
else
|
24
23
|
shell.say "Sorry but some thing went worng!"
|
25
24
|
shell.say ""
|
@@ -9,30 +9,22 @@ class Admin < Padrino::Application
|
|
9
9
|
# set :reload, false # Reload application files (default in development)
|
10
10
|
# set :default_builder, "foo" # Set a custom form builder (default 'StandardFormBuilder')
|
11
11
|
# set :locale_path, "bar" # Set path for I18n translations (default your_app/locales)
|
12
|
-
# enable :auto_locale # Auto Set locale if url match /:locale/foo/bar (disabled by default)
|
13
12
|
# disable :padrino_helpers # Disables padrino markup helpers (enabled by default if present)
|
14
13
|
# disable :padrino_mailer # Disables padrino mailer (enabled by default if present)
|
15
14
|
# disable :flash # Disables rack-flash (enabled by default)
|
16
15
|
# enable :authentication # Enable padrino-admin authentication (disabled by default)
|
17
|
-
# layout
|
16
|
+
# layout :my_layout # Layout can be in views/layouts/foo.ext or views/foo.ext (default :application)
|
18
17
|
#
|
19
|
-
layout false
|
20
18
|
enable :authentication
|
21
19
|
disable :store_location
|
22
20
|
set :login_page, "/admin/sessions/new"
|
23
21
|
|
24
22
|
access_control.roles_for :any do |role|
|
23
|
+
role.protect "/"
|
25
24
|
role.allow "/sessions"
|
26
25
|
end
|
27
26
|
|
28
27
|
access_control.roles_for :admin do |role, account|
|
29
|
-
|
30
|
-
role.allow "/"
|
31
|
-
|
32
|
-
role.project_module :accounts do |project|
|
33
|
-
project.menu :list, "/admin/accounts.js"
|
34
|
-
project.menu :new, "/admin/accounts/new"
|
35
|
-
end
|
36
28
|
end
|
37
29
|
|
38
30
|
end
|
@@ -1,21 +1,21 @@
|
|
1
1
|
Admin.controllers :sessions do
|
2
|
-
|
2
|
+
|
3
3
|
get :new do
|
4
|
-
render "/sessions/new"
|
4
|
+
render "/sessions/new", nil, :layout => false
|
5
5
|
end
|
6
6
|
|
7
7
|
post :create do
|
8
8
|
if account = Account.authenticate(params[:email], params[:password])
|
9
9
|
set_current_account(account)
|
10
|
-
redirect
|
10
|
+
redirect url(:base, :index)
|
11
11
|
else
|
12
|
-
flash[:
|
13
|
-
redirect
|
12
|
+
flash[:warning] = "Login or password wrong."
|
13
|
+
redirect url(:sessions, :new)
|
14
14
|
end
|
15
15
|
end
|
16
16
|
|
17
17
|
get :destroy do
|
18
18
|
set_current_account(nil)
|
19
|
-
|
19
|
+
redirect url(:sessions, :new)
|
20
20
|
end
|
21
21
|
end
|