Skip to content

Commit

Permalink
Change name to SlackQuiet
Browse files Browse the repository at this point in the history
  • Loading branch information
dbstratta committed Jan 31, 2018
1 parent f3aaa64 commit e244eb2
Show file tree
Hide file tree
Showing 29 changed files with 168 additions and 148 deletions.
9 changes: 3 additions & 6 deletions .credo.exs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# You can give explicit globs or simply directories.
# In the latter case `**/*.{ex,exs}` will be used.
#
#
included: ["lib/", "src/", "web/", "apps/"],
excluded: [~r"/_build/", ~r"/deps/"]
},
Expand Down Expand Up @@ -74,7 +74,6 @@
#
{Credo.Check.Design.TagTODO, exit_status: 0},
{Credo.Check.Design.TagFIXME, exit_status: 0},

{Credo.Check.Readability.FunctionNames},
{Credo.Check.Readability.LargeNumbers},
{Credo.Check.Readability.MaxLineLength, priority: :low, max_length: 80},
Expand All @@ -92,7 +91,6 @@
{Credo.Check.Readability.VariableNames},
{Credo.Check.Readability.Semicolons},
{Credo.Check.Readability.SpaceAfterCommas},

{Credo.Check.Refactor.DoubleBooleanNegation},
{Credo.Check.Refactor.CondStatements},
{Credo.Check.Refactor.CyclomaticComplexity},
Expand All @@ -104,7 +102,6 @@
{Credo.Check.Refactor.Nesting},
{Credo.Check.Refactor.PipeChainStart},
{Credo.Check.Refactor.UnlessWithElse},

{Credo.Check.Warning.BoolOperationOnSameValues},
{Credo.Check.Warning.ExpensiveEmptyEnumCheck},
{Credo.Check.Warning.IExPry},
Expand Down Expand Up @@ -136,11 +133,11 @@
{Credo.Check.Warning.NameRedeclarationByAssignment, false},
{Credo.Check.Warning.NameRedeclarationByCase, false},
{Credo.Check.Warning.NameRedeclarationByDef, false},
{Credo.Check.Warning.NameRedeclarationByFn, false},
{Credo.Check.Warning.NameRedeclarationByFn, false}

# Custom checks can be created using `mix credo.gen.check`.
#
]
}
]
}
}
2 changes: 1 addition & 1 deletion .iex.exs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import SlackSilence.LastUsageRegistry
import SlackQuiet.LastUsageRegistry
10 changes: 6 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@ services:
- docker

script:
- docker build -t slack_silence_test -f dev.dockerfile .
- docker run --rm slack_silence_test mix test
- docker build -t slack_quiet_test -f dev.dockerfile .
- docker run --rm slack_quiet_test mix test
- docker run --rm slack_quiet_test mix format --check-formatted
- docker run --rm slack_quiet_test mix credo

after_success:
- if [ "$TRAVIS_BRANCH" == "master" ]; then
docker build -t sophilabs/slack-silence:latest .;
docker build -t sophilabs/slack-quiet:latest .;
echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin;
docker push sophilabs/slack-silence:latest;
docker push sophilabs/slack-quiet:latest;
fi
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM elixir:1.6.1

LABEL name="slack_silence"
LABEL name="slack_quiet"
LABEL version="1.0.0"
LABEL maintainer="[email protected]"

Expand Down
36 changes: 24 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,30 @@
# SlackSilence
# Slack Quiet

