gdritter repos tms / e5936bd
Basic schema + examples for what is currently TMS Getty Ritter 7 years ago
10 changed file(s) with 294 addition(s) and 0 deletion(s). Collapse all Expand all
1 *~
2 dist-newstyle
3 .ghc.environment*
4 .dante-dist
1 Copyright (c) 2017, Getty Ritter
2 All rights reserved.
3
4 Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
5
6 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
7
8 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
9
10 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
11
12 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
1 <!DOCTYPE html>
2 <html>
3 <head>
4 </head>
5 <body>
6 <div class="all">
7 <div class="header"><h1>what happens when computer</h1></div>
8 <div class="nav">{{{ menu }}}</div>
9 <div class="main">{{{ content }}}</div>
10 {{#tag_list}}
11 <div class="tags">
12 <ul>
13 {{tags}}
14 <a href="tag/{{tag}}" class="tag">{{tag}}</a>
15 {{/tags}}
16 </ul>
17 </div>
18 {{/tag_list}}
19 <div class="footer">&copy; 2017 getty ritter</div>
20 </div>
21 </body>
22 </html>
1 {
2 name "what happens when computer"
3
4 artifacts [
5 (every "posts/%.telml" {
6 produce "posts/%.html"
7 arguments {
8 content (render (telml standard))
9 url target
10 }
11 })
12
13 (every "pages/%.telml" {
14 produce "%.html"
15 renderer (telml standard)
16 })
17
18 (all "posts/*.telml" {
19 produce "archive.html"
20 renderer (telml standard)
21 })
22
23 (all "posts/*.telml" {
24 produce "tags.html"
25 renderer (telml standard)
26 })
27
28 (all "posts/*.telml" {
29 produce "feed.xml"
30 renderer (telml rss)
31 })
32 ]
33
34 tagsets {
35 default {
36 center (basic 1 "<div align=\"center\">{{0}}</div>")
37 youtube (basic 3
38 "<div align=\"center\">"
39 "<iframe width=\"" 1 "\" height=\"" 2 "\" "
40 "src=\"http://youtube.com/embed/\"" 0 "\" "
41 "frameborder=\"0\" allowfullscreen></iframe>"
42 "</div>"
43 )
44 audio (basic 1
45 "<div align=\"center\"><audio controls=\"controls\">"
46 "<source src=\"" 0 "\" type=\"audio/mp3\"/>"
47 "</audio></div>"
48 )
49 }
50
51 standard {
52 wd (basic 2 "<span class=\"word\">" 0 "<span class=\"meaning\">" 1 "</span></span>")
53 sidenote (basic 1 "")
54 ref (basic 1 "<label for=\"" 0 "\" class=\"sidenote-number\"></label>")
55 }
56
57 rss {
58 wd (basic 2 0)
59 sidenote (basic 1 "")
60 ref (basic 1 "")
61 }
62 }
63 }
1 <entry>
2 <title>{{title}}</title>
3 <link>{{url}}</link>
4 <id>{{url}}</id>
5 <updated>{{date}}</updated>
6 <author>
7 <name>Getty Ritter</name>
8 <email>what-happens-when-computer@infinitenegativeutility.com</email>
9 </author>
10 <content type="html">
11 <![CDATA[{{{content}}}]]>
12 </content>
13 </entry>
1 {
2 name "simple site"
3
4 defaults {
5 template "main.mustache"
6 }
7
8 artifacts [
9
10 (every "pages/%.md" {
11 produce "pages/%.html"
12 arguments {
13 content (render markdown)
14 title (meta title)
15 }
16 })
17
18 (all "pages/*.md" {
19 produce "combined.html"
20 arguments {
21 renderer (collect (render markdown))
22 title "combined"
23 }
24 })
25
26 (just "pages/index.md" {
27 produce "index.html"
28 arguments {
29 content (render markdown)
30 title "index"
31 }
32 })
33
34 ]
35 }
1 {-# LANGUAGE RecordWildCards #-}
2 {-# LANGUAGE OverloadedStrings #-}
3 {-# LANGUAGE OverloadedLists #-}
4
5 module TMS.Spec where
6
7 import Data.Adnot ((.:), (.:?), (.!=))
8 import qualified Data.Adnot as A
9 import qualified Data.Foldable as F
10 import qualified Data.Map as M
11 import qualified Data.Text as T
12 import qualified Data.Sequence as S
13
14 data TMSSpec = TMSSpec
15 { specName :: T.Text
16 , specArtifacts :: S.Seq Artifact
17 , specDefaults :: M.Map T.Text T.Text
18 , specTagsets :: M.Map T.Text Tagset
19 } deriving (Eq, Show)
20
21 instance A.FromAdnot TMSSpec where
22 parseAdnot = A.withProd "TMSSpec" $ \o -> do
23 specName <- o .: "name"
24 specArtifacts <- o .: "artifacts"
25 specDefaults <- o .:? "defaults" .!= mempty
26 specTagsets <- o .:? "tagsets" .!= mempty
27 return TMSSpec { .. }
28
29 data Artifact
30 = ArtifactEvery T.Text ArtifactDesc
31 | ArtifactAll T.Text ArtifactDesc
32 | ArtifactJust T.Text ArtifactDesc
33 deriving (Eq, Show)
34
35 instance A.FromAdnot Artifact where
36 parseAdnot = A.withSum "artifact" $ \ t as -> do
37 let [pathV, descV] = F.toList as
38 path <- A.parseAdnot pathV
39 desc <- A.parseAdnot descV
40 case t of
41 "every" -> return $ ArtifactEvery path desc
42 "all" -> return $ ArtifactAll path desc
43 "just" -> return $ ArtifactJust path desc
44 _ -> Left "???"
45
46
47 data ArtifactDesc = ArtifactDesc
48 { artifactProduces :: T.Text
49 , artifactTagset :: Maybe T.Text
50 , artifactArgs :: M.Map T.Text ArgExpr
51 } deriving (Eq, Show)
52
53 instance A.FromAdnot ArtifactDesc where
54 parseAdnot = A.withProd "artifact description" $ \ o -> do
55 artifactProduces <- o .: "produce"
56 artifactTagset <- o .:? "tagset"
57 artifactArgs <- o .:? "arguments" .!= mempty
58 return ArtifactDesc { .. }
59
60 data ArgExpr
61 = StringExpr T.Text
62 | CallExpr T.Text (S.Seq ArgExpr)
63 deriving (Eq, Show)
64
65 instance A.FromAdnot ArgExpr where
66 parseAdnot (A.Sum tag payload) = do
67 args <- mapM A.parseAdnot (F.toList payload)
68 return (CallExpr tag (S.fromList args))
69 parseAdnot (A.String s) = return (StringExpr s)
70
71 type Tagset = M.Map T.Text TagDesc
72
73 data TagDesc = BasicTag Int [TagFragment] deriving (Eq, Show)
74
75 instance A.FromAdnot TagDesc where
76 parseAdnot = A.withSum "tag description" $ \ t vs -> do
77 let (r:rs) = F.toList vs
78 n' <- A.parseAdnot r
79 rs' <- mapM A.parseAdnot rs
80 return (BasicTag n' rs')
81
82
83 data TagFragment
84 = TFString T.Text
85 | TFIndex Int
86 deriving (Eq, Show)
87
88 instance A.FromAdnot TagFragment where
89 parseAdnot (A.Integer n) = return (TFIndex (fromIntegral n))
90 parseAdnot (A.String t) = return (TFString t)
91 parseAdnot _ = Left "Invalid fragment type"
1 module TMS where
2
3 import qualified Data.Adnot as A
4 import qualified Data.ByteString as BS
5
6 import qualified TMS.Spec as Spec
7
8 main :: IO ()
9 main = do
10 f <- BS.getContents
11 print (A.decodeEither f :: Either String Spec.TMSSpec)
1 module Main where
2
3 import qualified TMS
4
5 main :: IO ()
6 main = TMS.main
1 name: tms
2 version: 0.1.0.0
3 -- synopsis:
4 -- description:
5 license: BSD3
6 license-file: LICENSE
7 author: Getty Ritter <gdritter@galois.com>
8 maintainer: Getty Ritter <gdritter@galois.com>
9 copyright: ©2017 Getty Ritter
10 -- category:
11 build-type: Simple
12 cabal-version: >= 1.14
13
14 library
15 exposed-modules: TMS
16 , TMS.Spec
17 hs-source-dirs: src
18 build-depends: base >=4.7 && <5
19 , adnot
20 , bytestring
21 , stache
22 , shake
23 , text
24 , containers
25 , telml
26 , telml-markup
27 default-language: Haskell2010
28 default-extensions: ScopedTypeVariables
29
30 executable tms
31 hs-source-dirs: tms
32 main-is: Main.hs
33 default-extensions: ScopedTypeVariables
34 ghc-options: -Wall
35 build-depends: base >=4.7 && <5
36 , tms
37 default-language: Haskell2010