-
Notifications
You must be signed in to change notification settings - Fork 1
/
MasXml.hs
35 lines (30 loc) · 1.06 KB
/
MasXml.hs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
--
-- (c) [email protected], 2013
--
-- Note to self: xmlgen does not play well with OverloadedStrings
--
-- | Generate MetaDoc software page XML for MAPI
{-# LANGUAGE OverloadedStrings #-}
module MasXml (
genMasXml
, renderMasXml
) where
import LmodPackage
import SoftwarePages (packageVersionUrl)
import Data.Monoid
import Text.XML.Generator
import qualified Data.Text as T
import qualified Data.ByteString.Lazy.Char8 as BS
renderMasXml site baseUrl p =
xrender $ genMasXml (T.pack site) (T.pack baseUrl) p
genMasXml :: T.Text -> T.Text -> [Package] -> Xml Doc
genMasXml site baseUrl p = doc defaultDocInfo $
xelem "MetaDoc" $
xattr "version" "1.3.0" <> xattr "site_name" site <#>
xelem "software" (xelems $ map (genMasPackageInfo baseUrl) p)
genMasPackageInfo :: T.Text -> Package -> Xml Elem
genMasPackageInfo baseUrl p = xelem "sw_entry" $
xattr "progName" (displayName p) <>
xattr "version" (defaultVersionName p) <>
xattr "license" (license p) <>
xattr "infoURL" (baseUrl `T.append` packageVersionUrl p)