packages feed

bamboo 2009.6.8 → 2009.6.9

raw patch · 14 files changed

+38/−79 lines, 14 filesdep ~hack-contrib

Dependency ranges changed: hack-contrib

Files

bamboo.cabal view
@@ -1,5 +1,5 @@ Name:                 bamboo-Version:              2009.6.8+Version:              2009.6.9 Build-type:           Simple Synopsis:             A simple blog middleware on hack Description:          A simple blog middleware on hack@@ -22,7 +22,7 @@     , xhtml, utf8-string >= 0.3.3, pandoc, parsec >= 2, gravatar >= 0.3     , data-default >= 0.2     , mps >= 2009.5.13, hcheat >= 2009.5.13-    , hack >= 2009.5.19, hack-contrib >= 2009.5.19+    , hack >= 2009.5.19, hack-contrib >= 2009.6.9   hs-source-dirs: src/   exposed-modules:                       Bamboo
changelog.md view
@@ -1,3 +1,10 @@+2009.6.9+--------++### Feature++* respect hack.script_name, this allows bamboo to be mounted in a sub path without configuration in site.txt+ 2009.6.8 -------- 
src/Bamboo.hs view
@@ -2,8 +2,8 @@  import Bamboo.Controller.Application (paths_with_theme) import Hack-import Hack.Contrib.Middleware.RawRouter+import Hack.Contrib.Middleware.RegexpRouter import Bamboo.Type.ThemeInterface (Theme)  bamboo_with_theme :: Theme -> Middleware-bamboo_with_theme x = route (paths_with_theme x)+bamboo_with_theme x = regexp_router (paths_with_theme x)
src/Bamboo/Controller/Application.hs view
@@ -12,30 +12,29 @@ import Bamboo.Controller.Static import Bamboo.Controller.Tag import qualified Bamboo.Type.ThemeInterface as I-import Control.Monad.State  paths_with_theme :: I.Theme -> [(String, Application)] paths_with_theme t = -  [  x "$"                                  I.Index               index            -  ,  x "(\\?.+)?$"                          I.Index               index            -  ,  x "rss.xml$"                           I.IndexFeed           index_feed       -  ,  x blog_regex                           I.Post                post             -  ,  x "static/."                           I.Static              static           -  ,  x "tag/.*/rss.xml$"                    I.TagFeed             tag_feed         -  ,  x "tag/."                              I.Tag                 tag-  ,  for_extension  Search  $ x "search"    I.Search              search           -  ,  for_extension  Comment $ Just ("comment/create", comment_create )+  [  x "/?$"                                 I.Index               index            +  ,  x "/?(\\?.+)?$"                         I.Index               index            +  ,  x "/rss.xml$"                           I.IndexFeed           index_feed       +  ,  x blog_regex                            I.Post                post             +  ,  x "/static/."                           I.Static              static           +  ,  x "/tag/.*/rss.xml$"                    I.TagFeed             tag_feed         +  ,  x "/tag/."                              I.Tag                 tag+  ,  for_extension  Search  $ x "/search"    I.Search              search           +  ,  for_extension  Comment $ Just ("/comment/create", comment_create )   ]   .filter isJust   .map fromJust-  .map_fst ((static_config.root /) > ("^" ++))+  .map_fst ("^" ++)      where     x a b c = Just (a, render_with_theme t (b, c))+    blog_regex = "/" ++ static_config.url_date_matcher  render_with_theme :: I.Theme -> (I.Interface, Controller) -> Application-render_with_theme t (i, c) = \env -> do-  execStateT c def {env} >>= t i+render_with_theme t (i, c) = run c (t i)  for_extension :: Extension -> Maybe a -> Maybe a for_extension ext x = 
src/Bamboo/Controller/Helper.hs view
@@ -44,10 +44,6 @@ io :: (MonadIO m) => IO a -> m a io = liftIO -blog_regex :: String-blog_regex = static_config.url_date_matcher-- fill_latest_posts :: Part () fill_latest_posts = do   s <- get@@ -108,6 +104,3 @@  not_found :: Controller not_found = get >>= \s -> put s {S.status = 404}--not_found_response :: IO Response-not_found_response = return $ def { Hack.status = 404 }
src/Bamboo/Controller/Index.hs view
@@ -1,10 +1,3 @@--- the controller is the most complex module for a reason:--- models are made as simple and small as possible--- views are pure functions.---- a note on encoding:--- uniform utf-8 enforced by custom io wrapper- {-# LANGUAGE NoMonomorphismRestriction #-} {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NamedFieldPuns #-}
src/Bamboo/Env.hs view
@@ -32,4 +32,3 @@ import Data.List (isSuffixOf, isInfixOf, isPrefixOf, sortBy, intersperse)  import Data.Maybe (fromMaybe, fromJust, isJust, isNothing) import Text.XHtml.Strict (toHtml, Html)-
src/Bamboo/Helper.hs view
@@ -12,6 +12,8 @@ import Control.Monad (liftM2, when) import Data.Default import Data.Maybe+import Hack.Contrib.Utils (script_name)+import Hack (Env) import System.Directory import System.FilePath.Posix hiding ((<.>)) import System.IO as IO@@ -121,7 +123,6 @@   >>= set_host_name                ( for_s HostName                        )   >>= set_author_email             ( for_s AuthorEmail                     )   >>= set_per_page                 ( for_i PerPage                         )-  >>= set_root                     ( for_s Root ^^ clean_path              )   >>= set_navigation               ( for_l Navigation ^^ (home_nav :)      )   >>= set_bamboo_url               ( for_s BambooUrl                       )   >>= set_sidebar                  ( for_l Sidebar >>= load_sidebar        )@@ -152,10 +153,6 @@     for_i = for > (^^ read)     for_l = for > (^^ parse_list)     for_b = for > (^^ parse_boolean)-    -    clean_path user_root-      | user_root.belongs_to ["/", ""]  = "/"-      | otherwise =  user_root.("/" /).remove_trailing_slash      load_widget x = do       exists <- x.file_exist@@ -217,7 +214,6 @@     set_per_page                 v' x = v' >>= \v -> r $ c v x $ x { per_page                 = p v}     set_picture_prefix           v' x = v' >>= \v -> r $ c v x $ x { picture_prefix           = p v}     set_post_date_format         v' x = v' >>= \v -> r $ c v x $ x { post_date_format         = p v}-    set_root                     v' x = v' >>= \v -> r $ c v x $ x { root                     = p v}     set_sidebar                  v' x = v' >>= \v -> r $ c v x $ x { sidebar                  = p v}     set_summary_for_root         v' x = v' >>= \v -> r $ c v x $ x { summary_for_root         = p v}     set_summary_for_rss          v' x = v' >>= \v -> r $ c v x $ x { summary_for_rss          = p v}@@ -279,6 +275,9 @@   where     at s = xs.lookup (s.show_data) .fromJust     css_list s = s.parse_list.map -      (\x -> "/theme/" ++ at Theme.Name ++ "/css/" ++ x ++ ".css")+      (\x -> "theme/" ++ at Theme.Name ++ "/css/" ++ x ++ ".css")     js_list s  = s.parse_list.map -      (\x -> "/theme/" ++ at Theme.Name ++ "/js/" ++ x ++ ".js")+      (\x -> "theme/" ++ at Theme.Name ++ "/js/" ++ x ++ ".js")++slashed_script_name :: Env -> String+slashed_script_name env = "/" / env.script_name
src/Bamboo/Helper/ByteString.hs view
@@ -13,7 +13,6 @@ import qualified Data.ByteString.Lazy as LB import qualified Data.ByteString.Lazy.UTF8 as LU import qualified Data.ByteString.UTF8 as SU-import qualified Data.ByteString.UTF8 as U import qualified Prelude as P  @@ -55,9 +54,6 @@  lower :: S.ByteString -> S.ByteString lower = S.map toLower--isInfixOf :: S.ByteString -> S.ByteString -> Bool-isInfixOf = S.isInfixOf  read_bytestring :: String -> IO S.ByteString read_bytestring = u2b > S.readFile
src/Bamboo/Helper/StateHelper.hs view
@@ -6,7 +6,6 @@ module Bamboo.Helper.StateHelper where  import Bamboo.Env hiding (cut)-import Data.ByteString (ByteString) import Hack import Hack.Contrib.Utils import Network.CGI (urlDecode)@@ -16,27 +15,14 @@ import qualified Bamboo.Type.Config as C import qualified Data.ByteString.Char8 as S --- static_config.root = /blog--- raw_uri = blog/x--- full_uri = /blog/x--- uri = full_uri - (/blog/)-remove_root :: String -> String-remove_root s-  | static_config.root.is "/" = s-  | otherwise = s.slice (static_config.root.length) (s.length)--raw_uri :: Env -> String-raw_uri env = ( env.script_name ++ env.path_info )-  .(urlDecode > tail > remove_trailing_slash )--uri :: Env ->String-uri env = raw_uri env .b2u .remove_root+uri :: Env -> String+uri = path_info > urlDecode > tail > remove_trailing_slash > b2u  -- global parse_date :: String -> String -> Maybe CalendarTime parse_date format s = parseCalendarTime defaultTimeLocale format s ^   (\d -> if d.ctYear < 1910 then d {ctYear = d.ctYear + 100} else d )-  + format_time :: String -> CalendarTime -> String format_time = formatCalendarTime defaultTimeLocale @@ -56,9 +42,9 @@ html_only_for ext x = if has_extension ext then x else toHtml ""  -- controller-cut :: ByteString+cut :: S.ByteString cut = static_config.C.cut.to_sb-match_cut, is_cut :: ByteString -> Bool+match_cut, is_cut :: S.ByteString -> Bool match_cut = S.lines > any (S.isPrefixOf cut) is_cut    = S.isPrefixOf cut 
src/Bamboo/Model/Helper.hs view
@@ -20,12 +20,6 @@ meta :: String -> String meta = (++ ".meta") -image_extensions :: [String]-image_extensions = ["jpg", "jpeg", "png", "gif"]--is_image :: String -> Bool-is_image x = image_extensions.any (`isSuffixOf` x)- spaced_url :: String -> String spaced_url = gsub "/" " / " 
src/Bamboo/Model/Post.hs view
@@ -10,7 +10,6 @@ import Text.XHtml.Strict ((+++), (<<), hotlink, p) import qualified Bamboo.Helper.ByteString as BS import qualified Data.ByteString.Char8 as S-import qualified Data.ByteString.Char8 as S import qualified MPS as MPS  data Post = Post @@ -29,7 +28,7 @@   resource_type = const $ static_config.post_id  instance Markable Post where-  markup = (reader &&& body) > splash render_to_html+  markup = (reader &&& full) > splash render_to_html    instance Datable Post where   date = uid > get_date@@ -79,7 +78,7 @@  match :: String -> Post -> Bool match s x = [title > to_sb, body]-  .map (send_to x > BS.lower > BS.isInfixOf (s.lower.to_sb))+  .map (send_to x > BS.lower > S.isInfixOf (s.lower.to_sb))   .or  search :: String -> IO [Post]@@ -104,7 +103,6 @@  id_to_uri :: SC id_to_uri id = -  static_config.root /      [ pretty_date     , static_config.url_date_title_seperator     , formatted_title@@ -115,7 +113,7 @@     formatted_title =        static_config         .url_title_subs-        .map (\(a,b) -> gsub a b)+        .map (splash gsub)         .inject (id.get_title) apply          pretty_date = id.get_date.format_time (static_config.url_date_format)
src/Bamboo/Type/Config.hs view
@@ -16,7 +16,6 @@   | AuthorEmail   | PerPage   | Navigation-  | Root   | Sidebar   | Footer   | Favicon@@ -51,7 +50,6 @@     , per_page                  :: Int     , navigation                :: [String]     , bamboo_url                :: String-    , root                      :: String     , default_reader            :: Reader     , sidebar                   :: [StaticWidget]     , footer                    :: Maybe StaticWidget@@ -122,7 +120,6 @@       , per_page                  = 7       , navigation                = def       , bamboo_url                = bamboo_url_current-      , root                      = "/"       , default_reader            = def       , sidebar                   = def       , footer                    = def
src/Bamboo/Type/ThemeInterface.hs view
@@ -3,8 +3,6 @@ import Bamboo.Type.State (State) import Hack (Response) -data ThemeConfig = ThemeConfig- data Interface =      Index   | IndexFeed