Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DO NOT MERGE] Live view starting state #10

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ erl_crash.dump
*.beam
/config/*.secret.exs
/assets/node_modules
.#*
40 changes: 38 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,42 @@
# Pointing Party
Welcome to Elixir School's workshop on Real-Time Phoenix with Channels, PubSub, Presence and LiveView! This application exists to guide workshop participants through each of these topics by allowing them to build out a set of features to support a fantastically fun game of "pointing poker".
Welcome to Elixir School's workshop on Real-Time Phoenix with Channels, PubSub, Presence and LiveView! This application exists to guide workshop participants through each of these topics by allowing them to build out a set of features to support a fantastically fun game of "pointing party".

Collaborators can sign in with a username and click a button to start the "pointing party". Tickets are displayed for estimation and each user can cast their store point estimate vote. Once all the votes are cast, a winner is declared and the participants can move on to estimate the next ticket.

The master branch of this app represents the starting state of the code for this workshop. Clone down and make sure you're on the master branch in order to follow along.
The master branch of this app represents the starting state of the code for this workshop. Clone down and make sure you're on the master branch in order to follow along.

## Resources

### Phoenix Channels

* [Official guide](https://hexdocs.pm/phoenix/channels.html)
* [API documentation](https://hexdocs.pm/phoenix/Phoenix.Channel.html#content)

### Phoenix PubSub

* [API documentation](https://hexdocs.pm/phoenix_pubsub/Phoenix.PubSub.html)

### Phoenix LiveView

* [LiveView announcement](https://dockyard.com/blog/2018/12/12/phoenix-liveview-interactive-real-time-apps-no-need-to-write-javascript) by Chris McCord
* [API documentation](https://hexdocs.pm/phoenix_live_view/Phoenix.LiveView.html)
* ["Walk-Through of Phoenix LiveView"](https://elixirschool.com/blog/phoenix-live-view/) by Sophie DeBenedetto
* ["Building Real-Time Features with Phoenix Live View and PubSub"](https://elixirschool.com/blog/live-view-with-pub-sub/) by Sophie DeBenedetto
* ["Using Channels with LiveView for Better UX"](https://elixirschool.com/blog/live-view-with-channels/) by Sophie DeBenedetto
* ["Tracking Users in a Chat App with LiveView, PubSub Presence"](https://elixirschool.com/blog/live-view-with-presence/) by Sophie DeBenedetto

### Property-based Testing and StreamData

* [StreamData on GitHub](https://github.com/whatyouhide/stream_data)
* [StreamData documentation](https://hexdocs.pm/stream_data/StreamData.html)
* [Elixir School article on StreamData](https://elixirschool.com/en/lessons/libraries/stream-data/)
* [_Property-Based Testing with PropEr, Erlang, and Elixir_ and _PropEr Testing_](https://propertesting.com/) by Fred Hebert
* ["An introduction to property-based testing"](https://fsharpforfunandprofit.com/posts/property-based-testing/) by Scott Wlaschin
* ["Choosing properties for property-based testing"](https://fsharpforfunandprofit.com/posts/property-based-testing-2/) by Scott Wlaschin

### Estimation

* [_Agile Estimating and Planning_](https://www.mountaingoatsoftware.com/books/agile-estimating-and-planning) by Mike Cohn of Mountain Goat Software
* [planningpoker.com](https://www.planningpoker.com/) is a full-featured estimation tool that may work well for your team.

Thanks to James Grenning and Mike Cohn for their inspiration and their work in software estimation!
5 changes: 4 additions & 1 deletion assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ import "phoenix_html"
// Import local files
//
// Local files can be imported directly using relative paths, for example:
import socket from "./socket"
import LiveSocket from "phoenix_live_view"

const liveSocket = new LiveSocket("/live")
liveSocket.connect()
113 changes: 0 additions & 113 deletions assets/js/socket.js

This file was deleted.

39 changes: 0 additions & 39 deletions assets/js/users.js

This file was deleted.

8 changes: 3 additions & 5 deletions assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"dependencies": {
"phoenix": "file:../deps/phoenix",
"phoenix_html": "file:../deps/phoenix_html",
"ramda": "^0.26.1"
"phoenix_live_view": "file:../deps/phoenix_live_view"
},
"devDependencies": {
"@babel/core": "^7.0.0",
Expand Down
1 change: 1 addition & 0 deletions config/config.exs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ config :pointing_party,

# Configures the endpoint
config :pointing_party, PointingPartyWeb.Endpoint,
live_view: [signing_salt: "SECRET_SALT"],
url: [host: "localhost"],
secret_key_base: "w1I+WClCAIRKxSX5/M7gFHQLa9pnn4AuVDO6XmUgTZxJl+VqMOr2Q5Ou+2CSoLdJ",
render_errors: [view: PointingPartyWeb.ErrorView, accepts: ~w(html json)],
Expand Down
3 changes: 2 additions & 1 deletion config/dev.exs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ config :pointing_party, PointingPartyWeb.Endpoint,
~r"priv/static/.*(js|css|png|jpeg|jpg|gif|svg)$",
~r"priv/gettext/.*(po)$",
~r"lib/pointing_party_web/{live,views}/.*(ex)$",
~r"lib/pointing_party_web/templates/.*(eex)$"
~r"lib/pointing_party_web/templates/.*(eex)$",
~r"lib/pointing_party_web/live/.*(ex)$"
]
]

Expand Down
5 changes: 3 additions & 2 deletions lib/pointing_party/vote_calculator.ex
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ defmodule PointingParty.VoteCalculator do

defp handle_tie(%{majority: nil, calculated_votes: calculated_votes}) do
calculated_votes
|> Enum.sort_by(&elem(&1, 1))
|> Enum.take(2)
|> Enum.sort_by(&elem(&1, 1), &>=/2)
|> Enum.map(&elem(&1, 0))
|> Enum.sort()
|> Enum.take(2)
end

defp handle_tie(%{majority: majority}), do: majority
Expand Down
3 changes: 3 additions & 0 deletions lib/pointing_party_web.ex
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ defmodule PointingPartyWeb do

import Plug.Conn
import PointingPartyWeb.Gettext
import Phoenix.LiveView.Controller, only: [live_render: 3]
alias PointingPartyWeb.Router.Helpers, as: Routes
end
end
Expand All @@ -42,6 +43,7 @@ defmodule PointingPartyWeb do
import PointingPartyWeb.ErrorHelpers
import PointingPartyWeb.LayoutHelpers
import PointingPartyWeb.Gettext
import Phoenix.LiveView, only: [live_render: 2, live_render: 3, live_link: 1, live_link: 2]
alias PointingPartyWeb.Router.Helpers, as: Routes
end
end
Expand All @@ -51,6 +53,7 @@ defmodule PointingPartyWeb do
use Phoenix.Router
import Plug.Conn
import Phoenix.Controller
import Phoenix.LiveView.Router
end
end

Expand Down
49 changes: 0 additions & 49 deletions lib/pointing_party_web/channels/room_channel.ex

This file was deleted.

33 changes: 0 additions & 33 deletions lib/pointing_party_web/channels/user_socket.ex

This file was deleted.

5 changes: 4 additions & 1 deletion lib/pointing_party_web/controllers/card_controller.ex
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
defmodule PointingPartyWeb.CardController do
use PointingPartyWeb, :controller

import Phoenix.LiveView.Controller

def index(conn, _params) do
render(conn, "index.html")
%{assigns: %{username: username}} = conn
# render the LiveView here
end
end
Loading