Commit 146cfc99 authored by Henrik Tramberend's avatar Henrik Tramberend
Browse files

Gardening and image background examples

parent 0d544fdd
......@@ -4,25 +4,21 @@ import Common
import Context
import Control.Exception
import Control.Monad ()
import qualified Data.ByteString.Char8 as B
import Data.IORef ()
import Data.List
import Data.Maybe
import Data.String ()
import Data.Yaml.Pretty
import Development.Shake
import Development.Shake.FilePath
import Project
import Resources
import Server
import System.Directory
import System.Exit
import System.FilePath ()
import System.FilePath.Glob
import qualified Text.Mustache as M ()
import Text.Pandoc ()
import Text.Printf ()
import Utilities
import Web.Browser
main :: IO ()
main = do
......@@ -80,6 +76,11 @@ main = do
need ["html"]
allMarkdownA <++> metaA <++> allImagesA >>= watchFiles
--
phony "open" $ do
need ["html"]
liftIO $ openBrowser index
return ()
--
phony "server" $ do
need ["watch"]
runHttpServer dirs True
......@@ -184,4 +185,5 @@ main = do
-- Calculate some directories
-- | Some constants that might need tweaking
options :: ShakeOptions
options = shakeOptions {shakeFiles = ".shake"}
......@@ -46,6 +46,7 @@ executable decker
, multimap
, mustache
, network-uri
, open-browser
, pandoc
, pandoc-citeproc
, pandoc-types
......
......@@ -52,6 +52,7 @@ provisioningFromMeta meta =
Just (MetaInlines i) -> read $ stringify i
_ -> SymLink
provisioningClasses :: [(String, Provisioning)]
provisioningClasses =
[ ("copy", Copy)
, ("symlink", SymLink)
......@@ -276,6 +277,7 @@ removeCommonPrefix =
| otherwise = (al, bl)
removeCommonPrefix_ pathes = pathes
isPrefix :: FilePath -> FilePath -> Bool
isPrefix a b = isPrefix_ (splitPath a) (splitPath b)
where
isPrefix_ :: Eq a => [a] -> [a] -> Bool
......
......@@ -8,11 +8,9 @@ module Server
, Server
) where
import Control.Applicative
import Control.Concurrent
import Control.Exception
import Control.Monad
import Data.List
import Data.Text
import Network.WebSockets
import Network.WebSockets.Snap
......@@ -25,6 +23,7 @@ import System.FilePath.Posix
import System.Random
-- Logging and port configuration for the server.
serverConfig :: ProjectDirs -> Int -> IO (Config Snap a)
serverConfig dirs port = do
let logDir = Project.log dirs
let accessLog = logDir </> "server-access.log"
......@@ -85,7 +84,7 @@ startHttpServer dirs port = do
reloadClients :: Server -> IO ()
reloadClients = reloadAll . snd
-- | Kill the server.
-- | Kills the server.
stopHttpServer :: Server -> IO ()
stopHttpServer = killThread . fst
......
......@@ -87,6 +87,7 @@ runShakeInContext context options rules = do
_ <- waitForTwitchPassive files
return False
watchFiles :: [FilePath] -> Action ()
watchFiles = setFilesToWatch
-- | Monadic version of list concatenation.
......@@ -94,6 +95,8 @@ watchFiles = setFilesToWatch
(<++>) = liftM2 (++)
-- | Generates an index.md file with links to all generated files of interest.
writeIndex ::
FilePath -> FilePath -> [FilePath] -> [FilePath] -> [FilePath] -> Action ()
writeIndex out baseUrl decks handouts pages = do
let decksLinks = map (makeRelative baseUrl) decks
let handoutsLinks = map (makeRelative baseUrl) handouts
......@@ -237,6 +240,7 @@ provisionMetaResource method dirs base (key, path)
| key `elem` compiletimeMetaKeys = findLocalFile dirs base path
provisionMetaResource _ _ _ (key, path) = return path
putCurrentDocument :: FilePath -> Action ()
putCurrentDocument out = do
dirs <- getProjectDirs
let rel = makeRelative (public dirs) out
......@@ -286,6 +290,7 @@ markdownToPdfPage markdownFile out = do
putNormal $ "# pandoc (for " ++ out ++ ")"
pandocMakePdf options processed out
pandocMakePdf :: WriterOptions -> Pandoc -> FilePath -> Action ()
pandocMakePdf options processed out = do
result <- liftIO $ makePDF "pdflatex" writeLaTeX options processed
case result of
......@@ -471,10 +476,13 @@ elementAttributes =
-- | Resources in meta data that are needed at compile time. They have to be
-- specified as local URLs and must exist.
runtimeMetaKeys :: [String]
runtimeMetaKeys = ["css"]
compiletimeMetaKeys :: [String]
compiletimeMetaKeys = ["bibliography", "csl", "citation-abbreviations"]
metaKeys :: [String]
metaKeys = runtimeMetaKeys ++ compiletimeMetaKeys
-- Transitively splices all include files into the pandoc document.
......
......@@ -8,8 +8,10 @@ history: True
1. RevealJS style with `data-background-image` attribute
2. decker style with image and title text header
3. decker style with image and title text header and attributes
4. decker style with image and title text header and attributes
3. decker style with attributes `size`, `repeat`, `color`
3. decker style with attributes `position`, `size`, `repeat`, `color`
3. decker style with attributes `position`, `size`, `repeat`, `color`
# RevealJs Style {data-background-image="include/06-metal.png"}
......@@ -29,8 +31,20 @@ history: True
# Image in Title 2 ![](include/06-metal.png){size="50%" repeat="repeat"}
# Image in Title 3 ![](include/06-metal.png){size="50%" repeat="no-repeat" color="black"}
# Image in Title 3 ![](include/06-metal.png){size="50%" repeat="no-repeat" color="red"}
## Source
# Image in Title 3 ![](include/06-metal.png){size="50%" repeat="no-repeat" color="red"}
# Image in Title 4 ![](include/06-metal.png){size="50%" repeat="no-repeat" color="black" position="10px 10px"}
## Source
# Image in Title 4 ![](include/06-metal.png){size="50%" repeat="no-repeat" position="10px 10px"}
# Image in Title 5 ![](include/06-metal.png){size="300%" repeat="no-repeat" color="white" position="-600px -300px"}
## Source
# Image in Title 3 ![](include/06-metal.png){size="50%" repeat="no-repeat" color="black"}
# Image in Title 5 ![](include/06-metal.png){size="300%" repeat="no-repeat" position="-600px -300px"}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment