notee 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (246) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/notee/application.js +19539 -17294
  3. data/app/controllers/notee/application_controller.rb +5 -0
  4. data/app/controllers/notee/categories_controller.rb +7 -3
  5. data/app/controllers/notee/comments_controller.rb +9 -4
  6. data/app/controllers/notee/images_controller.rb +2 -2
  7. data/app/controllers/notee/posts_controller.rb +11 -4
  8. data/app/controllers/notee/roles_controller.rb +1 -1
  9. data/app/controllers/notee/tokens_controller.rb +9 -15
  10. data/app/controllers/notee/trashes_controller.rb +60 -0
  11. data/app/controllers/notee/users_controller.rb +26 -6
  12. data/app/models/notee/application_record.rb +27 -0
  13. data/app/models/notee/authority.rb +377 -0
  14. data/app/models/notee/category.rb +15 -2
  15. data/app/models/notee/comment.rb +6 -0
  16. data/app/models/notee/image.rb +2 -2
  17. data/app/models/notee/post.rb +7 -5
  18. data/app/models/notee/user.rb +97 -41
  19. data/app/views/layouts/notee/application.html.erb +3 -1
  20. data/config/routes.rb +19 -9
  21. data/db/migrate/20160605141437_create_notee_posts.rb +1 -0
  22. data/db/migrate/20160605141510_create_notee_categories.rb +4 -1
  23. data/db/migrate/20160605141547_create_notee_images.rb +4 -2
  24. data/db/migrate/20160803154954_create_notee_comments.rb +2 -1
  25. data/db/migrate/20160809145754_create_notee_users.rb +1 -0
  26. data/lib/notee/helpers/notee_helper.rb +65 -46
  27. data/lib/notee/helpers/view_helper.rb +10 -2
  28. data/lib/notee/status.rb +1 -2
  29. data/lib/notee/version.rb +1 -1
  30. data/lib/tasks/config/notee.rb +26 -0
  31. data/lib/tasks/config/schedule.rb +7 -0
  32. data/lib/tasks/controllers/notee_controller.rb +65 -0
  33. data/lib/tasks/javascripts/notee/highlight.pack.js +2 -0
  34. data/lib/tasks/notee_tasks.rake +105 -51
  35. data/lib/tasks/stylesheets/notee/highlight/agate.css +108 -0
  36. data/lib/tasks/stylesheets/notee/highlight/androidstudio.css +66 -0
  37. data/lib/tasks/stylesheets/notee/highlight/arduino-light.css +88 -0
  38. data/lib/tasks/stylesheets/notee/highlight/arta.css +73 -0
  39. data/lib/tasks/stylesheets/notee/highlight/ascetic.css +45 -0
  40. data/lib/tasks/stylesheets/notee/highlight/atelier-cave-dark.css +83 -0
  41. data/lib/tasks/stylesheets/notee/highlight/atelier-cave-light.css +85 -0
  42. data/lib/tasks/stylesheets/notee/highlight/atelier-dune-dark.css +69 -0
  43. data/lib/tasks/stylesheets/notee/highlight/atelier-dune-light.css +69 -0
  44. data/lib/tasks/stylesheets/notee/highlight/atelier-estuary-dark.css +84 -0
  45. data/lib/tasks/stylesheets/notee/highlight/atelier-estuary-light.css +84 -0
  46. data/lib/tasks/stylesheets/notee/highlight/atelier-forest-dark.css +69 -0
  47. data/lib/tasks/stylesheets/notee/highlight/atelier-forest-light.css +69 -0
  48. data/lib/tasks/stylesheets/notee/highlight/atelier-heath-dark.css +69 -0
  49. data/lib/tasks/stylesheets/notee/highlight/atelier-heath-light.css +69 -0
  50. data/lib/tasks/stylesheets/notee/highlight/atelier-lakeside-dark.css +69 -0
  51. data/lib/tasks/stylesheets/notee/highlight/atelier-lakeside-light.css +69 -0
  52. data/lib/tasks/stylesheets/notee/highlight/atelier-plateau-dark.css +84 -0
  53. data/lib/tasks/stylesheets/notee/highlight/atelier-plateau-light.css +84 -0
  54. data/lib/tasks/stylesheets/notee/highlight/atelier-savanna-dark.css +84 -0
  55. data/lib/tasks/stylesheets/notee/highlight/atelier-savanna-light.css +84 -0
  56. data/lib/tasks/stylesheets/notee/highlight/atelier-seaside-dark.css +69 -0
  57. data/lib/tasks/stylesheets/notee/highlight/atelier-seaside-light.css +69 -0
  58. data/lib/tasks/stylesheets/notee/highlight/atelier-sulphurpool-dark.css +69 -0
  59. data/lib/tasks/stylesheets/notee/highlight/atelier-sulphurpool-light.css +69 -0
  60. data/lib/tasks/stylesheets/notee/highlight/atom-one-dark.css +96 -0
  61. data/lib/tasks/stylesheets/notee/highlight/atom-one-light.css +96 -0
  62. data/lib/tasks/stylesheets/notee/highlight/brown-paper.css +64 -0
  63. data/lib/tasks/stylesheets/notee/highlight/brown-papersq.png +0 -0
  64. data/lib/tasks/stylesheets/notee/highlight/codepen-embed.css +60 -0
  65. data/lib/tasks/stylesheets/notee/highlight/color-brewer.css +71 -0
  66. data/lib/tasks/stylesheets/notee/highlight/darcula.css +77 -0
  67. data/lib/tasks/stylesheets/notee/highlight/dark.css +63 -0
  68. data/lib/tasks/stylesheets/notee/highlight/darkula.css +6 -0
  69. data/lib/tasks/stylesheets/notee/highlight/default.css +99 -0
  70. data/lib/tasks/stylesheets/notee/highlight/docco.css +97 -0
  71. data/lib/tasks/stylesheets/notee/highlight/dracula.css +76 -0
  72. data/lib/tasks/stylesheets/notee/highlight/far.css +71 -0
  73. data/lib/tasks/stylesheets/notee/highlight/foundation.css +88 -0
  74. data/lib/tasks/stylesheets/notee/highlight/github-gist.css +71 -0
  75. data/lib/tasks/stylesheets/notee/highlight/github.css +99 -0
  76. data/lib/tasks/stylesheets/notee/highlight/googlecode.css +89 -0
  77. data/lib/tasks/stylesheets/notee/highlight/grayscale.css +101 -0
  78. data/lib/tasks/stylesheets/notee/highlight/gruvbox-dark.css +108 -0
  79. data/lib/tasks/stylesheets/notee/highlight/gruvbox-light.css +108 -0
  80. data/lib/tasks/stylesheets/notee/highlight/hopscotch.css +83 -0
  81. data/lib/tasks/stylesheets/notee/highlight/hybrid.css +102 -0
  82. data/lib/tasks/stylesheets/notee/highlight/idea.css +97 -0
  83. data/lib/tasks/stylesheets/notee/highlight/ir-black.css +73 -0
  84. data/lib/tasks/stylesheets/notee/highlight/kimbie.dark.css +74 -0
  85. data/lib/tasks/stylesheets/notee/highlight/kimbie.light.css +74 -0
  86. data/lib/tasks/stylesheets/notee/highlight/magula.css +70 -0
  87. data/lib/tasks/stylesheets/notee/highlight/mono-blue.css +59 -0
  88. data/lib/tasks/stylesheets/notee/highlight/monokai-sublime.css +83 -0
  89. data/lib/tasks/stylesheets/notee/highlight/monokai.css +70 -0
  90. data/lib/tasks/stylesheets/notee/highlight/obsidian.css +88 -0
  91. data/lib/tasks/stylesheets/notee/highlight/ocean.css +74 -0
  92. data/lib/tasks/stylesheets/notee/highlight/paraiso-dark.css +72 -0
  93. data/lib/tasks/stylesheets/notee/highlight/paraiso-light.css +72 -0
  94. data/lib/tasks/stylesheets/notee/highlight/pojoaque.css +83 -0
  95. data/lib/tasks/stylesheets/notee/highlight/pojoaque.jpg +0 -0
  96. data/lib/tasks/stylesheets/notee/highlight/purebasic.css +96 -0
  97. data/lib/tasks/stylesheets/notee/highlight/qtcreator_dark.css +83 -0
  98. data/lib/tasks/stylesheets/notee/highlight/qtcreator_light.css +83 -0
  99. data/lib/tasks/stylesheets/notee/highlight/railscasts.css +106 -0
  100. data/lib/tasks/stylesheets/notee/highlight/rainbow.css +85 -0
  101. data/lib/tasks/stylesheets/notee/highlight/school-book.css +72 -0
  102. data/lib/tasks/stylesheets/notee/highlight/school-book.png +0 -0
  103. data/lib/tasks/stylesheets/notee/highlight/solarized-dark.css +84 -0
  104. data/lib/tasks/stylesheets/notee/highlight/solarized-light.css +84 -0
  105. data/lib/tasks/stylesheets/notee/highlight/sunburst.css +102 -0
  106. data/lib/tasks/stylesheets/notee/highlight/tomorrow-night-blue.css +75 -0
  107. data/lib/tasks/stylesheets/notee/highlight/tomorrow-night-bright.css +74 -0
  108. data/lib/tasks/stylesheets/notee/highlight/tomorrow-night-eighties.css +74 -0
  109. data/lib/tasks/stylesheets/notee/highlight/tomorrow-night.css +75 -0
  110. data/lib/tasks/stylesheets/notee/highlight/tomorrow.css +72 -0
  111. data/lib/tasks/stylesheets/notee/highlight/vs.css +68 -0
  112. data/lib/tasks/stylesheets/notee/highlight/xcode.css +93 -0
  113. data/lib/tasks/stylesheets/notee/highlight/xt256.css +92 -0
  114. data/lib/tasks/stylesheets/notee/highlight/zenburn.css +80 -0
  115. data/lib/tasks/stylesheets/notee/normalize.css +427 -0
  116. data/lib/tasks/stylesheets/notee/notee_default.css +386 -0
  117. data/lib/tasks/views/notee/about.html.erb +43 -0
  118. data/lib/tasks/views/notee/archives.html.erb +16 -0
  119. data/lib/tasks/views/notee/categories.html.erb +15 -0
  120. data/lib/tasks/views/notee/partials/_foote.html.erb +3 -0
  121. data/lib/tasks/views/notee/partials/_header.html.erb +17 -0
  122. data/lib/tasks/views/notee/partials/_profile.html.erb +9 -0
  123. data/lib/tasks/views/notee/partials/_sidebar.html.erb +23 -0
  124. data/lib/tasks/views/notee/posts.html.erb +53 -0
  125. data/lib/tasks/views/notee/show.html.erb +42 -0
  126. data/lib/tasks/views/notee/writers.html.erb +11 -0
  127. metadata +115 -240
  128. data/lib/tasks/css/notee_default.css +0 -59
  129. data/test/dummy/db/development.sqlite3 +0 -0
  130. data/test/dummy/db/test.sqlite3 +0 -0
  131. data/test/dummy/log/development.log +0 -3087
  132. data/test/dummy/log/test.log +0 -872
  133. data/test/dummy/tmp/cache/assets/sprockets/v3.0/-t/-tdJTrCcY92VpiO_z6SIt_iHkHDtn1-8Vf__p-Ve9lU.cache +0 -1
  134. data/test/dummy/tmp/cache/assets/sprockets/v3.0/0K/0KQJQyRy3gQkymW0xnPhM4_OpLtoTcw9Rutx4F4IajE.cache +0 -1
  135. data/test/dummy/tmp/cache/assets/sprockets/v3.0/1B/1Bb2_fhXoTmM27WcuQJ2sr0UCMHh6TjrBIwd6Ks8qJ0.cache +0 -1
  136. data/test/dummy/tmp/cache/assets/sprockets/v3.0/1N/1NYje2ld9grEMpvxBFjocEWWMPi4jNPuPLdlkV1Wq5A.cache +0 -0
  137. data/test/dummy/tmp/cache/assets/sprockets/v3.0/1s/1sPuKGE0jImBtnCnczIk6NpOn9cYeyBZsXHvpXJ1tGA.cache +0 -2
  138. data/test/dummy/tmp/cache/assets/sprockets/v3.0/1s/1sRxHck-81_JSGvEidXPx2S86Cbe0UjizohTg5lkd-U.cache +0 -0
  139. data/test/dummy/tmp/cache/assets/sprockets/v3.0/3d/3dw9fS6dak9HSgJqviXZ6CCibFx8--QDKyWjrqKqraI.cache +0 -0
  140. data/test/dummy/tmp/cache/assets/sprockets/v3.0/4S/4SCYKO2aAiXfZPZF1vTYeIQegrrqvH-2jlfGl1I6juQ.cache +0 -1
  141. data/test/dummy/tmp/cache/assets/sprockets/v3.0/4z/4zE2reLAwChLIBivfo5JfQjRwOM2sBvlDLXftsA772o.cache +0 -1
  142. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5L/5Lly_CA8DZvPhQV2jDQx-Y6P_y3Ygra9t5jfSlGhHDA.cache +0 -0
  143. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5p/5pDjSjY69Pd-A64UKCqQ_yxQouHkmBElVBKf1IZT2HM.cache +0 -1
  144. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5p/5pnvfhvSgahCnLPLbhB7dM8lSEhk2w39UTDXe83gYng.cache +0 -0
  145. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5r/5r2K8e-LRVnmo3VUaNdNx3K1b_BgFMOboxlnTQC_Ckk.cache +0 -1
  146. data/test/dummy/tmp/cache/assets/sprockets/v3.0/5u/5ue4ZdF425UevYa9Danha84KDME2s4InW-zR-y-Y0SM.cache +0 -2
  147. data/test/dummy/tmp/cache/assets/sprockets/v3.0/6Q/6Qq8Rnvquz8oH8ojJlj79pSAhSHH_VoWRS0Cn-d-yLQ.cache +0 -1
  148. data/test/dummy/tmp/cache/assets/sprockets/v3.0/6Y/6Y--Gdy-iDkVFcgE3j660zOA3sf_osOedfJpeV_Kxh4.cache +0 -0
  149. data/test/dummy/tmp/cache/assets/sprockets/v3.0/7G/7GrmDrSvjAFvLUcaRN95cQLmvkzf8D_cvGlhRyL01HA.cache +0 -1
  150. data/test/dummy/tmp/cache/assets/sprockets/v3.0/83/83mXRYYdvGZS4tNS_IFZLa5P6e-fg9MSMqWG4MJ-Jks.cache +0 -1
  151. data/test/dummy/tmp/cache/assets/sprockets/v3.0/8H/8HKewCH2XL9errlVDVPK8QZg0LoH-_Q3zqQ1pjCYBEU.cache +0 -1
  152. data/test/dummy/tmp/cache/assets/sprockets/v3.0/8v/8vJIODLLCFZwV8yIF98dlb5_CQZlgBdCLiM8UA6WiSA.cache +0 -1
  153. data/test/dummy/tmp/cache/assets/sprockets/v3.0/9W/9WtQTxW8TE4CQvkem1QkHVjZFB93XAJo3ioPSt6U5wM.cache +0 -0
  154. data/test/dummy/tmp/cache/assets/sprockets/v3.0/AH/AHLaBPz-xNABgeh1V66iU7wJ6FCxvFIie5V05wRvI84.cache +0 -1
  155. data/test/dummy/tmp/cache/assets/sprockets/v3.0/C1/C1S3q8MtvUImrUe70fZPf9wxMfxdcWPSRXRrv4H6_lo.cache +0 -1
  156. data/test/dummy/tmp/cache/assets/sprockets/v3.0/D4/D4ftsVSRtZadejqqBmur8bfiHLhZFCaIjpsAdJT28Iw.cache +0 -1
  157. data/test/dummy/tmp/cache/assets/sprockets/v3.0/DS/DSOLSc6A5RVSmvM415eEWAWG_AgOvZcLZOXQjsXyWQA.cache +0 -2
  158. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fr/FrWiXIfDo2-fsKFSgef9Bs-0HjC7dOgBY8IVBLCq9ag.cache +0 -1
  159. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Fz/FzjTR8U_FOgMIbfYBgJfzujyNBozRZd-3YYTkiAQTOg.cache +0 -1
  160. data/test/dummy/tmp/cache/assets/sprockets/v3.0/G6/G6nKI6E9cfkIZqH5EnbMJtS4DKHApFlNTKh__ZuK774.cache +0 -2
  161. data/test/dummy/tmp/cache/assets/sprockets/v3.0/HH/HHQp4rqJ3kx9sfFo3AAW2DS6zHl28lCqALB5YnKXeG8.cache +0 -0
  162. data/test/dummy/tmp/cache/assets/sprockets/v3.0/IN/INpQmG9J4AOUCg2YWypvnwq9ce01SFPnDGidI2qcU_8.cache +0 -1
  163. data/test/dummy/tmp/cache/assets/sprockets/v3.0/J0/J038M_TjhJBb-678LCin4jaJSkSaaXy7XHJbEp1Bo5I.cache +0 -2
  164. data/test/dummy/tmp/cache/assets/sprockets/v3.0/JI/JIHr2A9bWoln5XahhS15lRxvHSXdQZ7OrlbAW1IzayM.cache +0 -1
  165. data/test/dummy/tmp/cache/assets/sprockets/v3.0/JI/JId5JhtAhhN90V7z1OSItT9m4n4H_Nfk3IGtOW0mA_s.cache +0 -3
  166. data/test/dummy/tmp/cache/assets/sprockets/v3.0/JP/JPylOhsUjr9NtL1AViDe-Sz0-iLPZGPww463ChRqhEw.cache +0 -0
  167. data/test/dummy/tmp/cache/assets/sprockets/v3.0/JU/JUdbchVNMjz67zIvPztSzFfpU_VO4Rl9V86GzJH28_A.cache +0 -2
  168. data/test/dummy/tmp/cache/assets/sprockets/v3.0/K0/K0Ou5PNqxeODBFSEnIeg7EaidQVBRvPH-SPrTF1tRVA.cache +0 -1
  169. data/test/dummy/tmp/cache/assets/sprockets/v3.0/KS/KSTuVqjLw0xUGYH5WcnAloHDphCDQr4cFjXKKl5vW7M.cache +0 -0
  170. data/test/dummy/tmp/cache/assets/sprockets/v3.0/L-/L--JLWiCS6RZ0l_EciZOoY0eTEs6BGBED1YZ7hj13vQ.cache +0 -1
  171. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ME/META30ksADpNoAnM_vlhKhlLOfxBlo5uJjJKSJa264o.cache +0 -1
  172. data/test/dummy/tmp/cache/assets/sprockets/v3.0/MH/MHQULHaqwmMfm67LLiF_ZDlM6Zix3aPput7pxTViWQ0.cache +0 -1
  173. data/test/dummy/tmp/cache/assets/sprockets/v3.0/NK/NKXg7894FsAVQJxXzYkUOgd131zYAeWOIxmegdT-LFk.cache +0 -2
  174. data/test/dummy/tmp/cache/assets/sprockets/v3.0/NW/NWx4g28WkpCPeRLdgMDaUuLO2e4UIw2bs-HKy-ixIlU.cache +0 -1
  175. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Nj/NjPNj--fkweGPvPTHkDlefKtB5bpFaGG9X60M_goNUo.cache +0 -2
  176. data/test/dummy/tmp/cache/assets/sprockets/v3.0/OI/OI6uxGcnsKavdWTtwDAasU3wPx8QXhzBgV0X2n1KjMQ.cache +0 -0
  177. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Oh/Ohok7uysixzjxK1FE7m-KJv6gqYQH4svN8nZyRBOgwA.cache +0 -1
  178. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ot/Ot7COhZjTueyAONhzjXiOOwv0uTS9EtXGgxYznVMIvs.cache +0 -3
  179. data/test/dummy/tmp/cache/assets/sprockets/v3.0/P4/P4KZGx6J2yGIq1PMq13fnsaXrS47R-S_sYrQrcUL59I.cache +0 -3
  180. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Pn/Pn9eXmle4fRjakm_xgwyXs5YzlWELSuhbi3nnV2-Ink.cache +0 -0
  181. data/test/dummy/tmp/cache/assets/sprockets/v3.0/QY/QYNLSW9XctrfttzhOfkik5INswRo-qBjjwQvA7S_lyc.cache +0 -1
  182. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Qb/Qbb4ATlvuCS0fudaTweqJoma2S99Mr2Q6ISbIpDoMso.cache +0 -0
  183. data/test/dummy/tmp/cache/assets/sprockets/v3.0/R6/R6E4Q8O1upT5p_U-ySDbO3dFY6SMeSwmubqJUfSJedo.cache +0 -0
  184. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Rv/RvcRQ_I7meCLqBRooErlcPwcbH0tdDuvO5SQ_Xy45Qk.cache +0 -2
  185. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Sz/SzRmx7uSmniNAGO1zMPd4qzEgM8eAaWBqaxestc32Jg.cache +0 -0
  186. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Tk/TkRyIpbn-1DcVexPTWUljWQOek0D_q6yO_jYNGwKM_o.cache +0 -0
  187. data/test/dummy/tmp/cache/assets/sprockets/v3.0/U1/U1E_3Z4bItTBl9s8aX6O2rceqAD5GfoNzF8AqYs9Hig.cache +0 -0
  188. data/test/dummy/tmp/cache/assets/sprockets/v3.0/UC/UCe1qLwGTD6W2etoFOMln6E2DgTq8Xnm7eGvCs6YGEE.cache +0 -1
  189. data/test/dummy/tmp/cache/assets/sprockets/v3.0/UZ/UZhrzLOgNG132Xf1yJ7H7lSq4S3TyDoPphdzwKU8fqQ.cache +0 -3
  190. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Ud/UdBXq-s3u32R-gjMCYZv9RJH4n1xSt8PnBpWxg-JzGE.cache +0 -1
  191. data/test/dummy/tmp/cache/assets/sprockets/v3.0/VD/VDaYJQJdErZ0zVg9KgvidORf7a13jqM72Uk97zzuUZU.cache +0 -2
  192. data/test/dummy/tmp/cache/assets/sprockets/v3.0/WT/WTExV_4iBOBS-SWMh6jqm61uSp83ezH5DPIkjfktls4.cache +0 -3
  193. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Wi/Wia5tzg4hJNhNhKWgY7pkrxWbvr6n0YaKXl80wh6qPg.cache +0 -1
  194. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Wl/WldqQqssrkJedTdiFt86Y6FDn5ww1MirVAAnOpRqeCE.cache +0 -3
  195. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Wv/WvAZ72pGsB5VpmTmGBucm1eztH129yQ1YmrRMy-yS4g.cache +0 -0
  196. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Wz/WzSkff9VUQsb0DJ5RB3m3SfxRTMU97qhyNCqiIHlJPw.cache +0 -1
  197. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Yx/Yx6fZ9ju2qCb4Ps_0iEzNR7KgDNTE2gIRjcdOMFXNlo.cache +0 -2
  198. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ZO/ZOUPFk5_ZB8Wtn42g9PiY6Qu7KSbipNG04Qa5YSP6sw.cache +0 -0
  199. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ZT/ZT-4a7lIKMm0Swxyt7MdXMz5v6r5MaVvtHvqAT6T8Ts.cache +0 -0
  200. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Zb/ZbvOW6HdEiql0zdGkCPG-EK8beJAmp1ovBR1Oy1V6Fw.cache +0 -1
  201. data/test/dummy/tmp/cache/assets/sprockets/v3.0/Zu/ZuAoFB2A_kFOIb19dNUzEU5jP-SzQLmauPCURINz2Fo.cache +0 -0
  202. data/test/dummy/tmp/cache/assets/sprockets/v3.0/_r/_rmEe1ir-igQN0twVhxrxngbLIFJkINITWVGNye4-MM.cache +0 -2
  203. data/test/dummy/tmp/cache/assets/sprockets/v3.0/aE/aEQNT9eY4cAc2ACQnD35BkLV5dEezB-drcCoF1SzjAc.cache +0 -0
  204. data/test/dummy/tmp/cache/assets/sprockets/v3.0/bK/bKPdLlYXb5ZZU8vrzCdKqLgCXyeiXHExSl9lwGIofU0.cache +0 -0
  205. data/test/dummy/tmp/cache/assets/sprockets/v3.0/br/brGLDCuoxhnIrvwsuWmzjnwDV7Bn_nezqOrXiI0oco0.cache +0 -3
  206. data/test/dummy/tmp/cache/assets/sprockets/v3.0/c3/c3Jo7UkNggNJH21U9HD-Y5Lipd68yZXcl6FGMbzFEeM.cache +0 -0
  207. data/test/dummy/tmp/cache/assets/sprockets/v3.0/c4/c4YjuvK4zQOjr5Q6N7A_-NHM59NF0kGApLBxSZ5JgqA.cache +0 -1
  208. data/test/dummy/tmp/cache/assets/sprockets/v3.0/c9/c9B4H9i5OvdAnZpel-KocssCcsd3TS2Gqe4uKAFjiKQ.cache +0 -1
  209. data/test/dummy/tmp/cache/assets/sprockets/v3.0/dM/dMJ_N4wD6R1wforGNMdyz6wec-5a7_H03vxu0pgPhLc.cache +0 -0
  210. data/test/dummy/tmp/cache/assets/sprockets/v3.0/dr/drYndmRIbBKroImntO4XhUYV5kqxE2q2qE_aYRwYj4Q.cache +0 -0
  211. data/test/dummy/tmp/cache/assets/sprockets/v3.0/du/dumQ6K8NP4rz74ofF4DxxFRetR-K07c75MhZrUQDbqY.cache +0 -3
  212. data/test/dummy/tmp/cache/assets/sprockets/v3.0/fn/fns6a_EwXvrlRyeQjB9lcYXHfIZi0guP75oUWPuz4Z0.cache +0 -0
  213. data/test/dummy/tmp/cache/assets/sprockets/v3.0/g3/g3NfArxOfOGHlWIGK-Znm2-gh1Oyud_f5ZEFuGrOv2g.cache +0 -0
  214. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gF/gFErWaVWbjefUiSe3yI-bWCrUD3SsMHomSjTacMlSDM.cache +0 -2
  215. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gG/gGCsoohK0vflREMUeOrfW4KZeI73jU9ld5t0pzfjh4U.cache +0 -0
  216. data/test/dummy/tmp/cache/assets/sprockets/v3.0/gZ/gZp3uXMHuYQC4hzCr7bQfetKNdJAtbQmg3so2KpW1Dw.cache +0 -2
  217. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/Hz6pNt28QsuyrFcIx0afHONIVEGdLBEC64cV2zh2xAM.cache +0 -2
  218. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hZ/hZi1k6tpxxCGYxRe7zY74ItcOI8gZrREOpGuA8JSpGg.cache +0 -0
  219. data/test/dummy/tmp/cache/assets/sprockets/v3.0/hv/hvw4qAvufcLTOeT9ie13DTIDt3SOLih2iH9P603ZOFQ.cache +0 -0
  220. data/test/dummy/tmp/cache/assets/sprockets/v3.0/iZ/iZGxFM6U5PSEZmHGlksi8vAVBMlMiyjOBaL8HIGcOPE.cache +0 -0
  221. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ig/iguUMDAVIm9pfM52njpM4hqpnNYkwKTWvNXQyolgR74.cache +0 -0
  222. data/test/dummy/tmp/cache/assets/sprockets/v3.0/jJ/jJTo0slnuZqKDbuFGjyBEkenWViH1MiTvb7gNjc4SL4.cache +0 -1
  223. data/test/dummy/tmp/cache/assets/sprockets/v3.0/jN/jNM9mSzc6sg9yU7srXH0l2_bPIXbqLtJVBML2umXb9w.cache +0 -0
  224. data/test/dummy/tmp/cache/assets/sprockets/v3.0/jh/jhx8TAOiUaenqesmOiahNzaVcnpiciOE8VKZdrxGerc.cache +0 -1
  225. data/test/dummy/tmp/cache/assets/sprockets/v3.0/kT/kTif4yPNd0vB6fWie0kxsN5Gwubl8sqAOyydwpiyHzo.cache +0 -1
  226. data/test/dummy/tmp/cache/assets/sprockets/v3.0/m3/m3lSeIbfcyVVkENoCOiz_6LvNubosVesCJBkdI88aNk.cache +0 -1
  227. data/test/dummy/tmp/cache/assets/sprockets/v3.0/m6/m6kJHQNOyyMHxod8TObJKAp8iV_noMwYPWsBh-CCG0k.cache +0 -1
  228. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mX/mXJ655Gxgvg2C08jNcMFB9OQ2G6HrtGc_MfVIpYycsg.cache +0 -3
  229. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mr/MrG8zKUbpqoyxO2GdEOuWmFBUIpOKL3upEtfOWsYluQ.cache +0 -0
  230. data/test/dummy/tmp/cache/assets/sprockets/v3.0/mr/mr-hjupF6Lf8wABiaoi8L9823j20yjhhTnrn4FNsEZI.cache +0 -1
  231. data/test/dummy/tmp/cache/assets/sprockets/v3.0/n2/n2T4JbhKpnbSE5uhnXyPzu4WnDOkMu78BrJ-Huhn7YU.cache +0 -2
  232. data/test/dummy/tmp/cache/assets/sprockets/v3.0/nC/nCuKY2iJdzgSyWS09dThZ5T57F8vGBo0w-ycyuEidUk.cache +0 -1
  233. data/test/dummy/tmp/cache/assets/sprockets/v3.0/og/ogVEMp7SPQ-wAJz4mNXdRrx52GXFvHKpSx3bS7dr_t8.cache +0 -1
  234. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pE/pEhaat2KBd5SrT7szC_8R1_6hK17FTpvoRFkmCRSD3M.cache +0 -0
  235. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pO/pOOGu7nAdun08PmdiHZas85h5Kqbgs6_M5vHQQKJgW8.cache +0 -1
  236. data/test/dummy/tmp/cache/assets/sprockets/v3.0/pX/pXIDW5zCrR8MxxTON9elPRDkMBEefpa-fWViSmyJGns.cache +0 -2
  237. data/test/dummy/tmp/cache/assets/sprockets/v3.0/qF/qFG1ZnUOHTHsxMxvN1iTKNCA05nrecKPlygtJzvMdSs.cache +0 -2
  238. data/test/dummy/tmp/cache/assets/sprockets/v3.0/sS/sS00IDFTJ19zoTjrB2-Sypybo0I1qXoTtW8JabBMoAo.cache +0 -0
  239. data/test/dummy/tmp/cache/assets/sprockets/v3.0/sb/sbB7Wbcww5hxA8e-5K0oBKQDnlNNnY90t0YUIdYE138.cache +0 -1
  240. data/test/dummy/tmp/cache/assets/sprockets/v3.0/xX/xXo4fouecqy2oZpxsgtkqL6uyIDuKLwBUwmzddno9hw.cache +0 -0
  241. data/test/dummy/tmp/cache/assets/sprockets/v3.0/x_/x_WcnsWyMV1QzLUnFW5J4gZHs0gACREYGaSom7xcaBQ.cache +0 -1
  242. data/test/dummy/tmp/cache/assets/sprockets/v3.0/yC/yCp-2wuXWORHGqxfwG37-mb00X8GpHiRjrlo2QQX3lU.cache +0 -1
  243. data/test/dummy/tmp/cache/assets/sprockets/v3.0/yW/yWtPpcB-kB8_hw5k0prtaOvTW5A5PaCT0ZaJSdh8Zkw.cache +0 -0
  244. data/test/dummy/tmp/cache/assets/sprockets/v3.0/ys/ysFM6FIJniGme1T62LOmRFt3h7g0scd6o6BFIjS5Ppg.cache +0 -0
  245. data/test/dummy/tmp/cache/assets/sprockets/v3.0/z4/z4i9WzpZRzFXynWsqewNMikNdcZ9f9mGFdlrIP5N6Gs.cache +0 -1
  246. data/test/dummy/tmp/cache/assets/sprockets/v3.0/zN/zNfQXfFXMTyOoz3HbVM-_4m-46rWO7XrZPvGs4aJCQc.cache +0 -2
