proclaim 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/CHANGELOG +6 -0
- data/Gemfile +14 -0
- data/LICENSE +674 -0
- data/README.md +137 -0
- data/Rakefile +65 -0
- data/VERSION +1 -0
- data/app/assets/images/ajax_loader.gif +0 -0
- data/app/assets/javascripts/proclaim.js +18 -0
- data/app/assets/javascripts/proclaim/comments_handler.js.coffee +192 -0
- data/app/assets/javascripts/proclaim/editor.js.coffee +50 -0
- data/app/assets/javascripts/proclaim/images.js.coffee +3 -0
- data/app/assets/javascripts/proclaim/subscriptions.js.coffee +3 -0
- data/app/assets/stylesheets/proclaim.css.scss +28 -0
- data/app/assets/stylesheets/proclaim/comments.css.scss +14 -0
- data/app/assets/stylesheets/proclaim/images.scss +3 -0
- data/app/assets/stylesheets/proclaim/posts.css.scss +77 -0
- data/app/assets/stylesheets/proclaim/subscriptions.css.scss +3 -0
- data/app/controllers/proclaim/application_controller.rb +44 -0
- data/app/controllers/proclaim/comments_controller.rb +128 -0
- data/app/controllers/proclaim/images_controller.rb +108 -0
- data/app/controllers/proclaim/posts_controller.rb +131 -0
- data/app/controllers/proclaim/subscriptions_controller.rb +67 -0
- data/app/helpers/proclaim/application_helper.rb +34 -0
- data/app/helpers/proclaim/comments_helper.rb +4 -0
- data/app/helpers/proclaim/images_helper.rb +4 -0
- data/app/helpers/proclaim/posts_helper.rb +4 -0
- data/app/helpers/proclaim/subscriptions_helper.rb +4 -0
- data/app/mailers/proclaim/subscription_mailer.rb +43 -0
- data/app/models/proclaim/comment.rb +35 -0
- data/app/models/proclaim/image.rb +19 -0
- data/app/models/proclaim/post.rb +133 -0
- data/app/models/proclaim/subscription.rb +63 -0
- data/app/policies/application_policy.rb +53 -0
- data/app/policies/proclaim/comment_policy.rb +27 -0
- data/app/policies/proclaim/image_policy.rb +29 -0
- data/app/policies/proclaim/post_policy.rb +38 -0
- data/app/policies/proclaim/subscription_policy.rb +32 -0
- data/app/uploaders/proclaim/image_uploader.rb +82 -0
- data/app/views/layouts/proclaim/subscription_mailer.html.erb +133 -0
- data/app/views/proclaim/comments/_comment.html.erb +33 -0
- data/app/views/proclaim/comments/_form.html.erb +51 -0
- data/app/views/proclaim/posts/_form.html.erb +67 -0
- data/app/views/proclaim/posts/edit.html.erb +3 -0
- data/app/views/proclaim/posts/index.html.erb +30 -0
- data/app/views/proclaim/posts/new.html.erb +3 -0
- data/app/views/proclaim/posts/show.html.erb +46 -0
- data/app/views/proclaim/subscription_mailer/new_comment_notification_email.html.erb +11 -0
- data/app/views/proclaim/subscription_mailer/new_post_notification_email.html.erb +15 -0
- data/app/views/proclaim/subscription_mailer/welcome_email.html.erb +25 -0
- data/app/views/proclaim/subscriptions/_form.html.erb +32 -0
- data/app/views/proclaim/subscriptions/new.html.erb +8 -0
- data/app/views/proclaim/subscriptions/subscribed.html.erb +7 -0
- data/app/views/proclaim/subscriptions/unsubscribe.html.erb +7 -0
- data/app/views/proclaim/subscriptions/unsubscribed.html.erb +3 -0
- data/config/routes.rb +18 -0
- data/db/migrate/20141108222616_create_proclaim_posts.rb +15 -0
- data/db/migrate/20141114235359_create_proclaim_comments.rb +15 -0
- data/db/migrate/20141115022230_create_proclaim_comment_hierarchies.rb +26 -0
- data/db/migrate/20141210234057_create_proclaim_subscriptions.rb +17 -0
- data/db/migrate/20141222224905_create_proclaim_images.rb +12 -0
- data/lib/generators/proclaim/install_generator.rb +23 -0
- data/lib/generators/proclaim/templates/README +27 -0
- data/lib/generators/proclaim/templates/initialize_proclaim.rb +22 -0
- data/lib/generators/proclaim/views_generator.rb +24 -0
- data/lib/proclaim.rb +22 -0
- data/lib/proclaim/engine.rb +39 -0
- data/lib/proclaim/version.rb +3 -0
- data/lib/tasks/proclaim_tasks.rake +4 -0
- data/proclaim.gemspec +46 -0
- data/test/controllers/proclaim/comments_controller_test.rb +228 -0
- data/test/controllers/proclaim/images_controller_test.rb +123 -0
- data/test/controllers/proclaim/posts_controller_test.rb +303 -0
- data/test/controllers/proclaim/subscriptions_controller_test.rb +93 -0
- data/test/dummy/README.rdoc +28 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/assets/javascripts/application.js +14 -0
- data/test/dummy/app/assets/stylesheets/application.css +16 -0
- data/test/dummy/app/controllers/application_controller.rb +15 -0
- data/test/dummy/app/helpers/application_helper.rb +28 -0
- data/test/dummy/app/models/user.rb +7 -0
- data/test/dummy/app/views/layouts/application.html.erb +16 -0
- data/test/dummy/bin/bundle +3 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/config.ru +4 -0
- data/test/dummy/config/application.rb +24 -0
- data/test/dummy/config/boot.rb +5 -0
- data/test/dummy/config/database.yml +25 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/development.rb +45 -0
- data/test/dummy/config/environments/production.rb +80 -0
- data/test/dummy/config/environments/test.rb +49 -0
- data/test/dummy/config/initializers/assets.rb +8 -0
- data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/test/dummy/config/initializers/cookies_serializer.rb +3 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/mime_types.rb +4 -0
- data/test/dummy/config/initializers/session_store.rb +3 -0
- data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/test/dummy/config/locales/en.yml +23 -0
- data/test/dummy/config/routes.rb +5 -0
- data/test/dummy/config/secrets.yml +22 -0
- data/test/dummy/db/migrate/20141117214323_create_users.rb +10 -0
- data/test/dummy/db/schema.rb +75 -0
- data/test/dummy/log/development.log +131 -0
- data/test/dummy/log/test.log +25961 -0
- data/test/dummy/public/404.html +67 -0
- data/test/dummy/public/422.html +67 -0
- data/test/dummy/public/500.html +66 -0
- data/test/dummy/public/favicon.ico +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/0b69f7cc441d56def3a51688e6a7a8474dc476d1/proclaim.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/comments.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/images.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/posts.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sass/12a97df611d5fb0e395afda829edf8b9372acde7/subscriptions.css.scssc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/04adcece63bc645379e6de797e7998f8 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/06620fc450f0a9b4a482a7bc08387711 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/076dd0d567a92c34163b3b98af1d48ba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/09fc2eadf6d6062b2cc135a44e4e73db +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/09fe8c62e8ae706e01058b4b4d056c8e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/13fe41fee1fe35b49d145bcc06610705 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/142fd040033525acb73ad2ccf1406aea +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1762aeeaf38da3b8d989a5b66b088004 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/194ac1a695334e303516614579b3926d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/197ea008934db3e7ea8045302d206b92 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/19eba2635fec0895379c3e38f81ada84 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1c2ebe72fcd7ff1379a561552ca30f85 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/1f42c80faacb651f670ec2b0998e49dc +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2243230e778a749ecbf0415a52e75be0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/23ad87e715c70312aa61dde4fbb4bfe1 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/245b8735db4ea90bcaa91c011a1f447e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/26a42dac0cec64483f4126d2de4b0c9e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/2f5173deea6c795b8fdde723bb4b63af +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/30151c8f6d93717f06fa12774612ddf4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/357970feca3ac29060c1e3861e2c0953 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3c623d200214a5334aaf170537db087f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/3ec36650a50759fd4b75794cb253936f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/40431cdcc10c75ba1f275ecfe42623d3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4226218a4b06608115b21063353370ea +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/437901953eb8707af6c27ca59cf65d91 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/461885b8ad31ef6a94c9a4f2e332b7eb +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4792f46317cda92ccd5b278ec61f9ac5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/4dcb3434b91b1c62f897a1741c6d398b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5101cda93cf70f0fc0837713be587780 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/52d8c61de0703e0d7cf97d0f7b0cca7a +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/57f3d19a9bd484ac68c46f962a8684b2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/587e7c1332c8d8b69746dd85164e2cef +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5934d5d0d1ac6657842708e85c73cf51 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/5af081799d7da2f04ead6a516c6015ad +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/69ee5af8d9a655898a67bc538ca1c7e7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6d1c56259648b0383bc438c875a448c3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/6e7de35055967df848aa490830043e51 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/70bc59560ee544af7bb2f727247db307 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/728cb566999910549092ff0a98e2853b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/72b5f0d35e9d69b744a156edad98f983 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/72ffa34d552e3fd02f28a6f845a5ac5b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7369d324e84bc872c42b3e717ff4ad6c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/749a8b0e45b11df748a256dd04ceb1f7 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/77fb9f62552d9b786f9407ef11cc9a09 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/797823842565e01fc989ad8df0bd4254 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7c139afa2296ac17483520109aecd449 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/7fb99e2b35af65c4f58bfb92dd4185b4 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/819de31c63b704f9ddf4865587a91d41 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8604b464bf846e5223da37ef2f29b524 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/88fc815613b473e98e9307b1d423918d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8bc4341aa4060b8646e8134722cf3b11 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8cf8fd5ff8eae12211a88f971af30236 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/8da3b4a9f17aafff49eb263bdb758f44 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9168e513bae02f041dbb806d6dbe94ac +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/920c1322be1212a54b7c4f2751d5e7bf +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/92205679a36afd387a2ba5c585a5a62c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/940566ebcae2d4e5c56a881ab66f2cf0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/976967e07e2944a7ecc7403667f1f96b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/99bdde70cefa71745279232be575f14e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9a8e402a7e32063e46647403b43553a5 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/9b09ad72f8cc33503878b01c713d92d0 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a20dbdfebf37fe50e832a6273c972553 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/a3c6189fad6cb9ae955f6d5a43a61d51 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/abb54e11ff057a3e22a5a97d27cc4fa3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ad18e3875541d4298b1df133d494b93f +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/b9b7c575c22943d49734d52381c5ee16 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ba269a52f100d3d6cffda81e82e1ed49 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bc7a0846b4881b0832d41de2b1724dba +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bcb2df87f9611d3cc3ef8a5575e54fb8 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/bcf33791d3286af3ba2cdf6a6756c89e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/be32d0a530ce861537d6abfa41333df9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/c8270a6f07dccc5f00e6b2b43f10efd2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cd82cd410a50bffcfb6e21e3c49a85c9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ce4ccaa06bdee6426486224bc7e54187 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/cffd775d018f68ce5dba1ee0d951a994 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d0bdb8592e4eed80aa2341e37f20dbc9 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d4b784b16fa1b1dfcca6590689a8c157 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d771ace226fc8215a3572e0aa35bb0d6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/d968bd38a69bbf5c0065e2df3d30cfd3 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/daa4d4b8a5ce46d6c4ecf031e0c61cfe +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/dc2effd195334219a7e4acfdc7ec7974 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/de36ab6c3b1a9b62a586d98373dd569c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e3aec457d5c753090d6521f2bb2d91b6 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/e8d6158b1fed2f574242b55856a3953d +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ea82f6aececcf81eef3e2e15a9225e66 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ed9f5c17f71ec75de10b1bb029ebd7a2 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f2984adaeaa5322e3a040705c6d40622 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f62fd0cf9f5e7e077ec9c4daeccb06ae +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f78ea69bdbba5738c052e9eb04e6c208 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f7cbd26ba1d28d48de824f0e94586655 +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/f864e553f706456dbdf168319970ec2e +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fb0f641bfcbb0101c040da9ff736447b +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/fe426a44cf23cf82032091cbffff898c +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ff732ea47a86c449582b2a81ef2930da +0 -0
- data/test/dummy/tmp/cache/assets/test/sprockets/ffc4980851addaacf12abeebfa63e07f +0 -0
- data/test/dummy/tmp/generators/config/initializers/proclaim.rb +22 -0
- data/test/factories/proclaim/comment.rb +11 -0
- data/test/factories/proclaim/image.rb +6 -0
- data/test/factories/proclaim/post.rb +14 -0
- data/test/factories/proclaim/subscription.rb +13 -0
- data/test/factories/user.rb +6 -0
- data/test/helpers/proclaim/comments_helper_test.rb +6 -0
- data/test/helpers/proclaim/posts_helper_test.rb +6 -0
- data/test/helpers/proclaim/subscriptions_helper_test.rb +6 -0
- data/test/integration/with_javascript/comment_test.rb +353 -0
- data/test/integration/with_javascript/post_form_test.rb +179 -0
- data/test/integration/with_javascript/post_subscription_test.rb +273 -0
- data/test/integration/without_javascript/blog_subscription_test.rb +87 -0
- data/test/integration/without_javascript/post_test.rb +140 -0
- data/test/integration/without_javascript/subscription_email_test.rb +95 -0
- data/test/integration/without_javascript/unsubscribe_test.rb +32 -0
- data/test/mailers/previews/proclaim/subscription_mailer_preview.rb +22 -0
- data/test/mailers/proclaim/subscription_mailer_test.rb +87 -0
- data/test/models/proclaim/comment_test.rb +41 -0
- data/test/models/proclaim/image_test.rb +70 -0
- data/test/models/proclaim/post_test.rb +127 -0
- data/test/models/proclaim/subscription_test.rb +66 -0
- data/test/policies/proclaim/comment_policy_test.rb +71 -0
- data/test/policies/proclaim/post_policy_test.rb +87 -0
- data/test/policies/proclaim/subscription_policy_test.rb +91 -0
- data/test/proclaim_test.rb +7 -0
- data/test/support/images/test.jpg +0 -0
- data/test/support/pages/posts/edit_page.rb +5 -0
- data/test/support/pages/posts/show_page.rb +47 -0
- data/test/support/wait_for_ajax.rb +11 -0
- data/test/test_helper.rb +56 -0
- data/vendor/assets/images/link.png +0 -0
- data/vendor/assets/images/remove.png +0 -0
- data/vendor/assets/images/resize-bigger.png +0 -0
- data/vendor/assets/images/resize-smaller.png +0 -0
- data/vendor/assets/images/unlink.png +0 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-embeds.js +197 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-embeds.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-images.js +572 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-images.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-maps.js +50 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-maps.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-plugin.js +496 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-plugin.min.js +10 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-tables.js +132 -0
- data/vendor/assets/javascripts/addons/medium-editor-insert-tables.min.js +10 -0
- data/vendor/assets/javascripts/medium-editor-insert-plugin.all.js +1415 -0
- data/vendor/assets/javascripts/medium-editor-insert-plugin.all.min.js +10 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin-frontend.css +55 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin-frontend.min.css +10 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin.css +277 -0
- data/vendor/assets/stylesheets/medium-editor-insert-plugin.min.css +10 -0
- metadata +791 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
module Proclaim
|
2
|
+
class CommentPolicy < ApplicationPolicy
|
3
|
+
def create?
|
4
|
+
# Users can comment on whatever they want, but guests can only comment
|
5
|
+
# on published posts
|
6
|
+
if @user
|
7
|
+
true
|
8
|
+
else
|
9
|
+
@record.post.published?
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def update?
|
14
|
+
not @user.nil?
|
15
|
+
end
|
16
|
+
|
17
|
+
def destroy?
|
18
|
+
not @user.nil?
|
19
|
+
end
|
20
|
+
|
21
|
+
class Scope < Scope
|
22
|
+
def resolve
|
23
|
+
scope.all
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Proclaim
|
2
|
+
class ImagePolicy < ApplicationPolicy
|
3
|
+
def cache?
|
4
|
+
create?
|
5
|
+
end
|
6
|
+
|
7
|
+
def create?
|
8
|
+
not @user.nil? # As long as there's a user, it can create images
|
9
|
+
end
|
10
|
+
|
11
|
+
def discard?
|
12
|
+
destroy?
|
13
|
+
end
|
14
|
+
|
15
|
+
def destroy?
|
16
|
+
not @user.nil? # As long as there's a user, it can destroy images
|
17
|
+
end
|
18
|
+
|
19
|
+
class Scope < Scope
|
20
|
+
def resolve
|
21
|
+
if @user
|
22
|
+
scope.all # Users can access all images
|
23
|
+
else
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
module Proclaim
|
2
|
+
class PostPolicy < ApplicationPolicy
|
3
|
+
def index?
|
4
|
+
true # Anyone can list posts
|
5
|
+
end
|
6
|
+
|
7
|
+
def show?
|
8
|
+
if @user
|
9
|
+
true # A logged in user can see anything
|
10
|
+
else
|
11
|
+
@record.published? # Guests can see published posts
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def create?
|
16
|
+
not @user.nil? # As long as there's a user, it can create posts
|
17
|
+
end
|
18
|
+
|
19
|
+
def update?
|
20
|
+
not @user.nil? # As long as there's a user, it can update posts
|
21
|
+
end
|
22
|
+
|
23
|
+
def destroy?
|
24
|
+
not @user.nil? # As long as there's a user, it can destroy posts
|
25
|
+
end
|
26
|
+
|
27
|
+
class Scope < Scope
|
28
|
+
def resolve
|
29
|
+
if @user
|
30
|
+
scope.all # Users can access all posts
|
31
|
+
else
|
32
|
+
# Guests can see all posts that are published
|
33
|
+
scope.published
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module Proclaim
|
2
|
+
class SubscriptionPolicy < ApplicationPolicy
|
3
|
+
def create?
|
4
|
+
# A user can subscribe to anything. Guests can only subscribe to
|
5
|
+
# published posts or the blog in general.
|
6
|
+
if @user.nil? and @record.post
|
7
|
+
@record.post.published?
|
8
|
+
else
|
9
|
+
true
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
def unsubscribe?
|
14
|
+
destroy?
|
15
|
+
end
|
16
|
+
|
17
|
+
def destroy?
|
18
|
+
true # Anyone can unsubscribe (it requires a token anyway)
|
19
|
+
end
|
20
|
+
|
21
|
+
class Scope < Scope
|
22
|
+
def resolve
|
23
|
+
if @user
|
24
|
+
scope.all # Users can access all subscriptions
|
25
|
+
else
|
26
|
+
# Guests can see none
|
27
|
+
nil
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,82 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Proclaim
|
3
|
+
class ImageUploader < CarrierWave::Uploader::Base
|
4
|
+
before :remove, :backup_cache_id
|
5
|
+
after :remove, :delete_cache_directory
|
6
|
+
after :remove, :delete_store_directory
|
7
|
+
|
8
|
+
# Include RMagick or MiniMagick support:
|
9
|
+
# include CarrierWave::RMagick
|
10
|
+
# include CarrierWave::MiniMagick
|
11
|
+
|
12
|
+
# Choose what kind of storage to use for this uploader:
|
13
|
+
storage :file
|
14
|
+
# storage :fog
|
15
|
+
|
16
|
+
# Override the directory where uploaded files will be stored.
|
17
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
18
|
+
def store_dir
|
19
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
20
|
+
end
|
21
|
+
|
22
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
23
|
+
# def default_url
|
24
|
+
# # For Rails 3.1+ asset pipeline compatibility:
|
25
|
+
# # ActionController::Base.helpers.asset_path("fallback/" + [version_name, "default.png"].compact.join('_'))
|
26
|
+
#
|
27
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
28
|
+
# end
|
29
|
+
|
30
|
+
# Process files as they are uploaded:
|
31
|
+
# process :scale => [200, 300]
|
32
|
+
#
|
33
|
+
# def scale(width, height)
|
34
|
+
# # do something
|
35
|
+
# end
|
36
|
+
|
37
|
+
# Create different versions of your uploaded files:
|
38
|
+
# version :thumb do
|
39
|
+
# process :resize_to_fit => [50, 50]
|
40
|
+
# end
|
41
|
+
|
42
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
43
|
+
# For images you might use something like this:
|
44
|
+
# def extension_white_list
|
45
|
+
# %w(jpg jpeg gif png)
|
46
|
+
# end
|
47
|
+
|
48
|
+
# Override the filename of the uploaded files:
|
49
|
+
# Avoid using model.id or version_name here, see uploader/store.rb for details.
|
50
|
+
# def filename
|
51
|
+
# "something.jpg" if original_filename
|
52
|
+
# end
|
53
|
+
|
54
|
+
private
|
55
|
+
|
56
|
+
def backup_cache_id
|
57
|
+
@cache_id_was = cache_id
|
58
|
+
end
|
59
|
+
|
60
|
+
def delete_cache_directory
|
61
|
+
@cache_id = @cache_id_was
|
62
|
+
delete_cache_id
|
63
|
+
end
|
64
|
+
|
65
|
+
def delete_store_directory
|
66
|
+
store_path = store_dir
|
67
|
+
if Pathname.new(store_dir).relative?
|
68
|
+
store_path = File.expand_path(store_dir, CarrierWave.root)
|
69
|
+
end
|
70
|
+
|
71
|
+
begin
|
72
|
+
Dir.rmdir(store_path)
|
73
|
+
rescue Errno::ENOENT
|
74
|
+
# Ignore: path does not exist
|
75
|
+
rescue Errno::ENOTDIR
|
76
|
+
# Ignore: path is not a dir
|
77
|
+
rescue Errno::ENOTEMPTY, Errno::EEXIST
|
78
|
+
# Ignore: dir is not empty
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,133 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta content='text/html; charset=UTF-8' http-equiv='Content-Type' />
|
5
|
+
|
6
|
+
<style>
|
7
|
+
* {
|
8
|
+
box-sizing: border-box;
|
9
|
+
}
|
10
|
+
|
11
|
+
table.main
|
12
|
+
{
|
13
|
+
width: 100%;
|
14
|
+
}
|
15
|
+
|
16
|
+
table.post
|
17
|
+
{
|
18
|
+
width: 600px;
|
19
|
+
margin: 0 auto;
|
20
|
+
}
|
21
|
+
|
22
|
+
td.post_title
|
23
|
+
{
|
24
|
+
text-align: center;
|
25
|
+
border-bottom: solid 1px #ddd;
|
26
|
+
}
|
27
|
+
|
28
|
+
td.post_title h1
|
29
|
+
{
|
30
|
+
margin: 0 0 10px 0;
|
31
|
+
padding: 0;
|
32
|
+
}
|
33
|
+
|
34
|
+
.mediumInsert
|
35
|
+
{
|
36
|
+
margin: 0px;
|
37
|
+
}
|
38
|
+
|
39
|
+
.mediumInsert.small
|
40
|
+
{
|
41
|
+
float: left;
|
42
|
+
max-width: calc(33.33% + 40px);
|
43
|
+
min-height: 18px;
|
44
|
+
}
|
45
|
+
|
46
|
+
.mediumInsert img
|
47
|
+
{
|
48
|
+
display: block;
|
49
|
+
margin: 0px;
|
50
|
+
vertical-align: top;
|
51
|
+
max-width: 600px;
|
52
|
+
border: 0px none;
|
53
|
+
}
|
54
|
+
|
55
|
+
.mediumInsert.small img
|
56
|
+
{
|
57
|
+
max-width: 100%;
|
58
|
+
}
|
59
|
+
|
60
|
+
figure.mediumInsert-images
|
61
|
+
{
|
62
|
+
width: 100%;
|
63
|
+
margin: 0px;
|
64
|
+
text-align: center;
|
65
|
+
}
|
66
|
+
|
67
|
+
figure.mediumInsert-images.small
|
68
|
+
{
|
69
|
+
padding-bottom: 18px;
|
70
|
+
padding-right: 30px;
|
71
|
+
}
|
72
|
+
|
73
|
+
figure.mediumInsert-images:first-child
|
74
|
+
{
|
75
|
+
margin-right: 0px;
|
76
|
+
width: 100%;
|
77
|
+
}
|
78
|
+
|
79
|
+
.medium-editor-insert-plugin p
|
80
|
+
{
|
81
|
+
margin: 0px 0px 10px;
|
82
|
+
box-sizing: border-box;
|
83
|
+
}
|
84
|
+
|
85
|
+
td.post_body
|
86
|
+
{
|
87
|
+
padding-bottom: 10px;
|
88
|
+
}
|
89
|
+
|
90
|
+
td.post_body blockquote
|
91
|
+
{
|
92
|
+
padding: 10px 20px;
|
93
|
+
margin: 0 0 20px;
|
94
|
+
border-left: 5px solid #eeeeee;
|
95
|
+
}
|
96
|
+
|
97
|
+
td.post_information
|
98
|
+
{
|
99
|
+
border-top: solid 1px #ddd;
|
100
|
+
border-bottom: solid 1px #ddd;
|
101
|
+
padding: 10px;
|
102
|
+
clear: both;
|
103
|
+
}
|
104
|
+
|
105
|
+
table.footer
|
106
|
+
{
|
107
|
+
margin-top: 20px;
|
108
|
+
color: #888;
|
109
|
+
}
|
110
|
+
</style>
|
111
|
+
</head>
|
112
|
+
<body>
|
113
|
+
<table class = "main">
|
114
|
+
<tr><td><%= yield %></td></tr>
|
115
|
+
</table>
|
116
|
+
|
117
|
+
<table class = "footer">
|
118
|
+
<tr>
|
119
|
+
<td>
|
120
|
+
<% url = root_url.gsub(/\A.*:\/\//, '').gsub(/\A(.*?)\/*\z/, '\1') %>
|
121
|
+
|
122
|
+
<% if @subscription.post %>
|
123
|
+
You're receiving this email because you requested to be notified if a new comment was made on <%= link_to "this post", @subscription.post %>
|
124
|
+
at <%= link_to url, posts_url %>.
|
125
|
+
<% else %>
|
126
|
+
You're receiving this email because you requested to be notified if a new post was made at <%= link_to url, posts_url %>.
|
127
|
+
<% end %>
|
128
|
+
If you no longer wish to receive these emails, simply <%= link_to "unsubscribe", unsubscribe_url(@subscription.token) %>.
|
129
|
+
</td>
|
130
|
+
</tr>
|
131
|
+
</table>
|
132
|
+
</body>
|
133
|
+
</html>
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<div id = "comment_<%= comment.id %>" class = "comment">
|
2
|
+
<div class = "comment_body">
|
3
|
+
<%= comment.body %>
|
4
|
+
</div>
|
5
|
+
<p class = "comment_author">By <%= comment.author %></p>
|
6
|
+
|
7
|
+
<%
|
8
|
+
deleteMessage = "Are you sure you want to delete this comment?"
|
9
|
+
unless comment.children.empty?
|
10
|
+
deleteMessage += " Note that this will remove all replies to this "\
|
11
|
+
"comment as well."
|
12
|
+
end
|
13
|
+
|
14
|
+
replyComment = comment.children.build
|
15
|
+
%>
|
16
|
+
|
17
|
+
<%= link_to "Reply", "#", class: "reply",
|
18
|
+
data: {
|
19
|
+
form: "#{render(partial: "proclaim/comments/form", locals: {comment: replyComment, target: target})}",
|
20
|
+
target: target
|
21
|
+
} %>
|
22
|
+
|
23
|
+
<% if policy(comment).destroy? %>
|
24
|
+
<%= link_to "Edit", "#", class: "edit",
|
25
|
+
data: {
|
26
|
+
form: "#{render(partial: "proclaim/comments/form", locals: {comment: comment})}"
|
27
|
+
} %>
|
28
|
+
<% end %>
|
29
|
+
|
30
|
+
<% if policy(comment).destroy? %>
|
31
|
+
<%= link_to "Delete", comment, method: :delete, remote: true, class: "delete", data: { confirm: deleteMessage } %>
|
32
|
+
<% end %>
|
33
|
+
</div>
|
@@ -0,0 +1,51 @@
|
|
1
|
+
<%
|
2
|
+
target ||= nil
|
3
|
+
main ||= false
|
4
|
+
|
5
|
+
formClass = "comment_form"
|
6
|
+
namespace = nil
|
7
|
+
namespace_space = ""
|
8
|
+
|
9
|
+
if comment.parent and comment.new_record?
|
10
|
+
namespace = "reply_to_#{comment.parent.id}"
|
11
|
+
namespace_space = namespace + "_"
|
12
|
+
end
|
13
|
+
|
14
|
+
if main
|
15
|
+
formClass += " main_comment_form"
|
16
|
+
end
|
17
|
+
%>
|
18
|
+
|
19
|
+
<%
|
20
|
+
random_number_1 = rand(4)+1
|
21
|
+
random_number_2 = rand(4)+1
|
22
|
+
%>
|
23
|
+
|
24
|
+
<%= form_for comment, namespace: namespace, remote: true, format: :json, html: {class: formClass}, data: {target: target} do |f| %>
|
25
|
+
<%= f.label :author %><br />
|
26
|
+
<%= f.text_field :author %><br />
|
27
|
+
<%= f.label :body %><br />
|
28
|
+
<%= f.text_area :body %><br />
|
29
|
+
|
30
|
+
|
31
|
+
|
32
|
+
<% if comment.new_record? %>
|
33
|
+
<%= label namespace_space+"antispam", "answer", "Spam bots can't do math. What is #{random_number_1} + #{random_number_2}?" %><br />
|
34
|
+
<%= text_field "antispam", "answer", id: namespace_space+"antispam_answer" %><br />
|
35
|
+
<%= hidden_field "antispam", "solution", value: random_number_1+random_number_2, id: namespace_space+"antispam_solution" %>
|
36
|
+
<% end %>
|
37
|
+
|
38
|
+
<%= label namespace_space+"subscription", "subscribe", "Notify me of other comments on this post" %><br />
|
39
|
+
<%= check_box "subscription", "subscribe", {id: namespace_space+"subscription_subscribe", class: "subscription_subscribe"}, "true", nil %><br />
|
40
|
+
|
41
|
+
<div class = "subscription_email" style = "display: none;">
|
42
|
+
<%= label namespace_space+"subscription", "email"%><br />
|
43
|
+
<%= text_field "subscription", "email", id: namespace_space+"subscription_email" %>
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<%= f.hidden_field :post_id %>
|
47
|
+
<%= f.hidden_field :parent_id %>
|
48
|
+
|
49
|
+
<%= f.submit "Comment" %>
|
50
|
+
<%= f.button "Cancel", class: "cancel_comment" %>
|
51
|
+
<% end %>
|
@@ -0,0 +1,67 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
$(document).ready(function()
|
3
|
+
{
|
4
|
+
<% if @post.new_record? %>
|
5
|
+
new Editor($(document).find("form.new_post"),
|
6
|
+
$(document).find("input#post_title"),
|
7
|
+
$(document).find("form.new_post h1.editable"),
|
8
|
+
$(document).find("input#post_body"),
|
9
|
+
$(document).find("form.new_post div.editable"));
|
10
|
+
<% else %>
|
11
|
+
new Editor($(document).find("form.edit_post"),
|
12
|
+
$(document).find("input#post_title"),
|
13
|
+
$(document).find("form.edit_post h1.editable"),
|
14
|
+
$(document).find("input#post_body"),
|
15
|
+
$(document).find("form.edit_post div.editable"));
|
16
|
+
<% end %>
|
17
|
+
});
|
18
|
+
</script>
|
19
|
+
|
20
|
+
<%= form_for(@post) do |f| %>
|
21
|
+
<% if @post.errors.any? %>
|
22
|
+
<div id="error_explanation">
|
23
|
+
<h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2>
|
24
|
+
|
25
|
+
<ul>
|
26
|
+
<% @post.errors.full_messages.each do |message| %>
|
27
|
+
<li><%= message %></li>
|
28
|
+
<% end %>
|
29
|
+
</ul>
|
30
|
+
</div>
|
31
|
+
<% end %>
|
32
|
+
|
33
|
+
<div class = "post">
|
34
|
+
<h1 class = "post_title editable" data-disable-return="true" data-disable-toolbar="true" data-placeholder="Post Title"><%= @post.title %></h1>
|
35
|
+
|
36
|
+
<div class = "post_body editable" data-placeholder = "Post Body" data-image-upload-path="<%= cache_image_path %>" data-image-delete-path="<%= discard_image_path %>">
|
37
|
+
<%= raw @post.body %>
|
38
|
+
</div>
|
39
|
+
|
40
|
+
<div class = "post_information" style = "margin-bottom: 30px;">
|
41
|
+
<% if @post.published? %>
|
42
|
+
Written <%= timeago_tag @post.published_at, format: "%B %d, %Y" %> by
|
43
|
+
<% elsif @post.new_record? %>
|
44
|
+
Currently being written by
|
45
|
+
<% else %>
|
46
|
+
Draft last updated <%= timeago_tag @post.updated_at, format: "%B %d, %Y" %> by
|
47
|
+
<% end %>
|
48
|
+
<%= @post.author.send(Proclaim.author_name_method) %>
|
49
|
+
</div>
|
50
|
+
|
51
|
+
<%= f.hidden_field :title %>
|
52
|
+
<%= f.hidden_field :body %>
|
53
|
+
|
54
|
+
<% if @post.published? and not @post.new_record? %>
|
55
|
+
This post has already been published
|
56
|
+
<% else %>
|
57
|
+
<div class = "field">
|
58
|
+
<%= label_tag :publish, "Publish this post" %>
|
59
|
+
<%= check_box_tag :publish, "true", @post.published? %>
|
60
|
+
</div>
|
61
|
+
<% end %>
|
62
|
+
|
63
|
+
<div class="actions" style = "margin-top: 30px;">
|
64
|
+
<%= f.submit %>
|
65
|
+
</div>
|
66
|
+
</div>
|
67
|
+
<% end %>
|