packages feed

free-theorems-webui 0.1 → 0.2

raw patch · 5 files changed

+61/−33 lines, 5 filesdep +dataencdep −base64-string

Dependencies added: dataenc

Dependencies removed: base64-string

Files

Pages.hs view
@@ -19,6 +19,8 @@       [ header <<          [ thetitle << title_text          , thelink ! [rel "stylesheet", thetype "text/css", href (relativeURLOf "style.css")] << ""+         , script ! [src "http://code.jquery.com/jquery-1.4.2.min.js", thetype "text/javascript"] << ""+         , script ! [src (relativeURLOf "ui-tweaks.js"), thetype "text/javascript"] << ""          ]       , body <<          [ thediv ! [identifier "header"] <<@@ -36,8 +38,8 @@    in page_template title_text <<          [ p ! [identifier "help"] << "Help" `at` "?help"          , thediv <<-            [ p << ("This tool allows to generate free theorems for sublanguages of Haskell as described " +++ "here" `at` "?help"  +++ ".")-            , p << ("The source code of the underlying library and a shell-based application using it is available " +++ "here" `at` hackage "free-theorems" +++ " and " +++ "here" `at` hackage "ftshell" +++ ".")+            [ p << ("This tool allows to generate free theorems for sublanguages of Haskell. See the " +++ "help page" `at` "?help"  +++ " for details.")+            , p << ("The source is available at hackage as " +++ ("free-theorems-webui" `at` hackage "free-theorems-webui") +++ ". See also: " +++ ("free-theorems (library)" `at` hackage "free-theorems") +++ " and " +++ ("ftshell (shell interface)" `at` hackage "ftshell") +++ ".")             , p << ("You may also want to try the following related tools:" +++ ulist << [ li << "Automatically Generating Counterexamples to Naive Free Theorems" `at` "http://www-ps.iai.uni-bonn.de/cgi-bin/exfind.cgi"                                                                                          , li << "Taming Selective Strictness" `at` "http://www-ps.iai.uni-bonn.de/cgi-bin/polyseq.cgi"                                                                                          ])
TypesetAsImage.hs view
@@ -5,9 +5,8 @@ import System.IO (openTempFile, hClose, hPutStr, getContents) import System (system) import Data.List (intercalate)-import Data.Char--- Needs package: base64-string-import Codec.Binary.Base64.String as Base64+import qualified Data.ByteString as BS+import qualified Codec.Binary.Base64 as Base64 import Text.XHtml  import System.IO.Unsafe (unsafeInterleaveIO)@@ -25,17 +24,22 @@  where    asHtml pngImage =      let-       header = drop 16 pngImage-       w = sum $ zipWith (*) [256^3, 256^2, 256, 1] $ map ord $ take 4 header-       h = sum $ zipWith (*) [256^3, 256^2, 256, 1] $ map ord $ take 4 $ drop 4 header+       -- Extract width and height from the PNG header+       header = BS.drop 16 pngImage+       w = valueOf $ BS.take 4 header+       h = valueOf $ BS.take 4 $ BS.drop 4 header+       valueOf = sum . zipWith (*) [256^3, 256^2, 256, 1]+                     . map fromEnum+                     . BS.unpack      in-       image ! [ src $ "data:image/png;base64," ++ Base64.encode pngImage+       image ! [ src $ "data:image/png;base64," ++ Base64.encode (BS.unpack pngImage)                , alt formula                , width  (show (w `div` 2))                , height (show (h `div` 2))                ]  +typesetAsPNG :: String -> IO BS.ByteString typesetAsPNG formula = unsafeInterleaveIO $ do    tmp_dir <- getTemporaryDirectory    (tempPath, tempHandle) <- openTempFile tmp_dir "temp.tex"@@ -54,7 +58,7 @@    system $ "dvipng -x 2400 -T tight -z 9 -bg transparent -o " ++ pathTo "png" ++ " " ++ pathTo "dvi" ++ " > /dev/null"    removeFile $ pathTo "dvi" -   pngImage <- readFile $ pathTo "png"+   pngImage <- BS.readFile $ pathTo "png"    removeFile $ pathTo "png"     return pngImage
free-theorems-webui.cabal view
@@ -1,5 +1,5 @@ Name:     free-theorems-webui-Version:  0.1+Version:  0.2  Synopsis: CGI-based web interface for the free-theorems package. Description:@@ -16,6 +16,7 @@    To start it locally for offline usage, just call "free-theorems-webui" after installation. (This needs python) License:    PublicDomain Category:   Language+Author:     Matthias Bartsch Maintainer: bartsch@cs.uni-bonn.de  Cabal-Version: >= 1.2@@ -24,6 +25,7 @@  Data-files:    style.css+   ui-tweaks.js    lambdaTeX.tex    runLocalServer.py @@ -63,7 +65,7 @@                 , directory     >= 1.0.0.2                 , filepath      >= 1.1.0.1                 , xhtml         >= 3000-2-0-1-                , base64-string >= 0.2+                , dataenc                 , haskell98    if flag(our_server)       hs-source-dirs: . our_server_config
style.css view
@@ -1,25 +1,23 @@-body { padding:0px; margin: 0px; }+body { padding: 0px; margin: 0px; } -/* renamed from "div.top" */ #header {-   margin:0px; padding:10px; margin-bottom:20px;-   background-color:#efefef;-   border-bottom:1px solid black;+   margin: 0px; padding: 10px; margin-bottom: 20px;+   background-color: #efefef;+   border-bottom: 1px solid black; } -/* renamed from "span.title" */ h1 {    display: inline;    font-size: xx-large;    font-weight: bold; }-/* renamed from "span.subtitle" */ h2 {    display: inline;    font-size: large;    font-weight: normal;    padding-left:30px; }+ #help {    position: absolute;    top:   0em;@@ -27,29 +25,23 @@ }  #content > div {-   border:1px dotted black;-   padding:10px; margin:10px;+   border: 1px dotted black;+   padding: 10px; margin: 10px; } -/* renamed from "div.submain" */-#footer { padding:10px; margin:11px; }--p.subtitle { font-size:large; font-weight:bold; }--input.type { font-family:monospace; }--input[type="submit"] { font-family:monospace; background-color:#efefef; }+input.type, textarea { font-family: monospace; } -span.mono { font-family:monospace; }+input[type="radio"], input[type="checkbox"] {+   margin-left: 5px;+}  pre {-   margin:10px; margin-left:20px; padding:10px;-	border:1px solid black;+   margin: 10px; margin-left: 20px; padding:10px;+	border: 1px solid black; }  p { text-align:justify; } -/* Added later */ .error { background: #fcc; }  textarea { height: 20em; width: 30em; }
+ ui-tweaks.js view
@@ -0,0 +1,28 @@+$(document).ready(function(){++   var disableStyleOptions = function(shouldBeDisabled) {+      /* Disable (or enable) the options for selecting a theorem style */+      $("input[name=style]").attr("disabled", shouldBeDisabled);+   };++   /* When the selected language model changes,+    * disable the options for selecting a theorem style for "basic"+    * but enable them for "fix" and "seq".+    */+   $("input[value=basic]").change(function(){+      disableStyleOptions(true);+   });+   $("input[value=fix]").change(function(){+      disableStyleOptions(false);+   });+   $("input[value=seq]").change(function(){+      disableStyleOptions(false);+   });++   /* Trigger the change event on the pre-selected option+    * to have the style options enabled/disabled correctly+    * after the page is loaded.+    */+   $("input[name=model]:checked").change();++});