@@ -12,10 +12,11 @@
12
12
  #
13
13
 
14
14
  module Notee
15
- class Category < ActiveRecord::Base
15
+ class Category < ApplicationRecord
16
+
16
17
  # callbacks
17
18
  before_save :set_slug
18
- before_destroy :protect_default
19
+ before_save :protect_default
19
20
 
20
21
  # relations
21
22
  has_many :children, class_name: Notee::Category, foreign_key: 'parent_id', dependent: :destroy
@@ -29,5 +30,17 @@ module Notee
29
30
  def protect_default
30
31
  return false if self.id == 1
31
32
  end
33
+
34
+ def self.before_destroy_parent(id)
35
+ @child_with_parent =Category.where(parent_id: id)
36
+
37
+ Category.skip_callback(:update, :before, :update_authority)
38
+ Category.skip_callback(:update, :before, :destroy_authority)
39
+ @child_with_parent.each do |child|
40
+ child.update(parent_id: nil)
41
+ end
42
+ Category.set_callback(:update, :before, :update_authority)
43
+ Category.set_callback(:update, :before, :destroy_authority)
44
+ end
32
45
  end
33
46
  end
@@ -1,5 +1,11 @@
1
1
  module Notee
2
2
  class Comment < ActiveRecord::Base
3
+
4
+ # scopes
5
+ scope :trash, -> { where(is_deleted: true) }
6
+ scope :time_limit, -> { where('updated_at <= ?', Time.current - 60*60*24*30) }
7
+
8
+ # validates
3
9
  validates :post_id, presence: true
