inmanis/templates/homepage.hamlet
Yann Esposito (Yogsototh) 40dbdfb240
2021 out of the grave
2021-07-27 00:03:32 +02:00

55 lines
2.5 KiB
Text

$if isNothing currentUserId
<div #login>
<a href=@{AuthR LoginR}> Log in
$else
<div #logout>
<a href="@{UserR $ userNickname $ fromJust currentUser}">#{ userNickname $ fromJust currentUser}</a>
<a href=@{AuthR LogoutR}> Log out</a>
<div .button
opened="Add new entry"
closed="Hide input form"
flipshow="#formEntry">
Add a new entry
<div #formEntry .hide>
<h2>Add a new entry
<form method=post action=@{EntriesR} enctype=#{enctype}>
^{widget}
<input type=submit value="Post">
$if null entries
<p> There is no entry. Sniff... I feel lonely.
$else
<ul>
$forall Entity entryId entry <- entries
<li .entryLine>
<div class="vote#{cssClassVoteForEntry entryId votes}" url=@{EntryR entryId}>
<div .yeah>#{entryYeah entry}
<div .neah>#{entryNeah entry}
<div .firstline>
$if isNothing $ entryUrl entry
<a href=@{EntryR entryId}>
#{entryTitle entry} <span class="small light">&#x270E;</span>
$else
<a href=#{fromJust $ entryUrl entry}>
#{entryTitle entry} <span class="small light">»</span>
<div .secondline>
<span .score>score: #{show $ floor $ scoreForEntry entry}
<span .age>submitted #{humanReadableRelativeTime currentTime (entryCreated entry)} by #{creatorOfEntry entryId creators}
<div .thirdline .actions>
<a class="comment" href="@{EntryR entryId}?action=comment#commentbutton">#{nbCommentOfEntry entryId nbComments}</a>
$maybe userId <- currentUserId
$if currentCreator entry userId
\ - #
<a class="edit" href="@{EntryR entryId}?action=edit#editentry">edit</a>
\ - #
<span .delete .action
opened="delete"
closed="cancel"
flipshow="#destroy#{show entryId}">
delete
<span #destroy#{show entryId} .action .hide>
<span .sep>/
<span .destroy .action .red url="@{EntryR entryId}">
destroy
$else
$nothing