Skip to content

Commit

Permalink
updated css and added daily visitor counter
Browse files Browse the repository at this point in the history
  • Loading branch information
Mast3rwaf1z committed Nov 6, 2024
1 parent f97e1d2 commit fb4a029
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
17 changes: 15 additions & 2 deletions app/Index.hs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import IHP.HSX.QQ (hsx)
import Text.Blaze.Html (Html)

import CodeBlock (hsxIntroCodeBlock, introCodeIndex)
import Database.Database (getVisits)
import Database.Database (getVisits, AdminTable (getData))
import Layout (layout)
import Page (Page, PageSetting (Description, EmbedImage, EmbedText, Route))
import Section (section)
import Database.Schema (EntityField(VisitTimestamp), Visit (Visit, visitTimestamp))
import Database.Persist ((>.))

intro :: Html
intro = section [hsx|
Expand Down Expand Up @@ -41,13 +43,24 @@ intro = section [hsx|
page :: IO Html
page = do
visits <- show . length <$> getVisits
lastVisit <- foldr max 0 <$> fmap (map visitTimestamp) (getData [] :: IO [Visit])
visitsToday <- show . length <$> getData [VisitTimestamp >. lastVisit-(24*60*60)]
return [hsx|
<h1>Skademaskinen</h1>
<img src="/static/icon.png" style="border-radius:50%">
<br>
<hr>
{intro}
Visitors: <p id="visits">{visits}</p>
<table class="common-table">
<tr>
<th class="common-table-element">Visits</th>
<th class="common-table-element">Visits today</th>
</tr>
<tr>
<th class="common-table-element">{visits}</th>
<th class="common-table-element">{visitsToday}</th>
</tr>
</table>
<script>
fetch("/api/visits/new", {
method: "post",
Expand Down
1 change: 0 additions & 1 deletion static/stylesheet.css
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ button:active {
border-collapse: collapse;
overflow:scroll;
max-height:300px;
min-width: 1000px;
}

.common-table-row {
Expand Down

0 comments on commit fb4a029

Please sign in to comment.