4
10
  validates :content, presence: true
5
11
  end
@@ -11,13 +11,13 @@
11
11
  require 'securerandom'
12
12
 
13
13
  module Notee
14
- class Image < ActiveRecord::Base
14
+ class Image < ApplicationRecord
15
15
  # accessors
16
16
  attr_accessor :file
17
17
 
18
18
  # callbacks
19
19
  before_save :manage_image
20
- before_destroy :protect_default
20
+ before_save :protect_default
21
21
 
22
22
  private
23
23
 
@@ -17,20 +17,25 @@
17
17
  #
18
18
 
19
19
  module Notee
20
- class Post < ActiveRecord::Base
20
+ class Post < ApplicationRecord
21
21
  # callbacks
22
22
  before_create :set_title
23
23
  before_create :set_slug
24
+
24
25
  before_save :set_published_at
25
- before_save :check_role
26
26
 
27
27
  # relations
28
+ belongs_to :user
28
29
  belongs_to :category
29
30
  belongs_to :thumbnail, class_name: Notee::Image, foreign_key: 'thumbnail_id'
30
31
 
31
32
  # accessors
32
33
  attr_accessor :editor_id
33
34
 
35
+ def set_user_id
36
+ self.user_id = Authority.get_user_id
37
+ end
38
+
34
39
  private
