Skip to content

Latest commit

 

History

27 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

plug_ribbon

This Plug module injects a ribbon to your web application.

Used to differentiate between environments.

Based on stnly/plug_ribbon, this version is safe to use in exrm & distillery releases.

Setup

To use plug_ribbon in your projects, edit your mix.exs file and add plug_ribbon as a dependency:

defp deps do
  [
    {:plug_ribbon, github: "MikeAlbertFleetSolutions/plug_ribbon"}
  ]
end

Usage

This plug should be one of the last ones in your pipeline.

Add the plug for the specific environments that you want the ribbon to be shown, include the text to be shown.

defmodule MyPhoenixApp.Router do
  use MyPhoenixApp.Web, :router

  pipeline :browser do
    plug :accepts, ["html"]
    plug :fetch_session
    plug :fetch_flash
    plug :protect_from_forgery
    unless Mix.env == :prod do
      plug Plug.Ribbon, "Not Prod"
    end
  end

  pipeline :api do
    plug :accepts, ["json"]
  end

  scope "/", MyPhoenixApp do
    pipe_through :browser # Use the default browser stack

    get "/", 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 the specified label.

Testing

mix test

Build notes:

To create docker image:

docker build --pull --tag plug_ribbon -f Dockerfile .

To create docker container from image during development:

docker run -it --rm -v ${WORKSPACE}/plug_ribbon:/app -w /app plug_ribbon

Before checking-in

mix format && mix credo && mix minify && mix test

About

Injects a ribbon into your web application to differentiate between environments

Resources

Stars

0 stars

Watchers

4 watching

Forks

Releases

Packages

Contributors

Languages