From b1d9b7e6d94b4bcf8ff9d9c62d987be0138b6e63 Mon Sep 17 00:00:00 2001 From: Chris Done Date: Mon, 3 Nov 2014 17:47:32 +0100 Subject: [PATCH] Show README and changelog from metadata table @snoyberg Check out these locally when your data is generated, they demonstrate varying readme and changelog formats. http://localhost:3000/package/yesod-core http://localhost:3000/package/fay http://localhost:3000/package/base http://localhost:3000/package/conduit http://localhost:3000/package/aeson http://localhost:3000/package/bytestring Pity there's no standard CHANGELOG format but it's better than nothing and looks pretty in the conduit/base case. --- Handler/Package.hs | 5 +---- templates/package.hamlet | 16 +++++++++++++--- templates/package.lucius | 20 ++++++++++++++++++-- 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/Handler/Package.hs b/Handler/Package.hs index b530fbc..940dd77 100644 --- a/Handler/Package.hs +++ b/Handler/Package.hs @@ -13,7 +13,6 @@ import qualified Database.Esqueleto as E import Formatting import Import import Text.Email.Validate -import Text.Markdown -- | Page metadata package. getPackageR :: PackageName -> Handler Html @@ -38,9 +37,7 @@ getPackageR pn = do recentDownloads <- count [DownloadPackage ==. pn, DownloadTimestamp >=. nowMinus30] metadata <- getBy404 (UniqueMetadata pn) return (packages, downloads, recentDownloads, metadata) - readmeText <- return "TODO" - let readmeHtml = markdown def readmeText - deps = enumerate (metadataDeps metadata) + let deps = enumerate (metadataDeps metadata) authors = enumerate (parseIdentitiesLiberally (metadataAuthor metadata)) maintainers = let ms = enumerate (parseIdentitiesLiberally (metadataMaintainer metadata)) in if ms == authors diff --git a/templates/package.hamlet b/templates/package.hamlet index 49522f7..d096a3b 100644 --- a/templates/package.hamlet +++ b/templates/package.hamlet @@ -109,12 +109,22 @@ $newline never #{fromMaybe title $ stripSuffix ", exclusive" title} -
+
-
- #{readmeHtml} + #{metadataReadme metadata} + +$maybe log <- metadataChangelog metadata +
+
+
+

Changes +
+
+
+
+ #{log}
diff --git a/templates/package.lucius b/templates/package.lucius index 19aa376..62c8f79 100644 --- a/templates/package.lucius +++ b/templates/package.lucius @@ -79,13 +79,13 @@ h3 { } } -.readme-container { +.markdown-container { margin-top: 1em; border-top: 1px solid #ddd; padding-top: 1em; margin-bottom: 0em; border-bottom: 1px solid #ddd; - padding-bottom: 2em; + padding-bottom: 1em; background: #f4f4f4; h1,h2,h3,h4,h5 { @@ -124,3 +124,19 @@ h3 { padding: 1em; } } + +.changelog-container { + margin-top: 0.5em; + h1 { font-size: 1.2em; } + h2,h3,h4,h5 { font-size: 1.2em; } +} + +h2.changes-title { + margin-top: 1em; + font-size: 1.5em; + color: #555; +} + +.readme-container { + margin-top: 1em; +}