publify_core 9.0.0.pre1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of publify_core might be problematic. Click here for more details.

Files changed (372) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +21 -0
  3. data/README.rdoc +3 -0
  4. data/Rakefile +35 -0
  5. data/app/assets/fonts/open-sans-bold.woff +0 -0
  6. data/app/assets/fonts/open-sans.woff +0 -0
  7. data/app/assets/images/admin/loading.gif +0 -0
  8. data/app/assets/images/admin/typologo.gif +0 -0
  9. data/app/assets/images/calendar_date_select/calendar.gif +0 -0
  10. data/app/assets/images/close.gif +0 -0
  11. data/app/assets/images/closelabel.gif +0 -0
  12. data/app/assets/images/go.png +0 -0
  13. data/app/assets/images/loading.gif +0 -0
  14. data/app/assets/images/nextlabel.gif +0 -0
  15. data/app/assets/images/overlay.png +0 -0
  16. data/app/assets/images/powered.gif +0 -0
  17. data/app/assets/images/prevlabel.gif +0 -0
  18. data/app/assets/images/spinner-blue.gif +0 -0
  19. data/app/assets/images/spinner.gif +0 -0
  20. data/app/assets/images/thumb_blank.jpg +0 -0
  21. data/app/assets/javascripts/application.js +2 -0
  22. data/app/assets/javascripts/cookies.js +60 -0
  23. data/app/assets/javascripts/datetimepicker.js +1470 -0
  24. data/app/assets/javascripts/lang/da_DK.js +17 -0
  25. data/app/assets/javascripts/lang/default.js +21 -0
  26. data/app/assets/javascripts/lang/en_US.js +21 -0
  27. data/app/assets/javascripts/lang/fr_FR.js +21 -0
  28. data/app/assets/javascripts/lang/nl_NL.js +21 -0
  29. data/app/assets/javascripts/lang/zh_TW.js +17 -0
  30. data/app/assets/javascripts/lightbox.js +350 -0
  31. data/app/assets/javascripts/observe.js +28 -0
  32. data/app/assets/javascripts/publify.js +11 -0
  33. data/app/assets/javascripts/publify_admin.js +138 -0
  34. data/app/assets/javascripts/quicktags.js +440 -0
  35. data/app/assets/javascripts/set-timeago-lang.js +3 -0
  36. data/app/assets/javascripts/sidebar.js +28 -0
  37. data/app/assets/javascripts/spinnable.js +5 -0
  38. data/app/assets/javascripts/tagmanager.js +481 -0
  39. data/app/assets/javascripts/typeahead.js +1139 -0
  40. data/app/assets/javascripts/widearea.js +486 -0
  41. data/app/assets/stylesheets/accounts.css.scss +7 -0
  42. data/app/assets/stylesheets/administration_structure.css.scss +239 -0
  43. data/app/assets/stylesheets/coderay.css +135 -0
  44. data/app/assets/stylesheets/datetimepicker.css +306 -0
  45. data/app/assets/stylesheets/lightbox.css +63 -0
  46. data/app/assets/stylesheets/publify.css.scss +9 -0
  47. data/app/assets/stylesheets/publify_admin.css.scss +11 -0
  48. data/app/assets/stylesheets/rss.css +53 -0
  49. data/app/assets/stylesheets/sidebar_admin.css.scss +36 -0
  50. data/app/assets/stylesheets/tagmanager.css +102 -0
  51. data/app/assets/stylesheets/user-styles.css +29 -0
  52. data/app/assets/stylesheets/widearea.css +133 -0
  53. data/app/controllers/accounts_controller.rb +2 -0
  54. data/app/controllers/admin/base_controller.rb +41 -0
  55. data/app/controllers/admin/cache_controller.rb +33 -0
  56. data/app/controllers/admin/content_controller.rb +174 -0
  57. data/app/controllers/admin/dashboard_controller.rb +87 -0
  58. data/app/controllers/admin/feedback_controller.rb +159 -0
  59. data/app/controllers/admin/migrations_controller.rb +20 -0
  60. data/app/controllers/admin/notes_controller.rb +69 -0
  61. data/app/controllers/admin/pages_controller.rb +88 -0
  62. data/app/controllers/admin/post_types_controller.rb +56 -0
  63. data/app/controllers/admin/profiles_controller.rb +48 -0
  64. data/app/controllers/admin/redirects_controller.rb +47 -0
  65. data/app/controllers/admin/resources_controller.rb +30 -0
  66. data/app/controllers/admin/seo_controller.rb +45 -0
  67. data/app/controllers/admin/settings_controller.rb +53 -0
  68. data/app/controllers/admin/sidebar_controller.rb +66 -0
  69. data/app/controllers/admin/tags_controller.rb +53 -0
  70. data/app/controllers/admin/textfilters_controller.rb +6 -0
  71. data/app/controllers/admin/themes_controller.rb +37 -0
  72. data/app/controllers/admin/users_controller.rb +65 -0
  73. data/app/controllers/articles_controller.rb +205 -0
  74. data/app/controllers/authors_controller.rb +27 -0
  75. data/app/controllers/base_controller.rb +45 -0
  76. data/app/controllers/comments_controller.rb +69 -0
  77. data/app/controllers/content_controller.rb +31 -0
  78. data/app/controllers/feedback_controller.rb +47 -0
  79. data/app/controllers/notes_controller.rb +37 -0
  80. data/app/controllers/setup_controller.rb +62 -0
  81. data/app/controllers/tags_controller.rb +55 -0
  82. data/app/controllers/text_controller.rb +9 -0
  83. data/app/controllers/textfilter_controller.rb +3 -0
  84. data/app/controllers/theme_controller.rb +59 -0
  85. data/app/controllers/trackbacks_controller.rb +36 -0
  86. data/app/controllers/xml_controller.rb +70 -0
  87. data/app/helpers/admin/base_helper.rb +87 -0
  88. data/app/helpers/admin/feedback_helper.rb +42 -0
  89. data/app/helpers/articles_helper.rb +8 -0
  90. data/app/helpers/authors_helper.rb +39 -0
  91. data/app/helpers/base_helper.rb +246 -0
  92. data/app/helpers/blog_helper.rb +12 -0
  93. data/app/helpers/xml_helper.rb +16 -0
  94. data/app/mailers/notification_mailer.rb +38 -0
  95. data/app/models/ability.rb +52 -0
  96. data/app/models/archives_sidebar.rb +45 -0
  97. data/app/models/article/factory.rb +56 -0
  98. data/app/models/article/states.rb +178 -0
  99. data/app/models/article.rb +321 -0
  100. data/app/models/blog.rb +290 -0
  101. data/app/models/blog_sweeper.rb +86 -0
  102. data/app/models/comment.rb +53 -0
  103. data/app/models/config_manager.rb +81 -0
  104. data/app/models/content.rb +138 -0
  105. data/app/models/content_base.rb +95 -0
  106. data/app/models/feedback/states.rb +256 -0
  107. data/app/models/feedback.rb +225 -0
  108. data/app/models/meta_sidebar.rb +8 -0
  109. data/app/models/note.rb +144 -0
  110. data/app/models/page.rb +36 -0
  111. data/app/models/page_cache.rb +33 -0
  112. data/app/models/page_sidebar.rb +12 -0
  113. data/app/models/ping.rb +116 -0
  114. data/app/models/post_type.rb +15 -0
  115. data/app/models/redirect.rb +45 -0
  116. data/app/models/redirection.rb +4 -0
  117. data/app/models/resource.rb +28 -0
  118. data/app/models/search_sidebar.rb +7 -0
  119. data/app/models/sidebar.rb +138 -0
  120. data/app/models/static_sidebar.rb +20 -0
  121. data/app/models/tag.rb +63 -0
  122. data/app/models/tag_sidebar.rb +27 -0
  123. data/app/models/text_filter.rb +61 -0
  124. data/app/models/trackback.rb +58 -0
  125. data/app/models/trigger.rb +45 -0
  126. data/app/models/user.rb +148 -0
  127. data/app/services/migrator.rb +25 -0
  128. data/app/services/title_builder.rb +80 -0
  129. data/app/uploaders/resource_uploader.rb +30 -0
  130. data/app/views/accounts/confirm.html.erb +8 -0
  131. data/app/views/admin/cache/show.html.erb +18 -0
  132. data/app/views/admin/content/_article_list.html.erb +26 -0
  133. data/app/views/admin/content/_form.html.erb +165 -0
  134. data/app/views/admin/content/autosave.js.erb +5 -0
  135. data/app/views/admin/content/edit.html.erb +3 -0
  136. data/app/views/admin/content/index.html.erb +48 -0
  137. data/app/views/admin/content/index.js.erb +1 -0
  138. data/app/views/admin/content/new.html.erb +3 -0
  139. data/app/views/admin/dashboard/_comment.html.erb +18 -0
  140. data/app/views/admin/dashboard/_comments.html.erb +10 -0
  141. data/app/views/admin/dashboard/_drafts.html.erb +25 -0
  142. data/app/views/admin/dashboard/_inbound.html.erb +31 -0
  143. data/app/views/admin/dashboard/_overview.html.erb +23 -0
  144. data/app/views/admin/dashboard/_welcome.html.erb +28 -0
  145. data/app/views/admin/dashboard/index.html.erb +17 -0
  146. data/app/views/admin/feedback/_button.html.erb +19 -0
  147. data/app/views/admin/feedback/_feedback.html.erb +7 -0
  148. data/app/views/admin/feedback/_ham.html.erb +17 -0
  149. data/app/views/admin/feedback/_spam.html.erb +23 -0
  150. data/app/views/admin/feedback/article.html.erb +69 -0
  151. data/app/views/admin/feedback/edit.html.erb +48 -0
  152. data/app/views/admin/feedback/ham.js +1 -0
  153. data/app/views/admin/feedback/index.html.erb +53 -0
  154. data/app/views/admin/feedback/spam.js +1 -0
  155. data/app/views/admin/migrations/show.html.erb +39 -0
  156. data/app/views/admin/notes/_form.html.erb +37 -0
  157. data/app/views/admin/notes/_header.html.erb +6 -0
  158. data/app/views/admin/notes/_list.html.erb +13 -0
  159. data/app/views/admin/notes/_note.html.erb +14 -0
  160. data/app/views/admin/notes/edit.html.erb +11 -0
  161. data/app/views/admin/notes/index.html.erb +11 -0
  162. data/app/views/admin/notes/show.html.erb +14 -0
  163. data/app/views/admin/pages/_form.html.erb +101 -0
  164. data/app/views/admin/pages/_pages.html.erb +21 -0
  165. data/app/views/admin/pages/edit.html.erb +1 -0
  166. data/app/views/admin/pages/index.html.erb +17 -0
  167. data/app/views/admin/pages/new.html.erb +1 -0
  168. data/app/views/admin/post_types/_index_and_form.html.erb +65 -0
  169. data/app/views/admin/post_types/edit.html.erb +1 -0
  170. data/app/views/admin/post_types/index.html.erb +1 -0
  171. data/app/views/admin/profiles/index.html.erb +10 -0
  172. data/app/views/admin/redirects/_index_and_form.html.erb +68 -0
  173. data/app/views/admin/redirects/edit.html.erb +1 -0
  174. data/app/views/admin/redirects/index.html.erb +1 -0
  175. data/app/views/admin/resources/index.html.erb +68 -0
  176. data/app/views/admin/seo/_general.html.erb +123 -0
  177. data/app/views/admin/seo/_permalinks.html.erb +53 -0
  178. data/app/views/admin/seo/_titles.html.erb +210 -0
  179. data/app/views/admin/seo/show.html.erb +32 -0
  180. data/app/views/admin/settings/display.html.erb +110 -0
  181. data/app/views/admin/settings/feedback.html.erb +125 -0
  182. data/app/views/admin/settings/index.html.erb +73 -0
  183. data/app/views/admin/settings/write.html.erb +87 -0
  184. data/app/views/admin/shared/_edit.html.erb +4 -0
  185. data/app/views/admin/shared/_menu.html.erb +122 -0
  186. data/app/views/admin/shared/_twitter_alert.html.erb +3 -0
  187. data/app/views/admin/sidebar/_available.html.erb +6 -0
  188. data/app/views/admin/sidebar/_available.json.erb +6 -0
  189. data/app/views/admin/sidebar/_config.html.erb +27 -0
  190. data/app/views/admin/sidebar/_target.html.erb +9 -0
  191. data/app/views/admin/sidebar/_target_sidebar.html.erb +20 -0
  192. data/app/views/admin/sidebar/destroy.js.erb +1 -0
  193. data/app/views/admin/sidebar/index.html.erb +31 -0
  194. data/app/views/admin/sidebar/sortable.js.erb +3 -0
  195. data/app/views/admin/sidebar/update.js.erb +2 -0
  196. data/app/views/admin/tags/_index_and_form.html.erb +59 -0
  197. data/app/views/admin/tags/edit.html.erb +1 -0
  198. data/app/views/admin/tags/index.html.erb +1 -0
  199. data/app/views/admin/themes/index.html.erb +27 -0
  200. data/app/views/admin/users/_form.html.erb +215 -0
  201. data/app/views/admin/users/edit.html.erb +8 -0
  202. data/app/views/admin/users/index.html.erb +39 -0
  203. data/app/views/admin/users/new.html.erb +8 -0
  204. data/app/views/archives_sidebar/_content.html.erb +13 -0
  205. data/app/views/articles/_article.html.erb +9 -0
  206. data/app/views/articles/_article_collection.html.erb +8 -0
  207. data/app/views/articles/_article_content.html.erb +5 -0
  208. data/app/views/articles/_article_excerpt.html.erb +13 -0
  209. data/app/views/articles/_article_links.html.erb +10 -0
  210. data/app/views/articles/_comment.html.erb +1 -0
  211. data/app/views/articles/_comment_errors.html.erb +2 -0
  212. data/app/views/articles/_comment_form.html.erb +48 -0
  213. data/app/views/articles/_comment_list.html.erb +5 -0
  214. data/app/views/articles/_comment_preview.html.erb +4 -0
  215. data/app/views/articles/_full_article_content.html.erb +2 -0
  216. data/app/views/articles/_password_form.html.erb +10 -0
  217. data/app/views/articles/_protected_article_content.html.erb +6 -0
  218. data/app/views/articles/_trackback.html.erb +6 -0
  219. data/app/views/articles/archives.html.erb +25 -0
  220. data/app/views/articles/comment.js.erb +5 -0
  221. data/app/views/articles/comment_failed.js.erb +3 -0
  222. data/app/views/articles/error.html.erb +3 -0
  223. data/app/views/articles/feedback_atom_feed.atom.builder +8 -0
  224. data/app/views/articles/feedback_rss_feed.rss.builder +21 -0
  225. data/app/views/articles/index.html.erb +1 -0
  226. data/app/views/articles/index_atom_feed.atom.builder +8 -0
  227. data/app/views/articles/index_rss_feed.rss.builder +20 -0
  228. data/app/views/articles/live_search.html.erb +10 -0
  229. data/app/views/articles/read.html.erb +61 -0
  230. data/app/views/articles/search.html.erb +8 -0
  231. data/app/views/articles/trackback.xml.builder +5 -0
  232. data/app/views/articles/view_page.html.erb +3 -0
  233. data/app/views/authors/show.html.erb +40 -0
  234. data/app/views/authors/show_atom_feed.atom.builder +8 -0
  235. data/app/views/authors/show_rss_feed.rss.builder +20 -0
  236. data/app/views/comments/_comment.html.erb +16 -0
  237. data/app/views/comments/index.html.erb +1 -0
  238. data/app/views/comments/index_atom_feed.atom.builder +8 -0
  239. data/app/views/comments/index_rss_feed.rss.builder +20 -0
  240. data/app/views/comments/preview.html.erb +1 -0
  241. data/app/views/comments/preview.js.erb +3 -0
  242. data/app/views/devise/mailer/reset_password_instructions.html.erb +13 -0
  243. data/app/views/devise/passwords/edit.html.erb +28 -0
  244. data/app/views/devise/passwords/new.html.erb +20 -0
  245. data/app/views/devise/registrations/new.html.erb +36 -0
  246. data/app/views/devise/sessions/new.html.erb +32 -0
  247. data/app/views/devise/shared/_links.html.erb +15 -0
  248. data/app/views/errors/404.html.erb +2 -0
  249. data/app/views/layouts/accounts.html.erb +33 -0
  250. data/app/views/layouts/administration.html.erb +37 -0
  251. data/app/views/layouts/default.html.erb +32 -0
  252. data/app/views/layouts/editor.html.erb +31 -0
  253. data/app/views/meta_sidebar/_content.html.erb +8 -0
  254. data/app/views/notes/_note.html.erb +15 -0
  255. data/app/views/notes/error.html.erb +3 -0
  256. data/app/views/notes/index.html.erb +15 -0
  257. data/app/views/notes/show.html.erb +5 -0
  258. data/app/views/notes/show_in_reply.html.erb +16 -0
  259. data/app/views/notification_mailer/_mail_footer.html.erb +7 -0
  260. data/app/views/notification_mailer/_mail_header.html.erb +1 -0
  261. data/app/views/notification_mailer/article.html.erb +6 -0
  262. data/app/views/notification_mailer/comment.html.erb +11 -0
  263. data/app/views/notification_mailer/notif_user.html.erb +14 -0
  264. data/app/views/page_sidebar/_content.html.erb +12 -0
  265. data/app/views/search_sidebar/_content.html.erb +10 -0
  266. data/app/views/settings/done.html.erb +2 -0
  267. data/app/views/settings/install.html.erb +12 -0
  268. data/app/views/setup/index.html.erb +13 -0
  269. data/app/views/shared/_atom_header.atom.builder +6 -0
  270. data/app/views/shared/_atom_item_article.atom.builder +39 -0
  271. data/app/views/shared/_atom_item_comment.atom.builder +10 -0
  272. data/app/views/shared/_atom_item_trackback.atom.builder +9 -0
  273. data/app/views/shared/_flash.erb +10 -0
  274. data/app/views/shared/_page_header.html.erb +26 -0
  275. data/app/views/shared/_rss_item_article.rss.builder +35 -0
  276. data/app/views/shared/_rss_item_comment.rss.builder +8 -0
  277. data/app/views/shared/_rss_item_trackback.rss.builder +7 -0
  278. data/app/views/sidebar/_row.html.erb +1 -0
  279. data/app/views/sidebar/_sidebar.html.erb +5 -0
  280. data/app/views/sidebar/display_plugins.html.erb +5 -0
  281. data/app/views/sidebar/show.html.erb +1 -0
  282. data/app/views/static_sidebar/_content.html.erb +2 -0
  283. data/app/views/tag_sidebar/_content.html.erb +10 -0
  284. data/app/views/tags/index.html.erb +15 -0
  285. data/app/views/tags/show.html.erb +1 -0
  286. data/app/views/theme/static_view_test.html.erb +1 -0
  287. data/app/views/trackbacks/index_atom_feed.atom.builder +7 -0
  288. data/app/views/trackbacks/index_rss_feed.rss.builder +20 -0
  289. data/app/views/trackbacks/trackback.xml.builder +4 -0
  290. data/app/views/xml/_googlesitemap_item_article.googlesitemap.builder +5 -0
  291. data/app/views/xml/_googlesitemap_item_category.googlesitemap.builder +4 -0
  292. data/app/views/xml/_googlesitemap_item_page.googlesitemap.builder +4 -0
  293. data/app/views/xml/_googlesitemap_item_tag.googlesitemap.builder +4 -0
  294. data/app/views/xml/feed.googlesitemap.builder +7 -0
  295. data/app/views/xml/rsd.rsd.builder +8 -0
  296. data/config/i18n-tasks.yml +49 -0
  297. data/config/initializers/devise.rb +265 -0
  298. data/config/initializers/mime_types.rb +6 -0
  299. data/config/locales/da.yml +827 -0
  300. data/config/locales/de.yml +827 -0
  301. data/config/locales/en.yml +827 -0
  302. data/config/locales/es-MX.yml +827 -0
  303. data/config/locales/fr.yml +827 -0
  304. data/config/locales/he.yml +827 -0
  305. data/config/locales/it.yml +827 -0
  306. data/config/locales/ja.yml +827 -0
  307. data/config/locales/lt.yml +827 -0
  308. data/config/locales/nb-NO.yml +827 -0
  309. data/config/locales/nl.yml +827 -0
  310. data/config/locales/pl.yml +827 -0
  311. data/config/locales/pt-BR.yml +827 -0
  312. data/config/locales/ro.yml +827 -0
  313. data/config/locales/ru.yml +827 -0
  314. data/config/locales/sidebars.da.yml +20 -0
  315. data/config/locales/sidebars.de.yml +20 -0
  316. data/config/locales/sidebars.en.yml +20 -0
  317. data/config/locales/sidebars.es-MX.yml +20 -0
  318. data/config/locales/sidebars.fr.yml +20 -0
  319. data/config/locales/sidebars.he.yml +20 -0
  320. data/config/locales/sidebars.it.yml +20 -0
  321. data/config/locales/sidebars.ja.yml +20 -0
  322. data/config/locales/sidebars.lt.yml +20 -0
  323. data/config/locales/sidebars.nb-NO.yml +20 -0
  324. data/config/locales/sidebars.nl.yml +20 -0
  325. data/config/locales/sidebars.pl.yml +20 -0
  326. data/config/locales/sidebars.pt-BR.yml +20 -0
  327. data/config/locales/sidebars.ro.yml +20 -0
  328. data/config/locales/sidebars.ru.yml +20 -0
  329. data/config/locales/sidebars.zh-CN.yml +20 -0
  330. data/config/locales/sidebars.zh-TW.yml +20 -0
  331. data/config/locales/zh-CN.yml +827 -0
  332. data/config/locales/zh-TW.yml +827 -0
  333. data/config/routes.rb +177 -0
  334. data/db/migrate/113_initial_schema.rb +205 -0
  335. data/db/migrate/114_fixes_buggy_articles_and_notes.rb +52 -0
  336. data/db/migrate/115_drops_categories_for_tags.rb +34 -0
  337. data/db/migrate/20150207131657_add_missing_indexes.rb +19 -0
  338. data/db/migrate/20150807134129_simplify_redirect_relations.rb +38 -0
  339. data/db/migrate/20150808052637_add_blog_ids.rb +33 -0
  340. data/db/migrate/20150808191127_add_blog_id_to_redirects.rb +15 -0
  341. data/db/migrate/20150810094754_add_blog_id_to_tags.rb +15 -0
  342. data/db/migrate/20160108111120_add_devise_to_users.rb +53 -0
  343. data/db/migrate/20160108184201_move_last_connection_to_last_sign_in_at.rb +16 -0
  344. data/db/migrate/20160110094906_remove_profiles_rights.rb +14 -0
  345. data/db/migrate/20160605103918_replace_profile_id_with_string.rb +30 -0
  346. data/db/migrate/20160605154632_remove_profiles.rb +24 -0
  347. data/db/migrate/20160701061851_demand_blog_id_on_contents.rb +9 -0
  348. data/db/migrate/20160701062604_add_blog_id_to_resources.rb +28 -0
  349. data/db/seeds.rb +37 -0
  350. data/lib/email_notify.rb +26 -0
  351. data/lib/format.rb +17 -0
  352. data/lib/publify_core/engine.rb +23 -0
  353. data/lib/publify_core/lang.rb +5 -0
  354. data/lib/publify_core/version.rb +3 -0
  355. data/lib/publify_core.rb +56 -0
  356. data/lib/publify_guid.rb +9 -0
  357. data/lib/publify_plugins.rb +72 -0
  358. data/lib/publify_textfilter_markdown.rb +44 -0
  359. data/lib/publify_textfilter_none.rb +14 -0
  360. data/lib/publify_textfilter_smartypants.rb +14 -0
  361. data/lib/publify_textfilter_textile.rb +21 -0
  362. data/lib/publify_textfilter_twitterfilter.rb +33 -0
  363. data/lib/publify_time.rb +30 -0
  364. data/lib/sidebar_field.rb +115 -0
  365. data/lib/sidebar_registry.rb +33 -0
  366. data/lib/spam_protection.rb +101 -0
  367. data/lib/stateful.rb +106 -0
  368. data/lib/tasks/publify_core_tasks.rake +4 -0
  369. data/lib/text_filter_plugin.rb +182 -0
  370. data/lib/theme.rb +72 -0
  371. data/lib/transforms.rb +45 -0
  372. metadata +865 -0
