create gists
This commit is contained in:
parent
79a17290d5
commit
43a8412f06
90 changed files with 1777 additions and 2107 deletions
25
lib/zoeyscomputer_web/controllers/gist_json.ex
Normal file
25
lib/zoeyscomputer_web/controllers/gist_json.ex
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
defmodule ZoeyscomputerWeb.GistJSON do
|
||||
alias Zoeyscomputer.Gists.Gist
|
||||
|
||||
@doc """
|
||||
Renders a list of gists.
|
||||
"""
|
||||
def index(%{gists: gists}) do
|
||||
%{data: for(gist <- gists, do: data(gist))}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders a single gist.
|
||||
"""
|
||||
def show(%{gist: gist}) do
|
||||
%{data: data(gist)}
|
||||
end
|
||||
|
||||
defp data(%Gist{} = gist) do
|
||||
%{
|
||||
id: gist.id,
|
||||
code: gist.code,
|
||||
lang: gist.lang
|
||||
}
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue