<%= if @current_user do %>
- <%= @current_user.username %>
+ - <%= link "My Videos", to: video_path(@conn, :index) %>
-
<%= link "Log out", to: session_path(@conn, :delete, @current_user),
method: "delete" %>
diff --git a/rumbl/web/templates/video/edit.html.eex b/rumbl/web/templates/video/edit.html.eex
index 096baad..3a11f48 100644
--- a/rumbl/web/templates/video/edit.html.eex
+++ b/rumbl/web/templates/video/edit.html.eex
@@ -1,6 +1,6 @@
Edit video
-<%= render "form.html", changeset: @changeset,
+<%= render "form.html", changeset: @changeset, categories: @categories,
action: video_path(@conn, :update, @video) %>
<%= link "Back", to: video_path(@conn, :index) %>
diff --git a/rumbl/web/templates/video/form.html.eex b/rumbl/web/templates/video/form.html.eex
index fdd4dcb..a6f2e31 100644
--- a/rumbl/web/templates/video/form.html.eex
+++ b/rumbl/web/templates/video/form.html.eex
@@ -23,6 +23,12 @@
<%= error_tag f, :description %>
+
+ <%= label f, :category_id, "Category", class: "control-label" %>
+ <%= select f, :category_id, @categories, class: "form-control",
+ prompt: "Choose a category" %>
+
+
<%= submit "Submit", class: "btn btn-primary" %>
diff --git a/rumbl/web/templates/video/index.html.eex b/rumbl/web/templates/video/index.html.eex
index e5b8f70..138b699 100644
--- a/rumbl/web/templates/video/index.html.eex
+++ b/rumbl/web/templates/video/index.html.eex
@@ -3,24 +3,25 @@
- User |
+ ID |
Url |
Title |
- Description |
-
+ description |
+ Categories |
|
<%= for video <- @videos do %>
- <%= video.user_id %> |
+ <%= video.id %> |
<%= video.url %> |
<%= video.title %> |
<%= video.description %> |
+ <%= video.category_id%> |
- <%= link "Show", to: video_path(@conn, :show, video), class: "btn btn-default btn-xs" %>
+ <%= link "Watch", to: watch_path(@conn, :show, video), class: "btn btn-default btn-xs" %>
<%= link "Edit", to: video_path(@conn, :edit, video), class: "btn btn-default btn-xs" %>
<%= link "Delete", to: video_path(@conn, :delete, video), method: :delete, data: [confirm: "Are you sure?"], class: "btn btn-danger btn-xs" %>
|
diff --git a/rumbl/web/templates/video/new.html.eex b/rumbl/web/templates/video/new.html.eex
index 94ec097..47a31c8 100644
--- a/rumbl/web/templates/video/new.html.eex
+++ b/rumbl/web/templates/video/new.html.eex
@@ -1,6 +1,6 @@
-New video
+New Video
-<%= render "form.html", changeset: @changeset,
+<%= render "form.html", changeset: @changeset, categories: @categories,
action: video_path(@conn, :create) %>
<%= link "Back", to: video_path(@conn, :index) %>
diff --git a/rumbl/web/templates/video/show.html.eex b/rumbl/web/templates/video/show.html.eex
index 9399c65..f6cfe5e 100644
--- a/rumbl/web/templates/video/show.html.eex
+++ b/rumbl/web/templates/video/show.html.eex
@@ -3,8 +3,8 @@
-
- User:
- <%= @video.user_id %>
+ Video Id
+ <%= @video.id %>
-
@@ -22,6 +22,11 @@
<%= @video.description %>
+ -
+ Category
+ <%= @video.category_id %>
+
+
<%= link "Edit", to: video_path(@conn, :edit, @video) %>
diff --git a/rumbl/web/templates/watch/show.html.eex b/rumbl/web/templates/watch/show.html.eex
new file mode 100644
index 0000000..dcc1010
--- /dev/null
+++ b/rumbl/web/templates/watch/show.html.eex
@@ -0,0 +1,24 @@
+<%= @video.title %>
+
+
+ <%= content_tag :div, id: "video",
+ data: [id: @video.id, player_id: player_id(@video)] do %>
+ <% end %>
+
+
+
+
+
Annotations
+
+
+
+
+
+
+
+
diff --git a/rumbl/web/views/watch_view.ex b/rumbl/web/views/watch_view.ex
new file mode 100644
index 0000000..bbc8725
--- /dev/null
+++ b/rumbl/web/views/watch_view.ex
@@ -0,0 +1,9 @@
+defmodule Rumbl.WatchView do
+ use Rumbl.Web, :view
+
+ def player_id(video) do
+ ~r{^.*(?:youtu\.be/|\w+/|v=)(?[^#&?]*)}
+ |> Regex.named_captures(video.url)
+ |> get_in(["id"])
+ end
+end
diff --git a/rumbl/web/web.ex b/rumbl/web/web.ex
index e466fa9..c5266f1 100644
--- a/rumbl/web/web.ex
+++ b/rumbl/web/web.ex
@@ -37,6 +37,7 @@ defmodule Rumbl.Web do
import Rumbl.Router.Helpers
import Rumbl.Gettext
+ import Rumbl.Auth, only: [authenticate_user: 2] # New import
end
end
@@ -59,6 +60,8 @@ defmodule Rumbl.Web do
def router do
quote do
use Phoenix.Router
+
+ import Rumbl.Auth, only: [authenticate_user: 2] # New import
end
end