)
where
+import qualified Codec.Binary.UTF8.String as UTF8
import Control.Monad.Trans
+import qualified Data.ByteString.Lazy as L hiding (ByteString)
import Data.Char
import qualified Data.Map as M
import Data.Maybe
let cssHref = [uriToString id (mkObjectURI baseURI styleSheet) ""]
scriptSrc = [uriToString id (baseURI { uriPath = uriPath baseURI </> "js" }) ""]
- feeds <- arrIO0 (findFeeds (envStorage env)) -< ()
- javaScripts <- arrIO0 (findJavaScripts (envStorage env)) -< ()
-
pageTitle <- listA (readSubPage env) -< (name, Just page, "PageTitle")
leftSideBar <- listA (readSubPage env) -< (name, Just page, "SideBar/Left")
rightSideBar <- listA (readSubPage env) -< (name, Just page, "SideBar/Right")
+= sattr "type" "text/css"
+= attr "href" (arr id >>> mkText)
)
- += ( constL feeds
- >>>
- eelem "link"
- += sattr "rel" "alternate"
- += sattr "type" "application/rss+xml"
- += attr "title" (txt siteName <+> txt " - " <+> mkText)
- += attr "href" (arr (mkFeedURIStr baseURI) >>> mkText)
- )
+ += mkFeedList env
+= ( constL scriptSrc
>>>
eelem "script"
+= txt ("Rakka.isLocked=" ++ trueOrFalse isLocked ++ ";")
+= txt ("Rakka.isGlobalLocked=" ++ trueOrFalse isGLocked ++ ";")
)
- += ( constL javaScripts
- >>>
- eelem "script"
- += sattr "type" "text/javascript"
- += attr "src" (arr (mkObjectURIStr baseURI) >>> mkText)
- )
+ += mkGlobalJSList env
)
+= ( eelem "body"
+= ( eelem "div"
let cssHref = [uriToString id (mkObjectURI baseURI styleSheet) ""]
scriptSrc = [uriToString id (baseURI { uriPath = uriPath baseURI </> "js" }) ""]
- feeds <- arrIO0 (findFeeds (envStorage env)) -< ()
- javaScripts <- arrIO0 (findJavaScripts (envStorage env)) -< ()
-
pageTitle <- listA (readSubPage env) -< (name, Nothing, "PageTitle")
leftSideBar <- listA (readSubPage env) -< (name, Nothing, "SideBar/Left")
rightSideBar <- listA (readSubPage env) -< (name, Nothing, "SideBar/Right")
+= sattr "type" "text/css"
+= attr "href" (arr id >>> mkText)
)
- += ( constL feeds
- >>>
- eelem "link"
- += sattr "rel" "alternate"
- += sattr "type" "application/rss+xml"
- += attr "title" (txt siteName <+> txt " - " <+> mkText)
- += attr "href" (arr (mkFeedURIStr baseURI) >>> mkText)
- )
+ += mkFeedList env
+= ( constL scriptSrc
>>>
eelem "script"
+= txt ("Rakka.baseURI = \"" ++ uriToString id baseURI "" ++ "\";")
+= txt ("Rakka.isGlobalLocked=" ++ trueOrFalse isGLocked ++ ";")
)
- += ( constL javaScripts
- >>>
- eelem "script"
- += sattr "type" "text/javascript"
- += attr "src" (arr (mkObjectURIStr baseURI) >>> mkText)
- )
+ += mkGlobalJSList env
)
+= ( eelem "body"
+= ( eelem "div"
let cssHref = [uriToString id (mkObjectURI baseURI styleSheet) ""]
scriptSrc = [uriToString id (baseURI { uriPath = uriPath baseURI </> "js" }) ""]
- feeds <- arrIO0 (findFeeds (envStorage env)) -< ()
- javaScripts <- arrIO0 (findJavaScripts (envStorage env)) -< ()
-
pageTitle <- listA (readSubPage env) -< (name, Nothing, "PageTitle")
leftSideBar <- listA (readSubPage env) -< (name, Nothing, "SideBar/Left")
rightSideBar <- listA (readSubPage env) -< (name, Nothing, "SideBar/Right")
+= sattr "type" "text/css"
+= attr "href" (arr id >>> mkText)
)
- += ( constL feeds
- >>>
- eelem "link"
- += sattr "rel" "alternate"
- += sattr "type" "application/rss+xml"
- += attr "title" (txt siteName <+> txt " - " <+> mkText)
- += attr "href" (arr (mkFeedURIStr baseURI) >>> mkText)
- )
+ += mkFeedList env
+= ( constL scriptSrc
>>>
eelem "script"
+= txt ("Rakka.baseURI = \"" ++ uriToString id baseURI "" ++ "\";")
+= txt ("Rakka.isGlobalLocked=" ++ trueOrFalse isGLocked ++ ";")
)
- += ( constL javaScripts
- >>>
- eelem "script"
- += sattr "type" "text/javascript"
- += attr "src" (arr (mkObjectURIStr baseURI) >>> mkText)
- )
+ += mkGlobalJSList env
)
+= ( eelem "body"
+= ( eelem "div"
setStatus status
+mkFeedList :: (ArrowIO a, ArrowXml a) => Environment -> a b XmlTree
+mkFeedList env
+ = proc _ -> do SiteName siteName <- getSysConfA (envSysConf env) -< ()
+ BaseURI baseURI <- getSysConfA (envSysConf env) -< ()
+
+ feed <- unlistA <<< arrIO0 (findFeeds $ envStorage env) -< ()
+
+ ( eelem "link"
+ += sattr "rel" "alternate"
+ += sattr "type" "application/rss+xml"
+ += attr "title" (txt siteName <+> txt " - " <+> mkText)
+ += attr "href" (arr (mkFeedURIStr baseURI) >>> mkText) ) -<< feed
+
+
findFeeds :: Storage -> IO [PageName]
findFeeds sto
= do cond <- newCondition
return (map hpPageName $ srPages result)
+mkGlobalJSList :: (ArrowIO a, ArrowXml a, ArrowChoice a) => Environment -> a b XmlTree
+mkGlobalJSList env
+ = proc _ -> do BaseURI baseURI <- getSysConfA (envSysConf env) -< ()
+
+ scriptName <- unlistA <<< arrIO0 (findJavaScripts $ envStorage env) -< ()
+ pageM <- getPageA (envStorage env) -< (scriptName, Nothing)
+
+ case pageM of
+ Nothing -> none -< ()
+ Just page
+ | isEntity page
+ -> ( if entityIsBinary page then
+ ( eelem "script"
+ += sattr "type" "text/javascript"
+ += attr "src" (arr (mkObjectURIStr baseURI . pageName) >>> mkText) )
+ else
+ ( eelem "script"
+ += sattr "type" "text/javascript"
+ += (arr (UTF8.decode . L.unpack . entityContent) >>> mkText) )
+ ) -<< page
+ | otherwise
+ -> none -< ()
+
+
findJavaScripts :: Storage -> IO [PageName]
findJavaScripts sto
= do cond <- newCondition