put link to index in footer of gallery pages
This commit is contained in:
parent
b44fd97029
commit
b62586b4ad
5 changed files with 27 additions and 12 deletions
|
@ -5,7 +5,7 @@ import Control.Exception
|
|||
import Data.Function (on, (&))
|
||||
import Data.List (sortOn, groupBy)
|
||||
import qualified Data.Text.Lazy as Lazy
|
||||
import System.FilePath ((</>), takeDirectory)
|
||||
import System.FilePath ((</>), takeDirectory, joinPath, splitPath)
|
||||
import GHC.Exts (Down (..), the)
|
||||
|
||||
import BuilderQQ
|
||||
|
@ -17,13 +17,14 @@ newtype NoThumb = NoThumb FilePath
|
|||
instance Show NoThumb where show (NoThumb dir) = "no thumbnail for " ++ dir
|
||||
|
||||
make :: Text -- ^ title
|
||||
-> FilePath -- ^ gallery url prefix
|
||||
-> Bool -- ^ nsfw is included?
|
||||
-> [(FilePath, Info)]
|
||||
-> Lazy.Text
|
||||
make title nsfw infos = toLazyText $ make' title nsfw infos
|
||||
make title prefix nsfw infos = toLazyText $ make' title prefix nsfw infos
|
||||
|
||||
make' :: Text -> Bool -> [(FilePath, Info)] -> Builder
|
||||
make' title nsfw infos = [b|@0
|
||||
make' :: Text -> FilePath -> Bool -> [(FilePath, Info)] -> Builder
|
||||
make' title prefix nsfw infos = [b|@0
|
||||
<!DOCTYPE html>
|
||||
<html lang=en>
|
||||
<meta charset=utf-8>
|
||||
|
@ -45,6 +46,10 @@ make' title nsfw infos = [b|@0
|
|||
$4.items
|
||||
</ul>
|
||||
</main>
|
||||
|
||||
<footer>
|
||||
<a href=$@undir>all galleries</a>
|
||||
</footer>
|
||||
|]
|
||||
where
|
||||
items = map (uncurry $ makeYearItems nsfw) infosByYear
|
||||
|
@ -55,6 +60,7 @@ make' title nsfw infos = [b|@0
|
|||
let year = #year info,
|
||||
then group by Down year using groupBy']
|
||||
groupBy' f = groupBy ((==) `on` f)
|
||||
undir = joinPath (replicate (length (splitPath prefix)) "..")
|
||||
|
||||
makeYearItems :: Bool -- ^ nsfw
|
||||
-> Integer -- ^ year
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue