1module ProjectM36.Relation.Show.HTML where
3import ProjectM36.Relation
6import qualified Data.List as L
7import ProjectM36.Attribute
8import Data.Text (append, Text, pack)
9import qualified Data.Text as T
10import qualified Data.Text.IO as TIO
12attributesAsHTML :: Attributes -> Text
13attributesAsHTML attrs = "<tr>" `append` (T.concat $ map oneAttrHTML attrNameList) `append` "</tr>"
15 oneAttrHTML attrName = "<th>" `append` attrName `append` "</th>"
16 attrNameList = sortedAttributeNameList (attributeNameSet attrs)
18relationAsHTML :: Relation -> Text
19relationAsHTML rel@(Relation attrNameSet tupleSet) = "<table border=\"1\">" `append` (attributesAsHTML attrNameSet) `append` (tupleSetAsHTML tupleSet) `append` "<tfoot>" `append` tablefooter `append` "</tfoot></table>"
21 tablefooter = "<tr><td colspan=\"100%\">" `append` (pack $ show (cardinality rel)) `append` " tuples</td></tr>"
23writeHTML :: Text -> IO ()
24writeHTML = TIO.writeFile "/home/agentm/rel.html"
26writeRel :: Relation -> IO ()
27writeRel = writeHTML . relationAsHTML
29tupleAsHTML :: RelationTuple -> Text
30tupleAsHTML tuple = "<tr>" `append` T.concat (L.map tupleFrag (tupleSortedAssocs tuple)) `append` "</tr>"
32 tupleFrag tup = "<td>" `append` atomToText (snd tup) `append` "</td>"
34tupleSetAsHTML :: RelationTupleSet -> Text
35tupleSetAsHTML tupSet = foldr folder "" (asList tupSet)
37 folder tuple acc = acc `append` tupleAsHTML tuple
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list