notee 0.4.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/notee/application.js +19539 -17294
- data/app/controllers/notee/application_controller.rb +5 -0
- data/app/controllers/notee/categories_controller.rb +7 -3
- data/app/controllers/notee/comments_controller.rb +9 -4
- data/app/controllers/notee/images_controller.rb +2 -2
- data/app/controllers/notee/posts_controller.rb +11 -4
- data/app/controllers/notee/roles_controller.rb +1 -1
- data/app/controllers/notee/tokens_controller.rb +9 -15
- data/app/controllers/notee/trashes_controller.rb +60 -0
- data/app/controllers/notee/users_controller.rb +26 -6
- data/app/models/notee/application_record.rb +27 -0
- data/app/models/notee/authority.rb +377 -0
- data/app/models/notee/category.rb +15 -2
- data/app/models/notee/comment.rb +6 -0
- data/app/models/notee/image.rb +2 -2
- data/app/models/notee/post.rb +7 -5
- data/app/models/notee/user.rb +97 -41
- data/app/views/layouts/notee/application.html.erb +3 -1
- data/config/routes.rb +19 -9
- data/db/migrate/20160605141437_create_notee_posts.rb +1 -0
- data/db/migrate/20160605141510_create_notee_categories.rb +4 -1
- data/db/migrate/20160605141547_create_notee_images.rb +4 -2
- data/db/migrate/20160803154954_create_notee_comments.rb +2 -1
- data/db/migrate/20160809145754_create_notee_users.rb +1 -0
- data/lib/notee/helpers/notee_helper.rb +65 -46
- data/lib/notee/helpers/view_helper.rb +10 -2
- data/lib/notee/status.rb +1 -2
- data/lib/notee/version.rb +1 -1
- data/lib/tasks/config/notee.rb +26 -0
- data/lib/tasks/config/schedule.rb +7 -0
- data/lib/tasks/controllers/notee_controller.rb +65 -0
- data/lib/tasks/javascripts/notee/highlight.pack.js +2 -0
- data/lib/tasks/notee_tasks.rake +105 -51
- data/lib/tasks/stylesheets/notee/highlight/agate.css +108 -0
- data/lib/tasks/stylesheets/notee/highlight/androidstudio.css +66 -0
- data/lib/tasks/stylesheets/notee/highlight/arduino-light.css +88 -0
- data/lib/tasks/stylesheets/notee/highlight/arta.css +73 -0
- data/lib/tasks/stylesheets/notee/highlight/ascetic.css +45 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-cave-dark.css +83 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-cave-light.css +85 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-dune-dark.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-dune-light.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-estuary-dark.css +84 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-estuary-light.css +84 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-forest-dark.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-forest-light.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-heath-dark.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-heath-light.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-lakeside-dark.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-lakeside-light.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-plateau-dark.css +84 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-plateau-light.css +84 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-savanna-dark.css +84 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-savanna-light.css +84 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-seaside-dark.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-seaside-light.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-sulphurpool-dark.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atelier-sulphurpool-light.css +69 -0
- data/lib/tasks/stylesheets/notee/highlight/atom-one-dark.css +96 -0
- data/lib/tasks/stylesheets/notee/highlight/atom-one-light.css +96 -0
- data/lib/tasks/stylesheets/notee/highlight/brown-paper.css +64 -0
- data/lib/tasks/stylesheets/notee/highlight/brown-papersq.png +0 -0
- data/lib/tasks/stylesheets/notee/highlight/codepen-embed.css +60 -0
- data/lib/tasks/stylesheets/notee/highlight/color-brewer.css +71 -0
- data/lib/tasks/stylesheets/notee/highlight/darcula.css +77 -0
- data/lib/tasks/stylesheets/notee/highlight/dark.css +63 -0
- data/lib/tasks/stylesheets/notee/highlight/darkula.css +6 -0
- data/lib/tasks/stylesheets/notee/highlight/default.css +99 -0
- data/lib/tasks/stylesheets/notee/highlight/docco.css +97 -0
- data/lib/tasks/stylesheets/notee/highlight/dracula.css +76 -0
- data/lib/tasks/stylesheets/notee/highlight/far.css +71 -0
- data/lib/tasks/stylesheets/notee/highlight/foundation.css +88 -0
- data/lib/tasks/stylesheets/notee/highlight/github-gist.css +71 -0
- data/lib/tasks/stylesheets/notee/highlight/github.css +99 -0
- data/lib/tasks/stylesheets/notee/highlight/googlecode.css +89 -0
- data/lib/tasks/stylesheets/notee/highlight/grayscale.css +101 -0
- data/lib/tasks/stylesheets/notee/highlight/gruvbox-dark.css +108 -0
- data/lib/tasks/stylesheets/notee/highlight/gruvbox-light.css +108 -0
- data/lib/tasks/stylesheets/notee/highlight/hopscotch.css +83 -0
- data/lib/tasks/stylesheets/notee/highlight/hybrid.css +102 -0
- data/lib/tasks/stylesheets/notee/highlight/idea.css +97 -0
- data/lib/tasks/stylesheets/notee/highlight/ir-black.css +73 -0
- data/lib/tasks/stylesheets/notee/highlight/kimbie.dark.css +74 -0
- data/lib/tasks/stylesheets/notee/highlight/kimbie.light.css +74 -0
- data/lib/tasks/stylesheets/notee/highlight/magula.css +70 -0
- data/lib/tasks/stylesheets/notee/highlight/mono-blue.css +59 -0
- data/lib/tasks/stylesheets/notee/highlight/monokai-sublime.css +83 -0
- data/lib/tasks/stylesheets/notee/highlight/monokai.css +70 -0
- data/lib/tasks/stylesheets/notee/highlight/obsidian.css +88 -0
- data/lib/tasks/stylesheets/notee/highlight/ocean.css +74 -0
- data/lib/tasks/stylesheets/notee/highlight/paraiso-dark.css +72 -0
- data/lib/tasks/stylesheets/notee/highlight/paraiso-light.css +72 -0
- data/lib/tasks/stylesheets/notee/highlight/pojoaque.css +83 -0
- data/lib/tasks/stylesheets/notee/highlight/pojoaque.jpg +0 -0
- data/lib/tasks/stylesheets/notee/highlight/purebasic.css +96 -0
- data/lib/tasks/stylesheets/notee/highlight/qtcreator_dark.css +83 -0
- data/lib/tasks/stylesheets/notee/highlight/qtcreator_light.css +83 -0
- data/lib/tasks/stylesheets/notee/highlight/railscasts.css +106 -0
- data/lib/tasks/stylesheets/notee/highlight/rainbow.css +85 -0
- data/lib/tasks/stylesheets/notee/highlight/school-book.css +72 -0
- data/lib/tasks/stylesheets/notee/highlight/school-book.png +0 -0
- data/lib/tasks/stylesheets/notee/highlight/solarized-dark.css +84 -0
- data/lib/tasks/stylesheets/notee/highlight/solarized-light.css +84 -0
- data/lib/tasks/stylesheets/notee/highlight/sunburst.css +102 -0
- data/lib/tasks/stylesheets/notee/highlight/tomorrow-night-blue.css +75 -0
- data/lib/tasks/stylesheets/notee/highlight/tomorrow-night-bright.css +74 -0
- data/lib/tasks/stylesheets/notee/highlight/tomorrow-night-eighties.css +74 -0
- data/lib/tasks/stylesheets/notee/highlight/tomorrow-night.css +75 -0
- data/lib/tasks/stylesheets/notee/highlight/tomorrow.css +72 -0
- data/lib/tasks/stylesheets/notee/highlight/vs.css +68 -0
- data/lib/tasks/stylesheets/notee/highlight/xcode.css +93 -0
- data/lib/tasks/stylesheets/notee/highlight/xt256.css +92 -0
- data/lib/tasks/stylesheets/notee/highlight/zenburn.css +80 -0
- data/lib/tasks/stylesheets/notee/normalize.css +427 -0
- data/lib/tasks/stylesheets/notee/notee_default.css +386 -0
- data/lib/tasks/views/notee/about.html.erb +43 -0
- data/lib/tasks/views/notee/archives.html.erb +16 -0
- data/lib/tasks/views/notee/categories.html.erb +15 -0
- data/lib/tasks/views/notee/partials/_foote.html.erb +3 -0
- data/lib/tasks/views/notee/partials/_header.html.erb +17 -0
- data/lib/tasks/views/notee/partials/_profile.html.erb +9 -0
- data/lib/tasks/views/notee/partials/_sidebar.html.erb +23 -0
- data/lib/tasks/views/notee/posts.html.erb +53 -0
- data/lib/tasks/views/notee/show.html.erb +42 -0
- data/lib/tasks/views/notee/writers.html.erb +11 -0
- metadata +115 -240
- data/lib/tasks/css/notee_default.css +0 -59
- data/test/dummy/db/development.sqlite3 +0 -0
- data/test/dummy/db/test.sqlite3 +0 -0
- data/test/dummy/log/development.log +0 -3087
- data/test/dummy/log/test.log +0 -872
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/-t/-tdJTrCcY92VpiO_z6SIt_iHkHDtn1-8Vf__p-Ve9lU.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/0K/0KQJQyRy3gQkymW0xnPhM4_OpLtoTcw9Rutx4F4IajE.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/1B/1Bb2_fhXoTmM27WcuQJ2sr0UCMHh6TjrBIwd6Ks8qJ0.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/1N/1NYje2ld9grEMpvxBFjocEWWMPi4jNPuPLdlkV1Wq5A.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/1s/1sPuKGE0jImBtnCnczIk6NpOn9cYeyBZsXHvpXJ1tGA.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/1s/1sRxHck-81_JSGvEidXPx2S86Cbe0UjizohTg5lkd-U.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/3d/3dw9fS6dak9HSgJqviXZ6CCibFx8--QDKyWjrqKqraI.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/4S/4SCYKO2aAiXfZPZF1vTYeIQegrrqvH-2jlfGl1I6juQ.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/4z/4zE2reLAwChLIBivfo5JfQjRwOM2sBvlDLXftsA772o.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/5p/5pDjSjY69Pd-A64UKCqQ_yxQouHkmBElVBKf1IZT2HM.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/5p/5pnvfhvSgahCnLPLbhB7dM8lSEhk2w39UTDXe83gYng.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/5r/5r2K8e-LRVnmo3VUaNdNx3K1b_BgFMOboxlnTQC_Ckk.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/5u/5ue4ZdF425UevYa9Danha84KDME2s4InW-zR-y-Y0SM.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/6Q/6Qq8Rnvquz8oH8ojJlj79pSAhSHH_VoWRS0Cn-d-yLQ.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/6Y/6Y--Gdy-iDkVFcgE3j660zOA3sf_osOedfJpeV_Kxh4.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/7G/7GrmDrSvjAFvLUcaRN95cQLmvkzf8D_cvGlhRyL01HA.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/83/83mXRYYdvGZS4tNS_IFZLa5P6e-fg9MSMqWG4MJ-Jks.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/8H/8HKewCH2XL9errlVDVPK8QZg0LoH-_Q3zqQ1pjCYBEU.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/8v/8vJIODLLCFZwV8yIF98dlb5_CQZlgBdCLiM8UA6WiSA.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/9W/9WtQTxW8TE4CQvkem1QkHVjZFB93XAJo3ioPSt6U5wM.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/AH/AHLaBPz-xNABgeh1V66iU7wJ6FCxvFIie5V05wRvI84.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/C1/C1S3q8MtvUImrUe70fZPf9wxMfxdcWPSRXRrv4H6_lo.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/D4/D4ftsVSRtZadejqqBmur8bfiHLhZFCaIjpsAdJT28Iw.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/DS/DSOLSc6A5RVSmvM415eEWAWG_AgOvZcLZOXQjsXyWQA.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fr/FrWiXIfDo2-fsKFSgef9Bs-0HjC7dOgBY8IVBLCq9ag.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fz/FzjTR8U_FOgMIbfYBgJfzujyNBozRZd-3YYTkiAQTOg.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/G6/G6nKI6E9cfkIZqH5EnbMJtS4DKHApFlNTKh__ZuK774.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/HH/HHQp4rqJ3kx9sfFo3AAW2DS6zHl28lCqALB5YnKXeG8.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/IN/INpQmG9J4AOUCg2YWypvnwq9ce01SFPnDGidI2qcU_8.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/J0/J038M_TjhJBb-678LCin4jaJSkSaaXy7XHJbEp1Bo5I.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/JI/JIHr2A9bWoln5XahhS15lRxvHSXdQZ7OrlbAW1IzayM.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/JI/JId5JhtAhhN90V7z1OSItT9m4n4H_Nfk3IGtOW0mA_s.cache +0 -3
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/JP/JPylOhsUjr9NtL1AViDe-Sz0-iLPZGPww463ChRqhEw.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/JU/JUdbchVNMjz67zIvPztSzFfpU_VO4Rl9V86GzJH28_A.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/K0/K0Ou5PNqxeODBFSEnIeg7EaidQVBRvPH-SPrTF1tRVA.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/KS/KSTuVqjLw0xUGYH5WcnAloHDphCDQr4cFjXKKl5vW7M.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/L-/L--JLWiCS6RZ0l_EciZOoY0eTEs6BGBED1YZ7hj13vQ.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/ME/META30ksADpNoAnM_vlhKhlLOfxBlo5uJjJKSJa264o.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/MH/MHQULHaqwmMfm67LLiF_ZDlM6Zix3aPput7pxTViWQ0.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/NK/NKXg7894FsAVQJxXzYkUOgd131zYAeWOIxmegdT-LFk.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/NW/NWx4g28WkpCPeRLdgMDaUuLO2e4UIw2bs-HKy-ixIlU.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Nj/NjPNj--fkweGPvPTHkDlefKtB5bpFaGG9X60M_goNUo.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Oh/Ohok7uysixzjxK1FE7m-KJv6gqYQH4svN8nZyRBOgwA.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ot/Ot7COhZjTueyAONhzjXiOOwv0uTS9EtXGgxYznVMIvs.cache +0 -3
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/P4/P4KZGx6J2yGIq1PMq13fnsaXrS47R-S_sYrQrcUL59I.cache +0 -3
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Pn/Pn9eXmle4fRjakm_xgwyXs5YzlWELSuhbi3nnV2-Ink.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/QY/QYNLSW9XctrfttzhOfkik5INswRo-qBjjwQvA7S_lyc.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Qb/Qbb4ATlvuCS0fudaTweqJoma2S99Mr2Q6ISbIpDoMso.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/R6/R6E4Q8O1upT5p_U-ySDbO3dFY6SMeSwmubqJUfSJedo.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Rv/RvcRQ_I7meCLqBRooErlcPwcbH0tdDuvO5SQ_Xy45Qk.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Sz/SzRmx7uSmniNAGO1zMPd4qzEgM8eAaWBqaxestc32Jg.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Tk/TkRyIpbn-1DcVexPTWUljWQOek0D_q6yO_jYNGwKM_o.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/U1/U1E_3Z4bItTBl9s8aX6O2rceqAD5GfoNzF8AqYs9Hig.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/UC/UCe1qLwGTD6W2etoFOMln6E2DgTq8Xnm7eGvCs6YGEE.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/UZ/UZhrzLOgNG132Xf1yJ7H7lSq4S3TyDoPphdzwKU8fqQ.cache +0 -3
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ud/UdBXq-s3u32R-gjMCYZv9RJH4n1xSt8PnBpWxg-JzGE.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/VD/VDaYJQJdErZ0zVg9KgvidORf7a13jqM72Uk97zzuUZU.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/WT/WTExV_4iBOBS-SWMh6jqm61uSp83ezH5DPIkjfktls4.cache +0 -3
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Wi/Wia5tzg4hJNhNhKWgY7pkrxWbvr6n0YaKXl80wh6qPg.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Wl/WldqQqssrkJedTdiFt86Y6FDn5ww1MirVAAnOpRqeCE.cache +0 -3
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Wv/WvAZ72pGsB5VpmTmGBucm1eztH129yQ1YmrRMy-yS4g.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Wz/WzSkff9VUQsb0DJ5RB3m3SfxRTMU97qhyNCqiIHlJPw.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Yx/Yx6fZ9ju2qCb4Ps_0iEzNR7KgDNTE2gIRjcdOMFXNlo.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/ZO/ZOUPFk5_ZB8Wtn42g9PiY6Qu7KSbipNG04Qa5YSP6sw.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/ZT/ZT-4a7lIKMm0Swxyt7MdXMz5v6r5MaVvtHvqAT6T8Ts.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Zb/ZbvOW6HdEiql0zdGkCPG-EK8beJAmp1ovBR1Oy1V6Fw.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/Zu/ZuAoFB2A_kFOIb19dNUzEU5jP-SzQLmauPCURINz2Fo.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/_r/_rmEe1ir-igQN0twVhxrxngbLIFJkINITWVGNye4-MM.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/aE/aEQNT9eY4cAc2ACQnD35BkLV5dEezB-drcCoF1SzjAc.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/bK/bKPdLlYXb5ZZU8vrzCdKqLgCXyeiXHExSl9lwGIofU0.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/br/brGLDCuoxhnIrvwsuWmzjnwDV7Bn_nezqOrXiI0oco0.cache +0 -3
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/c3/c3Jo7UkNggNJH21U9HD-Y5Lipd68yZXcl6FGMbzFEeM.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/c4/c4YjuvK4zQOjr5Q6N7A_-NHM59NF0kGApLBxSZ5JgqA.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/c9/c9B4H9i5OvdAnZpel-KocssCcsd3TS2Gqe4uKAFjiKQ.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/dM/dMJ_N4wD6R1wforGNMdyz6wec-5a7_H03vxu0pgPhLc.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/dr/drYndmRIbBKroImntO4XhUYV5kqxE2q2qE_aYRwYj4Q.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/du/dumQ6K8NP4rz74ofF4DxxFRetR-K07c75MhZrUQDbqY.cache +0 -3
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/fn/fns6a_EwXvrlRyeQjB9lcYXHfIZi0guP75oUWPuz4Z0.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/g3/g3NfArxOfOGHlWIGK-Znm2-gh1Oyud_f5ZEFuGrOv2g.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/gF/gFErWaVWbjefUiSe3yI-bWCrUD3SsMHomSjTacMlSDM.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/gG/gGCsoohK0vflREMUeOrfW4KZeI73jU9ld5t0pzfjh4U.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/gZ/gZp3uXMHuYQC4hzCr7bQfetKNdJAtbQmg3so2KpW1Dw.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/Hz6pNt28QsuyrFcIx0afHONIVEGdLBEC64cV2zh2xAM.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/hv/hvw4qAvufcLTOeT9ie13DTIDt3SOLih2iH9P603ZOFQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/iZ/iZGxFM6U5PSEZmHGlksi8vAVBMlMiyjOBaL8HIGcOPE.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/ig/iguUMDAVIm9pfM52njpM4hqpnNYkwKTWvNXQyolgR74.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/jJ/jJTo0slnuZqKDbuFGjyBEkenWViH1MiTvb7gNjc4SL4.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/jN/jNM9mSzc6sg9yU7srXH0l2_bPIXbqLtJVBML2umXb9w.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/jh/jhx8TAOiUaenqesmOiahNzaVcnpiciOE8VKZdrxGerc.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/kT/kTif4yPNd0vB6fWie0kxsN5Gwubl8sqAOyydwpiyHzo.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/m3/m3lSeIbfcyVVkENoCOiz_6LvNubosVesCJBkdI88aNk.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/m6/m6kJHQNOyyMHxod8TObJKAp8iV_noMwYPWsBh-CCG0k.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/mX/mXJ655Gxgvg2C08jNcMFB9OQ2G6HrtGc_MfVIpYycsg.cache +0 -3
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/mr/MrG8zKUbpqoyxO2GdEOuWmFBUIpOKL3upEtfOWsYluQ.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/mr/mr-hjupF6Lf8wABiaoi8L9823j20yjhhTnrn4FNsEZI.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/n2/n2T4JbhKpnbSE5uhnXyPzu4WnDOkMu78BrJ-Huhn7YU.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/nC/nCuKY2iJdzgSyWS09dThZ5T57F8vGBo0w-ycyuEidUk.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/og/ogVEMp7SPQ-wAJz4mNXdRrx52GXFvHKpSx3bS7dr_t8.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/pO/pOOGu7nAdun08PmdiHZas85h5Kqbgs6_M5vHQQKJgW8.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/pX/pXIDW5zCrR8MxxTON9elPRDkMBEefpa-fWViSmyJGns.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/qF/qFG1ZnUOHTHsxMxvN1iTKNCA05nrecKPlygtJzvMdSs.cache +0 -2
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/sS/sS00IDFTJ19zoTjrB2-Sypybo0I1qXoTtW8JabBMoAo.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/sb/sbB7Wbcww5hxA8e-5K0oBKQDnlNNnY90t0YUIdYE138.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/xX/xXo4fouecqy2oZpxsgtkqL6uyIDuKLwBUwmzddno9hw.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/x_/x_WcnsWyMV1QzLUnFW5J4gZHs0gACREYGaSom7xcaBQ.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/yC/yCp-2wuXWORHGqxfwG37-mb00X8GpHiRjrlo2QQX3lU.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/yW/yWtPpcB-kB8_hw5k0prtaOvTW5A5PaCT0ZaJSdh8Zkw.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/ys/ysFM6FIJniGme1T62LOmRFt3h7g0scd6o6BFIjS5Ppg.cache +0 -0
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/z4/z4i9WzpZRzFXynWsqewNMikNdcZ9f9mGFdlrIP5N6Gs.cache +0 -1
- data/test/dummy/tmp/cache/assets/sprockets/v3.0/zN/zNfQXfFXMTyOoz3HbVM-_4m-46rWO7XrZPvGs4aJCQc.cache +0 -2
@@ -1,6 +1,11 @@
|
|
1
1
|
module Notee
|
2
2
|
class ApplicationController < ActionController::Base
|
3
3
|
before_action :restrict_access_json
|
4
|
+
before_filter :set_request_filter
|
5
|
+
|
6
|
+
def set_request_filter
|
7
|
+
Thread.current[:request] = request
|
8
|
+
end
|
4
9
|
|
5
10
|
def restrict_access_json
|
6
11
|
return redirect_to new_token_path unless confirm_exist_token
|
@@ -6,7 +6,7 @@ module Notee
|
|
6
6
|
before_action :set_category, only: [:show, :update, :destroy]
|
7
7
|
|
8
8
|
def index
|
9
|
-
@categories = Category.
|
9
|
+
@categories = Category.where(is_deleted: false)
|
10
10
|
render json: { status: 'success', categories: @categories }
|
11
11
|
end
|
12
12
|
|
@@ -27,9 +27,12 @@ module Notee
|
|
27
27
|
|
28
28
|
def update
|
29
29
|
respond_to do |format|
|
30
|
+
Category.skip_callback(:save, :before, :set_slug)
|
30
31
|
if @category.update(category_params)
|
32
|
+
Category.set_callback(:save, :before, :set_slug)
|
31
33
|
format.json { render json: @category, status: 200 }
|
32
34
|
else
|
35
|
+
Category.set_callback(:save, :before, :set_slug)
|
33
36
|
format.json { render json: @category.errors, status: :unprocessable_entity }
|
34
37
|
end
|
35
38
|
end
|
@@ -37,10 +40,11 @@ module Notee
|
|
37
40
|
|
38
41
|
def destroy
|
39
42
|
respond_to do |format|
|
40
|
-
if @category.
|
43
|
+
if @category.update(slug: nil, is_deleted: true)
|
44
|
+
Category.before_destroy_parent(@category.id)
|
41
45
|
format.json { render json: @category, status: 200 }
|
42
46
|
else
|
43
|
-
format.json { render json: @category.errors, status: :
|
47
|
+
format.json { render json: @category.errors, status: :unprocessable_entity }
|
44
48
|
end
|
45
49
|
end
|
46
50
|
end
|
@@ -5,7 +5,7 @@ module Notee
|
|
5
5
|
before_action :set_comment, only: [:update, :destroy]
|
6
6
|
|
7
7
|
def index
|
8
|
-
comments = Comment.
|
8
|
+
comments = Comment.where(is_deleted: false).order(updated_at: :desc)
|
9
9
|
render json: { status: 'success', comments: comments }
|
10
10
|
end
|
11
11
|
|
@@ -25,7 +25,7 @@ module Notee
|
|
25
25
|
|
26
26
|
def update
|
27
27
|
respond_to do |format|
|
28
|
-
if @comment.update(
|
28
|
+
if @comment.update(is_hidden: !@comment.is_hidden)
|
29
29
|
format.json { render json: @comment, status: 200 }
|
30
30
|
else
|
31
31
|
format.json { render json: @comment.errors, status: :unprocessable_entity }
|
@@ -34,8 +34,13 @@ module Notee
|
|
34
34
|
end
|
35
35
|
|
36
36
|
def destroy
|
37
|
-
|
38
|
-
|
37
|
+
respond_to do |format|
|
38
|
+
if @comment.update(is_deleted: true)
|
39
|
+
format.json { render json: @comment, status: 200 }
|
40
|
+
else
|
41
|
+
format.json { render json: @comment.errors, status: :internal_server_error }
|
42
|
+
end
|
43
|
+
end
|
39
44
|
end
|
40
45
|
|
41
46
|
private
|
@@ -5,7 +5,7 @@ module Notee
|
|
5
5
|
class ImagesController < ApplicationController
|
6
6
|
|
7
7
|
def index
|
8
|
-
@images = Image.
|
8
|
+
@images = Image.where(is_deleted: false).order(updated_at: :desc)
|
9
9
|
render json: { status: 'success', images: @images }
|
10
10
|
end
|
11
11
|
|
@@ -31,7 +31,7 @@ module Notee
|
|
31
31
|
return unless @del_img = Image.find_by(content: params[:name])
|
32
32
|
|
33
33
|
respond_to do |format|
|
34
|
-
if @del_img.
|
34
|
+
if @del_img.update(is_deleted: true)
|
35
35
|
format.json { render json: @del_img, status: 200 }
|
36
36
|
else
|
37
37
|
format.json { render json: @del_img.errors, status: :internal_server_error }
|
@@ -7,7 +7,7 @@ module Notee
|
|
7
7
|
|
8
8
|
# GET /posts
|
9
9
|
def index
|
10
|
-
@posts = Post.
|
10
|
+
@posts = Post.where(is_deleted: false).order(updated_at: :desc)
|
11
11
|
render json: { status: 'success', posts: @posts }
|
12
12
|
end
|
13
13
|
|
@@ -19,6 +19,7 @@ module Notee
|
|
19
19
|
# POST /posts
|
20
20
|
def create
|
21
21
|
@post = Post.new(post_params)
|
22
|
+
@post.set_user_id
|
22
23
|
respond_to do |format|
|
23
24
|
if @post.save
|
24
25
|
format.json { render json: @post, status: 200 }
|
@@ -30,6 +31,7 @@ module Notee
|
|
30
31
|
|
31
32
|
# PATCH/PUT /posts/1
|
32
33
|
def update
|
34
|
+
post_params[:user_id] = @post.user_id
|
33
35
|
respond_to do |format|
|
34
36
|
if @post.update(post_params)
|
35
37
|
format.json { render json: @post, status: 200 }
|
@@ -41,8 +43,13 @@ module Notee
|
|
41
43
|
|
42
44
|
# DELETE /posts/1
|
43
45
|
def destroy
|
44
|
-
|
45
|
-
|
46
|
+
respond_to do |format|
|
47
|
+
if @post.update(is_deleted: true)
|
48
|
+
format.json { render json: @post, status: 200 }
|
49
|
+
else
|
50
|
+
format.json { render json: @post.errors, status: :internal_server_error }
|
51
|
+
end
|
52
|
+
end
|
46
53
|
end
|
47
54
|
|
48
55
|
private
|
@@ -53,7 +60,7 @@ module Notee
|
|
53
60
|
|
54
61
|
# Only allow a trusted parameter "white list" through.
|
55
62
|
def post_params
|
56
|
-
params.require(:post).permit(:title, :content, :slug, :status, :category_id, :thumbnail_id, :published_at, :seo_keyword, :seo_description, :secret_published_password)
|
63
|
+
params.require(:post).permit(:title, :content, :slug, :status, :user_id, :category_id, :thumbnail_id, :published_at, :seo_keyword, :seo_description, :secret_published_password)
|
57
64
|
end
|
58
65
|
end
|
59
66
|
end
|
@@ -9,25 +9,19 @@ module Notee
|
|
9
9
|
end
|
10
10
|
|
11
11
|
def create
|
12
|
-
|
13
|
-
if token = Token.create!
|
14
|
-
session[:access_token] = token.access_token
|
15
|
-
return redirect_to root_path
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
if now_user = User.sign_in(params[:id], params[:password])
|
20
|
-
if token = Token.create!(user_id: now_user.id)
|
21
|
-
session[:access_token] = token.access_token
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
12
|
+
User.sign_in(params[:id], params[:password])
|
25
13
|
redirect_to root_path
|
26
14
|
end
|
27
15
|
|
28
16
|
def destroy
|
29
|
-
|
30
|
-
|
17
|
+
respond_to do |format|
|
18
|
+
if @token = Token.find_by_access_token(session[:access_token]).destroy!
|
19
|
+
session.delete(:access_token)
|
20
|
+
format.json { render json: @token, status: 200 }
|
21
|
+
else
|
22
|
+
format.json { render json: @token.errors, status: :unprocessable_entity }
|
23
|
+
end
|
24
|
+
end
|
31
25
|
end
|
32
26
|
end
|
33
27
|
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
require_dependency 'notee/application_controller'
|
2
|
+
|
3
|
+
module Notee
|
4
|
+
class TrashesController < ApplicationController
|
5
|
+
before_action :set_trash, only: [:update]
|
6
|
+
|
7
|
+
def index
|
8
|
+
trash_model = get_model
|
9
|
+
if @trashes = trash_model.trash
|
10
|
+
render json: { status: 'success', trashes: @trashes }
|
11
|
+
else
|
12
|
+
render json: @trashes.errors, status: 422
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def update
|
17
|
+
get_model.skip_callback(:update, :before, :update_authority)
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
if @trash.update(is_deleted: false)
|
21
|
+
format.json { render json: @trash, status: 200 }
|
22
|
+
else
|
23
|
+
format.json { render json: @trash.errors, status: :unprocessable_entity }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
get_model.set_callback(:update, :before, :update_authority)
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.cleanup
|
31
|
+
Post.trash.time_limit.delete_all
|
32
|
+
Category.trash.time_limit.delete_all
|
33
|
+
Image.trash.time_limit.delete_all
|
34
|
+
User.trash.time_limit.delete_all
|
35
|
+
Comment.trash.time_limit.delete_all
|
36
|
+
end
|
37
|
+
|
38
|
+
private
|
39
|
+
|
40
|
+
def get_model
|
41
|
+
case params[:model]
|
42
|
+
when 'posts'
|
43
|
+
return Post
|
44
|
+
when 'categories'
|
45
|
+
return Category
|
46
|
+
when 'images'
|
47
|
+
return Image
|
48
|
+
when 'users'
|
49
|
+
return User
|
50
|
+
when 'comments'
|
51
|
+
return Comment
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
def set_trash
|
56
|
+
trash_model = get_model
|
57
|
+
@trash = trash_model.find_by(id: params[:id])
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -3,13 +3,14 @@ require_dependency 'notee/application_controller'
|
|
3
3
|
|
4
4
|
module Notee
|
5
5
|
class UsersController < ApplicationController
|
6
|
+
|
6
7
|
# callbacks
|
7
8
|
before_action :set_user, only: [:show, :update, :destroy]
|
8
9
|
before_action :convert_from_string_to_int, only: [:create, :update]
|
9
10
|
|
10
11
|
# GET /users
|
11
12
|
def index
|
12
|
-
@users = User.
|
13
|
+
@users = User.where(is_deleted: false).order(updated_at: :desc)
|
13
14
|
render json: { status: 'success', users: @users }
|
14
15
|
end
|
15
16
|
|
@@ -18,10 +19,14 @@ module Notee
|
|
18
19
|
render json: { status: 'success', user: @user }
|
19
20
|
end
|
20
21
|
|
22
|
+
def mypage
|
23
|
+
@user = Token.find_by(access_token: session[:access_token]).user
|
24
|
+
render json: { status: 'success', user: @user }
|
25
|
+
end
|
26
|
+
|
21
27
|
# POST /posts
|
22
28
|
def create
|
23
29
|
@user = User.new(user_params)
|
24
|
-
@user.file = user_params[:profile_img]
|
25
30
|
respond_to do |format|
|
26
31
|
if @user.save
|
27
32
|
format.json { render json: @user, status: 200 }
|
@@ -33,7 +38,6 @@ module Notee
|
|
33
38
|
|
34
39
|
# PATCH/PUT /posts/1
|
35
40
|
def update
|
36
|
-
@user.file = user_params[:profile_img]
|
37
41
|
respond_to do |format|
|
38
42
|
if @user.update(user_params)
|
39
43
|
format.json { render json: @user, status: 200 }
|
@@ -43,10 +47,26 @@ module Notee
|
|
43
47
|
end
|
44
48
|
end
|
45
49
|
|
50
|
+
def update_password
|
51
|
+
@user = Token.find_by(access_token: session[:access_token]).user
|
52
|
+
respond_to do |format|
|
53
|
+
if @user.update_password(user_params)
|
54
|
+
format.json { render json: @user, status: 200 }
|
55
|
+
else
|
56
|
+
format.json { render json: @user.errors, status: :unprocessable_entity }
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
46
61
|
# DELETE /posts/1
|
47
62
|
def destroy
|
48
|
-
|
49
|
-
|
63
|
+
respond_to do |format|
|
64
|
+
if @user.update(is_deleted: true)
|
65
|
+
format.json { render json: @user, status: 200 }
|
66
|
+
else
|
67
|
+
format.json { render json: @user.errors, status: :internal_server_error }
|
68
|
+
end
|
69
|
+
end
|
50
70
|
end
|
51
71
|
|
52
72
|
private
|
@@ -61,7 +81,7 @@ module Notee
|
|
61
81
|
|
62
82
|
# Only allow a trusted parameter "white list" through.
|
63
83
|
def user_params
|
64
|
-
params.require(:user).permit(:name, :email, :password, :password_confirm, :profile, :profile_img, :role)
|
84
|
+
params.require(:user).permit(:name, :email, :now_password, :password, :password_confirm, :profile, :profile_img, :role, :file)
|
65
85
|
end
|
66
86
|
end
|
67
87
|
end
|
@@ -1,5 +1,32 @@
|
|
1
1
|
module Notee
|
2
2
|
class ApplicationRecord < ActiveRecord::Base
|
3
3
|
self.abstract_class = true
|
4
|
+
|
5
|
+
# scopes
|
6
|
+
scope :trash, -> { where(is_deleted: true) }
|
7
|
+
scope :not_trash, -> { where(is_deleted: false) }
|
8
|
+
scope :time_limit, -> { where('updated_at <= ?', Time.current - 60*60*24*30) }
|
9
|
+
|
10
|
+
# authority check
|
11
|
+
before_create :create_authority
|
12
|
+
before_update :update_authority, unless: :is_destroy?
|
13
|
+
before_update :destroy_authority, if: :is_destroy?
|
14
|
+
|
15
|
+
def create_authority
|
16
|
+
Authority.check('create', self)
|
17
|
+
end
|
18
|
+
|
19
|
+
def update_authority
|
20
|
+
Authority.check('update', self)
|
21
|
+
end
|
22
|
+
|
23
|
+
def destroy_authority
|
24
|
+
Authority.check('destroy', self)
|
25
|
+
end
|
26
|
+
|
27
|
+
def is_destroy?
|
28
|
+
return true if self.is_deleted == true
|
29
|
+
false
|
30
|
+
end
|
4
31
|
end
|
5
32
|
end
|
@@ -0,0 +1,377 @@
|
|
1
|
+
module Notee
|
2
|
+
class Authority
|
3
|
+
include ActiveModel::Model
|
4
|
+
|
5
|
+
class AuthorityError < StandardError; end
|
6
|
+
class << self
|
7
|
+
|
8
|
+
TARGET_ARR = ['Post', 'Category', 'Image', 'User']
|
9
|
+
|
10
|
+
def check(crud, new_model_obj)
|
11
|
+
|
12
|
+
check_deleted
|
13
|
+
role = get_role
|
14
|
+
|
15
|
+
case role
|
16
|
+
when 'writer' then
|
17
|
+
writer(crud, new_model_obj)
|
18
|
+
when 'editor' then
|
19
|
+
editor(crud, new_model_obj)
|
20
|
+
when 'manager' then
|
21
|
+
manager(crud, new_model_obj)
|
22
|
+
when 'root' then
|
23
|
+
root_user(crud, new_model_obj)
|
24
|
+
else
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
|
29
|
+
def get_role
|
30
|
+
token = Token.find_by(access_token: Thread.current[:request].session[:access_token])
|
31
|
+
return token.user.role
|
32
|
+
end
|
33
|
+
|
34
|
+
def get_user_id
|
35
|
+
token = Token.find_by(access_token: Thread.current[:request].session[:access_token])
|
36
|
+
return token.user.id
|
37
|
+
end
|
38
|
+
|
39
|
+
private
|
40
|
+
|
41
|
+
# /////////////////////////////////
|
42
|
+
# WRITER
|
43
|
+
# /////////////////////////////////
|
44
|
+
|
45
|
+
# you can
|
46
|
+
# create: posts, categories, images
|
47
|
+
# update: my posts, categories, images, my user without role
|
48
|
+
# delete: my posts
|
49
|
+
|
50
|
+
# you cannot
|
51
|
+
# create: users
|
52
|
+
# update: other posts, other users, my user role
|
53
|
+
# delete: other posts, categories, images, users
|
54
|
+
|
55
|
+
def writer(crud, new_model_obj)
|
56
|
+
case crud
|
57
|
+
when 'create' then
|
58
|
+
writer_create(new_model_obj)
|
59
|
+
when 'update' then
|
60
|
+
writer_update(new_model_obj)
|
61
|
+
when 'destroy' then
|
62
|
+
writer_destroy(new_model_obj)
|
63
|
+
else
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def writer_create(new_model_obj)
|
68
|
+
case new_model_obj.class.name
|
69
|
+
when /Post/ then
|
70
|
+
# success
|
71
|
+
Rails.logger.debug("Writer create a post")
|
72
|
+
when /Category/ then
|
73
|
+
# success
|
74
|
+
Rails.logger.debug("Writer create a category")
|
75
|
+
when /Image/ then
|
76
|
+
# success
|
77
|
+
Rails.logger.debug("Writer create a image")
|
78
|
+
when /User/ then
|
79
|
+
# error
|
80
|
+
raise AuthorityError, 'Writer can not create User'
|
81
|
+
else
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
85
|
+
def writer_update(new_model_obj)
|
86
|
+
case new_model_obj.class.name
|
87
|
+
when /Post/ then
|
88
|
+
# error
|
89
|
+
raise AuthorityError, 'Writer can update only my Post' unless get_user_id == new_model_obj.user_id
|
90
|
+
|
91
|
+
# success
|
92
|
+
Rails.logger.debug("Writer update my post")
|
93
|
+
when /Category/ then
|
94
|
+
# success
|
95
|
+
Rails.logger.debug("Writer update a category")
|
96
|
+
when /Image/ then
|
97
|
+
# success
|
98
|
+
Rails.logger.debug("Writer update a image")
|
99
|
+
when /User/ then
|
100
|
+
# error
|
101
|
+
raise AuthorityError, 'Writer can update only my Post' unless get_user_id == new_model_obj.id
|
102
|
+
|
103
|
+
# success
|
104
|
+
Rails.logger.debug("Writer update my user")
|
105
|
+
else
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
def writer_destroy(new_model_obj)
|
111
|
+
case new_model_obj.class.name
|
112
|
+
when /Post/ then
|
113
|
+
# error
|
114
|
+
raise AuthorityError, 'Writer can destroy only my Post' unless get_user_id == new_model_obj.user_id
|
115
|
+
|
116
|
+
# success
|
117
|
+
Rails.logger.debug("Writer destroy my post")
|
118
|
+
when /Category/ then
|
119
|
+
# error
|
120
|
+
raise AuthorityError, 'Writer can not destroy Category'
|
121
|
+
when /Image/ then
|
122
|
+
# error
|
123
|
+
raise AuthorityError, 'Writer can not destroy Image'
|
124
|
+
when /User/ then
|
125
|
+
# error
|
126
|
+
raise AuthorityError, 'Writer can not destroy User'
|
127
|
+
else
|
128
|
+
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
# /////////////////////////////////
|
133
|
+
# EDITOR - Restriction
|
134
|
+
# /////////////////////////////////
|
135
|
+
|
136
|
+
# you can
|
137
|
+
# create: posts, categories, images
|
138
|
+
# update: posts, categories, images, my user without role
|
139
|
+
# delete: posts, categories, images
|
140
|
+
|
141
|
+
# you cannot
|
142
|
+
# - create: users
|
143
|
+
# - update: other users, my user role
|
144
|
+
# - delete: users
|
145
|
+
|
146
|
+
def editor(crud, new_model_obj)
|
147
|
+
case crud
|
148
|
+
when 'create' then
|
149
|
+
editor_create(new_model_obj)
|
150
|
+
when 'update' then
|
151
|
+
editor_update(new_model_obj)
|
152
|
+
when 'destroy' then
|
153
|
+
editor_destroy(new_model_obj)
|
154
|
+
else
|
155
|
+
|
156
|
+
end
|
157
|
+
end
|
158
|
+
|
159
|
+
def editor_create(new_model_obj)
|
160
|
+
case new_model_obj.class.name
|
161
|
+
when /Post/ then
|
162
|
+
# success
|
163
|
+
Rails.logger.debug("Editor create a post")
|
164
|
+
when /Category/ then
|
165
|
+
# success
|
166
|
+
Rails.logger.debug("Editor create a category")
|
167
|
+
when /Image/ then
|
168
|
+
# success
|
169
|
+
Rails.logger.debug("Editor create a image")
|
170
|
+
when /User/ then
|
171
|
+
# error
|
172
|
+
raise AuthorityError, 'Editor can not destroy User'
|
173
|
+
else
|
174
|
+
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def editor_update(new_model_obj)
|
179
|
+
case new_model_obj.class.name
|
180
|
+
when /Post/ then
|
181
|
+
# success
|
182
|
+
Rails.logger.debug("Editor update a post")
|
183
|
+
when /Category/ then
|
184
|
+
# success
|
185
|
+
Rails.logger.debug("Editor update a category")
|
186
|
+
when /Image/ then
|
187
|
+
# success
|
188
|
+
Rails.logger.debug("Editor update a image")
|
189
|
+
when /User/ then
|
190
|
+
# error
|
191
|
+
raise AuthorityError, 'Editor can update only my Post' unless get_user_id == new_model_obj.id
|
192
|
+
|
193
|
+
# success
|
194
|
+
Rails.logger.debug("Editor update a user")
|
195
|
+
else
|
196
|
+
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
def editor_destroy(new_model_obj)
|
201
|
+
case new_model_obj.class.name
|
202
|
+
when /Post/ then
|
203
|
+
# success
|
204
|
+
Rails.logger.debug("Editor destroy a post")
|
205
|
+
when /Category/ then
|
206
|
+
# success
|
207
|
+
Rails.logger.debug("Editor destroy a category")
|
208
|
+
when /Image/ then
|
209
|
+
# success
|
210
|
+
Rails.logger.debug("Editor destroy a image")
|
211
|
+
when /User/ then
|
212
|
+
# error
|
213
|
+
raise AuthorityError, 'Editor can not destroy User'
|
214
|
+
else
|
215
|
+
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
# /////////////////////////////////
|
220
|
+
# MANAGER - Restriction
|
221
|
+
# /////////////////////////////////
|
222
|
+
|
223
|
+
# you can
|
224
|
+
# create: posts, categories, images, users
|
225
|
+
# update: posts, categories, images, users
|
226
|
+
# delete: posts, categories, images, users
|
227
|
+
|
228
|
+
# you cannot
|
229
|
+
# - create: none
|
230
|
+
# - update: none
|
231
|
+
# - delete: none
|
232
|
+
|
233
|
+
def manager(crud, new_model_obj)
|
234
|
+
case crud
|
235
|
+
when 'create' then
|
236
|
+
manager_create(new_model_obj)
|
237
|
+
when 'update' then
|
238
|
+
manager_update(new_model_obj)
|
239
|
+
when 'destroy' then
|
240
|
+
manager_destroy(new_model_obj)
|
241
|
+
else
|
242
|
+
|
243
|
+
end
|
244
|
+
end
|
245
|
+
|
246
|
+
def manager_create(new_model_obj)
|
247
|
+
case new_model_obj.class.name
|
248
|
+
when /Post/ then
|
249
|
+
# success
|
250
|
+
Rails.logger.debug("Manager create a post")
|
251
|
+
when /Category/ then
|
252
|
+
# success
|
253
|
+
Rails.logger.debug("Manager create a category")
|
254
|
+
when /Image/ then
|
255
|
+
# success
|
256
|
+
Rails.logger.debug("Manager create a image")
|
257
|
+
when /User/ then
|
258
|
+
# success
|
259
|
+
Rails.logger.debug("Manager create a user")
|
260
|
+
else
|
261
|
+
|
262
|
+
end
|
263
|
+
end
|
264
|
+
|
265
|
+
def manager_update(new_model_obj)
|
266
|
+
case new_model_obj.class.name
|
267
|
+
when /Post/ then
|
268
|
+
# success
|
269
|
+
Rails.logger.debug("Manager update a post")
|
270
|
+
when /Category/ then
|
271
|
+
# success
|
272
|
+
Rails.logger.debug("Manager update a category")
|
273
|
+
when /Image/ then
|
274
|
+
# success
|
275
|
+
Rails.logger.debug("Manager update a image")
|
276
|
+
when /User/ then
|
277
|
+
# success
|
278
|
+
Rails.logger.debug("Manager update a user")
|
279
|
+
else
|
280
|
+
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
def manager_destroy(new_model_obj)
|
285
|
+
case new_model_obj.class.name
|
286
|
+
when /Post/ then
|
287
|
+
# success
|
288
|
+
Rails.logger.debug("Manager destroy a post")
|
289
|
+
when /Category/ then
|
290
|
+
# success
|
291
|
+
Rails.logger.debug("Manager destroy a category")
|
292
|
+
when /Image/ then
|
293
|
+
# success
|
294
|
+
Rails.logger.debug("Manager destroy a image")
|
295
|
+
when /User/ then
|
296
|
+
# success
|
297
|
+
Rails.logger.debug("Manager destroy a user")
|
298
|
+
else
|
299
|
+
|
300
|
+
end
|
301
|
+
end
|
302
|
+
|
303
|
+
# /////////////////////////////////
|
304
|
+
# ROOT
|
305
|
+
# /////////////////////////////////
|
306
|
+
|
307
|
+
# you can
|
308
|
+
# create: users
|
309
|
+
# update: none
|
310
|
+
# delete: none
|
311
|
+
|
312
|
+
# you cannot
|
313
|
+
# - create: posts, categories, images
|
314
|
+
# - update: posts, categories, images, users
|
315
|
+
# - delete: posts, categories, images, users
|
316
|
+
|
317
|
+
def root_user(crud, new_model_obj)
|
318
|
+
case crud
|
319
|
+
when 'create' then
|
320
|
+
root_create(new_model_obj)
|
321
|
+
when 'update' then
|
322
|
+
root_update(new_model_obj)
|
323
|
+
else
|
324
|
+
# error
|
325
|
+
raise AuthorityError, 'Root user only create User, and update own profile'
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
def root_create(new_model_obj)
|
330
|
+
case new_model_obj.class.name
|
331
|
+
when /User/ then
|
332
|
+
# success
|
333
|
+
Rails.logger.debug("Root user create a user")
|
334
|
+
else
|
335
|
+
# error
|
336
|
+
raise AuthorityError, 'Root user only create User'
|
337
|
+
end
|
338
|
+
end
|
339
|
+
|
340
|
+
def root_update(new_model_obj)
|
341
|
+
case new_model_obj.class.name
|
342
|
+
when /User/ then
|
343
|
+
raise AuthorityError, 'Root user only update own profile' unless new_model_obj.id == 0
|
344
|
+
# success
|
345
|
+
Rails.logger.debug("Root user update own profile")
|
346
|
+
else
|
347
|
+
# error
|
348
|
+
raise AuthorityError, 'Root user only update own profile'
|
349
|
+
end
|
350
|
+
end
|
351
|
+
|
352
|
+
# /////////////////////////////////
|
353
|
+
# DELETED
|
354
|
+
# /////////////////////////////////
|
355
|
+
|
356
|
+
# you can
|
357
|
+
# create: none
|
358
|
+
# update: none
|
359
|
+
# delete: none
|
360
|
+
|
361
|
+
# you cannot
|
362
|
+
# - create: all
|
363
|
+
# - update: all
|
364
|
+
# - delete: all
|
365
|
+
|
366
|
+
def check_deleted
|
367
|
+
token = Token.find_by(access_token: Thread.current[:request].session[:access_token])
|
368
|
+
if token.user.is_deleted
|
369
|
+
# error
|
370
|
+
raise AuthorityError, 'This User is Deleted..'
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
end
|
375
|
+
end
|
376
|
+
end
|
377
|
+
|