-- Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
--
-- This program is free software; you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation; either version 2 of the License, or
-- (at your option) any later version.
--
-- This program is distributed in the hope that it will be useful,
-- but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-- GNU General Public License for more details.
--
-- You should have received a copy of the GNU General Public License
-- along with this program; if not, write to the Free Software
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-- |
-- Copyright : Copyright (C) 2009 Emil Axelsson <emax@chalmers.se>
-- License : GNU GPL, version 2 or above
--
-- Maintainer : Emil Axelsson <emax@chalmers.se>
module Types where
import Text.Pandoc
data MetaInfo = MetaInfo
{ title :: [Inline]
, authors :: [[Inline]]
, date :: [Inline]
, comment :: [Inline]
, keywords :: [[Inline]]
}
deriving (Eq, Show)
data Context = Context
{ -- | Optional link to CSS file
cssLink_ :: Maybe FilePath
-- | Optional editor command
, editor_ :: Maybe String
-- | Show the edit/regenerate script?
, showScript_ :: Bool
-- | Path to root of bookshelf
, rootPath_ :: FilePath
-- | Path to current node, relative to the root
, relPath_ :: FilePath
}
deriving (Eq, Show)
data ShelfInfo = ShelfInfo
{ -- | The document's context
shelfContext :: Context
-- | The full name of the associated main document. `Nothing` means
-- that there is no main document.
, mainDocument :: Maybe String
-- | The full name of the shelf document.
, shelfDocument :: String
}
class HasContext a
where
cssLink :: a -> Maybe FilePath
editor :: a -> Maybe String
showScript :: a -> Bool
rootPath :: a -> FilePath
relPath :: a -> FilePath
instance HasContext Context
where
cssLink = cssLink_
editor = editor_
showScript = showScript_
rootPath = rootPath_
relPath = relPath_
instance HasContext ShelfInfo
where
cssLink = cssLink_ . shelfContext
editor = editor_ . shelfContext
showScript = showScript_ . shelfContext
rootPath = rootPath_ . shelfContext
relPath = relPath_ . shelfContext