35
40
 
36
41
  def set_title
@@ -48,8 +53,5 @@ module Notee
48
53
  end
49
54
  end
50
55
 
51
- def check_role
52
-
53
- end
54
56
  end
55
57
  end
@@ -1,74 +1,130 @@
1
1
  module Notee
2
- class User < ActiveRecord::Base
3
- # enums
4
- enum role: { writer: 0, editor: 10, manager: 20, suspended: 99 }
5
-
6
- # writer
7
- # - create: posts, categories, images
8
- # - update: my posts, my user
9
- # - delete: my posts (Logical delete)
10
-
11
- # editor
12
- # - create: posts, categories, images
13
- # - update: posts, categories, images, my user
14
- # - delete: posts, categories, images (Logical delete)
2
+ class User < ApplicationRecord
15
3
 
16
- # manager
17
- # - create: posts, categories, images, users
18
- # - update: posts, categories, images, users
19
- # - delete: posts, categories, images, users (Logical delete)
4
+ # relations
5
+ has_many :posts
20
6
 
21
- # suspended
22
- # all none
23
-
24
- # root
25
- # all
7
+ # enums
8
+ enum role: { writer: 0, editor: 10, manager: 20, root: 9999 }
26
9
 
27
10
  # accessors
28
11
  attr_accessor :file
