MIT License

项目介绍

fgrehm/letter_opener_web 是一个托管在 GitHub 上的开源项目,主要使用 HTML 编写,采用 MIT License 许可证,目前获得 814 个 Star、129 次 Fork。

仓库全名
fgrehm/letter_opener_web
开源许可证
MIT License
Star 数
814
Fork 数
129
未关闭 Issue
16

README 摘要

letteropenerweb Gives letteropener an interface for browsing sent emails. Installation First add the gem to your development environment and run the bundle command to install it. Usage Add to your routes.rb: And make sure you have :letteropener delivery method configured for your app. Then visit http://localhost:3000/letteropener after sending an email and have fun. If you are running the app from a Vagrant machine…

完整内容见 GitHub 原始 README 或本页 。

常见问题

letter_opener_web 用什么语言开发?

主要使用 HTML 编写,采用 MIT License 许可证,目前有 814 个 Star。

letter_opener_web 可以免费商用吗?

仓库采用 MIT License 许可证,可免费使用与修改,商业使用请遵守许可证条款(例如保留版权声明与许可声明)。

如何获取 letter_opener_web 的源码?

可以直接克隆仓库:git clone https://github.com/fgrehm/letter_opener_web.git,默认分支为 master;安装与运行步骤见仓库 README。

letter_opener_web 最近还在维护吗?

仓库最近一次更新为 4月8日,当前有 16 个未关闭 Issue;Star 数为 814,可作为社区活跃度的参考。

关于

A web interface for browsing Ruby on Rails sent emails

描述取自 GitHub 官方 API,中文内容由 GitRead 中文社区 编辑团队整理。

简要分析

热度分
1078
价值分
526
活跃状态
活跃

语言占比

CSS
HTML
JavaScript
Ruby
Shell

Release

README

letter_opener_web

Build Status Gem Version Code Climate

Gives letter_opener an interface for browsing sent emails.

Installation

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

group :development do
  gem 'letter_opener_web', '~> 3.0'
end

Usage

Add to your routes.rb:

Your::Application.routes.draw do
  mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.development?
end

And make sure you have :letter_opener delivery method configured for your app. Then visit http://localhost:3000/letter_opener after sending an email and have fun.

If you are running the app from a Vagrant machine or Docker container, you might want to skip letter_opener’s launchy calls and avoid messages like these:

12:33:42 web.1  | Failure in opening /vagrant/tmp/letter_opener/1358825621_ba83a22/rich.html
with options {}: Unable to find a browser command. If this is unexpected, Please rerun with
environment variable LAUNCHY_DEBUG=true or the '-d' commandline option and file a bug at
https://github.com/copiousfreetime/launchy/issues/new

In that case (or if you really just want to browse mails using the web interface and don’t care about opening emails automatically), you can set :letter_opener_web as your delivery method on your config/environments/development.rb:

config.action_mailer.delivery_method = :letter_opener_web

Configuration

letters_location

If you’re using :letter_opener_web as your delivery method, you can change the location of the letters by adding the following to an initializer (or in development.rb):

LetterOpenerWeb.configure do |config|
  config.letters_location = Rails.root.join('your', 'new', 'path')
end

auto_dark_mode

You can control whether LetterOpenerWeb applies an automatic dark mode color inversion strategy when previewing emails.

By default, this is disabled to avoid conflicts with email templates that already implement their own prefers-color-scheme styling.

LetterOpenerWeb.configure do |config|
  config.auto_dark_mode = true
end

When enabled, LetterOpenerWeb applies a CSS-based inversion strategy to approximate dark mode for templates that do not define their own styles, similar to high-contrast or browser-level color inversion.

Usage on pre-production environments

Some people use this gem on staging / pre-production environments to avoid having real emails being sent out. To set that up you’ll need to:

  1. Move the gem out of the development group in your Gemfile
  2. Set config.action_mailer.delivery_method on the appropriate config/environments/<env>.rb
  3. Enable the route for the environments on your routes.rb.

In other words, your Gemfile will have:

gem 'letter_opener_web'

And your routes.rb:

Your::Application.routes.draw do
  # If you have a dedicated config/environments/staging.rb
  mount LetterOpenerWeb::Engine, at: "/letter_opener" if Rails.env.staging?

  # If you use RAILS_ENV=production in staging environments, you'll need another
  # way to disable it in "real production"
  mount LetterOpenerWeb::Engine, at: "/letter_opener" unless ENV["PRODUCTION_FOR_REAL"]
end

NOTICE: Using this gem on Heroku will only work if your app has just one Dyno and does not send emails from background jobs. For updates on this matter please subscribe to GH-35

Acknowledgements

Special thanks to @alexrothenberg for some ideas on this pull request and @pseudomuto for keeping the project alive for a few years.

Contributing

  1. Fork it and run bin/setup
  2. Create your feature branch (git switch -c my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

评论

暂无评论