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,30 @@
|
|
1
|
+
<% if policy(Proclaim::Post).new? %>
|
2
|
+
<%= link_to 'New Post', new_post_path %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% if @posts.empty? %>
|
6
|
+
<p>No posts have been made, yet.</p>
|
7
|
+
<% else %>
|
8
|
+
<% @posts.each do |post| %>
|
9
|
+
<h1><%= link_to post.title, post %></h1>
|
10
|
+
<div id = "post_<%= post.id %>">
|
11
|
+
<% excerpt = post.excerpt %>
|
12
|
+
<span class = "excerpt"><%= excerpt %></span>
|
13
|
+
|
14
|
+
<% if excerpt.length < post.body.length %>
|
15
|
+
. . . <%= link_to "(more)", post %>
|
16
|
+
<% end %>
|
17
|
+
</div>
|
18
|
+
<div class = "post_excerpt_information">
|
19
|
+
<div style = "float: right;">
|
20
|
+
<% if policy(post).edit? %>
|
21
|
+
<%= link_to 'Edit', edit_post_path(post) %>
|
22
|
+
<% end %>
|
23
|
+
<% if policy(post).destroy? %>
|
24
|
+
<%= link_to 'Delete', post, method: :delete, data: { confirm: 'Are you sure?' } %>
|
25
|
+
<% end %>
|
26
|
+
</div>
|
27
|
+
<%= post.author.send(Proclaim.author_name_method) %>
|
28
|
+
</div>
|
29
|
+
<% end %>
|
30
|
+
<% end %>
|
@@ -0,0 +1,46 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
$(document).ready(function()
|
3
|
+
{
|
4
|
+
new CommentsHandler('div.discussion',
|
5
|
+
'div.comment',
|
6
|
+
'form.comment_form',
|
7
|
+
'form.main_comment_form',
|
8
|
+
'button.cancel_comment',
|
9
|
+
'a.reply',
|
10
|
+
'a.edit',
|
11
|
+
'a.delete',
|
12
|
+
'input.subscription_subscribe',
|
13
|
+
'div.subscription_email')
|
14
|
+
});
|
15
|
+
</script>
|
16
|
+
|
17
|
+
<div class = "post">
|
18
|
+
<h1 class = "post_title"><%= @post.title %></h1>
|
19
|
+
|
20
|
+
<div class = "post_body show">
|
21
|
+
<%= raw @post.body %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class = "post_information">
|
25
|
+
<% if @post.published? %>
|
26
|
+
Written <%= timeago_tag @post.published_at, format: "%B %d, %Y" %> by
|
27
|
+
<% else %>
|
28
|
+
Draft last updated <%= timeago_tag @post.updated_at, format: "%B %d, %Y" %> by
|
29
|
+
<% end %>
|
30
|
+
<%= @post.author.send(Proclaim.author_name_method) %>
|
31
|
+
</div>
|
32
|
+
|
33
|
+
<h2>Comments</h2>
|
34
|
+
|
35
|
+
<div id="comments">
|
36
|
+
<%= comments_tree_for @post.comments.hash_tree %>
|
37
|
+
</div>
|
38
|
+
|
39
|
+
<% commentTemplate = @post.comments.build %>
|
40
|
+
<%= render partial: "proclaim/comments/form",
|
41
|
+
locals: {
|
42
|
+
comment: commentTemplate,
|
43
|
+
target: "#comments",
|
44
|
+
main: true
|
45
|
+
} %>
|
46
|
+
</div>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<table class = "post">
|
2
|
+
<tr>
|
3
|
+
<td class = "post_body"><%= @comment.body %></td>
|
4
|
+
</tr>
|
5
|
+
|
6
|
+
<tr>
|
7
|
+
<td class = "post_information">
|
8
|
+
Written on <%= @comment.created_at.strftime("%B %d, %Y at %I:%M %p %Z") %> by <%= @comment.author %>
|
9
|
+
</td>
|
10
|
+
</tr>
|
11
|
+
</div>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<table class = "post">
|
2
|
+
<tr>
|
3
|
+
<td class = "post_title"><h1><%= @post.title %></h1></td>
|
4
|
+
</tr>
|
5
|
+
|
6
|
+
<tr>
|
7
|
+
<td class = "post_body"><%= raw @post.body %></td>
|
8
|
+
</tr>
|
9
|
+
|
10
|
+
<tr>
|
11
|
+
<td class = "post_information">
|
12
|
+
Written on <%= @post.published_at.strftime("%B %d, %Y at %I:%M %p %Z") %> by <%= @post.author.send(Proclaim.author_name_method) %>
|
13
|
+
</td>
|
14
|
+
</tr>
|
15
|
+
</div>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<table class = "post">
|
2
|
+
<tr>
|
3
|
+
<td class = "post_title"><h1>
|
4
|
+
<% if @subscription.post %>
|
5
|
+
You'll be notified!
|
6
|
+
<% else %>
|
7
|
+
Thanks for subscribing!
|
8
|
+
<% end %>
|
9
|
+
</h1></td>
|
10
|
+
</tr>
|
11
|
+
|
12
|
+
<tr>
|
13
|
+
<td class = "post_body">
|
14
|
+
<% if @subscription.post %>
|
15
|
+
<p>
|
16
|
+
You signed up to be notified of any new comments on <%= link_to "this post", @subscription.post %>.
|
17
|
+
</p>
|
18
|
+
<% else %>
|
19
|
+
<p>
|
20
|
+
You'll now begin receiving a notification each time a new post is made at <%= link_to root_url.gsub(/\A.*:\/\//, '').gsub(/\A(.*?)\/*\z/, '\1'), posts_url %>.
|
21
|
+
</p>
|
22
|
+
<% end %>
|
23
|
+
</td>
|
24
|
+
</tr>
|
25
|
+
</div>
|
@@ -0,0 +1,32 @@
|
|
1
|
+
<%= form_for(@subscription) do |f| %>
|
2
|
+
<% if @subscription.errors.any? %>
|
3
|
+
<div id="error_explanation">
|
4
|
+
<h2><%= pluralize(@subscription.errors.count, "error") %> prohibited this subscription from being saved:</h2>
|
5
|
+
|
6
|
+
<ul>
|
7
|
+
<% @subscription.errors.full_messages.each do |message| %>
|
8
|
+
<li><%= message %></li>
|
9
|
+
<% end %>
|
10
|
+
</ul>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<div class="field">
|
15
|
+
<%= f.label :email %><br>
|
16
|
+
<%= f.text_field :email %>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<%
|
20
|
+
random_number_1 = rand(4)+1
|
21
|
+
random_number_2 = rand(4)+1
|
22
|
+
%>
|
23
|
+
<div class="field">
|
24
|
+
<%= label "antispam", "answer", "Spam bots can't do math. What is #{random_number_1} + #{random_number_2}?" %><br />
|
25
|
+
<%= text_field "antispam", "answer" %><br />
|
26
|
+
<%= hidden_field "antispam", "solution", value: random_number_1+random_number_2 %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<div class="actions">
|
30
|
+
<%= f.submit "Subscribe" %>
|
31
|
+
</div>
|
32
|
+
<% end %>
|
@@ -0,0 +1,7 @@
|
|
1
|
+
<p>
|
2
|
+
Are you sure you'd like to unsubscribe from this notification item? Note that
|
3
|
+
if you've subscribed elsewhere (e.g. other comments), you'll still receive
|
4
|
+
notifications for them unless you unsubscribe from them as well.
|
5
|
+
</p>
|
6
|
+
|
7
|
+
<%= link_to "Yes, unsubscribe", unsubscribe_path(@subscription.token), method: :delete %>
|
data/config/routes.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
Proclaim::Engine.routes.draw do
|
2
|
+
resources :posts
|
3
|
+
|
4
|
+
resources :images, only: [:create, :destroy]
|
5
|
+
post 'images/cache' => 'images#cache', as: :cache_image
|
6
|
+
post 'images/discard' => 'images#discard', as: :discard_image
|
7
|
+
|
8
|
+
resources :comments, only: [:create, :update, :destroy]
|
9
|
+
|
10
|
+
resources :subscriptions, only: [:new, :create]
|
11
|
+
|
12
|
+
get 'subscriptions/subscribed' => 'subscriptions#subscribed', as: :subscribed
|
13
|
+
get 'subscriptions/unsubscribe' => 'subscriptions#unsubscribed', as: :unsubscribed
|
14
|
+
get 'subscriptions/unsubscribe/:token' => 'subscriptions#unsubscribe', as: :unsubscribe
|
15
|
+
delete 'subscriptions/unsubscribe/:token' => 'subscriptions#destroy'
|
16
|
+
|
17
|
+
root 'posts#index'
|
18
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateProclaimPosts < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :proclaim_posts do |t|
|
4
|
+
t.belongs_to :author, index: true
|
5
|
+
|
6
|
+
t.string :title, null: false, default: ""
|
7
|
+
t.text :body, null: false, default: ""
|
8
|
+
|
9
|
+
t.string :state, null: false, default: "draft", index: true
|
10
|
+
|
11
|
+
t.datetime :published_at
|
12
|
+
t.timestamps null: false
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
class CreateProclaimComments < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :proclaim_comments do |t|
|
4
|
+
t.belongs_to :post, index: true
|
5
|
+
t.integer :parent_id
|
6
|
+
|
7
|
+
t.string :author
|
8
|
+
t.text :body
|
9
|
+
|
10
|
+
t.timestamps null: false
|
11
|
+
end
|
12
|
+
|
13
|
+
add_foreign_key :proclaim_comments, :posts
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
class CreateProclaimCommentHierarchies < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :proclaim_comment_hierarchies, :id => false do |t|
|
4
|
+
# ID of the parent/grandparent/great-grandparent/etc. comments
|
5
|
+
t.integer :ancestor_id, null: false
|
6
|
+
|
7
|
+
# ID of the target comment
|
8
|
+
t.integer :descendant_id, null: false
|
9
|
+
|
10
|
+
# Number of generations between the ancestor and the descendant.
|
11
|
+
# Parent/child = 1, for example.
|
12
|
+
t.integer :generations, null: false
|
13
|
+
end
|
14
|
+
|
15
|
+
# For "all progeny of…" and leaf selects:
|
16
|
+
add_index :proclaim_comment_hierarchies,
|
17
|
+
[:ancestor_id, :descendant_id, :generations],
|
18
|
+
:unique => true,
|
19
|
+
:name => "comment_anc_desc_udx"
|
20
|
+
|
21
|
+
# For "all ancestors of…" selects,
|
22
|
+
add_index :proclaim_comment_hierarchies,
|
23
|
+
[:descendant_id],
|
24
|
+
:name => "comment_desc_idx"
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
class CreateProclaimSubscriptions < ActiveRecord::Migration
|
2
|
+
def change
|
3
|
+
create_table :proclaim_subscriptions do |t|
|
4
|
+
t.belongs_to :post, index: true
|
5
|
+
t.string :email
|
6
|
+
|
7
|
+
t.timestamps null: false
|
8
|
+
end
|
9
|
+
|
10
|
+
add_foreign_key :proclaim_subscriptions, :posts
|
11
|
+
|
12
|
+
# This ensures that even if two clients try to create the same
|
13
|
+
# subscription at exactly the same time, the database won't accept
|
14
|
+
# one of them (Rails would have)
|
15
|
+
add_index :proclaim_subscriptions, [:post_id, :email], :unique => true
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Proclaim
|
4
|
+
module Generators
|
5
|
+
class InstallGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../templates", __FILE__)
|
7
|
+
|
8
|
+
desc "Creates a Proclaim initializer and mounts Proclaim in routes."
|
9
|
+
|
10
|
+
def install_initializers
|
11
|
+
template "initialize_proclaim.rb", "config/initializers/proclaim.rb"
|
12
|
+
end
|
13
|
+
|
14
|
+
def mount_in_routes
|
15
|
+
route "mount Proclaim::Engine, at: \"/blog\""
|
16
|
+
end
|
17
|
+
|
18
|
+
def show_readme
|
19
|
+
readme "README" if behavior == :invoke
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
===============================================================================
|
2
|
+
|
3
|
+
Some setup you must do manually if you haven't yet:
|
4
|
+
|
5
|
+
1. Ensure that the mailer has default URL options in each environment. Here is
|
6
|
+
a possible configuration for `config/environments/development.rb`:
|
7
|
+
|
8
|
+
config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
|
9
|
+
|
10
|
+
In production, :host should be set to the actual host of your application.
|
11
|
+
|
12
|
+
2. Ensure you have defined root_url to *something* in your config/routes.rb.
|
13
|
+
For example:
|
14
|
+
|
15
|
+
root to: "home#index"
|
16
|
+
|
17
|
+
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
|
18
|
+
For example:
|
19
|
+
|
20
|
+
<p class="notice"><%= notice %></p>
|
21
|
+
<p class="alert"><%= alert %></p>
|
22
|
+
|
23
|
+
4. You can copy Proclaim views (for customization) to your app by running:
|
24
|
+
|
25
|
+
rails g proclaim:views
|
26
|
+
|
27
|
+
===============================================================================
|
@@ -0,0 +1,22 @@
|
|
1
|
+
Proclaim.setup do |config|
|
2
|
+
# The class to which posts belong. Changing this also changes the
|
3
|
+
# `current_author_method` and `authentication_method`. For example, setting
|
4
|
+
# `author_class = "Admin"` changes the default `current_author_method` to be
|
5
|
+
# `:current_admin`, etc.
|
6
|
+
#author_class = "User"
|
7
|
+
|
8
|
+
# Method to obtain the name of the author. This should be a method on the
|
9
|
+
# author class.
|
10
|
+
#author_name_method = :name
|
11
|
+
|
12
|
+
# Method to obtain the currently-authenticated user. Should return nil if
|
13
|
+
# no user is currently authenticated.
|
14
|
+
#current_author_method = :current_user
|
15
|
+
|
16
|
+
# Method to verify that a user is authenticated, and if not, will redirect
|
17
|
+
# to some sort of authentication page.
|
18
|
+
#authentication_method = :authenticate_user!
|
19
|
+
|
20
|
+
# Maximum length for the excerpts shown on the posts index.
|
21
|
+
#excerpt_length = 500
|
22
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require 'rails/generators/base'
|
2
|
+
|
3
|
+
module Proclaim
|
4
|
+
module Generators
|
5
|
+
class ViewsGenerator < Rails::Generators::Base
|
6
|
+
source_root File.expand_path("../../../../app/views/proclaim", __FILE__)
|
7
|
+
|
8
|
+
desc "Copy all Proclaim views into application"
|
9
|
+
|
10
|
+
def copy_views
|
11
|
+
if options[:views]
|
12
|
+
options[:views].each do |directory|
|
13
|
+
directory directory.to_sym, "app/views/proclaim/#{directory}"
|
14
|
+
end
|
15
|
+
else
|
16
|
+
directory :comments, "app/views/proclaim/comments"
|
17
|
+
directory :posts, "app/views/proclaim/posts"
|
18
|
+
directory :subscription_mailer, "app/views/proclaim/subscription_mailer"
|
19
|
+
directory :subscriptions, "app/views/proclaim/subscriptions"
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
data/lib/proclaim.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require "proclaim/engine"
|
2
|
+
|
3
|
+
module Proclaim
|
4
|
+
mattr_accessor :author_class
|
5
|
+
@@author_class = "User"
|
6
|
+
|
7
|
+
mattr_accessor :current_author_method
|
8
|
+
@@current_author_method = "current_#{@@author_class.underscore}".to_sym
|
9
|
+
|
10
|
+
mattr_accessor :author_name_method
|
11
|
+
@@author_name_method = :name
|
12
|
+
|
13
|
+
mattr_accessor :authentication_method
|
14
|
+
@@authentication_method = "authenticate_#{@@author_class.underscore}!".to_sym
|
15
|
+
|
16
|
+
mattr_accessor :excerpt_length
|
17
|
+
@@excerpt_length = 500 # 500 characters (won't interrupt words)
|
18
|
+
|
19
|
+
def self.setup
|
20
|
+
yield self
|
21
|
+
end
|
22
|
+
end
|