README.md in paul_revere-1.4 vs README.md in paul_revere-2.0.0

- old
+ new

@@ -1,85 +1,83 @@ -Paul Revere -=========== +# Paul Revere [![Build Status](https://travis-ci.org/thoughtbot/paul_revere.svg?branch=master)](https://travis-ci.org/thoughtbot/paul_revere) -Simple announcement plugin to include "one off" style announcements in Rails web apps. +This gem enables the inclusion of "one off" announcements in Rails applications. -[![Paul Revere's -Ride](http://f.cl.ly/items/2u260D0Y2j2T3O3o4017/Screen%20Shot%202013-01-23%20at%2010.46.06%20AM.png)](http://poetry.eserver.org/paul-revere.html) +## Installation -Install with the asset pipeline (Rails 3.1+, asset pipeline enabled) --------------------------------------------------------------------- +First, include the gem as normal in your Gemfile: -Install as normal in your Gemfile: + gem "paul_revere" - gem 'paul_revere' +Then, run the generator to create the migration and copy the javascript. -Run the generator to create the migration: - rails generate paul_revere -Add the announcement JS to `app/assets/javascripts/application.js`: +The announcements JS will be installed into vendor/assets/javascripts. +You can add the announcement JS to `app/assets/javascripts/application.js`: //= require announcements -Run the migration: +This will include the javascript into the `application.js` for the entire site. - rake db:migrate && rake db:migrate:redo +Finally, create the announcements table by running the migration: -Install without the asset pipeline (Rails 3.0 or asset pipeline disabled) ---------------------------------------------------------------------------- + rake db:migrate -Install as normal in your Gemfile: +## Background - gem 'paul_revere' +Paul Revere provides... -Run the generator to create the migration and copy the JavaScript file into public: +* A model called `Announcement`, which has timestamps and a "body" text column. +* A `current` class method on `Announcement` which returns the latest + `Announcement`, or a new unsaved instance. +* A view helper called `#current_announcement`, which will return that latest + `Announcement` record. +* A view partial called `_public_announcement`, which is intended to be shown to + all site users. +* A view partial called `_private_announcement`, which is intended to be shown + only to logged in users. Note that this merely wraps the rendering of the + public announcement with a call to a helper which checks that a user is signed + in. There is only one type of Announcement. +* A view partial called `_email_announcement`, which is intended to be used in + site emails which are sent out and need to include announcements. - rails generate paul_revere +## Usage -Add the announcement JS to your layout, such as `app/views/layouts/application.html.erb`: +* Install the gem, run the migration, ensure the javascript can be accessed. +* Use those partials in the correct places in your view code and mailer view + code where you want announcements to show up. - <%= javascript_include_tag 'announcements' %> +For example, to include the latest announcement for all site users: -Run the migration: +``` +<%= render "announcements/public_announcement" %> +``` - rake db:migrate && rake db:migrate:redo +To make an announcement, use the Rails console to create a new record: -Usage ------ +``` +Announcement.create!(body: "Free ice cream on Monday!") +``` -Paul Revere provides... +There is a helper method called `announcement_visibility_allowed?`, which is +what the `private_announcement` partial calls to determine whether to allow the +current session to view announcements. The built-in implementation just checks +that `current_user` is truth-y. Override that helper method if you want to do +something more interesting as a check here. -* A model called `Announcement`, which has nothing more than timestamps and a "body" column (text column). We view the most recent `Announcement` as the "current" announcement, and will select that to show on the site. -* A helper called `#current_announcement`, which will return that latest `Announcement` record. -* A view partial called `_announcement_for_all`, which is intended to be shown to all site users. -* A view partial called `_announcement`, which is intended to be shown only to logged in users. -* A view partial called `_email_announcement`, which is intended to be used in site emails which are sent out. +## Credits -So the flow would be... - -* Install the gem -* Use those partials in the correct places in your view code and mailer view code where you want announcements to show up: - - <%= render 'announcements/announcement_for_all' %> - -* When you want to make an announcement, use the Rails console to create a new `Announcement` record: - - Announcement.create!(body: 'This Web site is shutting down because you refuse to pay') - -Credits -------- - ![thoughtbot](http://thoughtbot.com/images/tm/logo.png) Paul Revere is maintained and funded by [thoughtbot, inc](http://thoughtbot.com/community) Thank you to all [the contributors](https://github.com/thoughtbot/paul_revere/contributors)! The names and logos for thoughtbot are trademarks of thoughtbot, inc. -License -------- +## License -Paul Revere is Copyright © 2009-2014 thoughtbot. It is free software, and may be redistributed under the terms specified in the MIT-LICENSE file. +Paul Revere is Copyright © 2009 thoughtbot, inc. It is free software, and may be +redistributed under the terms specified in the MIT-LICENSE file.