Add all
This commit is contained in:
parent
b35e18cd20
commit
82f55f7afe
80 changed files with 6687 additions and 5 deletions
32
lib/nulla_web/controllers/note_json.ex
Normal file
32
lib/nulla_web/controllers/note_json.ex
Normal file
|
@ -0,0 +1,32 @@
|
|||
defmodule NullaWeb.NoteJSON do
|
||||
alias Nulla.Notes.Note
|
||||
|
||||
@doc """
|
||||
Renders a list of notes.
|
||||
"""
|
||||
def index(%{notes: notes}) do
|
||||
%{data: for(note <- notes, do: data(note))}
|
||||
end
|
||||
|
||||
@doc """
|
||||
Renders a single note.
|
||||
"""
|
||||
def show(%{note: note}) do
|
||||
%{data: data(note)}
|
||||
end
|
||||
|
||||
defp data(%Note{} = note) do
|
||||
%{
|
||||
id: note.id,
|
||||
inReplyTo: note.inReplyTo,
|
||||
published: note.published,
|
||||
url: note.url,
|
||||
visibility: note.visibility,
|
||||
to: note.to,
|
||||
cc: note.cc,
|
||||
sensitive: note.sensitive,
|
||||
content: note.content,
|
||||
language: note.language
|
||||
}
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue