-- Copyright (C) 2009-2013 Emil Axelsson -- -- 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-2012 Emil Axelsson -- License : GNU GPL, version 2 or above -- -- Maintainer : Emil Axelsson module Types where import Text.CSL import Text.Pandoc data MetaInfo = MetaInfo { title :: [Inline] , authors :: [[Inline]] , date :: [Inline] , comment :: [Inline] , keywords :: [[Inline]] } deriving (Eq, Show) data Context = Context { -- | Pandoc HTML template htmlTemplate_ :: String -- | CSL style , cslStyle_ :: Style -- | List of available references , references_ :: [Reference] -- | Optional link to CSS file , cssLink_ :: Maybe FilePath -- | Optional link to MathJax.js file , mathjaxLink_ :: Maybe FilePath -- | Use MathML rendering? , mathml_ :: Bool -- | Path to root of bookshelf , rootPath_ :: FilePath -- | Path to current node, relative to the root , relPath_ :: FilePath } deriving (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 htmlTemplate :: a -> String cslStyle :: a -> Style references :: a -> [Reference] cssLink :: a -> Maybe FilePath mathjaxLink :: a -> Maybe FilePath mathml :: a -> Bool rootPath :: a -> FilePath relPath :: a -> FilePath instance HasContext Context where htmlTemplate = htmlTemplate_ cslStyle = cslStyle_ references = references_ cssLink = cssLink_ mathjaxLink = mathjaxLink_ mathml = mathml_ rootPath = rootPath_ relPath = relPath_ instance HasContext ShelfInfo where htmlTemplate = htmlTemplate_ . shelfContext cslStyle = cslStyle_ . shelfContext references = references_ . shelfContext cssLink = cssLink_ . shelfContext mathjaxLink = mathjaxLink_ . shelfContext mathml = mathml_ . shelfContext rootPath = rootPath_ . shelfContext relPath = relPath_ . shelfContext