packages feed

claferwiki 0.3.7 → 0.3.8

raw patch · 5 files changed

+81/−62 lines, 5 filesdep ~claferdep ~gititdep ~utf8-string

Dependency ranges changed: clafer, gitit, utf8-string

Files

Makefile view
@@ -3,9 +3,9 @@ 
 init:
 	cabal sandbox init --sandbox=../.clafertools-cabal-sandbox
-	cabal install pandoc-1.13.1 -fhighlighting -fhttps
+	cabal install pandoc gitit -fhighlighting -fhttps
 	cabal install --only-dependencies
-	
+
 install:
 	cabal install
 	@if test ! -d ".git"; then \
@@ -21,10 +21,13 @@ 	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+	cp -f  static/css/clafer.css $(to)/static/css/clafer.css
+
+clean:
+	cabal clean
README.md view
@@ -1,7 +1,7 @@ Clafer Wiki
 ===========
 
-v0.3.7
+v0.3.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. 
 
@@ -31,7 +31,7 @@ 
 Regardless of the installation method, the following are required:
 
-* [Clafer compiler](https://github.com/gsdlab/clafer/) v0.3.7.
+* [Clafer compiler](https://github.com/gsdlab/clafer/) v0.3.8.
 * [The Haskell Platform](http://hackage.haskell.org/platform) v2013.2.0.0.
   * Cabal >= 1.18
   * alternatively, GHC v7.6.3.
@@ -42,7 +42,7 @@ 
 1. `cabal update`
 2. `cabal install claferwiki`
-3. `cd <cabal's lib or share folder>`  (`C:\Users\<user>\AppData\Roaming\cabal\i386-windows-ghc-7.6.3\claferwiki-0.3.7` on Windows or `.cabal/share/x86_64-linux-ghc-7.6.3/claferwiki-0.3.7/` on Linux)
+3. `cd <cabal's lib or share folder>`  (`C:\Users\<user>\AppData\Roaming\cabal\i386-windows-ghc-7.6.3\claferwiki-0.3.8` on Windows or `.cabal/share/x86_64-linux-ghc-7.6.3/claferwiki-0.3.8/` on Linux)
   * execute `make install to=<target directory>`
   * this will copy the wiki files
 
@@ -69,6 +69,11 @@ 
 * 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`
+
 Wiki can be configured by editing the `gitit.cnf` file. See [Configuring and customizing gitit](http://gitit.net/README#configuring-and-customizing-gitit).
 
 Update
@@ -141,4 +146,4 @@   * Try a live instance of [ClaferMooVisualizer](http://t3-necsis.cs.uwaterloo.ca:8092)
 * Take a look at (incomplete) [Clafer by examples wiki](https://github.com/gsdlab/clafer/wiki)
 * Browse example models in the [test suite](https://github.com/gsdlab/clafer/tree/master/test/positive) and [MOO examples](https://github.com/gsdlab/clafer/tree/master/spl_configurator/dataset)
-* Post questions, report bugs, suggest improvements [GSD Lab Bug Tracker](http://gsd.uwaterloo.ca:8888/questions/). Tag your entries with `claferwiki` (so that we know what they are related to) and with `michal` (so that Michał gets a notification).+* Post questions, report bugs, suggest improvements [GSD Lab Bug Tracker](http://gsd.uwaterloo.ca:8888/questions/). Tag your entries with `claferwiki` (so that we know what they are related to) and with `michal` (so that Michał gets a notification).
claferwiki.cabal view
@@ -1,5 +1,5 @@ Name:           claferwiki
-version:        0.3.7
+version:        0.3.8
 stability:      experimental
 author:         Michał Antkiewicz, Chris Walker, Luke Michael Brown
 maintainer:     Michał Antkiewicz <mantkiew@gsd.uwaterloo.ca>
@@ -23,11 +23,11 @@ source-repository head
     type:           git
     location:       git://github.com/gsdlab/claferwiki.git
-library 
+library
   build-tools  :   ghc >= 7.6.3
   default-language:
                    Haskell2010
-  build-depends:   
+  build-depends:
                    base >= 4.6.0.1 && < 5,
                    containers >= 0.5.0.0,
                    directory >= 1.2.0.1,
@@ -38,13 +38,13 @@ 
                    mtl >= 2.1.2,
                    transformers >= 0.3.0.0,
-                   
+
                    MissingH >= 1.2.1.0,
                    SHA >= 1.6.4,
-                   utf8-string >= 0.3.7,
-                   gitit == 0.10.5.1,
+                   utf8-string >= 0.3.8,
+                   gitit >= 0.10.5.1,
 
-                   clafer == 0.3.7
+                   clafer == 0.3.8
   hs-source-dirs:  src
   ghc-options:     -Wall -fno-warn-unused-do-bind -fno-warn-orphans
   exposed-modules:
claferwiki.sh view
@@ -1,5 +1,5 @@ echo "-----------------------------------------"
-echo "| ClaferWiki v0.3.7                     |"
+echo "| ClaferWiki v0.3.8                     |"
 echo "| https://github.com/gsdlab/claferwiki/ |"
 echo "| By Michal Antkiewicz, Chris Walker    |"
 echo "| Generative Software Development Lab   |"
@@ -8,4 +8,14 @@ echo ""
 echo "Starting gitit..."
 echo ""
-gitit -f gitit.cnf+
+if [ "$1" == "--sandbox" ]; then
+	if [ -z "$2" ]; then
+		cabal sandbox init --sandbox=../.clafertools-cabal-sandbox
+	else
+		cabal sandbox init --sandbox=$2
+	fi
+	cabal exec gitit -- -f gitit.cnf
+else
+	gitit -f gitit.cnf
+fi
src/Network/Gitit/Plugin/ClaferWiki.hs view
@@ -44,7 +44,7 @@ import Language.Clafer.Css as Css
 import Language.Clafer.Generator.Html (highlightErrors)
 
--- | claferWiki collects Clafer code from .clafer code blocks, renders as HTML and graph, 
+-- | 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
 plugin = mkPageTransformM claferWiki
@@ -52,7 +52,7 @@ claferWiki :: Pandoc -> PluginM Pandoc
 claferWiki pandoc = do
 	-- make sure the directories and clafer.css exist
-	liftIO $ do 
+	liftIO $ do
 		createDirectoryIfMissing True "static/clafer/"
 		createDirectoryIfMissing True "static/css/"
 		cssExist <- doesFileExist "static/css/clafer.css"
@@ -61,33 +61,33 @@ 	serverURL <- liftIO $ getHostName
 	pageName <- getPageName
 	config <- askConfig
-	
+
 	let
 		serverPort = show $ portNumber config
 		-- produce the required outputs in a single compilation
 		allCompilationResults = compileFragments fragments claferModes
-		
+
 		htmlCode = extractOutput allCompilationResults Html
 		htmlCodeFragments = splitOn "\n<!-- # FRAGMENT /-->\n" htmlCode
-		
+
 		stats = maybe "No model." statistics $ extractCompilerResult allCompilationResults Html
 
-		dotGraph = maybe "" outputCode $ extractCompilerResult allCompilationResults Graph 
+		dotGraph = maybe "" outputCode $ extractCompilerResult allCompilationResults Graph
 
 		dotCVLGraph = maybe "" outputCode $ extractCompilerResult allCompilationResults CVLGraph
 
 	-- render the graphs to SVG using dot
-	(_, svgGraphWithoutRefs, _) <- liftIO $ readProcessWithExitCode "dot" [ "-Tsvg" ] dotGraph	
+	(_, svgGraphWithoutRefs, _) <- liftIO $ readProcessWithExitCode "dot" [ "-Tsvg" ] dotGraph
 	(_, 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
-	let 
+	let
 		initialWikiEnv = WikiEnv {
 							we_fileName = pageName,
 							we_serverURL = serverURL,
-							we_serverPort = serverPort, 
+							we_serverPort = serverPort,
 							we_htmlCodeFragments = htmlCodeFragments,
 							we_stats = stats,
 							we_graphNo = 0,		-- needed to construct unique IDs of <div> for graphs
@@ -108,13 +108,13 @@ 		fragments :: [ String ]
 		fragments = queryWith addFragment pandoc
 
-		-- collects compiler modes depending on the kinds of blocks on the page 
+		-- collects compiler modes depending on the kinds of blocks on the page
 		claferModes :: [ ClaferMode ]
 		claferModes = nub $ queryWith addMode pandoc
 
 		fragmentedModel = intercalate "//# FRAGMENT\n" fragments
 		completeModel = intercalate "\n" fragments
-		
+
 		addFragment :: Block -> [String]
 		addFragment (CodeBlock (_, [ "clafer" ], _) code) = [ code ++ "\n" ]
 		addFragment _                                     = []
@@ -131,14 +131,14 @@ 		extractCompilerResult result claferMode = either (const Nothing) (Map.lookup claferMode) result
 
 		extractOutput :: Either [ClaferErr] (Map.Map ClaferMode CompilerResult) -> ClaferMode -> String
-		extractOutput (Right compilerResultMap) claferMode = 
+		extractOutput (Right compilerResultMap) claferMode =
 			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 htmlCode = 
+		selfContained htmlCode =
 			concat [
 				Css.header,
 				"<style>",
@@ -153,7 +153,7 @@ data WikiEnv = WikiEnv {
 					we_fileName :: String,
 					we_serverURL :: String,
-					we_serverPort :: String, 
+					we_serverPort :: String,
 					-- | code fragments are consumed
 					we_htmlCodeFragments :: [ String ],
 					we_stats :: String,
@@ -166,7 +166,7 @@ 
 replaceClaferWikiBlocks :: Block -> State WikiEnv Block
 replaceClaferWikiBlocks (CodeBlock (_, [ "clafer" ], _) _) = do
-	wikiEnv <- get 
+	wikiEnv <- get
 	let (fragment:fragments) = we_htmlCodeFragments wikiEnv
 	put $ wikiEnv { we_htmlCodeFragments = fragments }
 	return $ RawBlock "html" ("<div class=\"code\">" ++ fragment ++ "</div>")
@@ -174,13 +174,13 @@ replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "links" ], _) _) = do
 	fileName <- gets we_fileName
 	return $ RawBlock "html" $ renderLinks fileName
-		
+
 replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "stats" ], _) _) = do
 	stats <- gets we_stats
 	return $ RawBlock "html" $ renderStats stats
 
 replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "graph" ], _) _) = do
-	wikiEnv <- get 
+	wikiEnv <- get
 	graphNo <- gets we_graphNo
 	svgGraphWithRefs <- gets we_svgGraphWithRefs
 	svgGraphWithoutRefs <- gets we_svgGraphWithoutRefs
@@ -206,55 +206,55 @@ 	return $ RawBlock "html" $ renderSummary fileName stats svgGraphWithoutRefs svgGraphWithRefs graphNo
 
 replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "mooviz" ], _) _) =  do
-	wikiEnv <- get 
+	wikiEnv <- get
 	return $ renderAnalyzeWithClaferMooViz (we_fileName wikiEnv) (we_serverURL wikiEnv) (we_serverPort wikiEnv)
 
 replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "config" ], _) _) =  do
-	wikiEnv <- get 
+	wikiEnv <- get
 	return $ renderConfigureWithClaferConfigurator (we_fileName wikiEnv) (we_serverURL wikiEnv) (we_serverPort wikiEnv)
 
 replaceClaferWikiBlocks (CodeBlock (_, [ "clafer", "ide" ], _) _) =  do
-	wikiEnv <- get 
+	wikiEnv <- get
 	return $ renderAddOpenInIDE (we_fileName wikiEnv) (we_serverURL wikiEnv) (we_serverPort wikiEnv)
 
 replaceClaferWikiBlocks block = return block
 
 renderLinks :: String -> String
-renderLinks fileName = 
-	"<div><b>Module Downloads:</b> | <a href=\"/clafer/" ++ 
-	fileName ++ 
-	".cfr\">[.cfr]</a> | <a href=\"/clafer/" ++ 
-	fileName ++ 
+renderLinks fileName =
+	"<div><b>Module Downloads:</b> | <a href=\"/clafer/" ++
+	fileName ++
+	".cfr\">[.cfr]</a> | <a href=\"/clafer/" ++
+	fileName ++
 	".html\">[.html]</a> |</div><br>\n"
-	
+
 renderStats :: String -> String
 renderStats stats =
-	"<div><b>Module Statistics:</b> \n| " ++ 
-	(intercalate " | " $ lines stats ) ++ 
+	"<div><b>Module Statistics:</b> \n| " ++
+	(intercalate " | " $ lines stats ) ++
 	" |</div><br>\n"
 
 
 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, 
+    svgGraphWithoutRefs,
     "</div>",
     "<div id=\"" ++ renderGraphId True graphNo ++  "\" style=\"display:none;width:100%;border:solid lightgray 1px;overflow-x:auto;\" ondblclick=\"" ++ renderHideRefs graphNo ++ "\">",
-    svgGraphWithRefs, 
+    svgGraphWithRefs,
     "</div>" ]
 
 renderGraph :: String  -> String
 renderGraph    svgGraph = unlines [
     "<div style=\"display:block;width:100%;border:solid lightgray 1px;overflow-x:auto;\">",
-    svgGraph, 
+    svgGraph,
     "</div>" ]
 
-renderShowRefs :: Int    -> String 
+renderShowRefs :: Int    -> String
 renderShowRefs    graphNo =
   "var gwr=document.getElementById('" ++ renderGraphId True graphNo ++  "'); gwr.style.display='block'; gwr.scrollLeft=this.scrollLeft; this.style.display='none';"
 
 renderHideRefs :: Int    -> String
-renderHideRefs    graphNo = 
+renderHideRefs    graphNo =
   "var gwor=document.getElementById('" ++ renderGraphId False graphNo ++  "'); gwor.style.display='block'; gwor.scrollLeft=this.scrollLeft;this.style.display='none';"
 
 renderGraphId :: Bool -> Int    -> String
@@ -263,13 +263,13 @@ 
 renderSummary :: String -> String -> String           -> String        -> Int    -> String
 renderSummary    fileName  stats     svgGraphWithoutRefs svgGraphWithRefs graphNo =
-	renderGraphWithToggle svgGraphWithoutRefs svgGraphWithRefs graphNo ++ 
+	renderGraphWithToggle svgGraphWithoutRefs svgGraphWithRefs graphNo ++
 	renderStats stats ++
 	renderLinks fileName
 
 
 compileFragments :: [ String ] -> [ ClaferMode ] -> Either [ClaferErr] (Map.Map ClaferMode CompilerResult)
-compileFragments    fragments     claferModes    = 
+compileFragments    fragments     claferModes    =
 	-- compile all clafer code
 	runClafer defaultClaferArgs{
 				mode=claferModes,
@@ -278,16 +278,17 @@ 				show_references=False } $ do
 											mapM_ addModuleFragment fragments
 											parse
-											compile
+											iModule <- desugar Nothing
+											compile iModule
 											generate
 
 
 renderAnalyzeWithClaferMooViz :: String -> String -> String -> Block
-renderAnalyzeWithClaferMooViz fileName serverURL serverPort = 
+renderAnalyzeWithClaferMooViz fileName serverURL serverPort =
     RawBlock "html" (unlines [
       "<div>" ++
-      "<a href=\"http://" ++ serverURL ++ ":8092/?claferFileURL=http://" ++ serverURL ++ ":" ++ serverPort ++ "/clafer/" ++ 
-      fileName ++  
+      "<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" ++
@@ -295,11 +296,11 @@       ])
 
 renderConfigureWithClaferConfigurator :: String -> String -> String -> Block
-renderConfigureWithClaferConfigurator fileName serverURL serverPort = 
+renderConfigureWithClaferConfigurator fileName serverURL serverPort =
     RawBlock "html" (unlines [
       "<div>" ++
-      "<a href=\"http://" ++ serverURL ++ ":8093/?claferFileURL=http://" ++ serverURL ++ ":" ++ serverPort ++ "/clafer/" ++ 
-      fileName ++  
+      "<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" ++
@@ -310,8 +311,8 @@ renderAddOpenInIDE fileName serverURL serverPort =
 	RawBlock "html" (unlines [
       "<div>" ++
-      "<a href=\"http://" ++ serverURL ++ ":8094/?claferFileURL=http://" ++ serverURL ++ ":" ++ serverPort ++ "/clafer/" ++ 
-      fileName ++  
+      "<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" ++
@@ -322,4 +323,4 @@ getPageName = replace " " "_" . replace "/" "_" . pgPageName . ctxLayout <$> getContext
 
 changeTransparentToLightGray :: String -> String
-changeTransparentToLightGray = replace "color=transparent" "color=lightgray"+changeTransparentToLightGray = replace "color=transparent" "color=lightgray"