packages feed

bamboo-launcher (empty) → 2009.5.22

raw patch · 6 files changed

+164/−0 lines, 6 filesdep +bamboodep +basedep +hacksetup-changed

Dependencies added: bamboo, base, hack, hack-contrib, hack-handler-happstack, haskell98, mps, process, utf8-prelude

Files

+ LICENSE view
@@ -0,0 +1,10 @@+Copyright (c) 2009, Jinjing Wang++All rights reserved.++Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:++Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.+Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.+Neither the name of the <ORGANIZATION> nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ Setup.lhs view
@@ -0,0 +1,4 @@+#! /usr/bin/env runhaskell++> import Distribution.Simple+> main = defaultMain
+ bamboo-launcher.cabal view
@@ -0,0 +1,23 @@+Name:                 bamboo-launcher+Version:              2009.5.22+Build-type:           Simple+Synopsis:             bamboo-launcher+Description:+        +    A standalone bamboo launcher to simplify deployment.++License:              BSD3+License-file:         LICENSE+Author:               Wang, Jinjing+Maintainer:           Wang, Jinjing <nfjinjing@gmail.com>+Build-Depends:        base+Cabal-version:        >= 1.2+category:             Web+homepage:             http://github.com/nfjinjing/hack/tree/master+data-files:           readme.md, changelog.md++Executable            bamboo+  ghc-options:        -Wall+  build-depends:      base, hack >= 2009.5.19, hack-contrib >= 2009.5.19, bamboo >= 2009.5.2, hack-handler-happstack >= 2009.5.19, mps >= 2009.5.13, utf8-prelude, process, haskell98+  hs-source-dirs:     src/+  main-is:            Launcher.hs
+ changelog.md view
@@ -0,0 +1,4 @@+2009.5.22+---------++Init
+ readme.md view
@@ -0,0 +1,38 @@+# Bamboo launcher: run bamboo blog engine in 3 steps++## Install++### 1. tokyo-cabinet (used for caching)++#### Mac++    port install tokyocabinet+    +#### Arch++    yaourt -S tokyocabinet++#### other distro+    +Just find this tokyo-cabinet package and install it :)++### 2. Bamboo Launcher++#### update cabal++    cabal update++#### install bamboo++    cabal install happy+    cabal install bamboo-launcher++### 3. Run++    mkdir myblog+    cd myblog+    bamboo++## Change port++    bamboo 4567
+ src/Launcher.hs view
@@ -0,0 +1,85 @@+module Main where++import Bamboo+import Hack+import Hack.Handler.Happstack hiding (port)++import Hack.Contrib.Utils+import Hack.Contrib.Middleware.ContentType+import Hack.Contrib.Middleware.ContentLength+import Hack.Contrib.Middleware.ShowExceptions+import Hack.Contrib.Middleware.Static++import Hack.Contrib.Middleware.BounceFavicon+import qualified Hack.Contrib.Middleware.Head as H+++import Prelude hiding ((.))+import MPSUTF8+import System+import System.Cmd+import System.IO++middleware_stack :: [Middleware]+middleware_stack = +  [  dummy_middleware+  +  -- filter+  ,  bounce_favicon++  -- completeness+  ,  content_length+  ,  content_type default_content_type++  -- debuging+  ,  show_exceptions Nothing+  +  -- optimization+  ,  H.head+  +  -- static serve+  ,  static (Just "db/public") ["/theme", "/images", "/plugin", "/favicon.ico"]+  +  -- real app+  ,  bamboo+  ]+  +  where+    default_content_type = "text/plain; charset=UTF-8"+  +-- test_app = \env -> return $ def .set_body (env.inputs.show)++app :: Application+app = use middleware_stack dummy_app++main :: IO ()+main = do+  args <- getArgs+  let port = if args.length == 1 then args.first.read else 3456+  paths <- ls "."+  if paths.has "db"+    then start port+    else do+      sep+      putStrLn $+        "I'm about to download a template from " ++ repo ++ " into ./db"+      putStrLn "Do you want to continue?   y or n"+      putStr $ u2b "❂ "+      hFlush stdout+      r <- getLine+      if r.is "y"+        then do+          system $ "git clone " ++ repo ++ " db"+          sep+          putStrLn "Template download complete!"+          putStrLn "You might want to remove db/.git manually."+          sep+          start port+        else+          putStrLn "Cya!"+  where+    start port = do +      putStrLn $ "server started on port " ++ port.show ++ "..."+      runWithConfig (ServerConf port "localhost") app+    sep = putStrLn $ 70.times '-'+    repo = "git://github.com/nfjinjing/bamboo-template.git"