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

View File

@ -2,12 +2,16 @@ defmodule LogsrvApi.Page do
alias LogsrvApi.{Filesystem,Page,Journal}
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)
tags = [:fun]
%{
title: title,
title: title |> String.capitalize(),
filename: fd,
date_modified: date_modified,
tags: tags

View File

@ -11,9 +11,14 @@
</head>
<body>
<header>
<section class="container">
<img style="padding:1em;border-radius:1em;" src={Routes.static_path(@conn, "/images/logseq-logo.png")} alt="Logo"/>
</section>
<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"/>
<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>
</header>
<%= @inner_content %>
</body>