[Initial check-in. golubovsky@gmail.com**20090311012737 Ignore-this: df699916fc974d9a696e0a48f2f10cbe ] { addfile ./LICENSE hunk ./LICENSE 1 +Copyright Dmitry Golubovsky 2008. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are +met: + + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + + * 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. + + * Neither the name of Dmitry Golubovsky nor the names of other + contributors may be used to endorse or promote products derived + from this software without specific prior written permission. + +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 +OWNER 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. addfile ./Setup.hs hunk ./Setup.hs 1 +import Distribution.Simple +import Distribution.Simple.PreProcess +import Distribution.PackageDescription +import Distribution.Simple.LocalBuildInfo +import Distribution.Simple.Program + +-- This Setup script installs a handler for .hsx files that need to be preprocessed +-- with `trhsx'. In order to use it, specify Build-Type: Custom in the .cabal file. + +newpp = hookedPreProcessors simpleUserHooks ++ [("hsx", ppTrhsx)] + +-- Define the custom hook which contains the handler for the .hsx suffix. + +main = defaultMainWithHooks (simpleUserHooks {hookedPreProcessors = newpp}) + +-- Preprocessor definition for trhsx. Based upon examples in Cabal sources. +-- Trhsx needs to be called with two parameters: input filepath and output filepath. + +ppTrhsx :: BuildInfo -> LocalBuildInfo -> PreProcessor + +ppTrhsx _bi lbi = + PreProcessor { + platformIndependent = False, + runPreProcessor = mkSimplePreProcessor $ \inFile outFile verbosity -> + rawSystemProgram verbosity progTrhsx [inFile, outFile] } + +-- Here we assume that trhsx is on the PATH so we just specify its name. + +progTrhsx = ConfiguredProgram { + programId = "trhsx" + ,programVersion = Nothing + ,programArgs = [] + ,programLocation = FoundOnSystem "trhsx" +} + + + addfile ./Simplepg.hsx hunk ./Simplepg.hsx 1 +-- An experimental utility to build a (X)HTML page out of a simple page +-- template and a set of scripts to embed and/or to make referred to +-- from the resulting page. + +-- The source of this program contains a template itself embedded as HSP XML. +-- All necessary elements are inserted into this template based on the command +-- line arguments. + + +module Main where + +import Data.Maybe +import Network.URI +import Control.Monad +import HSP +import HSP.HJScript +import HJScript +import HJScript.DOM +import qualified System.IO.UTF8 as B + + +-- The template. + +simplePg :: HSP XML +simplePg = + +
+