Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/stnly/plug_ribbon
:ribbon: Injects a ribbon into your web application depending on the environment
https://github.com/stnly/plug_ribbon
Last synced: 3 months ago
JSON representation
:ribbon: Injects a ribbon into your web application depending on the environment
- Host: GitHub
- URL: https://github.com/stnly/plug_ribbon
- Owner: stnly
- License: mit
- Created: 2015-06-24T03:26:04.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-13T07:18:31.000Z (over 9 years ago)
- Last Synced: 2024-09-16T17:51:41.298Z (4 months ago)
- Language: Elixir
- Homepage: https://git.io/plug_ribbon
- Size: 735 KB
- Stars: 23
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- freaking_awesome_elixir - Elixir - Injects a ribbon to your web application in the development environment. (Framework Components)
- fucking-awesome-elixir - plug_ribbon - Injects a ribbon to your web application in the development environment. (Framework Components)
- awesome-elixir - plug_ribbon - Injects a ribbon to your web application in the development environment. (Framework Components)
README
# plug_ribbon
[![Build Status](https://travis-ci.org/stnly/plug_ribbon.svg?branch=master)](https://travis-ci.org/stnly/plug_ribbon)
[![Hex Version](https://img.shields.io/hexpm/v/plug_ribbon.svg)](https://hex.pm/packages/plug_ribbon)
[![License](https://img.shields.io/badge/license-MIT-blue.svg)](LICENSE)This [Plug](https://github.com/elixir-lang/plug) module injects a ribbon to your web application in the configured environment.
Used to differentiate between environments.
![](priv/static/screenshot.png)
## Motivation
Inspired by [rack-dev-mark](https://github.com/dtaniwaki/rack-dev-mark)
## Setup
To use plug_ribbon in your projects, edit your `mix.exs` file and add plug_ribbon as a dependency:
```elixir
defp deps do
[
{:plug_ribbon, "~> 0.2.0"}
]
end
```## Usage
This plug should be one of the last ones in your pipeline.
Add the plug and specify a list of environment atoms that you want the ribbon to be shown.
```elixir
defmodule MyPhoenixApp.Router do
use MyPhoenixApp.Web, :routerpipeline :browser do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :protect_from_forgery
plug Plug.Ribbon, [:dev, :staging, :test]
endpipeline :api do
plug :accepts, ["json"]
endscope "/", MyPhoenixApp do
pipe_through :browser # Use the default browser stackget "/", PageController, :index
end# Other scopes may use custom stacks.
# scope "/api", Observes do
# pipe_through :api
# end
end
```After you are done, run `mix deps.get` in your shell to fetch the dependencies.
The ribbon will display a label with your current environment in capital letters.
`Mix.env |> Atom.to_string |> String.upcase`## Testing
```bash
$ mix test
```## License
See the [LICENSE](LICENSE) file for more information.