Cleanup
This commit is contained in:
parent
5c1376066a
commit
cce6e72254
10 changed files with 45 additions and 56 deletions
|
@ -132,11 +132,11 @@ instance Yesod App where
|
|||
}
|
||||
]
|
||||
|
||||
let navbarLeftMenuItems = [x | NavbarLeft x <- menuItems]
|
||||
let navbarRightMenuItems = [x | NavbarRight x <- menuItems]
|
||||
-- let navbarLeftMenuItems = [x | NavbarLeft x <- menuItems]
|
||||
-- let navbarRightMenuItems = [x | NavbarRight x <- menuItems]
|
||||
|
||||
let navbarLeftFilteredMenuItems = [x | x <- navbarLeftMenuItems, menuItemAccessCallback x]
|
||||
let navbarRightFilteredMenuItems = [x | x <- navbarRightMenuItems, menuItemAccessCallback x]
|
||||
-- let navbarLeftFilteredMenuItems = [x | x <- navbarLeftMenuItems, menuItemAccessCallback x]
|
||||
-- let navbarRightFilteredMenuItems = [x | x <- navbarRightMenuItems, menuItemAccessCallback x]
|
||||
|
||||
-- We break up the default layout into two components:
|
||||
-- default-layout is the contents of the body tag, and
|
||||
|
|
|
@ -17,6 +17,9 @@ import Handler.Helper
|
|||
getCommentR :: CommentId -> Handler Html
|
||||
getCommentR _ = error "Not yet implemented: getCommentR"
|
||||
|
||||
isCommentCreator :: Key Comment
|
||||
-> (UserId -> Comment -> HandlerFor App TypedContent)
|
||||
-> Handler TypedContent
|
||||
isCommentCreator commentId f =
|
||||
testLogged $ \userId -> do
|
||||
maybeComment <- runDB $ get commentId
|
||||
|
|
|
@ -17,8 +17,6 @@ where
|
|||
|
||||
import Import
|
||||
import Handler.Helper
|
||||
import Yesod.Auth
|
||||
import Yesod.Markdown
|
||||
import Data.Maybe
|
||||
import Data.Tree
|
||||
|
||||
|
@ -58,18 +56,17 @@ getCommentSons comments father@(Entity commentId _) =
|
|||
(father,
|
||||
filter (\(Entity _ c) -> commentReplyTo c == Just commentId) comments)
|
||||
|
||||
-- showCommentForest :: [Tree (Entity Comment)] -> Hamlet
|
||||
showCommentForest [] _ _ _ _ _ = [whamlet|$newline never
|
||||
|]
|
||||
|]
|
||||
showCommentForest trees creators currentId wdg enc voteComments=
|
||||
[whamlet|$newline always
|
||||
<ul>
|
||||
$forall tree <- trees
|
||||
^{showCommentTree tree creators currentId wdg enc voteComments}|]
|
||||
|
||||
-- cssClassVoteForVote :: (Eq a) => a
|
||||
-- -> [(a, [Entity (VoteCommentGeneric backend)])]
|
||||
-- -> Text
|
||||
cssClassVoteForVote :: (IsMap map,
|
||||
MapValue map ~ [Entity VoteComment])
|
||||
=> ContainerKey map -> map -> Text
|
||||
cssClassVoteForVote commentId voteComments =
|
||||
maybe "" strOfVote (lookup commentId voteComments)
|
||||
where
|
||||
|
@ -126,8 +123,8 @@ showCommentTree tree creators currentId widget enctype voteComments=
|
|||
&& currentId == maybeCreator
|
||||
|
||||
creatorOfEntity :: CommentId -> [(CommentId,[Entity User])] -> Text
|
||||
creatorOfEntity entityId creators =
|
||||
maybe "Anonymous Coward" entUserIdent (lookup entityId creators)
|
||||
creatorOfEntity entId creators =
|
||||
maybe "Anonymous Coward" entUserIdent (lookup entId creators)
|
||||
where
|
||||
entUserIdent [] = "Anonymous Coward"
|
||||
entUserIdent ((Entity _ creator):_) = userIdent creator
|
||||
|
@ -154,6 +151,7 @@ emptyEntryForm = renderDivs $ EntryRequest
|
|||
<*> aopt urlField "Url" Nothing
|
||||
<*> aopt textareaField "Text" Nothing
|
||||
|
||||
loginWidget :: Maybe a -> WidgetFor App ()
|
||||
loginWidget maybeUserId =
|
||||
[whamlet|$newline always
|
||||
$if isNothing maybeUserId
|
||||
|
|
|
@ -93,21 +93,21 @@ humanReadableRelativeTime currentTime createdTime =
|
|||
showDuration duration
|
||||
where
|
||||
duration = diffUTCTime currentTime createdTime
|
||||
second, minute, hour, day, year :: NominalDiffTime
|
||||
second = fromIntegral (1 :: Int)
|
||||
minute = (fromIntegral ( 60 :: Int)) * second
|
||||
oneSecond, minute, hour, day, year :: NominalDiffTime
|
||||
oneSecond = fromIntegral (1 :: Int)
|
||||
minute = (fromIntegral ( 60 :: Int)) * oneSecond
|
||||
hour = (fromIntegral ( 60 :: Int)) * minute
|
||||
day = (fromIntegral ( 24 :: Int)) * hour
|
||||
year = (fromIntegral (365 :: Int)) * day
|
||||
seconds,minutes,hours,days,years :: NominalDiffTime -> NominalDiffTime
|
||||
seconds t = t / second
|
||||
seconds t = t / oneSecond
|
||||
minutes t = t / minute
|
||||
hours t = t / hour
|
||||
days t = t / day
|
||||
years t = t / year
|
||||
showTime t = show (floor t :: Integer)
|
||||
showDuration t
|
||||
| t < second = "Just now"
|
||||
| t < oneSecond = "Just now"
|
||||
| t < minute = pack $ (showTime $ seconds t) ++ " seconds ago"
|
||||
| t < hour = pack $ (showTime $ minutes t) ++ " minutes ago"
|
||||
| t < day = pack $ (showTime $ hours t) ++ " hours ago"
|
||||
|
|
|
@ -1,6 +1,9 @@
|
|||
{-# LANGUAGE TupleSections, OverloadedStrings, NoImplicitPrelude #-}
|
||||
{-# LANGUAGE TupleSections #-}
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
{-# LANGUAGE NoImplicitPrelude #-}
|
||||
{-# LANGUAGE TypeFamilies #-}
|
||||
{-# LANGUAGE TemplateHaskell #-}
|
||||
{-# LANGUAGE ScopedTypeVariables #-}
|
||||
module Handler.Home
|
||||
( getHomeR
|
||||
, postEntriesR
|
||||
|
@ -11,6 +14,9 @@ import Import
|
|||
import Handler.Helper
|
||||
import Data.Maybe
|
||||
|
||||
intScore :: Entry -> Integer
|
||||
intScore = floor . scoreForEntry
|
||||
|
||||
-- |The `EntryRequest` correspond to the data needed
|
||||
-- to create a new entry.
|
||||
data EntryRequest = EntryRequest {
|
||||
|
@ -125,7 +131,7 @@ getHomeR = do
|
|||
|
||||
-- |When we receive a post request on HomeR resource (/ path)
|
||||
-- |We create a new resource
|
||||
-- postEntriesR :: Handler RepHtmlJson
|
||||
postEntriesR :: Handler TypedContent
|
||||
postEntriesR =
|
||||
testLogged $ \currentUserId -> do
|
||||
((res,_),_) <- runFormPost entryForm
|
||||
|
@ -143,7 +149,7 @@ postEntriesR =
|
|||
True -> errorPageJson "You must enter some text or some URL"
|
||||
False -> do
|
||||
entryId <- runDB $ insert newEntry
|
||||
voteId <- runDB $ insert $ Vote currentUserId entryId 1
|
||||
_voteId <- runDB $ insert $ Vote currentUserId entryId 1
|
||||
setMessage $ toHtml (title personRequest)
|
||||
redirect $ EntryR entryId
|
||||
_ -> errorPageJson "Please correct your entry form"
|
||||
|
|
|
@ -90,23 +90,23 @@ textEmphColor=base01
|
|||
altbackground, altbackHighlightColor, altforeground, alttextcolor :: String
|
||||
alttextSecondaryColor, alttextEmphColor :: String
|
||||
|
||||
altbackground=base01
|
||||
altbackHighlightColor=base02
|
||||
altforeground=base0
|
||||
altbackground=base2
|
||||
altbackHighlightColor=base2
|
||||
altforeground=base00
|
||||
alttextcolor=altforeground
|
||||
alttextSecondaryColor=base01
|
||||
alttextEmphColor=base1
|
||||
alttextSecondaryColor=base1
|
||||
alttextEmphColor=base01
|
||||
|
||||
base03, base02, base01, base00, base0, base1, base2, base3 :: String
|
||||
|
||||
base03="#002b36"
|
||||
base02="#073642"
|
||||
base01="#586e75"
|
||||
base00="#657b83"
|
||||
base0="#839496"
|
||||
base1="#93a1a1"
|
||||
base2="#eee8d5"
|
||||
base3="#fdf6e3"
|
||||
base03="hsl(218,20%,12%)"
|
||||
base02="hsl(218,20%,16%)"
|
||||
base01="hsl(218,20%,45%)"
|
||||
base00="hsl(218,20%,50%)"
|
||||
base0="hsl(218,20%,60%)"
|
||||
base1="hsl(218,20%,65%)"
|
||||
base2="hsl(218,20%,95%)"
|
||||
base3="hsl(218,20%,97%)"
|
||||
|
||||
yellow , orange , red , magenta , violet , blue , cyan , green :: String
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
<meta name="author" content="">
|
||||
|
||||
<meta name="viewport" content="width=device-width,initial-scale=1">
|
||||
<script src="https://code.jquery.com/jquery-2.2.4.min.js">
|
||||
<link href="http://fonts.googleapis.com/css?family=Source+Sans+Pro:400,700,400italic,700italic,200,200italic,300,300italic,600,600italic,900italic,900&subset=latin,latin-ext" rel="stylesheet" type="text/css">
|
||||
|
||||
^{pageHead pc}
|
||||
|
|
|
@ -33,7 +33,7 @@ $else
|
|||
<a href=#{fromJust $ entryUrl entry}>
|
||||
#{entryTitle entry} <span class="small light">»</span>
|
||||
<div .secondline>
|
||||
<span .score>score: #{show $ floor $ scoreForEntry entry}
|
||||
<span .score>score: #{show (intScore 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>
|
||||
|
|
|
@ -1,7 +1,3 @@
|
|||
.left {
|
||||
float: left;
|
||||
}
|
||||
|
||||
p:first-letter {
|
||||
font-size: 3em;
|
||||
}
|
||||
|
|
|
@ -15,14 +15,9 @@ body, form textarea , form input {
|
|||
-o-transition-duration: 0.3s;
|
||||
}
|
||||
|
||||
body::selection { background: none repeat scroll 0 0 #{altbackHighlightColor} }
|
||||
body::-moz-selection { background: none repeat scroll 0 0 #{altbackHighlightColor} }
|
||||
#main::selection { background: none repeat scroll 0 0 #{backHighlightColor} }
|
||||
#main::-moz-selection { background: none repeat scroll 0 0 #{backHighlightColor} }
|
||||
|
||||
body {
|
||||
background-color: #{base03};
|
||||
color: #{base0};
|
||||
background-color: #{background};
|
||||
color: #{foreground};
|
||||
font-size: 18px;
|
||||
line-height: 1.5em;
|
||||
}
|
||||
|
@ -56,12 +51,10 @@ p { line-height: 1.5em; }
|
|||
/* Dark background header and footer */
|
||||
header {
|
||||
color: #{base0};
|
||||
background-color: #{base03};
|
||||
text-align: center;
|
||||
top: 0;
|
||||
margin: 0;
|
||||
padding: 1em 1em 2em 1em;
|
||||
border-bottom: solid 1px #{base03};
|
||||
h1,h2 {
|
||||
line-height: 1em;
|
||||
margin: 0;
|
||||
|
@ -79,11 +72,9 @@ header {
|
|||
}
|
||||
footer {
|
||||
color: #{base0};
|
||||
background-color: #{base03};
|
||||
a:hover { color: #{yellow}; text-shadow: 0 0 1px #{shadowyellow}; }
|
||||
line-height: 2em;
|
||||
padding: 1em 1em 2em 1em;
|
||||
border-top: solid 1px #889;
|
||||
text-align: left;
|
||||
min-height: 4em;
|
||||
.content > div {font-size: .9em;}
|
||||
|
@ -105,12 +96,9 @@ footer {
|
|||
|
||||
/* Light background main view */
|
||||
#main {
|
||||
background-color: #{background};
|
||||
color: #{foreground};
|
||||
margin-top: 0;
|
||||
border-top: solid 1px #{base3};
|
||||
padding: 2em 0;
|
||||
box-shadow: 0 16px 16px #{black};
|
||||
}
|
||||
|
||||
/* Forms */
|
||||
|
@ -129,7 +117,6 @@ form {
|
|||
, input {
|
||||
color: #{base01};
|
||||
border-radius: 3px;
|
||||
background: #{base2};
|
||||
box-shadow: 1px 1px 2px #{base03} inset;
|
||||
border: 0; padding: .3em;
|
||||
max-width: 30em;
|
||||
|
@ -147,7 +134,6 @@ form {
|
|||
input[type="submit"]:hover {
|
||||
color: #{base0};
|
||||
border-color: #{base0};
|
||||
background-color:#{base2};
|
||||
box-shadow: 1px 1px 4px #{black};
|
||||
}
|
||||
input[type="submit"]:active {
|
||||
|
@ -170,7 +156,6 @@ form {
|
|||
border-radius: 3px;
|
||||
float:left; }
|
||||
.yeah, .neah {
|
||||
background-color: #{base2};
|
||||
box-shadow: 0px 0px 2px #{base0} inset;
|
||||
border-radius: 2px;
|
||||
cursor: pointer;
|
||||
|
|
Loading…
Reference in a new issue