Code Monkey home page Code Monkey logo

better-opener's Introduction

BetterOpener

Preview mails and other notifications in your browser instead of actually sending them out. Inspired by and similar in terms of functionality to the LetterOpener and the MailView gem BetterOpener tries to be better by:

  • providing support for outgoing notifications in general (email, sms so far)
  • supporting pre- and on-demand rendering
  • allowing remote access to notifications (helpful on staging servers and remote development machines)
  • displaying desktop notifications (with the accompanying chrome plugin)

Setup

Add the gem to your development environment and run the bundle install command to install it.

gem "better_opener", :group => :development

Then in Rails3 mount the bundled Sinatra app inline in your routes.rb:

if Rails.env == "development"
  mount BetterOpener::Server => "/notifications"
end

To prevent messages from actually being sent you need to set up email and/or sms interception.

Email

Set the delivery method in config/environments/development.rb

config.action_mailer.delivery_method = :better_opener

The design of the email interface is taken from the mail_view plugin.

SMS

SMS message support is provided for the sms_gateway gem. Edit your sms_gateway.yml file:

development:
  adapter: better_opener
  from: your_app

SMS interface:

SMS as displayed by the sinatra app

On-request Rendering

The messages that are being sent with one of the above delivery methods are static (pre-rendered at time of delivery). To preview your changes without going through all the steps to redeliver the message use the add_delayed_notification method like that:

class Emailer < ActionMailer::Base

 # ....

  def self.deliver_later(method, *params)
    if Rails.env == "development"
      BetterOpener.add_delayed_notification("email", Emailer, method, params)
    else
      Resque.enqueue(EmailJob, method, *params)
    end
  end

end

Chrome Plugin

To get actual desktop notifications, you will want to install the accompanying chrome-plugin. Point it to the (full) notification path that you mounted this gem on.

Chrome Notifications

better-opener's People

Contributors

learnjin avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.