mirror of
https://github.com/aelve/guide.git
synced 2024-12-24 21:35:06 +03:00
Group edits by IP
This commit is contained in:
parent
a029f06ea1
commit
a025db8d9b
@ -25,6 +25,9 @@ module Utils
|
||||
deleteAt,
|
||||
insertAt,
|
||||
|
||||
-- * 'Eq'
|
||||
equating,
|
||||
|
||||
-- * URLs
|
||||
Url,
|
||||
sanitiseUrl,
|
||||
@ -125,6 +128,9 @@ insertAt _ a [] = [a]
|
||||
insertAt 0 a xs = a:xs
|
||||
insertAt n a (x:xs) = x : insertAt (n-1) a xs
|
||||
|
||||
equating :: Eq b => (a -> b) -> (a -> a -> Bool)
|
||||
equating f = (==) `on` f
|
||||
|
||||
type Url = Text
|
||||
|
||||
sanitiseUrl :: Url -> Maybe Url
|
||||
|
16
src/View.hs
16
src/View.hs
@ -159,17 +159,23 @@ renderAdmin globalState edits = do
|
||||
includeJS "/js.js"
|
||||
includeJS "/jquery-2.2.0.min.js"
|
||||
includeCSS "/markup.css"
|
||||
title_ "admin – Aelve Guide"
|
||||
meta_ [name_ "viewport",
|
||||
content_ "width=device-width, initial-scale=1.0, user-scalable=yes"]
|
||||
|
||||
body_ $ do
|
||||
ul_ $ for_ edits $ \(edit, EditDetails{..}) -> li_ $ do
|
||||
editNode <- thisNode
|
||||
p_ $ do
|
||||
case editIP of
|
||||
h1_ "Pending edits"
|
||||
-- Group edits by IP
|
||||
let editGroups = groupBy (equating (editIP . snd)) edits
|
||||
-- For each group, show the IP and then edits as a list
|
||||
for_ editGroups $ \editGroup -> do
|
||||
h2_ $ case editIP (snd (head editGroup)) of
|
||||
Nothing -> "<unknown IP>"
|
||||
Just ip -> toHtml (show ip)
|
||||
", "
|
||||
ul_ $ do
|
||||
for_ editGroup $ \(edit, EditDetails{..}) -> li_ $ do
|
||||
editNode <- thisNode
|
||||
p_ $ do
|
||||
toHtml =<< liftIO (humanReadableTime editDate)
|
||||
emptySpan "1em"
|
||||
textButton "accept" $
|
||||
|
Loading…
Reference in New Issue
Block a user