To start your Phoenix server:
[![Build Status](https://travis-ci.org/sophilabs/slack-quiet.svg?branch=master)](https://travis-ci.org/sophilabs/slack-quiet)

* Install dependencies with `mix deps.get`
* Start Phoenix endpoint with `mix phx.server`
Slack Quiet is a Slack slash command to anonymously ask for silence in the workplace.

Now you can visit [`localhost:4000`](http:https://localhost:4000) from your browser.
## Usage

Ready to run in production? Please [check our deployment guides](http:https://www.phoenixframework.org/docs/deployment).
The command syntax is the following:

## Learn more
```
/quiet <location> <floor>
```

* Official website: http:https://www.phoenixframework.org/
* Guides: http:https://phoenixframework.org/docs/overview
* Docs: https://hexdocs.pm/phoenix
* Mailing list: http:https://groups.google.com/group/phoenix-talk
* Source: https://github.com/phoenixframework/phoenix
Example:

```
/quiet hq 1
```

## License

Slack Quiet is MIT Licensed. Copyright (c) 2018 Sophilabs, Inc.

## Credits

![Logo](https://s3.amazonaws.com/sophilabs-assets/logo/logo_300x66.gif)

This project is maintained and funded by Sophilabs, Inc.
The names and logos for sophilabs are trademarks of sophilabs, inc.
9 changes: 4 additions & 5 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
use Mix.Config

# Configures the endpoint
config :slack_silence, SlackSilenceWeb.Endpoint,
config :slack_quiet, SlackQuietWeb.Endpoint,
url: [host: "localhost"],
secret_key_base: "CQNu6sCApWrWdBlu/yj+Q/Vydp0D+U0AllMAv/69mWISGjen4EluDDrnmgOXAhPF",
render_errors: [view: SlackSilenceWeb.ErrorView, accepts: ~w(json)],
pubsub: [name: SlackSilence.PubSub,
adapter: Phoenix.PubSub.PG2]
render_errors: [view: SlackQuietWeb.ErrorView, accepts: ~w(json)],
pubsub: [name: SlackQuiet.PubSub, adapter: Phoenix.PubSub.PG2]

# Configures Elixir's Logger
config :logger, :console,
Expand All @@ -20,4 +19,4 @@ config :logger, :console,

# Import environment specific config. This must remain at the bottom
# of this file so it overrides the configuration defined above.
import_config "#{Mix.env}.exs"
import_config "#{Mix.env()}.exs"
2 changes: 1 addition & 1 deletion config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use Mix.Config
# The watchers configuration can be used to run external
# watchers to your application. For example, we use it
# with brunch.io to recompile .js and .css sources.
config :slack_silence, SlackSilenceWeb.Endpoint,
config :slack_quiet, SlackQuietWeb.Endpoint,
http: [port: 4000],
debug_errors: true,
code_reloader: true,
Expand Down
13 changes: 6 additions & 7 deletions config/prod.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use Mix.Config
# For production, we often load configuration from external
# sources, such as your system environment. For this reason,
# you won't find the :http configuration below, but set inside
# SlackSilenceWeb.Endpoint.init/2 when load_from_system_env is
# SlackQuietWeb.Endpoint.init/2 when load_from_system_env is
# true. Any dynamic configuration should be done there.
#
# Don't forget to configure the url host to something meaningful,
Expand All @@ -13,7 +13,7 @@ use Mix.Config
# containing the digested version of static files. This
# manifest is generated by the mix phx.digest task
# which you typically run after static files are built.
config :slack_silence, SlackSilenceWeb.Endpoint,
config :slack_quiet, SlackQuietWeb.Endpoint,
load_from_system_env: true,
url: [host: "example.com", port: 80],
cache_static_manifest: "priv/static/cache_manifest.json"
Expand All @@ -26,7 +26,7 @@ config :logger, level: :info
# To get SSL working, you will need to add the `https` key
# to the previous section and set your `:url` port to 443:
#
# config :slack_silence, SlackSilenceWeb.Endpoint,
# config :slack_quiet, SlackQuietWeb.Endpoint,
# ...
# url: [host: "example.com", port: 443],
# https: [:inet6,
Expand All @@ -41,7 +41,7 @@ config :logger, level: :info
# We also recommend setting `force_ssl`, ensuring no data is
# ever sent via http, always redirecting to https:
#
# config :slack_silence, SlackSilenceWeb.Endpoint,
# config :slack_quiet, SlackQuietWeb.Endpoint,
# force_ssl: [hsts: true]
#
# Check `Plug.SSL` for all available options in `force_ssl`.
Expand All @@ -56,10 +56,9 @@ config :logger, level: :info
# Alternatively, you can configure exactly which server to
# start per endpoint:
#
# config :slack_silence, SlackSilenceWeb.Endpoint, server: true
# config :slack_quiet, SlackQuietWeb.Endpoint, server: true
#

# Finally import the config/prod.secret.exs
# which should be versioned separately.
config :slack_silence, SlackSilenceWeb.Endpoint,
secret_key_base: System.get_env("SECRET_KEY_BASE")
config :slack_quiet, SlackQuietWeb.Endpoint, secret_key_base: System.get_env("SECRET_KEY_BASE")
2 changes: 1 addition & 1 deletion config/test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use Mix.Config

# We don't run a server during test. If one is required,
# you can enable the server option below.
config :slack_silence, SlackSilenceWeb.Endpoint,
config :slack_quiet, SlackQuietWeb.Endpoint,
http: [port: 4001],
server: false

Expand Down
2 changes: 1 addition & 1 deletion dev.dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM elixir:1.6.1

LABEL name="slack_silence_dev"
LABEL name="slack_quiet_dev"
LABEL version="1.0.0"
LABEL maintainer="[email protected]"

Expand Down
4 changes: 2 additions & 2 deletions lib/slack_silence.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule SlackSilence do
defmodule SlackQuiet do
@moduledoc """
SlackSilence keeps the contexts that define your domain
SlackQuiet keeps the contexts that define your domain
and business logic.
Contexts are also responsible for managing your data, regardless
Expand Down
16 changes: 9 additions & 7 deletions lib/slack_silence/application.ex
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
defmodule SlackSilence.Application do
defmodule SlackQuiet.Application do
@moduledoc false

use Application

# See https://hexdocs.pm/elixir/Application.html
Expand All @@ -7,22 +9,22 @@ defmodule SlackSilence.Application do
# Define workers and child supervisors to be supervised
children = [
# Start the endpoint when the application starts
SlackSilenceWeb.Endpoint,
SlackSilence.LastUsageRegistry
# Start your own worker by calling: SlackSilence.Worker.start_link(arg1, arg2, arg3)
# worker(SlackSilence.Worker, [arg1, arg2, arg3]),
SlackQuietWeb.Endpoint,
SlackQuiet.LastUsageRegistry
# Start your own worker by calling: SlackQuiet.Worker.start_link(arg1, arg2, arg3)
# worker(SlackQuiet.Worker, [arg1, arg2, arg3]),
]

# See https://hexdocs.pm/elixir/Supervisor.html
# for other strategies and supported options
opts = [strategy: :one_for_one, name: SlackSilence.Supervisor]
opts = [strategy: :one_for_one, name: SlackQuiet.Supervisor]
Supervisor.start_link(children, opts)
end

# Tell Phoenix to update the endpoint configuration
# whenever the application is updated.
def config_change(changed, _new, removed) do
SlackSilenceWeb.Endpoint.config_change(changed, removed)
SlackQuietWeb.Endpoint.config_change(changed, removed)
:ok
end
end
4 changes: 2 additions & 2 deletions lib/slack_silence/last_usage_registry.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
defmodule SlackSilence.LastUsageRegistry do
defmodule SlackQuiet.LastUsageRegistry do
@moduledoc """
We don't want to allow users to span `/silence` in Slack, so we throttle them.
We don't want to allow users to span `/quiet` in Slack, so we throttle them.
We maintain an Agent with information about the last usage of the command
for every user and we check if it has passed enough seconds since the last time.
Expand Down
25 changes: 13 additions & 12 deletions lib/slack_silence_web.ex
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
defmodule SlackSilenceWeb do
defmodule SlackQuietWeb do
@moduledoc """
The entrypoint for defining your web interface, such
as controllers, views, channels and so on.
This can be used in your application as:
use SlackSilenceWeb, :controller
use SlackSilenceWeb, :view
use SlackQuietWeb, :controller
use SlackQuietWeb, :view
The definitions below will be executed for every view,
controller, etc, so keep them short and clean, focused
Expand All @@ -19,24 +19,25 @@ defmodule SlackSilenceWeb do

def controller do
quote do
use Phoenix.Controller, namespace: SlackSilenceWeb
use Phoenix.Controller, namespace: SlackQuietWeb
import Plug.Conn
import SlackSilenceWeb.Router.Helpers
import SlackSilenceWeb.Gettext
import SlackQuietWeb.Router.Helpers
import SlackQuietWeb.Gettext
end
end

def view do
quote do
use Phoenix.View, root: "lib/slack_silence_web/templates",
namespace: SlackSilenceWeb
use Phoenix.View,
root: "lib/slack_quiet_web/templates",
namespace: SlackQuietWeb

# Import convenience functions from controllers
import Phoenix.Controller, only: [get_flash: 2, view_module: 1]

import SlackSilenceWeb.Router.Helpers
import SlackSilenceWeb.ErrorHelpers
import SlackSilenceWeb.Gettext
import SlackQuietWeb.Router.Helpers
import SlackQuietWeb.ErrorHelpers
import SlackQuietWeb.Gettext
end
end

Expand All @@ -51,7 +52,7 @@ defmodule SlackSilenceWeb do
def channel do
quote do
use Phoenix.Channel
import SlackSilenceWeb.Gettext
import SlackQuietWeb.Gettext
end
end

Expand Down
8 changes: 4 additions & 4 deletions lib/slack_silence_web/channels/user_socket.ex
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
defmodule SlackSilenceWeb.UserSocket do
defmodule SlackQuietWeb.UserSocket do
use Phoenix.Socket

## Channels
# channel "room:*", SlackSilenceWeb.RoomChannel
# channel "room:*", SlackQuietWeb.RoomChannel

## Transports
transport :websocket, Phoenix.Transports.WebSocket
transport(:websocket, Phoenix.Transports.WebSocket)
# transport :longpoll, Phoenix.Transports.LongPoll

# Socket params are passed from the client and can
Expand All @@ -30,7 +30,7 @@ defmodule SlackSilenceWeb.UserSocket do
# Would allow you to broadcast a "disconnect" event and terminate
# all active sockets and channels for a given user:
#
# SlackSilenceWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
# SlackQuietWeb.Endpoint.broadcast("user_socket:#{user.id}", "disconnect", %{})
#
# Returning `nil` makes this socket anonymous.
def id(_socket), do: nil
Expand Down
Loading

0 comments on commit e244eb2

Please sign in to comment.