packages feed

claferwiki 0.4.5 → 0.5.8

raw patch · 10 files changed

+333/−254 lines, 10 filesdep +happstack-serverdep +textdep −MissingHdep −SHAdep −mtldep ~basedep ~claferdep ~containersPVP ok

version bump matches the API change (PVP)

Dependencies added: happstack-server, text

Dependencies removed: MissingH, SHA, mtl, network, network-uri, time, transformers-compat

Dependency ranges changed: base, clafer, containers, gitit, split, transformers

API changes (from Hackage documentation)

Files

CHANGES.md view
@@ -1,3 +1,53 @@+* claferwiki Version 0.5.8, Nov 15, 2026++Minor release with Clafer 0.5.8.++* Builds with GHC 9.12.4 (Stackage nightly-2026-11-11) and still with GHC 9.6.7. The stack build uses gitit 0.16.1 of the snapshot, which can also load plugins when it is linked dynamically ([jgm/gitit#714](https://github.com/jgm/gitit/pull/714)).+* No longer depends on `MissingH`, `network-bsd`, `network`, `network-uri`, `SHA`, `time`, `mtl` and `transformers-compat`. Without a `Host` header in the request (HTTP/1.0), the links to the wiki use `localhost` and the configured port instead of the name of the machine.++* claferwiki Version 0.5.7, Nov 8, 2026++Minor release with Clafer 0.5.7.++* claferwiki Version 0.5.6, Nov 1, 2026++Minor release with Clafer 0.5.6.++* The models and their graphs show expressions with the parentheses that the grammar requires, e.g., `[ (1 + 2) * 3 = 9 ]`, which was shown as `[ 1 + 2 * 3 = 9 ]`.++* claferwiki Version 0.5.5, Oct 27, 2026++Minor release with Clafer 0.5.5.++* Models can use decimals, a new primitive type `decimal` with a fixed number of fractional digits, e.g., `cost -> decimal = 19.99`.+* The buttons for ClaferIDE, ClaferConfigurator, and ClaferMooVisualizer can link to the tools under paths, e.g., `https://wiselab.uwaterloo.ca/claferide/`: the environment variables `CLAFERIDE_URL`, `CLAFERCONFIGURATOR_URL`, and `CLAFERMOOVISUALIZER_URL` give the tools' URLs (by default, still the ports 8094, 8093, and 8092). Behind a reverse proxy, the model's URL in the links follows the headers `X-Forwarded-Proto` and `X-Forwarded-Prefix`, e.g., `https://wiselab.uwaterloo.ca/modelwiki/clafer/<page>.cfr`, so the proxy no longer needs to rewrite the links. The links no longer contain the port 80 when the wiki is reached without a port.++* claferwiki Version 0.5.4, Oct 25, 2026++Minor release with Clafer 0.5.4.++* The model graphs contain only the `svg` element of Graphviz's output, without its XML declaration, DOCTYPE and comments, which do not belong in an HTML page. HTML rewriting proxies, such as Apache's `mod_proxy_html`, mangled them and showed the graphs' double-click handler as text in the model summary.+* `custom.css` imports gitit's `highlighting.css` instead of `hk-pyg.css`, which gitit no longer provides: every page requested a missing stylesheet, and code blocks had no syntax highlighting.+* The live demo is at https://wiselab.uwaterloo.ca/modelwiki/.++[Release](https://github.com/gsdlab/claferwiki/pull/22)++* claferwiki Version 0.5.3, Oct 15, 2026++Minor release with Clafer 0.5.3.++* The buttons for ClaferIDE, ClaferConfigurator, and ClaferMooVisualizer link to the host and port that the browser used to reach the wiki (the `Host` or `X-Forwarded-Host` header), instead of the short host name of the machine, which made the links unreachable (e.g., `http://t3-necsis:8094/` instead of `http://t3-necsis.cs.uwaterloo.ca:8094/`).++[Release](https://github.com/gsdlab/claferwiki/pull/21)++* claferwiki Version 0.5.2 released on Oct 9, 2026++[Release](https://github.com/gsdlab/claferwiki/pull/20)++* claferwiki Version 0.5.1 released on Aug 24, 2023++[Release](https://github.com/gsdlab/claferwiki/pull/19)+ * claferwiki Version 0.4.5 released on Mar 13, 2017  [Release](https://github.com/gsdlab/claferwiki/pull/18)
LICENSE view
@@ -1,4 +1,5 @@-Copyright 2012-2017 Generative Software Development Lab <http://gsd.uwaterloo.ca>+Copyright 2012-2019 Generative Software Development Lab <http://gsd.uwaterloo.ca>+Copyright 2019-2023 Intelligent Systems Development Lab <https://uwaterloo.ca/wise-lab/>  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in
− Makefile
@@ -1,30 +0,0 @@-all:-	stack build--install:-	stack install-	stack install gitit-	@if test ! -d ".git"; then \-		cp -f  -r .git $(to); \-	fi-	mkdir -p $(to)-	cp -f stack.yaml $(to)-	cp -f  gitit.cnf $(to)-	cp -f  claferwiki.sh $(to)-	chmod +x $(to)/claferwiki.sh-	cp -f  README.md $(to)-	mkdir -p $(to)/static/img-	cp -f  static/img/logo.png $(to)/static/img-	mkdir -p $(to)/static/css-	cp -f  static/css/custom.css $(to)/static/css/custom.css-	cp -f  static/css/clafer.css $(to)/static/css/clafer.css--update:-	cp -f  claferwiki.sh $(to)-	cp -f  README.md $(to)-	cp -f  static/img/logo.png $(to)/static/img-	cp -f  static/css/custom.css $(to)/static/css/custom.css-	cp -f  static/css/clafer.css $(to)/static/css/clafer.css--clean:-	stack clean
README.md view
@@ -1,6 +1,6 @@ # Claferwiki -##### v0.4.5+##### v0.5.8  **Claferwiki** is a wiki system integrated with [Clafer compiler](https://github.com/gsdlab/clafer). [Clafer](http://clafer.org) is a lightweight yet powerful structural modeling language. Claferwiki allows for embedding Clafer model fragments in wiki pages and provides model authoring support including code highlighting, parse and semantic error reporting, hyperlinking from identifier use to its definition, and graphical view rendering. @@ -17,49 +17,32 @@  ### Live demo -[Try me!](http://t3-necsis.cs.uwaterloo.ca:8091/)+[Try me!](https://wiselab.uwaterloo.ca/modelwiki/) Also the [Railway Wiki](https://wiselab.uwaterloo.ca/railwaywiki/) and the [Traffic Lights Wiki](https://wiselab.uwaterloo.ca/trafficlightswiki/). -If the demo is down or you encounter a bug, please email [Michal Antkiewicz](mailto:mantkiew@gsd.uwaterloo.ca).+If the demo is down or you encounter a bug, please email [Michal Antkiewicz](mailto:michal.antkiewicz@uwaterloo.ca).  ## Contributors -* [Michał Antkiewicz](http://gsd.uwaterloo.ca/mantkiew), Main developer. Requirements, development, architecture, testing, technology transfer.+* [Michał Antkiewicz](https://uwaterloo.ca/wise-lab/profiles/michal-antkiewicz), Main developer. Requirements, development, architecture, testing, technology transfer. * Chris Walker, co-op student May-Aug, 2012. Developer of Clafer Wiki, HTML and GraphViz generators. * [Jimmy Liang](http://gsd.uwaterloo.ca/jliang), Clafer compiler support, including multi-fragment compilation, source/AST/IR traceability, parsing and compilation error reporting.  ## Getting the Clafer Wiki -Clafer can be installed either from Hackage or from the source code.--### Dependencies for running+ClaferWiki is a [gitit](https://github.com/jgm/gitit) plugin: gitit loads it when it starts,+compiling it with GHC, so GHC and the claferwiki package must be available where gitit runs. -Regardless of the installation method, the following are required:+### Dependencies -* [Clafer compiler](https://github.com/gsdlab/clafer/) v0.4.5-* [GHC](https://www.haskell.org/downloads) >= v7.10.*+* [Clafer compiler](https://github.com/gsdlab/clafer/) v0.5.8+* [GHC](https://www.haskell.org/downloads) v9.6.7 or v9.12.4+* [cabal-install](https://hackage.haskell.org/package/cabal-install) >= v3.10.3 (when building with `cabal`) * [Git](http://git-scm.com)-* [Gitit wiki](http://hackage.haskell.org/package/gitit) v0.12.2.1+* [Gitit wiki](http://hackage.haskell.org/package/gitit) v0.16.1 with plugin support (the `plugins` flag).+  A dynamically linked gitit (for example, from a Linux distribution) can only load plugins since v0.16.1+  ([jgm/gitit#714](https://github.com/jgm/gitit/pull/714)). * GraphViz -### Installation from Hackage--Claferwiki is now available on [Hackage](http://hackage.haskell.org/package/claferwiki-0.4.5/) and it can be installed using either [`stack`](https://github.com/commercialhaskell/stack) or [`cabal-install`](https://hackage.haskell.org/package/cabal-install).--#### Installation using `stack`--Stack is the only requirement: no other Haskell tooling needs to be installed because stack will automatically install everything that's needed.--1. `stack update`-2. `stack install claferwiki`--#### Installation using `cabal-install`--1. `cabal update`-2. `cabal install claferwiki-0.4.5 -fhighlighting -fhttps -fplugins -fnetwork-uri`-3. `cd <cabal's lib or share folder>`  (`C:\Users\<user>\AppData\Roaming\cabal\i386-windows-ghc-8.0.2\claferwiki-0.4.5` on Windows or `.cabal/share/x86_64-linux-ghc-8.0.2/claferwiki-0.4.5/` on Linux)-  * execute `make install to=<target directory>`-  * this will copy the wiki files- ### Important: branches must correspond  All related projects are following the *simultaneous release model*.@@ -68,42 +51,22 @@ Releases from branches 'master` are guaranteed to work well together. Development versions from branches `develop` should work well together but this might not always be the case. -### Installation from source code+### Installation -1. In some `<source directory>` where you want to have the wiki source code-   * execute `git clone git://github.com/gsdlab/claferwiki.git`-2. execute `stack update`-3. execute `make init`-4. [install clafer from source code](https://github.com/gsdlab/clafer#installation-from-the-source-code)-4. execute `make`-5. execute `make install to=<target directory>`-  * this will copy the wiki files-6. in `<target directory>`, execute `git init` to create a git repository for the wiki data-  * NOTE: see `repository-path:` option in `gitit.cnf`+The plugin library is available on [Hackage](http://hackage.haskell.org/package/claferwiki-0.5.4/)+and can be built with either `stack` or `cabal-install`: +* `stack build` in a clone of this repository builds claferwiki and gitit;+  start the wiki with `stack exec gitit -- -f gitit.cnf` (or `./claferwiki.sh`), so that gitit finds the packages.+* `cabal install --lib claferwiki` installs the library into the default GHC package environment,+  where gitit finds it; start the wiki with `gitit -f gitit.cnf`. +The wiki needs `gitit.cnf`, `static/` and `templates/` from this repository in the directory where gitit runs.+ # Usage  Wiki can be configured by editing the `gitit.cnf` file. See [Configuring and customizing gitit](http://gitit.net/README#configuring-and-customizing-gitit).--#### Installation using `stack`--* in the `<target directory>` execute `stack exec gitit -- -f gitit.cnf` to start the wiki server.--#### Using `cabal-install`--* in the `<target directory>` execute `claferwiki.sh` to start the wiki server.--The script can either use gitit and clafer installed in the user package space (default) or in the sandbox. The sandbox location can be provided using the parameter `--sandbox` as follows:--* `./claferwiki.sh --sandbox <relative or absolute path to the sandbox>`, or-* `./claferwiki.sh --sandbox` which will use the default sandbox location `../.clafertools-cabal-sandbox`--## Update--* in the `<source directory>` execute `git pull`-* execute `make update to=<target directory>`-  * this will keep the directory structure and your existing git repository with the wiki contents+The wiki data is a git repository; see the `repository-path:` option in `gitit.cnf`.  ## Features @@ -144,6 +107,20 @@ \`\`\`  To have the code blocks correctly processed, make sure to add an empty line before and after the code block, even if the code block is the last element on the page.++The blocks `{.clafer .ide}`, `{.clafer .config}`, and `{.clafer .mooviz}` become buttons that open the page's model in ClaferIDE, ClaferConfigurator, and ClaferMooVisualizer.+By default, the buttons link to the tools' ports 8094, 8093, and 8092 on the host that the browser used to reach the wiki.+The environment variables `CLAFERIDE_URL`, `CLAFERCONFIGURATOR_URL`, and `CLAFERMOOVISUALIZER_URL` give the tools' URLs instead, either full URLs or paths on the wiki's host, e.g., `CLAFERIDE_URL=/claferide/`.++Behind a reverse proxy, the wiki takes its own URL, which the tools load the model from, from the headers `X-Forwarded-Host`, `X-Forwarded-Proto`, and `X-Forwarded-Prefix`, e.g., with Apache:++```+ProxyPass /modelwiki/ http://127.0.0.1:8091/+<Location /modelwiki/>+    RequestHeader set X-Forwarded-Proto "https"+    RequestHeader set X-Forwarded-Prefix "/modelwiki"+</Location>+```  ## How it works 
claferwiki.cabal view
@@ -1,55 +1,47 @@-Name:                   claferwiki-version:                0.4.5-stability:              experimental+cabal-version:          3.8+name:                   claferwiki+version:                0.5.8 author:                 Michał Antkiewicz, Chris Walker, Luke Michael Brown-maintainer:             Michał Antkiewicz <mantkiew@gsd.uwaterloo.ca>+maintainer:             Michał Antkiewicz <michal.antkiewicz@uwaterloo.ca> synopsis:               A wiki-based IDE for literate modeling with Clafer description:            A wiki-based IDE for literate modeling with Clafer. A Plugin for the Gitit wiki which collects code blocks written in Clafer (.clafer), compiles them, renders into HTML and Dot, and replaces the code blocks with the results. homepage:               http://github.com/gsdlab/claferwiki+stability:              Experimental category:               Wiki build-type:             Simple copyright:              Michal Antkiewicz, Chris Walker, Luke Michael Brown license:                MIT license-file:           LICENSE-Tested-with:            GHC == 7.10.3-                      , GHC == 8.0.1-                      , GHC == 8.0.2-Cabal-version:          >= 1.22+Tested-with:            GHC == 9.6.7 || == 9.12.4 data-files:             claferwiki.sh                       , gitit.cnf-                      , Makefile                       , README.md-                      , CHANGES.md                       , static/img/logo.png                       , static/css/clafer.css                       , static/css/custom.css                       , templates/footer.st                       , stack.yaml+extra-doc-files:        CHANGES.md source-repository head     type:               git-    location:           git://github.com/gsdlab/claferwiki.git+    location:           https://github.com/gsdlab/claferwiki.git+ library-  build-tools  :        ghc >= 7.10.3   default-language:     Haskell2010-  build-depends:        base >= 4.7.0.1 && < 5-                      , containers >= 0.5.5.1+  build-depends:        base >= 4.18.3.0 && < 5+                      , containers >= 0.5.7.1                       , directory >= 1.2.1.0                       , process >= 1.2.0.0-                      , time >= 1.4.2-                      , transformers >= 0.3.0.0+                      , transformers >= 0.6 -                      , mtl >= 2.1.3.1-                      , network >= 2.4.2.3-                      , split >= 0.2.2+                      , split >= 0.2.3.2+                      , text >= 2.0 -                      , MissingH >= 1.3.0.1-                      , network-uri >= 2.6.0.3-                      , SHA >= 1.6.4.2                       , utf8-string >= 0.3.8-                      , gitit >= 0.12.0.1-                      , transformers-compat >= 0.3+                      , gitit >= 0.15.1.1+                      , happstack-server >= 7.0 -                      , clafer == 0.4.5+                      , clafer == 0.5.8   hs-source-dirs:       src   ghc-options:          -Wall -fno-warn-orphans   exposed-modules:      Network.Gitit.Plugin.ClaferWiki
claferwiki.sh view
@@ -1,5 +1,5 @@ echo "-----------------------------------------"-echo "| ClaferWiki v0.4.5                     |"+echo "| ClaferWiki v0.5.8                     |" echo "| https://github.com/gsdlab/claferwiki/ |" echo "| By Michal Antkiewicz, Chris Walker    |" echo "| Generative Software Development Lab   |"
src/Network/Gitit/Plugin/ClaferWiki.hs view
@@ -1,6 +1,6 @@-{-# LANGUAGE OverloadedStrings #-} {-- Copyright (C) 2012-2014 Michal Antkiewicz, Chris Walker <http://gsd.uwaterloo.ca>+ Copyright 2012-2019 Generative Software Development Lab <http://gsd.uwaterloo.ca>+ Copyright 2019-2023 Intelligent Systems Development Lab <https://uwaterloo.ca/wise-lab/>   Permission is hereby granted, free of charge, to any person obtaining a copy of  this software and associated documentation files (the "Software"), to deal in@@ -20,32 +20,36 @@  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE  SOFTWARE. -}-{-# LANGUAGE NamedFieldPuns #-}+{-# LANGUAGE NamedFieldPuns, OverloadedStrings #-} -- | A plugin for Gitit which integrates the Clafer compiler and links to other--- Clafer web tools: <http://https://github.com/gsdlab/ClaferIDE ClaferIDE>,--- <http://https://github.com/gsdlab/ClaferConfigurator ClaferConfigurator>, and--- <http://https://github.com/gsdlab/ClaferMooVisualizer ClaferMooVisualizer>+-- Clafer web tools: <https://github.com/gsdlab/ClaferIDE ClaferIDE>,+-- <https://github.com/gsdlab/ClaferConfigurator ClaferConfigurator>, and+-- <https://github.com/gsdlab/ClaferMooVisualizer ClaferMooVisualizer> module Network.Gitit.Plugin.ClaferWiki (plugin) where  import Network.Gitit.Interface -import Control.Applicative-import Control.Monad-import Control.Monad.Trans.State-import Data.List-import Data.List.Split+import Control.Applicative ((<|>))+import Control.Monad (unless)+import Control.Monad.Trans.State (evalState, get, gets, put, State)+import Data.ByteString.UTF8 (toString)+import Data.Char (isDigit, isSpace)+import Data.List (dropWhileEnd, intercalate, isPrefixOf, isSuffixOf, nub, tails)+import Data.List.Split (splitOn) import qualified Data.Map as Map-import Data.String.Utils (replace)-import Network.BSD (getHostName)+import Data.Maybe (fromMaybe)+import qualified Data.Text as T+import Data.Text.Lazy (toStrict)+import Data.Text.Lazy.Builder (Builder,  fromString, toLazyText, singleton)+import Happstack.Server (Request, getHeader) import System.Directory (createDirectoryIfMissing, doesFileExist)+import System.Environment (lookupEnv) import System.Process (readProcessWithExitCode)  import Language.Clafer-import Language.Clafer.Css as Css+import Language.Clafer.Css as Css (css, header) import Language.Clafer.Generator.Html (highlightErrors) -import Prelude- -- | claferWiki collects Clafer code from .clafer code blocks, renders as HTML and graph, --   and replaces the original blocks with RawBlocks containing the results plugin :: Plugin@@ -60,16 +64,19 @@         cssExist <- doesFileExist "static/css/clafer.css"         unless cssExist $ writeFile "static/css/clafer.css" css -    serverURL <- liftIO $ getHostName+    request <- askRequest     pageName <- getPageName     config <- askConfig+    [mooVizSetting, configuratorSetting, ideSetting] <-+        liftIO $ mapM lookupEnv ["CLAFERMOOVISUALIZER_URL", "CLAFERCONFIGURATOR_URL", "CLAFERIDE_URL"]      let-        serverPort = show $ portNumber config+        address = wikiAddress (show $ portNumber config) request         -- produce the required outputs in a single compilation         allCompilationResults = compileFragments fragments claferModes          htmlCode = extractOutput allCompilationResults Html+        htmlCodeFragments :: [String]         htmlCodeFragments = splitOn "\n<!-- # FRAGMENT /-->\n" htmlCode          stats = maybe "No model." statistics $ extractCompilerResult allCompilationResults Html@@ -83,19 +90,21 @@     (_, svgGraphWithRefs, _) <- liftIO $ readProcessWithExitCode "dot" [ "-Tsvg" ] $ changeTransparentToLightGray dotGraph     (_, svgCVLGraph, _) <- liftIO $ readProcessWithExitCode "dot" [ "-Tsvg" ] dotCVLGraph -        -- using the WikiEnv as state, replace clafer code blocks with appropriate results:-        -- html rendering of clafer code, graph rendering, download links, ide, configurator, and visualizer buttons+    -- using the WikiEnv as state, replace clafer code blocks with appropriate results:+    -- html rendering of clafer code, graph rendering, download links, ide, configurator, and visualizer buttons     let         initialWikiEnv = WikiEnv {                             we_fileName = pageName,-                            we_serverURL = serverURL,-                            we_serverPort = serverPort,+                            we_wikiURL = wa_wikiURL address,+                            we_mooVizURL = toolURL address "8092" mooVizSetting,+                            we_configuratorURL = toolURL address "8093" configuratorSetting,+                            we_ideURL = toolURL address "8094" ideSetting,                             we_htmlCodeFragments = htmlCodeFragments,                             we_stats = stats,                             we_graphNo = 0,     -- needed to construct unique IDs of <div> for graphs-                            we_svgGraphWithRefs = svgGraphWithRefs,-                            we_svgGraphWithoutRefs = svgGraphWithoutRefs,-                            we_svgCVLGraph = svgCVLGraph+                            we_svgGraphWithRefs = inlineSvg svgGraphWithRefs,+                            we_svgGraphWithoutRefs = inlineSvg svgGraphWithoutRefs,+                            we_svgCVLGraph = inlineSvg svgCVLGraph                          }         newPandoc = evalState (bottomUpM replaceClaferWikiBlocks pandoc) initialWikiEnv @@ -104,22 +113,25 @@     -- save html version     liftIO $ writeFile ("static/clafer/" ++ pageName ++ ".html") $ selfContained htmlCode -    return $ newPandoc+    return newPandoc     where         -- collect clafer model fragments-        fragments :: [ String ]-        fragments = queryWith addFragment pandoc+        fragments :: [String]+        fragments = queryWith extractFragment pandoc          -- collects compiler modes depending on the kinds of blocks on the page         claferModes :: [ ClaferMode ]         claferModes = nub $ queryWith addMode pandoc +        fragmentedModel :: String         fragmentedModel = intercalate "//# FRAGMENT\n" fragments++        completeModel :: String         completeModel = intercalate "\n" fragments -        addFragment :: Block -> [String]-        addFragment (CodeBlock (_, [ "clafer" ], _) code) = [ code ++ "\n" ]-        addFragment _                                     = []+        extractFragment :: Block -> [String]+        extractFragment (CodeBlock (_, [ "clafer" ], _) code) = [ T.unpack code ++ "\n" ]+        extractFragment _                                     = []          addMode :: Block -> [ClaferMode]         addMode (CodeBlock (_, [ "clafer" ], _) _)              = [Html]@@ -134,12 +146,13 @@          extractOutput :: Either [ClaferErr] (Map.Map ClaferMode CompilerResult) -> ClaferMode -> String         extractOutput (Right compilerResultMap) claferMode =-            case (Map.lookup claferMode compilerResultMap) of+            case Map.lookup claferMode compilerResultMap of                 Just CompilerResult{ outputCode } -> outputCode                 Just NoCompilerResult{ reason } -> "Error: No " ++ show claferMode ++ " output. Reason:" ++ reason                 Nothing -> "Error: No " ++ show claferMode ++ " output."         extractOutput (Left err) _ = highlightErrors fragmentedModel err +        selfContained :: String -> String         selfContained htmlCode =             concat [                 Css.header,@@ -154,8 +167,12 @@ -- | Environment (state) for rewriting the page data WikiEnv = WikiEnv {                     we_fileName :: String,-                    we_serverURL :: String,-                    we_serverPort :: String,+                    -- | the wiki's URL as the browser addressed it, ending with /+                    we_wikiURL :: String,+                    -- | the web tools' URLs, ending with /+                    we_mooVizURL :: String,+                    we_configuratorURL :: String,+                    we_ideURL :: String,                     -- | code fragments are consumed                     we_htmlCodeFragments :: [ String ],                     we_stats :: String,@@ -166,20 +183,25 @@                }  +mkHtmlBlock :: Builder -> Block+mkHtmlBlock = RawBlock "html" . toStrict . toLazyText+ replaceClaferWikiBlocks :: Block -> State WikiEnv Block replaceClaferWikiBlocks (CodeBlock (_, [ "clafer" ], _) _) = do     wikiEnv <- get-    let (fragment:fragments) = we_htmlCodeFragments wikiEnv-    put $ wikiEnv { we_htmlCodeFragments = fragments }-    return $ RawBlock "html" ("<div class=\"code\">" ++ fragment ++ "</div>")+    case we_htmlCodeFragments wikiEnv of+        (fragment:fragments) -> do+            put $ wikiEnv { we_htmlCodeFragments = fragments }+            return $ mkHtmlBlock $ "<div class=\"code\">" <> fromString fragment <> "</div>"+        []                   -> return $ Plain []  replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "links" ], _) _) = do     fileName <- gets we_fileName-    return $ RawBlock "html" $ renderLinks fileName+    return $ mkHtmlBlock $ renderLinks fileName  replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "stats" ], _) _) = do     stats <- gets we_stats-    return $ RawBlock "html" $ renderStats stats+    return $ mkHtmlBlock $ renderStats stats  replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "graph" ], _) _) = do     wikiEnv <- get@@ -187,15 +209,15 @@     svgGraphWithRefs <- gets we_svgGraphWithRefs     svgGraphWithoutRefs <- gets we_svgGraphWithoutRefs     put $ wikiEnv { we_graphNo = graphNo + 1 }-    return $ RawBlock "html" $ renderGraphWithToggle svgGraphWithoutRefs svgGraphWithRefs  graphNo+    return $ mkHtmlBlock $ renderGraphWithToggle svgGraphWithoutRefs svgGraphWithRefs graphNo  replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "cvlGraph" ], _) _) =  do     svgCVLGraph <- gets we_svgCVLGraph-    return $ RawBlock "html" $ renderGraph svgCVLGraph+    return $ mkHtmlBlock $ renderGraph svgCVLGraph  replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "cvlgraph" ], _) _) =  do     svgCVLGraph <- gets we_svgCVLGraph-    return $ RawBlock "html" $ renderGraph svgCVLGraph+    return $ mkHtmlBlock $ renderGraph svgCVLGraph  replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "summary" ], _) _) =  do     wikiEnv <- get@@ -205,124 +227,193 @@     svgGraphWithRefs <- gets we_svgGraphWithRefs     svgGraphWithoutRefs <- gets we_svgGraphWithoutRefs     put $ wikiEnv { we_graphNo = graphNo + 1 }-    return $ RawBlock "html" $ renderSummary fileName stats svgGraphWithoutRefs svgGraphWithRefs graphNo+    return $ mkHtmlBlock $ renderSummary fileName stats svgGraphWithoutRefs svgGraphWithRefs graphNo  replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "mooviz" ], _) _) =  do     wikiEnv <- get-    return $ renderAnalyzeWithClaferMooViz (we_fileName wikiEnv) (we_serverURL wikiEnv) (we_serverPort wikiEnv)+    return $ renderAnalyzeWithClaferMooViz (we_fileName wikiEnv) (we_mooVizURL wikiEnv) (we_wikiURL wikiEnv)  replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "config" ], _) _) =  do     wikiEnv <- get-    return $ renderConfigureWithClaferConfigurator (we_fileName wikiEnv) (we_serverURL wikiEnv) (we_serverPort wikiEnv)+    return $ renderConfigureWithClaferConfigurator (we_fileName wikiEnv) (we_configuratorURL wikiEnv) (we_wikiURL wikiEnv)  replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "ide" ], _) _) =  do     wikiEnv <- get-    return $ renderAddOpenInIDE (we_fileName wikiEnv) (we_serverURL wikiEnv) (we_serverPort wikiEnv)+    return $ renderAddOpenInIDE (we_fileName wikiEnv) (we_ideURL wikiEnv) (we_wikiURL wikiEnv)  replaceClaferWikiBlocks block = return block -renderLinks :: String -> String+-- new line builder+nl :: Builder+nl = singleton '\n'++renderLinks :: String -> Builder renderLinks fileName =-    "<div><b>Module Downloads:</b> | <a href=\"/clafer/" ++-    fileName ++-    ".cfr\">[.cfr]</a> | <a href=\"/clafer/" ++-    fileName ++-    ".html\">[.html]</a> |</div><br>\n"+    "<div><b>Module Downloads:</b> | <a href=\"/clafer/" <> nl <>+    fromString fileName <> nl <>+    ".cfr\">[.cfr]</a> | <a href=\"/clafer/" <> nl <>+    fromString fileName <> nl <>+    ".html\">[.html]</a> |</div><br>\n" <> nl -renderStats :: String -> String+renderStats :: String -> Builder renderStats stats =-    "<div><b>Module Statistics:</b> \n| " ++-    (intercalate " | " $ lines stats ) ++-    " |</div><br>\n"-+    "<div><b>Module Statistics:</b> \n| " <> nl <>+    fromString (intercalate " | " (lines stats)) <> nl <>+    " |</div><br>\n" <> nl -renderGraphWithToggle :: String           -> String        -> Int      -> String-renderGraphWithToggle    svgGraphWithoutRefs svgGraphWithRefs graphNo   = unlines [-    "<div id=\"" ++ renderGraphId False graphNo ++  "\" style=\"display:block;width:100%;border:solid lightgray 1px;overflow-x:auto;\" ondblclick=\"" ++ renderShowRefs graphNo ++ "\">",-    svgGraphWithoutRefs,-    "</div>",-    "<div id=\"" ++ renderGraphId True graphNo ++  "\" style=\"display:none;width:100%;border:solid lightgray 1px;overflow-x:auto;\" ondblclick=\"" ++ renderHideRefs graphNo ++ "\">",-    svgGraphWithRefs,-    "</div>" ]+renderGraphWithToggle :: String           -> String        -> Int      -> Builder+renderGraphWithToggle    svgGraphWithoutRefs svgGraphWithRefs graphNo   =+    "<div id=\"" <> renderGraphId False graphNo <> "\" style=\"display:block;width:100%;border:solid lightgray 1px;overflow-x:auto;\" ondblclick=\"" <> renderShowRefs graphNo <> "\">" <> nl <>+    fromString svgGraphWithoutRefs <> nl <>+    "</div>" <> nl <>+    "<div id=\"" <> renderGraphId True graphNo <>  "\" style=\"display:none;width:100%;border:solid lightgray 1px;overflow-x:auto;\" ondblclick=\"" <> renderHideRefs graphNo <> "\">" <> nl <>+    fromString svgGraphWithRefs <> nl <>+    "</div>" <> nl -renderGraph :: String  -> String-renderGraph    svgGraph = unlines [-    "<div style=\"display:block;width:100%;border:solid lightgray 1px;overflow-x:auto;\">",-    svgGraph,-    "</div>" ]+renderGraph :: String  -> Builder+renderGraph    svgGraph = +    "<div style=\"display:block;width:100%;border:solid lightgray 1px;overflow-x:auto;\">" <> nl <>+    fromString svgGraph <> nl <>+    "</div>" <> nl -renderShowRefs :: Int    -> String+renderShowRefs :: Int    -> Builder renderShowRefs    graphNo =-  "var gwr=document.getElementById('" ++ renderGraphId True graphNo ++  "'); gwr.style.display='block'; gwr.scrollLeft=this.scrollLeft; this.style.display='none';"+  "var gwr=document.getElementById('" <> renderGraphId True graphNo <> "'); gwr.style.display='block'; gwr.scrollLeft=this.scrollLeft; this.style.display='none';"  <> nl -renderHideRefs :: Int    -> String+renderHideRefs :: Int    -> Builder renderHideRefs    graphNo =-  "var gwor=document.getElementById('" ++ renderGraphId False graphNo ++  "'); gwor.style.display='block'; gwor.scrollLeft=this.scrollLeft;this.style.display='none';"+  "var gwor=document.getElementById('" <> renderGraphId False graphNo <>  "'); gwor.style.display='block'; gwor.scrollLeft=this.scrollLeft;this.style.display='none';" <> nl -renderGraphId :: Bool -> Int    -> String-renderGraphId    True    graphNo = "graphWithRefs" ++ show graphNo-renderGraphId    False   graphNo = "graphWithoutRefs" ++ show graphNo+renderGraphId :: Bool -> Int    -> Builder+renderGraphId    True    graphNo = fromString $ "graphWithRefs" ++ show graphNo+renderGraphId    False   graphNo = fromString $ "graphWithoutRefs" ++ show graphNo -renderSummary :: String -> String -> String           -> String        -> Int    -> String+renderSummary :: String -> String -> String           -> String        -> Int    -> Builder renderSummary    fileName  stats     svgGraphWithoutRefs svgGraphWithRefs graphNo =-    renderGraphWithToggle svgGraphWithoutRefs svgGraphWithRefs graphNo ++-    renderStats stats +++    renderGraphWithToggle svgGraphWithoutRefs svgGraphWithRefs graphNo <>+    renderStats stats <>     renderLinks fileName --compileFragments :: [ String ] -> [ ClaferMode ] -> Either [ClaferErr] (Map.Map ClaferMode CompilerResult)-compileFragments    fragments     claferModes    =+compileFragments :: [String] -> [ClaferMode] -> Either [ClaferErr] (Map.Map ClaferMode CompilerResult)+compileFragments    fragments   claferModes   =     -- compile all clafer code     runClafer defaultClaferArgs{                 mode=claferModes,                 keep_unused=True,                 add_comments=True,-                show_references=False } $ do-                                            mapM_ addModuleFragment fragments-                                            parse-                                            iModule <- desugar Nothing-                                            compile iModule-                                            generate-+                show_references=False } $+        do+            mapM_ addModuleFragment fragments+            parse+            iModule <- desugar Nothing+            compile iModule+            generate  renderAnalyzeWithClaferMooViz :: String -> String -> String -> Block-renderAnalyzeWithClaferMooViz fileName serverURL serverPort =-    RawBlock "html" (unlines [-      "<div>" ++-      "<a href=\"http://" ++ serverURL ++ ":8092/?claferFileURL=http://" ++ serverURL ++ ":" ++ serverPort ++ "/clafer/" ++-      fileName ++-      ".cfr\" target=\"_blank\" " ++-      "style=\"background-color: #ccc;color: white;text-decoration: none;padding: 1px 5px 1px 5px;\" >" ++-      "Analyze with ClaferMooVisualizer" ++-      "</a></div><br>\n"-      ])+renderAnalyzeWithClaferMooViz fileName toolURL' wikiURL =+    mkHtmlBlock +      ("<div>" <> nl <>+      "<a href=\"" <> fromString (escapeAttribute toolURL') <> "?claferFileURL=" <> fromString (escapeAttribute wikiURL) <> "clafer/" <> nl <>+      fromString fileName <> nl <>+      ".cfr\" target=\"_blank\" " <> nl <>+      "style=\"background-color: #ccc;color: white;text-decoration: none;padding: 1px 5px 1px 5px;\" >" <> nl <>+      "Analyze with ClaferMooVisualizer" <> nl <>+      "</a></div><br>" <> nl :: Builder)  renderConfigureWithClaferConfigurator :: String -> String -> String -> Block-renderConfigureWithClaferConfigurator fileName serverURL serverPort =-    RawBlock "html" (unlines [-      "<div>" ++-      "<a href=\"http://" ++ serverURL ++ ":8093/?claferFileURL=http://" ++ serverURL ++ ":" ++ serverPort ++ "/clafer/" ++-      fileName ++-      ".cfr\" target=\"_blank\" " ++-      "style=\"background-color: #ccc;color: white;text-decoration: none;padding: 1px 5px 1px 5px;\" >" ++-      "Configure with ClaferConfigurator" ++-      "</a></div><br>\n"-      ])+renderConfigureWithClaferConfigurator fileName toolURL' wikiURL =+    mkHtmlBlock +      ("<div>" <> nl <>+      "<a href=\"" <> fromString (escapeAttribute toolURL') <> "?claferFileURL=" <> fromString (escapeAttribute wikiURL) <> "clafer/" <> nl <>+      fromString fileName <> nl <>+      ".cfr\" target=\"_blank\" " <> nl <>+      "style=\"background-color: #ccc;color: white;text-decoration: none;padding: 1px 5px 1px 5px;\" >" <> nl <>+      "Configure with ClaferConfigurator" <> nl <>+      "</a></div><br>\n" :: Builder)  renderAddOpenInIDE :: String -> String -> String -> Block-renderAddOpenInIDE fileName serverURL serverPort =-    RawBlock "html" (unlines [-      "<div>" ++-      "<a href=\"http://" ++ serverURL ++ ":8094/?claferFileURL=http://" ++ serverURL ++ ":" ++ serverPort ++ "/clafer/" ++-      fileName ++-      ".cfr\" target=\"_blank\" " ++-      "style=\"background-color: #ccc;color: white;text-decoration: none;padding: 1px 5px 1px 5px;\" >" ++-      "Open in ClaferIDE" ++-      "</a></div><br>\n"-      ])+renderAddOpenInIDE    fileName  toolURL' wikiURL =+    mkHtmlBlock +      ("<div>" <> nl <>+      "<a href=\"" <> fromString (escapeAttribute toolURL') <> "?claferFileURL=" <> fromString (escapeAttribute wikiURL) <> "clafer/" <> nl <>+      fromString fileName <> nl <>+      ".cfr\" target=\"_blank\" " <> nl <>+      "style=\"background-color: #ccc;color: white;text-decoration: none;padding: 1px 5px 1px 5px;\" >" <> nl <>+      "Open in ClaferIDE" <> nl <>+      "</a></div><br>\n" :: Builder) +-- | The wiki as the browser addressed it, so that the links to the web tools and to the model+--   work from the client.+data WikiAddress = WikiAddress {+                    wa_scheme :: String,+                    -- | the host and the port, e.g., wiselab.uwaterloo.ca or localhost:8091+                    wa_authority :: String,+                    -- | the host without the port+                    wa_host :: String,+                    -- | e.g., https://wiselab.uwaterloo.ca/modelwiki/ or http://localhost:8091/+                    wa_wikiURL :: String+               }++-- | The host and the port from the X-Forwarded-Host header (behind a proxy) or the Host header+--   of the request; without either (only HTTP/1.0 clients omit Host), localhost and the+--   configured port. Behind a reverse proxy, X-Forwarded-Proto gives the+--   scheme (e.g., https) and X-Forwarded-Prefix the path of the wiki (e.g., /modelwiki).+wikiAddress :: String -> Request -> WikiAddress+wikiAddress port request =+    WikiAddress scheme authority (hostOf authority) (scheme ++ "://" ++ authority ++ prefix ++ "/")+  where+    firstValue name = case trim . takeWhile (/= ',') . toString <$> getHeader name request of+        Just value | not (null value) -> Just value+        _                             -> Nothing+    authority = fromMaybe ("localhost:" ++ port) (firstValue "x-forwarded-host" <|> firstValue "host")+    scheme = case firstValue "x-forwarded-proto" of+        Just "https" -> "https"+        _            -> "http"+    prefix = case dropWhileEnd (== '/') <$> firstValue "x-forwarded-prefix" of+        Just path@('/':_) -> path+        Just path         -> '/' : path+        Nothing           -> ""+    -- "host:port", "host", "[::1]:port", or "[::1]"+    hostOf host = case break (== ':') (reverse host) of+        (revPort@(_:_), ':' : revHost) | all isDigit revPort -> reverse revHost+        _                                                    -> host+    trim = dropWhileEnd isSpace . dropWhile isSpace++-- | The URL of a web tool, ending with /: from its environment variable, a URL or a path on the+--   wiki's host (e.g., /claferide/ behind a reverse proxy); by default, the tool's port on the+--   wiki's host.+toolURL :: WikiAddress -> String -> Maybe String -> String+toolURL address defaultPort setting = withSlash $ case setting of+    Just path@('/':_)              -> wa_scheme address ++ "://" ++ wa_authority address ++ path+    Just url | not (null url)      -> url+    _                              -> wa_scheme address ++ "://" ++ wa_host address ++ ":" ++ defaultPort ++ "/"+  where+    withSlash url = if "/" `isSuffixOf` url then url else url ++ "/"++-- | The headers come from the client, so they must not end an attribute.+escapeAttribute :: String -> String+escapeAttribute = concatMap escape+  where+    escape '"' = "&quot;"+    escape '&' = "&amp;"+    escape '<' = "&lt;"+    escape '>' = "&gt;"+    escape c   = [c]+ getPageName:: PluginM String getPageName = replace " " "_" . replace "/" "_" . pgPageName . ctxLayout <$> getContext +-- | dot's SVG output starts with an XML declaration, a DOCTYPE and comments, which+-- do not belong inside an HTML page (and HTML rewriting proxies mangle them);+-- keep only the svg element.+inlineSvg :: String -> String+inlineSvg svg = case filter ("<svg" `isPrefixOf`) (tails svg) of+    svgElement : _ -> svgElement+    []             -> svg+ changeTransparentToLightGray :: String -> String changeTransparentToLightGray = replace "color=transparent" "color=lightgray"++-- | Replaces every occurrence of the first string with the second.+replace :: String -> String -> String -> String+replace old new = intercalate new . splitOn old
stack.yaml view
@@ -1,25 +1,23 @@-# For GHC-8.0.2-extra-deps:-  - data-stringmap-1.0.1.1-  - gitit-0.12.2.1-  - sendfile-0.7.9-  - filestore-0.6.3.1-  - json-0.9.1-  - json-builder-0.3-  - recaptcha-0.1.0.3-  - uri-0.1.6.4-  - tagsoup-0.14.1-resolver: lts-8.5+# for GHC-9.12.4+resolver: nightly-2026-11-11  flags:   sendfile:     portable: true   gitit:     plugins: true-    network-uri: true-    https: true-    highlighting: true+  # Link zlib via the zlib package instead of pkg-config. On Arch-based+  # distributions zlib.pc adds -L/usr/lib, which makes the linker pick up the+  # system's identically named libHS*.so files instead of Stack's own.+  digest:+    pkg-config: false  packages: - '../clafer' - '.'++# GHC compiles the modules of a package on 8 threads, which takes a third less time than one+# thread; 16 threads are not faster.+# (build: semaphore: true, GHC's -jsem, fails with Stack 3.11.1: "semOpen: does not exist".)+ghc-options:+  "$everything": -j8
static/css/custom.css view
@@ -1,5 +1,5 @@ @import url("screen.css"); /* default gitit screen styles */-@import url("hk-pyg.css"); /* for syntax highlighting */+@import url("highlighting.css"); /* for syntax highlighting */ @import url("clafer.css"); /* for syntax highlighting for Clafer */  /* Put your custom style modifications here: */
templates/footer.st view
@@ -1,1 +1,1 @@-<div id="footer">powered by <a href="http://github.com/jgm/gitit/tree/master/">gitit-0.12.2.1</a> and <a href="https://github.com/gsdlab/clafer">clafer-0.4.5</a></div>+<div id="footer">powered by <a href="http://github.com/jgm/gitit/tree/master/">gitit-0.16</a> and <a href="https://github.com/gsdlab/clafer">clafer-0.5.8</a></div>