mirror of
https://github.com/commercialhaskell/stackage-server.git
synced 2026-01-11 19:58:28 +01:00
Add tag pages and tags list with minimal styling.
This commit is contained in:
parent
e6fb29c9ee
commit
c5aef41fde
@ -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
28
Handler/Tag.hs
Normal 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")
|
||||
@ -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
|
||||
@ -45,6 +45,7 @@ library
|
||||
Handler.Package
|
||||
Handler.PackageList
|
||||
Handler.CompressorStatus
|
||||
Handler.Tag
|
||||
|
||||
if flag(dev) || flag(library-only)
|
||||
cpp-options: -DDEVELOPMENT
|
||||
|
||||
@ -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">
|
||||
|
||||
7
templates/tag-list.hamlet
Normal file
7
templates/tag-list.hamlet
Normal 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
12
templates/tag-list.lucius
Normal 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
7
templates/tag.hamlet
Normal 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
12
templates/tag.lucius
Normal file
@ -0,0 +1,12 @@
|
||||
.packages > li {
|
||||
list-style-type: none;
|
||||
}
|
||||
|
||||
.packages {
|
||||
margin: 1em 0 0 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
h1 {
|
||||
margin-bottom: 0.5em;
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user