@@ -0,0 +1,87 @@
1
+ require 'feedjira'
2
+
3
+ class Admin::DashboardController < Admin::BaseController
4
+ require 'open-uri'
5
+ require 'time'
6
+ require 'rexml/document'
7
+
8
+ def index
9
+ t = Time.new
10
+ today = t.strftime('%Y-%m-%d 00:00')
11
+
12
+ # Since last venue
13
+ @newposts_count = Article.published_since(current_user.last_sign_in_at).count
14
+ @newcomments_count = Feedback.published_since(current_user.last_sign_in_at).count
15
+
16
+ # Today
17
+ @statposts = Article.published.where('published_at > ?', today).count
18
+ @statsdrafts = Article.drafts.where('created_at > ?', today).count
19
+ @statspages = Page.where('published_at > ?', today).count
20
+ @statuses = Note.where('published_at > ?', today).count
21
+ @statuserposts = Article.published.where('published_at > ?', today).where(user_id: current_user.id).count
22
+ @statcomments = Comment.where('created_at > ?', today).count
23
+ @presumedspam = Comment.presumed_spam.where('created_at > ?', today).count
24
+ @confirmed = Comment.ham.where('created_at > ?', today).count
25
+ @unconfirmed = Comment.unconfirmed.where('created_at > ?', today).count
26
+
27
+ @comments = Comment.last_published
28
+ @drafts = Article.drafts.where('user_id = ?', current_user.id).limit(5)
29
+
30
+ @statspam = Comment.spam.count
31
+ @inbound_links = inbound_links
32
+ @publify_links = publify_dev
33
+ publify_version
34
+ end
35
+
36
+ def publify_version
37
+ version = nil
38
+ begin
39
+ open(PUBLIFY_VERSION_URL) do |http|
40
+ publify_version = http.read[0..5]
41
+ version = publify_version.split('.')
42
+ end
43
+ rescue
44
+ return
45
+ end
46
+ if version[0].to_i > TYPO_MAJOR.to_i
47
+ flash[:error] = I18n.t('admin.dashboard.publify_version.error')
48
+ elsif version[1].to_i > TYPO_SUB.to_i
49
+ flash[:warning] = I18n.t('admin.dashboard.publify_version.warning')
50
+ elsif version[2].to_i > TYPO_MINOR.to_i
51
+ flash[:notice] = I18n.t('admin.dashboard.publify_version.notice')
52
+ end
53
+ end
54
+
55
+ private
56
+
57
+ def inbound_links
58
+ host = URI.parse(this_blog.base_url).host
59
+ return [] if Rails.env.development?
60
+ url = "http://www.google.com/search?q=link:#{host}&tbm=blg&output=rss"
61
+ fetch_rss(url).reverse.compact
62
+ end
63
+
64
+ def publify_dev
65
+ url = 'http://blog.publify.co/articles.rss'
66
+ fetch_rss(url)[0..2]
67
+ end
68
+
69
+ def fetch_rss(url)
70
+ open(url) do |http|
71
+ return parse_rss(http.read)
72
+ end
73
+ rescue
74
+ []
75
+ end
76
+
77
+ RssItem = Struct.new(:link, :title, :description, :description_link, :date, :author) do
78
+ def to_s
79
+ title
80
+ end
81
+ end
82
+
83
+ def parse_rss(body)
84
+ doc = Feedjira::Feed.parse(body)
85
+ doc.entries
86
+ end
87
+ end
@@ -0,0 +1,159 @@
1
+ class Admin::FeedbackController < Admin::BaseController
2
+ cache_sweeper :blog_sweeper
3
+ ONLY_DOMAIN = %w(unapproved presumed_ham presumed_spam ham spam).freeze
4
+
5
+ def index
6
+ scoped_feedback = this_blog.feedback
7
+
8
+ if params[:only].present?
9
+ @only_param = ONLY_DOMAIN.dup.delete(params[:only])
10
+ scoped_feedback = scoped_feedback.send(@only_param) if @only_param
11
+ end
12
+
13
+ params.delete(:page) if params[:page].blank? || params[:page] == '0'
14
+
15
+ @feedback = scoped_feedback.paginated(params[:page], this_blog.admin_display_elements)
16
+ end
17
+
18
+ def destroy
19
+ @record = Feedback.find params[:id]
20
+
21
+ unless @record.article.user_id == current_user.id
22
+ return redirect_to admin_feedback_index_url unless current_user.admin?
23
+ end
24
+
25
+ begin
26
+ @record.destroy
27
+ flash[:success] = I18n.t('admin.feedback.destroy.success')
28
+ rescue ActiveRecord::RecordNotFound
29
+ flash[:error] = I18n.t('admin.feedback.destroy.error')
30
+ end
31
+ redirect_to action: 'article', id: @record.article.id
32
+ end
33
+
34
+ def create
35
+ @article = Article.find(params[:article_id])
36
+ @comment = @article.comments.build(comment_params)
37
+ @comment.user_id = current_user.id
38
+
39
+ if request.post? && @comment.save
40
+ # We should probably wave a spam filter over this, but for now, just mark it as published.
41
+ @comment.mark_as_ham
42
+ @comment.save!
43
+ flash[:success] = I18n.t('admin.feedback.create.success')
44
+ end
45
+ redirect_to action: 'article', id: @article.id
46
+ end
47
+
48
+ def edit
49
+ @comment = Comment.find(params[:id])
50
+ @article = @comment.article
51
+ unless @article.access_by? current_user
52
+ redirect_to admin_feedback_index_url
53
+ return
54
+ end
55
+ end
56
+
57
+ def update
58
+ comment = Comment.find(params[:id])
59
+ unless comment.article.access_by? current_user
60
+ redirect_to admin_feedback_index_url
61
+ return
62
+ end
63
+ comment.attributes = comment_params
64
+ if request.post? && comment.save
65
+ flash[:success] = I18n.t('admin.feedback.update.success')
66
+ redirect_to action: 'article', id: comment.article.id
67
+ else
68
+ redirect_to action: 'edit', id: comment.id
69
+ end
70
+ end
71
+
72
+ def article
73
+ @article = this_blog.articles.find(params[:id])
74
+ @feedback = @article.comments.ham if params[:ham] && params[:spam].blank?
75
+ @feedback = @article.comments.spam if params[:spam] && params[:ham].blank?
76
+ @feedback ||= @article.comments
77
+ end
78
+
79
+ def change_state
80
+ return unless request.xhr?
81
+
82
+ @feedback = Feedback.find(params[:id])
83
+ template = @feedback.change_state!
84
+
85
+ respond_to do |format|
86
+ if params[:context] != 'listing'
87
+ @comments = Comment.last_published
88
+ page.replace_html('commentList', partial: 'admin/dashboard/comment')
89
+ elsif template == 'ham'
90
+ format.js { render 'ham' }
91
+ else
92
+ format.js { render 'spam' }
93
+ end
94
+ end
95
+ end
96
+
97
+ def bulkops
98
+ ids = (params[:feedback_check] || {}).keys.map(&:to_i)
99
+ items = Feedback.find(ids)
100
+ @unexpired = true
101
+
102
+ bulkop = (params[:bulkop_top] || {}).empty? ? params[:bulkop_bottom] : params[:bulkop_top]
103
+
104
+ case bulkop
105
+ when 'Delete Checked Items'
106
+ count = 0
107
+ ids.each do |id|
108
+ count += Feedback.delete(id)
109
+ end
110
+ flash[:success] = I18n.t('admin.feedback.bulkops.success_deleted', count: count)
111
+
112
+ if items.any(&:invalidates_cache?)
113
+ flush_cache
114
+ return
115
+ end
116
+ when 'Mark Checked Items as Ham'
117
+ update_feedback(items, :mark_as_ham!)
118
+ flash[:success] = I18n.t('admin.feedback.bulkops.success_mark_as_ham', count: ids.size)
119
+ when 'Mark Checked Items as Spam'
120
+ update_feedback(items, :mark_as_spam!)
121
+ flash[:success] = I18n.t('admin.feedback.bulkops.success_mark_as_spam', count: ids.size)
122
+ when 'Confirm Classification of Checked Items'
123
+ update_feedback(items, :confirm_classification!)
124
+ flash[:success] = I18n.t('admin.feedback.bulkops.success_classification', count: ids.size)
125
+ when 'Delete all spam'
126
+ if request.post?
127
+ Feedback.delete_all(['state = ?', 'spam'])
128
+ flash[:success] = I18n.t('admin.feedback.bulkops.success_deleted_spam')
129
+ end
130
+ else
131
+ flash[:error] = I18n.t('admin.feedback.bulkops.error')
132
+ end
133
+
134
+ if params[:article_id]
135
+ redirect_to action: 'article', id: params[:article_id], confirmed: params[:confirmed], published: params[:published]
136
+ else
137
+ redirect_to action: 'index', page: params[:page], search: params[:search], confirmed: params[:confirmed], published: params[:published]
138
+ end
139
+ end
140
+
141
+ private
142
+
143
+ def comment_params
144
+ params.require(:comment).permit(:author, :email, :url, :body)
145
+ end
146
+
147
+ def update_feedback(items, method)
148
+ items.each do |value|
149
+ value.send(method)
150
+ @unexpired && value.invalidates_cache? or next
151
+ flush_cache
152
+ end
153
+ end
154
+
155
+ def flush_cache
156
+ @unexpired = false
157
+ PageCache.sweep_all
158
+ end
159
+ end
@@ -0,0 +1,20 @@
1
+ class Admin::MigrationsController < Admin::BaseController
2
+ cache_sweeper :blog_sweeper
3
+ skip_before_action :look_for_needed_db_updates
4
+
5
+ def show
6
+ @current_version = migrator.current_schema_version
7
+ @needed_migrations = migrator.pending_migrations
8
+ end
9
+
10
+ def update
11
+ migrator.migrate
12
+ redirect_to admin_migrations_url
13
+ end
14
+
15
+ private
16
+
17
+ def migrator
18
+ @migrator ||= Migrator.new
19
+ end
20
+ end
@@ -0,0 +1,69 @@
1
+ class Admin::NotesController < Admin::BaseController
2
+ layout 'administration'
3
+ cache_sweeper :blog_sweeper
4
+
5
+ before_action :load_existing_notes, only: [:index, :edit]
6
+ before_action :find_note, only: [:edit, :update, :show, :destroy]
7
+
8
+ def index
9
+ @note = new_note
10
+ end
11
+
12
+ def show
13
+ unless @note.access_by?(current_user)
14
+ flash[:error] = I18n.t('admin.base.not_allowed')
15
+ redirect_to admin_notes_url
16
+ end
17
+ end
18
+
19
+ def edit
20
+ end
21
+
22
+ def create
23
+ note = new_note
24
+
25
+ note.published = true
26
+ note.attributes = params[:note].permit!
27
+ note.text_filter ||= current_user.default_text_filter
28
+ note.published_at ||= Time.now
29
+ if note.save
30
+ if params[:push_to_twitter] && note.twitter_id.blank?
31
+ unless note.send_to_twitter
32
+ flash[:error] = I18n.t('errors.problem_sending_to_twitter')
33
+ flash[:error] += " : #{note.errors.full_messages.join(' ')}"
34
+ end
35
+ end
36
+ flash[:notice] = I18n.t('notice.note_successfully_created')
37
+ else
38
+ flash[:error] = note.errors.full_messages
39
+ end
40
+ redirect_to admin_notes_url
41
+ end
42
+
43
+ def update
44
+ @note.attributes = params[:note].permit!
45
+ @note.save
46
+ redirect_to admin_notes_url
47
+ end
48
+
49
+ def destroy
50
+ @note.destroy
51
+ flash[:notice] = I18n.t('admin.base.successfully_deleted', name: 'note')
52
+ redirect_to admin_notes_url
53
+ end
54
+
55
+ private
56
+
57
+ def load_existing_notes
58
+ @notes = Note.page(params[:page]).per(this_blog.limit_article_display)
59
+ end
60
+
61
+ def find_note
62
+ @note = Note.find(params[:id])
63
+ end
64
+
65
+ def new_note
66
+ this_blog.notes.build(author: current_user,
67
+ text_filter: current_user.text_filter)
68
+ end
69
+ end
@@ -0,0 +1,88 @@
1
+ # coding: utf-8
2
+ require 'base64'
3
+
4
+ class Admin::PagesController < Admin::BaseController
5
+ before_action :set_images, only: [:new, :edit]
6
+ before_action :set_macro, only: [:new, :edit]
7
+ before_action :set_page, only: [:show, :edit, :update, :destroy]
8
+
9
+ layout :get_layout
10
+ cache_sweeper :blog_sweeper
11
+
12
+ def index
13
+ @search = params[:search] ? params[:search] : {}
14
+ @pages = Page.search_with(@search).page(params[:page]).per(this_blog.admin_display_elements)
15
+ end
16
+
17
+ def new
18
+ @page = Page.new
19
+ @page.text_filter ||= default_textfilter
20
+ @page.published = true
21
+ @page.user_id = current_user.id
22
+ end
23
+
24
+ def edit
25
+ @page.text_filter ||= default_textfilter
26
+ end
27
+
28
+ def create
29
+ @page = Page.new(page_params)
30
+ @page.published_at = Time.now
31
+ @page.blog = this_blog
32
+ @page.user_id = current_user.id
33
+
34
+ if @page.save
35
+ redirect_to admin_pages_url, notice: I18n.t('admin.pages.new.success')
36
+ else
37
+ render :new
38
+ end
39
+ end
40
+
41
+ def update
42
+ @page.text_filter ||= default_textfilter
43
+ if @page.update(page_params)
44
+ redirect_to admin_pages_url, notice: I18n.t('admin.pages.edit.success')
45
+ else
46
+ render :edit
47
+ end
48
+ end
49
+
50
+ def destroy
51
+ destroy_a(Page)
52
+ end
53
+
54
+ private
55
+
56
+ def default_textfilter
57
+ current_user.text_filter || blog.text_filter
58
+ end
59
+
60
+ def set_macro
61
+ @macros = TextFilterPlugin.macro_filters
62
+ end
63
+
64
+ def set_images
65
+ @images = Resource.images.by_created_at.page(1).per(10)
66
+ end
67
+
68
+ def get_layout
69
+ case action_name
70
+ when 'new', 'edit', 'create'
71
+ 'editor'
72
+ when 'show'
73
+ nil
74
+ else
75
+ 'administration'
76
+ end
77
+ end
78
+
79
+ # Use callbacks to share common setup or constraints between actions.
80
+ def set_page
81
+ @page = Page.find(params[:id])
82
+ end
83
+
84
+ # Never trust parameters from the scary internet, only allow the white list through.
85
+ def page_params
86
+ params.require(:page).permit(:title, :body, :name, :published, :text_filter)
87
+ end
88
+ end
@@ -0,0 +1,56 @@
1
+ class Admin::PostTypesController < Admin::BaseController
2
+ before_action :set_post_type, only: [:edit, :update, :destroy]
3
+ cache_sweeper :blog_sweeper
4
+
5
+ def index
6
+ @post_types = PostType.all
7
+ @post_type = PostType.new
8
+ end
9
+
10
+ def edit
11
+ @post_types = PostType.all
12
+ end
13
+
14
+ def create
15
+ @post_type = PostType.new(post_type_params)
16
+
17
+ if @post_type.save
18
+ redirect_to admin_post_types_url, notice: 'Post type was successfully created.'
19
+ else
20
+ render :index
21
+ end
22
+ end
23
+
24
+ def update
25
+ if @post_type.update(post_type_params)
26
+ redirect_to admin_post_types_url, notice: 'Post type was successfully updated.'
27
+ else
28
+ render :edit
29
+ end
30
+ end
31
+
32
+ def destroy
33
+ # Reset all Articles from the PostType we're destroying to the default PostType
34
+ # Wrap it in a transaction for safety
35
+ @post_type.transaction do
36
+ Article.where('post_type = ?', @post_type.permalink).each do |article|
37
+ article.post_type = 'read'
38
+ article.save
39
+ end
40
+ @post_type.destroy
41
+ end
42
+ redirect_to admin_post_types_url, notice: 'Post was successfully destroyed.'
43
+ end
44
+
45
+ private
46
+
47
+ # Use callbacks to share common setup or constraints between actions.
48
+ def set_post_type
49
+ @post_type = PostType.find(params[:id])
50
+ end
51
+
52
+ # Never trust parameters from the scary internet, only allow the white list through.
53
+ def post_type_params
54
+ params.require(:post_type).permit(:name, :description)
55
+ end
56
+ end
@@ -0,0 +1,48 @@
1
+ # This controller handles updating your own user data.
2
+ class Admin::ProfilesController < Admin::BaseController
3
+ before_action :set_user, only: [:index, :update]
4
+
5
+ def index
6
+ end
7
+
8
+ def update
9
+ @user.resource = upload_avatar if params[:user][:filename]
10
+
11
+ if @user.update(user_params)
12
+ redirect_to admin_profiles_url, notice: I18n.t('admin.profiles.index.success')
13
+ else
14
+ render :index
15
+ end
16
+ end
17
+
18
+ private
19
+
20
+ def upload_avatar
21
+ file = params[:user][:filename]
22
+
23
+ mime = if file.content_type
24
+ file.content_type.chomp
25
+ else
26
+ 'text/plain'
27
+ end
28
+
29
+ Resource.create(upload: file, mime: mime, created_at: Time.now)
30
+ end
31
+
32
+ # Use callbacks to share common setup or constraints between actions.
33
+ def set_user
34
+ @user = current_user
35
+ end
36
+
37
+ # Never trust parameters from the scary internet, only allow the white list through.
38
+ def user_params
39
+ params.require(:user).permit(:login, :password, :password_confirmation,
40
+ :email, :firstname, :lastname, :nickname,
41
+ :display_name, :notify_via_email,
42
+ :notify_on_new_articles, :notify_on_comments,
43
+ :text_filter_id, :state,
44
+ :twitter_account, :twitter_oauth_token,
45
+ :twitter_oauth_token_secret, :description,
46
+ :url, :msn, :yahoo, :jabber, :aim, :twitter)
47
+ end
48
+ end
@@ -0,0 +1,47 @@
1
+ class Admin::RedirectsController < Admin::BaseController
2
+ before_action :set_redirect, only: [:edit, :update, :destroy]
3
+
4
+ def index
5
+ @redirects = Redirect.where(content_id: nil).order('id desc').page(params[:page]).per(this_blog.admin_display_elements)
6
+ @redirect = Redirect.new
7
+ end
8
+
9
+ def edit
10
+ @redirects = Redirect.where(content_id: nil).order('id desc').page(params[:page]).per(this_blog.admin_display_elements)
11
+ end
12
+
13
+ def create
14
+ @redirect = this_blog.redirects.build(redirect_params)
15
+
16
+ if @redirect.save
17
+ redirect_to admin_redirects_url, notice: 'Redirect was successfully created.'
18
+ else
19
+ render :index
20
+ end
21
+ end
22
+
23
+ def update
24
+ if @redirect.update(redirect_params)
25
+ redirect_to admin_redirects_url, notice: 'Redirect was successfully updated.'
26
+ else
27
+ render :edit
28
+ end
29
+ end
30
+
31
+ def destroy
32
+ @redirect.destroy
33
+ redirect_to admin_redirects_url, notice: I18n.t('admin.redirects.destroy.success')
34
+ end
35
+
36
+ private
37
+
38
+ # Use callbacks to share common setup or constraints between actions.
39
+ def set_redirect
40
+ @redirect = Redirect.find(params[:id])
41
+ end
42
+
43
+ # Never trust parameters from the scary internet, only allow the white list through.
44
+ def redirect_params
45
+ params.require(:redirect).permit(:from_path, :to_path)
46
+ end
47
+ end
@@ -0,0 +1,30 @@
1
+ class Admin::ResourcesController < Admin::BaseController
2
+ cache_sweeper :blog_sweeper
3
+
4
+ def upload
5
+ file = params[:upload]
6
+
7
+ @up = Resource.new(blog: this_blog, upload: file)
8
+ @up.mime = @up.upload.content_type
9
+
10
+ if @up.save
11
+ flash[:success] = I18n.t('admin.resources.upload.success')
12
+ else
13
+ flash[:warning] = I18n.t('admin.resources.upload.warning')
14
+ end
15
+
16
+ redirect_to admin_resources_url
17
+ end
18
+
19
+ def index
20
+ @r = Resource.new
21
+ @resources = Resource.order('created_at DESC').page(params[:page]).per(this_blog.admin_display_elements)
22
+ end
23
+
24
+ def destroy
25
+ @record = Resource.find(params[:id])
26
+ @record.destroy
27
+ flash[:notice] = I18n.t('admin.resources.destroy.notice')
28
+ redirect_to admin_resources_url
29
+ end
30
+ end
@@ -0,0 +1,45 @@
1
+ class Admin::SeoController < Admin::BaseController
2
+ cache_sweeper :blog_sweeper
3
+ before_action :set_setting
4
+ before_action :set_section
5
+
6
+ def show
7
+ if @setting.permalink_format != '/%year%/%month%/%day%/%title%' &&
8
+ @setting.permalink_format != '/%year%/%month%/%title%' &&
9
+ @setting.permalink_format != '/%title%'
10
+ @setting.custom_permalink = @setting.permalink_format
11
+ @setting.permalink_format = 'custom'
12
+ end
13
+ end
14
+
15
+ def update
16
+ if settings_params[:permalink_format] == 'custom'
17
+ settings_params[:permalink_format] = settings_params[:custom_permalink]
18
+ end
19
+ if @setting.update_attributes(settings_params)
20
+ flash[:success] = I18n.t('admin.settings.update.success')
21
+ redirect_to admin_seo_path(section: @section)
22
+ else
23
+ flash[:error] = I18n.t('admin.settings.update.error',
24
+ messages: this_blog.errors.full_messages.join(', '))
25
+ render :show
26
+ end
27
+ end
28
+
29
+ private
30
+
31
+ def settings_params
32
+ @settings_params ||= params.require(:setting).permit!
33
+ end
34
+
35
+ VALID_SECTIONS = %w(general titles permalinks).freeze
36
+
37
+ def set_section
38
+ section = params[:section]
39
+ @section = VALID_SECTIONS.include?(section) ? section : 'general'
40
+ end
41
+
42
+ def set_setting
43
+ @setting = this_blog
44
+ end
45
+ end