Add tag pages and tags list with minimal styling.

This commit is contained in:
Dan Burton 2014-11-13 20:43:25 -08:00
parent e6fb29c9ee
commit c5aef41fde
9 changed files with 71 additions and 1 deletions

View File

@ -57,6 +57,7 @@ import Handler.Haddock
import Handler.Package
import Handler.PackageList
import Handler.CompressorStatus
import Handler.Tag
-- This line actually creates our YesodDispatch instance. It is the second half
-- of the call to mkYesodData which occurs in Foundation.hs. Please see the

28
Handler/Tag.hs Normal file
View File

@ -0,0 +1,28 @@
module Handler.Tag where
import qualified Database.Esqueleto as E
import Data.Slug (Slug, unSlug)
import Import
getTagListR :: Handler Html
getTagListR = do
tags <- fmap (map (\(E.Value v) -> v)) $ runDB $
E.selectDistinct $ E.from $ \tag -> do
E.orderBy [E.asc (tag E.^. TagTag)]
return (tag E.^. TagTag)
defaultLayout $ do
setTitle "Stackage tags"
$(widgetFile "tag-list")
getTagR :: Slug -> Handler Html
getTagR tagSlug = do
packages <- fmap (map (\(E.Value v) -> v)) $ runDB $
E.select $ E.from $ \tag -> do
E.where_ (tag E.^. TagTag E.==. E.val tagSlug)
E.orderBy [E.asc (tag E.^. TagPackage)]
return (tag E.^. TagPackage)
let tag = unSlug tagSlug
defaultLayout $ do
setTitle $ "Stackage tag"
$(widgetFile "tag")

View File

@ -30,3 +30,5 @@
/package/#PackageName/like PackageLikeR POST
/package/#PackageName/unlike PackageUnlikeR POST
/package/#PackageName/tag PackageTagR POST
/tags TagListR GET
/tag/#Slug TagR GET

View File

@ -45,6 +45,7 @@ library
Handler.Package
Handler.PackageList
Handler.CompressorStatus
Handler.Tag
if flag(dev) || flag(library-only)
cpp-options: -DDEVELOPMENT

View File

@ -23,7 +23,7 @@ $newline never
No tags yet. #
$forall tag <- tags
<span .tag>
<a>
<a href=@{TagR tag}>
#{tag}
, #
<i #add-tag class="fa fa-plus-square" title="Show/hide tag form">

View File

@ -0,0 +1,7 @@
<div .container>
<h1>Tags
<ul .tags>
$forall tag <- tags
<li>
<a href=@{TagR tag}>
#{tag}

12
templates/tag-list.lucius Normal file
View File

@ -0,0 +1,12 @@
.tags > li {
list-style-type: none;
}
.tags {
margin: 1em 0 0 0;
padding: 0;
}
h1 {
margin-bottom: 0.5em;
}

7
templates/tag.hamlet Normal file
View File

@ -0,0 +1,7 @@
<div .container>
<h1>Packages tagged: #{tag}
<ul .packages>
$forall package <- packages
<li>
<a href=@{PackageR package}>
#{package}

12
templates/tag.lucius Normal file
View File

@ -0,0 +1,12 @@
.packages > li {
list-style-type: none;
}
.packages {
margin: 1em 0 0 0;
padding: 0;
}
h1 {
margin-bottom: 0.5em;
}