
Security News
Follow-up and Clarification on Recent Malicious Ruby Gems Campaign
A clarification on our recent research investigating 60 malicious Ruby gems.
A simple, configurable toast notification system for Rails applications. FawToast provides an easy way to display flash messages as toast notifications with minimal setup.
Add this line to your application's Gemfile:
gem 'faw_toast'
And then execute:
bundle install
Or install it yourself as:
gem install faw_toast
After installing the gem, run the installation generator:
rails generate faw_toast:install
This will:
config/initializers/faw_toast.rb
application.html.erb
<%= stylesheet_link_tag "faw_toast", "data-turbo-track": "reload" %>
<%= javascript_include_tag "faw_toast", "data-turbo-track": "reload", type: "module" %>
If you are using sprockets
you may need to add the following lines to your app/config/manifest.js
//= link faw_toast.js
//= link faw_toast.css
FawToast works with Rails flash messages. You can use it like this
# In your controller
def create
# Your logic here
flash[:success] = "Item was successfully created!"
redirect_to items_path
end
# using Turbo Streams
flash.now[flash_type] = message
render turbo_stream: turbo_stream.append("faw-toast-container", partial: "faw_toast/toast"), status: status
# In your background job or service object
flash = {}
flash[type] = message
Turbo::StreamsChannel.broadcast_append_to(
channel,
target: "faw-toast-container",
partial: "faw_toast/toast",
locals: { flash: flash }
)
For Turbo Streams applications, you can use the built-in render_message
helper:
# In your controller
def create
# Your logic here
render_message(:success, :ok, "Item was successfully created!")
end
The render_message
method takes three parameters:
flash_type
: The type of flash message (:success, :alert, :danger, etc.)status
: The HTTP status code to return (:ok, :created, etc.)message
: The message to display in the toastThis helper automatically:
FawToast supports the following flash types out of the box:
:success
- Green border:alert
- Red border:danger
- Red border (same as alert, but provides semantic difference):info
- Sky blue border:notice
- Sky blue borderYou can configure FawToast by editing the initializer at config/initializers/faw_toast.rb
:
FawToast.configure do |config|
# Duration in seconds for which the toast will be displayed
config.duration_seconds = '7s'
# Background color of the progress bar. It can be any valid CSS color value
config.progress_bar_bg = "rgba(0, 0, 0, 0.2)"
# Position of the toast container
# Available options: 'top-right', 'top-left', 'bottom-right', 'bottom-left', 'top-center', 'bottom-center'
config.position = 'top-right'
# CSS classes for different flash types
config.css_classes = {
success: 'faw-toast-border-green',
alert: 'faw-toast-border-red',
danger: 'faw-toast-border-red',
info: 'faw-toast-border-sky',
notice: 'faw-toast-border-sky',
default: 'faw-toast-border-indigo'
}
end
FawToast uses CSS animations to show and hide toast notifications automatically. Each toast includes:
The toast appears with a slide-in animation, stays visible for the configured duration, and then slides out automatically.
The border position and animation direction are automatically determined based on the toast position:
For top-right and bottom-right positions:
For top-left and bottom-left positions:
For top-center position:
For bottom-center position:
After checking out the repo, run bin/setup
to install dependencies. Then, run rake spec
to run the tests. You can also run bin/console
for an interactive prompt that will allow you to experiment.
Bug reports and pull requests are welcome on GitHub at https://github.com/example/faw_toast.
The gem is available as open source under the terms of the MIT License.
FAQs
Unknown package
We found that faw_toast demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
A clarification on our recent research investigating 60 malicious Ruby gems.
Security News
ESLint now supports parallel linting with a new --concurrency flag, delivering major speed gains and closing a 10-year-old feature request.
Research
/Security News
A malicious Go module posing as an SSH brute forcer exfiltrates stolen credentials to a Telegram bot controlled by a Russian-speaking threat actor.