Compare commits

...

11 commits

16 changed files with 45 additions and 39 deletions

View file

@ -35,5 +35,4 @@ title: 00dani.me
app-name: lebd
username: dani
repository: https://gitlab.com/00dani/lebd
#analytics: UA-YOURCODE
fb-app-id: "_env:FB_APP_ID:142105433189339"

2
package-lock.json generated
View file

@ -1,6 +1,6 @@
{
"name": "lebd",
"version": "1.6.0",
"version": "1.6.4",
"lockfileVersion": 1,
"requires": true,
"dependencies": {

View file

@ -1,6 +1,6 @@
{
"name": "lebd",
"version": "1.6.0",
"version": "1.6.4",
"description": "the codebase backing 00dani.me, an indieweb.org site",
"repository": {
"type": "git",

View file

@ -1,5 +1,5 @@
name: lebd
version: "1.6.0"
version: "1.6.4"
dependencies:

View file

@ -67,6 +67,9 @@ mkYesodData "App" $(parseRoutesFile "config/routes")
-- | A convenient synonym for creating forms.
type Form x = Html -> MForm (HandlerT App IO) (FormResult x, Widget)
sessionLifetime :: Int
sessionLifetime = 120 -- minutes
-- Please see the documentation for the Yesod typeclass. There are a number
-- of settings which can be configured by overriding methods here.
instance Yesod App where
@ -77,7 +80,7 @@ instance Yesod App where
-- Store session data on the client in encrypted cookies,
-- default session idle timeout is 120 minutes
makeSessionBackend _ = sslOnlySessions . strictSameSiteSessions $ Just <$> defaultClientSessionBackend
120 -- timeout in minutes
sessionLifetime
"config/client_session_key.aes"
-- Redirect static requests to a subdomain - this is recommended for best
@ -97,7 +100,7 @@ instance Yesod App where
-- b) Validates that incoming write requests include that token in either a header or POST parameter.
-- To add it, chain it together with the defaultMiddleware: yesodMiddleware = defaultYesodMiddleware . defaultCsrfMiddleware
-- For details, see the CSRF documentation in the Yesod.Core.Handler module of the yesod-core package.
yesodMiddleware = defaultYesodMiddleware . defaultCsrfMiddleware
yesodMiddleware = defaultYesodMiddleware . defaultCsrfMiddleware . sslOnlyMiddleware sessionLifetime
defaultLayout widget = do
master <- getYesod

View file

@ -8,12 +8,15 @@ import Database.Esqueleto
import Widget.Feed ( hFeed )
import Model.Category ( Category, asTag )
import qualified Data.Text as T
getCategoryR :: Category -> Handler Html
getCategoryR tag = do
title <- asks $ siteTitle . appSettings
entries <- runDB . select . from $ \(entry `InnerJoin` category) -> do
on $ entry ^. EntryId ==. category ^. EntryCategoryEntryId
where_ $ category ^. EntryCategoryCategory ==. val tag
return entry
defaultLayout $ do
setTitle . toHtml . asTag $ tag
hFeed entries
T.concat [asTag tag, " ~ ", title] `hFeed` entries

View file

@ -20,10 +20,11 @@ getEntriesR :: K.EntryKind -> Handler Html
getEntriesR kind = do
entries <- runDB $ selectList [EntryKind ==. kind] [Desc EntryPublished]
title <- asks $ siteTitle . appSettings
let myTitle = T.concat [K.pluralise kind, " ~ ", title]
defaultLayout $ do
setTitle . toHtml . K.pluralise $ kind
atomLink (FeedKindR kind) $ T.concat [K.pluralise kind, " ~ ", title]
hFeed entries
FeedKindR kind `atomLink` myTitle
hFeed myTitle entries
getEntryR :: a -> EntryId -> Handler Html
getEntryR _ = renderEntry <=< getCached

View file

@ -58,11 +58,8 @@ data AppSettings = AppSettings
, appSkipCombining :: Bool
-- ^ Perform no stylesheet/script combining
-- Example app-specific configuration values.
, appAnalytics :: Maybe Text
-- ^ Google Analytics code
, appFacebookId :: Maybe Int
-- ^ Facebook app ID, also used for analytics.
-- ^ Facebook app ID.
, siteTitle :: Text
-- ^ Site-wide title.
@ -97,7 +94,6 @@ instance FromJSON AppSettings where
appMutableStatic <- o .:? "mutable-static" .!= defaultDev
appSkipCombining <- o .:? "skip-combining" .!= defaultDev
appAnalytics <- o .:? "analytics"
appFacebookId <- o .:? "fb-app-id"
siteTitle <- o .: "title"
siteUsername <- o .: "username"

View file

@ -4,5 +4,9 @@ module Widget.Feed ( hFeed ) where
import Import
import Widget.Entry ( hEntry )
hFeed :: [Entity Entry] -> Widget
hFeed entries = $(widgetFile "mf2/h-feed")
import qualified Data.Text as T
hFeed :: T.Text -> [Entity Entry] -> Widget
hFeed name entries = do
mroute <- getCurrentRoute
$(widgetFile "mf2/h-feed")

View file

@ -25,14 +25,3 @@ $doctype 5
<script src="https://code.jquery.com/jquery-3.2.1.slim.min.js" integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN" crossorigin="anonymous">
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.11.0/umd/popper.min.js" integrity="sha384-b/U6ypiBEHpOf/4+1nzFpr53nxSS+GLCkfwBdFNTxtclqqenISfwAzpKaMNFNmj4" crossorigin="anonymous">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta/js/bootstrap.min.js" integrity="sha384-h0AbiXch4ZDo7tp9hKZ4TsHbi047NrKGLO3SEJAg45jXxnGIfYzk4Si90RDIqNm1" crossorigin="anonymous">
$maybe analytics <- appAnalytics $ appSettings master
<script>
if(!window.location.href.match(/localhost/)){
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
ga('create', '#{analytics}', 'auto');
ga('send', 'pageview');
}

View file

@ -7,6 +7,13 @@ a
text-decoration: none
line-height: 1
code, kbd, pre, samp
font-family: Monoid, Hack, Inconsolata, Menlo, Monaco, Consolas, "Liberation Mono", monospace
code, pre
color: #cccccc
code
background-color: #141414
body
background-color: #1d1f21
color: #c9cacc

View file

@ -1,5 +1,5 @@
<header>
<nav .navbar .navbar-expand-lg .navbar-dark.bg-dark>
<nav .navbar .navbar-expand-md .navbar-dark.bg-dark>
<a .navbar-brand rel="home" href=@{HomeR}>#{siteTitle $ appSettings master}
<button type="button" .navbar-toggler data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar" aria-label="Toggle navigation">
<span .navbar-toggler-icon>

View file

@ -2,7 +2,7 @@ body > main
display: flex
flex-direction: column
align-items: center
> ol.h-feed
> div.h-feed
flex: 1
margin-bottom: 0
> aside.author
@ -16,7 +16,7 @@ body > main
body > main
flex-direction: row-reverse
align-items: unset
> ol.h-feed
> div.h-feed
margin-right: 2em
> aside.author
margin-bottom: 0

View file

@ -1,2 +1,2 @@
<aside .author>^{hCard user}
^{hFeed entries}
^{hFeed title entries}

View file

@ -1,5 +1,5 @@
ol.h-feed
list-style: none
padding-left: 0
> li:not(:last-child)
margin-bottom: 1em
div.h-feed
> ol.list-unstyled
margin-bottom: 0
> li:not(:last-child)
margin-bottom: 1em

View file

@ -1,3 +1,7 @@
<ol .h-feed>
$forall entry <- entries
<li>^{hEntry entry}
<div .h-feed>
<span .p-name hidden>#{name}
$maybe route <- mroute
<a .u-url href=@{route} hidden>
<ol .list-unstyled>
$forall entry <- entries
<li>^{hEntry entry}