]> gitweb @ CieloNegro.org - Rakka.git/blob - Rakka/Page.hs
Still in early development...
[Rakka.git] / Rakka / Page.hs
1 module Rakka.Page
2     ( PageName
3     , Page(..)
4     , encodePageName
5     )
6     where
7
8 import           Data.ByteString.Base (LazyByteString)
9 import qualified Data.ByteString.Char8 as C8
10 import           Data.Encoding
11 import           Data.Encoding.UTF8
12 import           Network.HTTP.Lucu
13 import           Network.URI
14 import           Subversion.Types
15
16
17 type PageName = String
18
19
20 data Page
21     = Redirect PageName
22     | Page {
23         pageName      :: PageName
24       , pageType      :: MIMEType
25       , pageIsTheme   :: Bool     -- text/css 以外では無意味
26       , pageIsFeed    :: Bool     -- text/x-rakka 以外では無意味
27       , pageIsLocked  :: Bool
28       , pageIsBoring  :: Bool
29       , pageRevision  :: Maybe RevNum
30       , pageSummary   :: Maybe String
31       , pageOtherLang :: [(String, PageName)]
32       , pageContent   :: LazyByteString
33       }
34
35
36 -- UTF-8 に encode してから 0x20 - 0x7E の範圍を除いて URI escape する。
37 encodePageName :: PageName -> FilePath
38 encodePageName = escapeURIString shouldEscape . C8.unpack . encode UTF8 
39     where
40       shouldEscape :: Char -> Bool
41       shouldEscape c
42           | c >= ' ' && c <= '~' = False
43           | otherwise            = True