12
+ attr_accessor :now_password
29
13
  attr_accessor :password
30
14
  attr_accessor :password_confirm
31
15
  attr_accessor :editor_id
32
16
 
33
17
  # callback
34
- before_save :confirm_password
35
- before_save :encrypt_password
18
+ before_create :confirm_password
19
+ before_create :encrypt_password
20
+ before_update :confirm_password, if: :has_password? # 1
21
+ before_update :encrypt_password, if: :has_password? # 2
22
+ before_update :set_user_id_to_root, if: :is_destroy?
23
+ before_update :restrict_change_own_role
36
24
  before_save :manage_profile_img
37
25
 
38
- def sign_in(name_or_email, password)
39
- user = find_by(name: name_or_email)
40
- user = find_by(email: name_or_email) unless user
41
- return false unless user
42
- return false unless user.encrypted_password == encrypt(password)
26
+ # constants
27
+ SECURE = 'SOFHGPOIJERPGOKSPDO2SPTI4RJ6POIFDJVS7ETJ1EITJHSPEKMVOEIGU'
28
+ CIPHER = 'aes-256-cbc'
43
29
 
44
- user
30
+ def update_password(params)
31
+ return false unless params[:now_password] == User.decrypt(self.encrypted_password)
32
+ return false unless params[:password] == params[:password_confirm]
33
+ self.update(params)
45
34
  end
46
35
 
47
36
  def encrypt(password)
48
- OpenSSL::Digest::MD5.hexdigest(password)
37
+ crypt = ActiveSupport::MessageEncryptor.new(SECURE, CIPHER)
38
+ crypt.encrypt_and_sign(password)
49
39
  end
50
40
 
51
- def confirm_password
52
- return false unless password == password_confirm
41
+ def self.decrypt(password)
42
+ crypt = ActiveSupport::MessageEncryptor.new(SECURE, CIPHER)
43
+ crypt.decrypt_and_verify(password)
53
44
  end
54
45
 
55
- def encrypt_password
56
- self.encrypted_password = encrypt(password)
46
+ def self.sign_in(name_or_email, password)
47
+
48
+ # root-user login
49
+ if Notee.notee_id == name_or_email && Notee.notee_password == password
50
+ return root_user_setting
51
+ end
52
+
53
+ # other-user login
54
+ user = not_trash.find_by(name: name_or_email)
55
+ user = not_trash.find_by(email: name_or_email) unless user
56
+ return false unless user
57
+ return false if user.id == 0 # root_user
58
+ return false unless password == decrypt(user.encrypted_password)
59
+
60
+ user_setting(user)
61
+ end
62
+
63
+ def self.user_setting(user)
64
+ if token = Token.create!(user_id: user.id)
65
+ Thread.current[:request].session[:access_token] = token.access_token
66
+ end
67
+ end
68
+
69
+ def self.root_user_setting
70
+ unless User.exists?(id: 0)
71
+ User.skip_callback(:create, :before, :create_authority)
72
+ User.create(id: 0, name: Notee.notee_id, email: "root", password: SecureRandom.hex, role: 9999)
73
+ User.set_callback(:create, :before, :create_authority)
74
+ end
75
+
76
+ if token = Token.create!(user_id: 0)
77
+ Thread.current[:request].session[:access_token] = token.access_token
78
+ end
79
+ end
80
+
81
+ private
82
+
83
+ def restrict_change_own_role
84
+ now_user = Token.find_by_access_token(Thread.current[:request].session[:access_token]).user
85
+ self.role = now_user.role if self.id == now_user.id
57
86
  end
58
87
 
59
88
  def manage_profile_img
60
- return unless file
61
- return if User.exists?(profile_img: file)
89
+ return unless self.file.present?
62
90
 
63
- image_dir = Rails.root.to_s + '/public/notee/profile/'
91
+ image_dir = Rails.root.to_s + "/public/notee/profile/"
64
92
  FileUtils.mkdir_p(image_dir) unless FileTest.exist?(image_dir)
