module Rakka.Wiki.Interpreter.Base.Image ( imageInterp , imgFrameInterp ) where import Control.Monad import Data.Maybe import Network.URI import Rakka.Page import Rakka.SystemConfig import Rakka.Wiki.Interpreter import Rakka.Wiki -- -- -- imageInterp :: Interpreter imageInterp = InlineCommandInterpreter { iciName = "img" , iciInterpret = \ (InlineCommand _ attrs inside) _ _ sysConf -> do BaseURI baseURI <- getSysConf sysConf (BaseURI undefined) let pageName = lookup "src" attrs when (pageName == Nothing) $ fail "\"src\" attribute is missing" let hrefAttr = ("href", uriToString id (mkPageURI baseURI (fromJust pageName)) "") srcAttr = ("src" , uriToString id (mkObjectURI baseURI (fromJust pageName)) "") altAttr = do alt <- lookup "alt" attrs return ("alt", alt) classAttr = case lookup "float" attrs of Nothing -> ("class", "inlineImage") Just "left" -> ("class", "inlineImage leftFloat") Just "right" -> ("class", "inlineImage rightFloat") Just others -> error ("unknown \"float\" attribute: " ++ others) anchorAttrs = [hrefAttr, classAttr] imgAttrs = catMaybes [Just srcAttr, altAttr] return (Anchor anchorAttrs [Image imgAttrs]) } --
-- -- -- --
--