Index controller built out.

This commit is contained in:
Ryan Pandya 2022-09-04 21:02:28 -07:00
parent 3f508c1781
commit 3caf827e55
3 changed files with 16 additions and 5 deletions

View File

@ -23,6 +23,7 @@ defmodule LogsrvApi.Filesystem do
def all(Page) do def all(Page) do
dir(:pages) dir(:pages)
|> File.ls! |> File.ls!
|> Enum.sort
|> Enum.map(fn(fd) -> |> Enum.map(fn(fd) ->
Page.init(fd) Page.init(fd)
end) end)
@ -31,6 +32,7 @@ defmodule LogsrvApi.Filesystem do
def all(Journal) do def all(Journal) do
dir(:journals) dir(:journals)
|> File.ls! |> File.ls!
|> Enum.sort |> Enum.reverse
|> Enum.map(fn(fd) -> |> Enum.map(fn(fd) ->
Journal.init(fd) Journal.init(fd)
end) end)

View File

@ -2,12 +2,16 @@ defmodule LogsrvApi.Page do
alias LogsrvApi.{Filesystem,Page,Journal} alias LogsrvApi.{Filesystem,Page,Journal}
def init(fd) do def init(fd) do
title = fd |> String.replace(~r/_/," ") |> String.replace(~r/\.md$/,"") title = fd
|> String.replace(~r/_/," ")
|> String.replace(~r/\.md$/,"")
|> String.replace("%2F","/")
date_modified = Page |> Filesystem.locate(fd) date_modified = Page |> Filesystem.locate(fd)
tags = [:fun] tags = [:fun]
%{ %{
title: title, title: title |> String.capitalize(),
filename: fd, filename: fd,
date_modified: date_modified, date_modified: date_modified,
tags: tags tags: tags

View File

@ -11,8 +11,13 @@
</head> </head>
<body> <body>
<header> <header>
<section class="container"> <section class="container" style="flex-direction:row-reverse;">
<img style="padding:1em;border-radius:1em;" src={Routes.static_path(@conn, "/images/logseq-logo.png")} alt="Logo"/> <img style="padding:1em;border-radius:1em;" src={Routes.static_path(@conn, "/images/logseq-logo.png")} alt="Logo"/>
<ul>
<li> <b>Directory:</b> <%= LogsrvApi.Filesystem.dir %> </li>
<li> <b>Journals:</b> <%= @pages |> length %> </li>
<li> <b>Pages:</b> <%= @journals |> length %> </li>
</ul>
</section> </section>
</header> </header>
<%= @inner_content %> <%= @inner_content %>