65
93
  image_name = Time.now.strftime('%Y%m%d%H%M%S') + '--' + SecureRandom.uuid + '.jpg'
94
+
95
+ return if User.exists?(profile_img: image_name)
96
+
66
97
  transaction do
67
- open(image_dir + '/' + image_name, 'wb') do |output|
68
- output.write(file.read)
98
+ open(image_dir + "/" + image_name, 'wb') do |output|
99
+ output.write(self.file.read)
100
+ end
101
+ self.profile_img = image_name
102
+ end
103
+ end
104
+
105
+ def set_user_id_to_root
106
+ posts = Post.where(user_id: self.id)
107
+
108
+ Post.skip_callback(:update, :before, :destroy_authority)
109
+ Post.transaction do
110
+ posts.each do |post|
111
+ post.update(user_id: 0)
69
112
  end
70
113
  end
71
- self.profile_img = image_name
114
+ Post.set_callback(:update, :before, :destroy_authority)
115
+
116
+ end
117
+
118
+ def confirm_password
119
+ return false unless password == password_confirm
120
+ end
121
+
122
+ def encrypt_password
123
+ self.encrypted_password = encrypt(self.password)
124
+ end
125
+
126
+ def has_password?
127
+ self.password.present?
72
128
  end
73
129
  end
74
130
  end
@@ -3,7 +3,9 @@
3
3
  <head>
4
4
  <title>Notee</title>
5
5
  <%= stylesheet_link_tag "notee/application", media: "all" %>
6
- <%= javascript_include_tag "notee/application" %>
6
+ <% unless new_token_path == "/notee" + request.path_info %>
7
+ <%= javascript_include_tag "notee/application" %>
8
+ <% end %>
7
9
  <%= favicon_link_tag(asset_path "favicon.ico") %>
8
10
  <%= csrf_meta_tags %>
9
11
  </head>
data/config/routes.rb CHANGED
@@ -2,25 +2,35 @@ Notee::Engine.routes.draw do
2
2
 
3
3
  root to: 'notees#index'
4
4
 
5
- get 'new' => 'notees#index'
6
- get 'edit/:id' => 'notees#index'
7
- get 'categories' => 'notees#index'
8
- get 'images' => 'notees#index'
9
- get 'comments' => 'notees#index'
10
- get 'users' => 'notees#index'
11
- get 'users/new' => 'notees#index'
12
- get 'users/edit/:id' => 'notees#index'
5
+ get 'posts' => 'notees#index'
6
+ get 'posts/new' => 'notees#index'
7
+ get 'posts/edit/:id' => 'notees#index'
8
+ get 'categories' => 'notees#index'
9
+ get 'categories/edit/:id' => 'notees#index'
10
+ get 'images' => 'notees#index'
11
+ get 'comments' => 'notees#index'
12
+ get 'users' => 'notees#index'
13
+ get 'users/new' => 'notees#index'
14
+ get 'users/edit/:id' => 'notees#index'
15
+ get 'trashes' => 'notees#index'
16
+ get 'trashes/:model' => 'notees#index'
17
+ get 'mypage' => 'notees#index'
18
+ get 'mypage/edit' => 'notees#index'
19
+ get 'mypage/edit/password' => 'notees#index'
13
20
 
14
21
  # post 'secret_published' => 'notees#secret_published'
15
22
  resources :tokens, only: [:new, :create, :destroy]
16
23
 
17
24
  scope :api, { format: 'json' } do
18
25
  resources :posts, only: [:index, :show, :create, :update, :destroy]
26
+ get 'users/mypage' => 'users#mypage'
27
+ put 'users/mypage' => 'users#update_password'
19
28
  resources :users, only: [:index, :show, :create, :update, :destroy]
20
29
  resources :images, only: [:index, :show, :create, :destroy]
21
30
  resources :categories, only: [:index, :show, :create, :update, :destroy]
22
31
  resources :statuses, only: [:index, :show]
23
- resources :comments, only: [:index, :show, :create, :update, :delete]
32
+ resources :comments, only: [:index, :show, :create, :update, :destroy]
24
33
  resources :roles, only: [:index, :show]
34
+ resources :trashes, only: [:index, :update]
25
35
  end
26
36
  end
@@ -12,6 +12,7 @@ class CreateNoteePosts < ActiveRecord::Migration
12
12
  t.integer :thumbnail_id, default: 0
13
13
  t.datetime :published_at
14
14
  t.integer :user_id
15
+ t.boolean :is_deleted, null: false, default: false
15
16
 
16
17
  # seo
17
18
  t.string :seo_keyword, default: ""
@@ -5,9 +5,10 @@ class CreateNoteeCategories < ActiveRecord::Migration
5
5
  create_table :notee_categories do |t|
6
6
 
7
7
  t.string :name, null: false, default: "category_name"
8
- t.string :slug, null: false, uniqueness: true
8
+ t.string :slug, uniqueness: true
9
9
  t.integer :parent_id
10
10
  t.boolean :is_private, null: false, default: false
11
+ t.boolean :is_deleted, null: false, default: false
11
12
 
12
13
  t.timestamps null: false
13
14
  end
@@ -15,6 +16,8 @@ class CreateNoteeCategories < ActiveRecord::Migration
15
16
  add_index :notee_categories, :slug, :unique => true
16
17
 
17
18
  # create default category
19
+ Notee::Category.skip_callback(:create, :before, :create_authority)
18
20
  Notee::Category.create :name => 'No_Category'
21
+ Notee::Category.set_callback(:create, :before, :create_authority)
19
22
  end
20
23
  end
@@ -5,6 +5,7 @@ class CreateNoteeImages < ActiveRecord::Migration
5
5
  create_table :notee_images do |t|
6
6
 
7
7
  t.string :content, null: false, uniqueness: true
8
+ t.boolean :is_deleted, null: false, default: false
8
9
 
9
10
  # if you have user_id
10
11
  # t.integer :user_id
@@ -13,8 +14,9 @@ class CreateNoteeImages < ActiveRecord::Migration
13
14
  end
14
15
 
15
16
  # create default image
16
- default_image = Notee::Image.create :content => 'aa'
17
- default_image.update_column("content", "default.png")
17
+ Notee::Image.skip_callback(:create, :before, :create_authority)
18
+ Notee::Image.create :content => 'default.png'
19
+ Notee::Image.set_callback(:create, :before, :create_authority)
18
20
  end
19
21
 
20
22
  end
@@ -5,7 +5,8 @@ class CreateNoteeComments < ActiveRecord::Migration
5
5
  t.text :content
6
6
  t.string :name
7
7
  t.string :email
8
- t.boolean :is_hidden
8
+ t.boolean :is_hidden, null: false, default: false
9
+ t.boolean :is_deleted, null: false, default: false
9
10
 
10
11
  t.timestamps
11
12
  end
@@ -7,6 +7,7 @@ class CreateNoteeUsers < ActiveRecord::Migration
7
7
  t.text :profile
8
8
  t.string :profile_img
9
9
  t.integer :role, null: false
10
+ t.boolean :is_deleted, null: false, default: false
10
11
 
11
12
  t.timestamps null: false
12
13
  end
@@ -4,76 +4,89 @@ module Notee
4
4
 
5
5
  def notee(search_txt)
6
6
  return false unless search_txt
7
- @notee = Notee::Post.find_by(id: search_txt)
8
- @notee = Notee::Post.find_by(slug: search_txt) unless @notee
7
+ post = Notee::Post.find_by(id: search_txt)
8
+ post = Notee::Post.find_by(slug: search_txt) unless post
9
9
 
10
- return if @notee.status == Notee::STATUS[:draft] ||
11
- @notee.status == Notee::STATUS[:deleted] ||
12
- @notee.status == Notee::STATUS[:privated]
13
- @notee
10
+ return if post.status == Notee::STATUS[:draft] ||
11
+ post.status == Notee::STATUS[:deleted] ||
12
+ post.status == Notee::STATUS[:privated] ||
13
+ post.is_deleted == true
14
+ post
14
15
  end
15
16
 
16
- def notees(search_txt = 'all')
17
- @notees = []
18
17
 
19
- if search_txt == 'all'
20
- # all_notees
21
- @notees = Notee::Post.where(status: Notee::STATUS[:published]).order(published_at: :desc)
22
- else
23
- # search_by_category_slug
24
- category_id = Notee::Category.find_by(slug: search_txt)
25
- category_id = Notee::Category.find_by(name: search_txt) unless category_id
26
- return false unless category_id
18
+ def notees
19
+ @posts = Notee::Post.where(status: Notee::STATUS[:published], is_deleted: false).order(published_at: :desc)
20
+ @posts
21
+ end
22
+
23
+
24
+ def category_notees(search_txt)
25
+ # search_by_category_slug
26
+ category = Notee::Category.find_by(slug: search_txt)
27
+ category = Notee::Category.find_by(name: search_txt) unless category
28
+ return false unless category
29
+ return false if category.is_deleted
30
+
31
+ @posts = Notee::Post.where(category_id: category.id, status: Notee::STATUS[:published], is_deleted: false).order(published_at: :desc)
32
+ @posts
33
+ end
34
+
27
35
 
28
- @notees = Notee::Post.where(category_id: category_id, status: Notee::STATUS[:published]).order(published_at: :desc)
36
+ def archive_notees(year, month)
37
+ if month
38
+ tmp_month = (month.to_s.size != 2 ? "0" : "") + month.to_s
39
+ tmp_date = year.to_s + tmp_month + "01"
40
+ begin_time = Date.parse(tmp_date).beginning_of_month
41
+ end_time = Date.parse(tmp_date).end_of_month
42
+ else
43
+ tmp_date = year.to_s + "0101"
44
+ begin_time = Date.parse(tmp_date).beginning_of_year
45
+ end_time = Date.parse(tmp_date).end_of_year
29
46
  end
30
47
 
31
- @notees
48
+ @posts = Notee::Post.where(published_at: begin_time..end_time).order(published_at: :desc)
49
+ @posts
32
50
  end
33
51
 
34
- # TODO: secret_mode
35
- # def secret_notees
36
- # @notees = Notee::Post.where(status: Notee::STATUS[:secret_published]).order(published_at: :desc)
37
- # end
38
52
 
39
- def notee_categories(sort = nil)
40
- @notee_categories = Notee::Category.all.order(created_at: :desc)
53
+ def writer_notees(name_or_id)
54
+ writer = Notee::User.find_by(name: name_or_id)
55
+ writer = Notee::User.find_by(name: name_or_id) unless writer
56
+ return false unless writer
57
+ return false if writer.is_deleted
58
+
59
+ @posts = writer.posts
60
+ end
41
61
 
42
- case sort
43
- when 'alphabetal'
44
- @notee_categories = @notee_categories.sort
45
- when 'size'
46
- @notee_categories = @notee_categories.sort_by {|category| category.name.size }
47
- end
48
62
 
49
- @notee_categories
63
+ def notee_categories
64
+ # DATA: {notee.category.name, notee.count}
65
+ Notee::Post.find_by_sql("SELECT category_id as category_id, count(*) as count FROM notee_posts WHERE notee_posts.status=1 and notee_posts.is_deleted=false GROUP BY category_id;")
50
66
  end
51
67
 
52
- def notee_archives(year, month)
53
- start_date = Date.new(year, month, 1)
54
- end_date = Date.new(year, month, -1)
55
- @notee_archives = Notee::Post.where(status: Notee::STATUS[:published], :published_at => start_date...end_date)
56
68
 
57
- @notee_archives
69
+ def notee_archives
70
+ # DATA: {notee.time, notee.count}
71
+ Notee::Post.find_by_sql("SELECT DATE_FORMAT(published_at, '%Y-%m') as time, count(*) as count FROM notee_posts WHERE status=1 and is_deleted=false GROUP BY DATE_FORMAT(published_at, '%Y-%m') ORDER BY time DESC;")
58
72
  end
59
73
 
60
- def notee_archives_menu(type = nil)
61
- case type
62
- when 'year'
63
- return Notee::Post.where(status: Notee::STATUS[:published]).group('year(published_at)').count
64
- when 'month'
65
- return Notee::Post.where(status: Notee::STATUS[:published]).group('year(published_at)').group('month(published_at)').count
66
- else
67
- return Notee::Post.where(status: Notee::STATUS[:published]).group('year(published_at)').group('month(published_at)').count
68
- end
74
+
75
+ def notee_writers
76
+ users = Notee::User.where(is_deleted: false)
77
+ writers = users.select { |user| user if user.posts.count > 0 }.map { |user| user }
78
+
79
+ writers
69
80
  end
70
81
 
82
+
71
83
  def notee_comments(id)
72
84
  return if id.nil?
73
- @notee_comments = Notee::Post.where(post_id: id)
85
+ @notee_comments = Notee::Comment.where(post_id: id, is_hidden: false, is_deleted: false)
74
86
  @notee_comments
75
87
  end
76
88
 
89
+
77
90
  def notee_set_meta_by_post(post)
78
91
  return {
79
92
  title: post.title,
@@ -82,6 +95,12 @@ module Notee
82
95
  og_image: request.base_url + "/notee/" + post.thumbnail.content
83
96
  }
84
97
  end
98
+
99
+
100
+ # TODO: secret_mode
101
+ # def secret_notees
102
+ # @notees = Notee::Post.where(status: Notee::STATUS[:secret_published]).order(published_at: :desc)
103
+ # end
85
104
  end
86
105
  end
87
106
  end