packages feed

MFlow 0.3.2.0 → 0.3.3

raw patch · 33 files changed

+532/−385 lines, 33 files

Files

Demos/Actions.hs view
@@ -1,17 +1,17 @@ 
 module Actions (actions) where
 
-import MFlow.Wai.Blaze.Html.All
+import MFlow.Wai.Blaze.Html.All hiding(page)
 import Menu 
 actions = do
-  r<- askm  $   p << b <<  "Two  boxes with one action each one"
+  r<- page  $   p << b <<  "Two  boxes with one action each one"
           ++> getString (Just "widget1") `waction` action
           <+> getString (Just "widget2") `waction` action
           <** submitButton "submit"
-  askm  $ p << ( show r ++ " returned")  ++> wlink ()  << p <<  " menu"
+  page  $ p << ( show r ++ " returned")  ++> wlink ()  << p <<  " menu"
   where
-  action n=  askm  $ getString (Just $ n ++ " action")<** submitButton "submit action"
+  action n=  page  $ getString (Just $ n ++ " action")<** submitButton "submit action"
 
--- to run it alone, change askm by ask and uncomment this:
+-- to run it alone, change page by ask and uncomment this:
 --main= runNavigation "" $ transientNav actions
Demos/AjaxSample.hs view
@@ -1,20 +1,24 @@-
+{-# OPTIONS -XCPP #-} 
 
 module AjaxSample ( ajaxsample) where
-import MFlow.Wai.Blaze.Html.All-import Menu
+
 import Data.Monoid
 import Data.ByteString.Lazy.Char8 as B+-- #define ALONE+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav ajaxsample+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif 
 ajaxsample= do
-   r <- askm  $   p << b <<  "Ajax example that increment the value in a box"
+   r <- page  $   p << b <<  "Ajax example that increment the value in a box"
             ++> do
                  let elemval= "document.getElementById('text1').value"
                  ajaxc <- ajax $ \n -> return . B.pack $ elemval <> "='" <> show(read  n +1) <>  "'"
                  b <<  "click the box "
                    ++> getInt (Just 0) <! [("id","text1"),("onclick", ajaxc  elemval)] <** submitButton "submit"
-   askm  $ p << ( show r ++ " returned")  ++> wlink ()  << p <<  " menu"
-
+   page  $ p << ( show r ++ " returned")  ++> wlink ()  << p <<  " menu"
 
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation "" $ transientNav ajaxsample
Demos/AutoCompList.hs view
@@ -1,19 +1,25 @@-
+{-# OPTIONS -XCPP #-} 
 module AutoCompList ( autocompList) where
-import MFlow.Wai.Blaze.Html.All
-import Menu
-import Data.List
+import Data.List+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav autocompList+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif 
+
 autocompList= do
-   r <- askm  $   p <<  "Autocomplete with a list of selected entries"
+   r <- page  $   p <<  "Autocomplete with a list of selected entries"
             ++> p <<  "enter  and press enter"
             ++> p <<  "when submit is pressed, the entries are returned"
             ++> wautocompleteList "red,green,blue" filter1 ["red"]
             <** submitButton "submit"
-   askm  $ p << ( show r ++ " selected")  ++> wlink () (p <<  " menu")
+   page  $ p << ( show r ++ " selected")  ++> wlink () (p <<  " menu")
 
    where
    filter1 s = return $ filter (isPrefixOf s) ["red","red rose","green","green grass","blue","blues"]
 
--- to run it alone, change askm by ask and uncomment this:
+-- to run it alone, change page by ask and uncomment this:
 --main= runNavigation "" $ transientNav autocompList
Demos/AutoComplete.hs view
@@ -1,20 +1,24 @@-
+{-# OPTIONS -XCPP #-} 
 module AutoComplete ( autocomplete1) where
-import MFlow.Wai.Blaze.Html.All
-import Menu
-import Data.List
+import Data.List+-- #define ALONE+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav autocomplete1+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif
 
 autocomplete1= do
-   r <- askm  $   p <<  "Autocomplete "
+   r <- page  $   p <<  "Autocomplete "
             ++> p <<  "when submit is pressed, the box value  is returned"
             ++> wautocomplete Nothing filter1 <! hint "red,green or blue"
             <** submitButton "submit"
-   askm  $ p << ( show r ++ " selected")  ++> wlink () (p <<  " menu")
+   page  $ p << ( show r ++ " selected")  ++> wlink () (p <<  " menu")
 
    where
    filter1 s = return $ filter (isPrefixOf s) ["red","red rose","green","green grass","blue","blues"]
 
 hint s= [("placeholder",s)]
 
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation "" $ transientNav autocomplete1
Demos/CheckBoxes.hs view
@@ -1,18 +1,22 @@-
+{-# OPTIONS -XCPP #-} 
 module CheckBoxes ( checkBoxes) where
+
+import Data.Monoid+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE import MFlow.Wai.Blaze.Html.All-import Menu
-import Data.Monoid
+main= runNavigation "" $ transientNav autocomplete1+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif
 
 checkBoxes= do
-   r <- askm  $ getCheckBoxes(  (setCheckBox False "Red"   <++ b <<  "red")
+   r <- page  $ getCheckBoxes(  (setCheckBox False "Red"   <++ b <<  "red")
                            <> (setCheckBox False "Green" <++ b <<  "green")
                            <> (setCheckBox False "blue"  <++ b <<  "blue"))
               <** submitButton "submit"
 
 
-   askm  $ p << ( show r ++ " selected")  ++> wlink () (p <<  " menu")
-
+   page  $ p << ( show r ++ " selected")  ++> wlink () (p <<  " menu")
 
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation "" $ transientNav checkBoxes
Demos/Combination.hs view
@@ -1,15 +1,21 @@-
+{-# OPTIONS -XCPP #-} 
 module Combination ( combination, wlogin1) where
-import MFlow.Wai.Blaze.Html.All
-import Menu
 import Counter(counterWidget)
-import Data.String
+import Data.String+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav combination+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif
 
 text= fromString
 
-combination =  askm  $ do
-     p << "Three active widgets in the same page with autoRefresh. Each widget refresh itself \
-          \with Ajax. If Ajax is not active, they will refresh by sending a new page."
+combination =  page $ 
+     p << "Three active widgets in the same page with autoRefresh. Each widget refresh itself"+     ++> p << "with Ajax. If Ajax is not active, they will refresh by sending a new page."
      ++> hr
      ++> p << "Login widget (use admin/admin)" ++> autoRefresh (pageFlow "r" wlogin1)  <++ hr
      **> p << "Counter widget" ++> autoRefresh (pageFlow "c" (counterWidget 0))  <++ hr
@@ -48,14 +54,14 @@ 
 
 hint s= [("placeholder",s)]
-onClickSubmit= [("onclick","if(window.jQuery){\n\
-                                  \$(this).parent().submit();}\n\
-                           \else {this.form.submit()}")]
+onClickSubmit= [("onclick","if(window.jQuery){\n"++
+                                  "$(this).parent().submit();}\n"++
+                           "else {this.form.submit()}")]
 radiob s n= wlabel (text s) $ setRadio s n <! onClickSubmit
 
 
 
--- | If not logged, it present a page flow which askm  for the user name, then the password if not logged
+-- | If not logged, it present a page flow which page  for the user name, then the password if not logged
 --
 -- If logged, it present the user name and a link to logout
 --
@@ -81,9 +87,4 @@ 
 focus = [("onload","this.focus()")]
 
-
-
-
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation "" $ transientNav  combination
 
Demos/ContentManagement.hs view
@@ -1,18 +1,19 @@-
+{-# OPTIONS -XCPP #-} 
 module ContentManagement ( textEdit) where
-import MFlow.Wai.Blaze.Html.All
 
 import Text.Blaze.Html5 as El
 import Text.Blaze.Html5.Attributes as At hiding (step)
 import Data.Monoid
 import Data.TCache.Memoization
 
-
-import Menu
-
--- to run it alone, change askm by ask and uncomment this:
---askm = ask
---main= runNavigation "" $ transientNav textEdit
+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav testEdit+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif
 
 
 
@@ -26,15 +27,15 @@ 
         second= p << i <<  "This is the original  of the second paragraph"
 
-    askm  $   p << b <<  "An example of content management"
+    page  $   p << b <<  "An example of content management"
         ++> first
         ++> second
         ++> wlink ()  << p <<  "click here to edit it"
     
-    askm  $   p <<  "Please login with edituser/edituser to edit it"
+    page  $   p <<  "Please login with edituser/edituser to edit it"
         ++> userWidget (Just editUser) userLogin
      
-    askm  $   p <<  "Now you can click the fields and edit them"
+    page  $   p <<  "Now you can click the fields and edit them"
         ++> p << b <<  "to save an edited field, press the save icon in the left"
         ++> tFieldEd editUser "first"  first
         **> tFieldEd editUser "second" second
@@ -42,12 +43,12 @@ 
     logout
    
-    askm  $   p <<  "the user sees the edited content. He can not edit"
+    page  $   p <<  "the user sees the edited content. He can not edit"
         ++> tFieldEd editUser "first"  first
         **> tFieldEd editUser "second" second
         **> wlink "a"  << p <<  "click to continue"
 
-    askm  $   p <<  "When texts are fixed,the edit facility and the original texts can be removed. The content is indexed by the field key"
+    page  $   p <<  "When texts are fixed,the edit facility and the original texts can be removed. The content is indexed by the field key"
         ++> tField "first"
         **> tField "second"
         **> p << "End of edit field demo" ++> wlink ()  << p <<  "click here to go to menu"
Demos/Counter.hs view
@@ -1,16 +1,23 @@-
+{-# OPTIONS -XCPP #-} 
 module Counter ( counter, counterWidget) where
-import MFlow.Wai.Blaze.Html.All
-import Menu
 import Data.Monoid
-import Data.String
+import Data.String++-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav counter+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif
 
 attr= fromString
 text= fromString
 
 counter= do
    
-   askm  $   explain
+   page  $   explain
        ++> pageFlow "c" (counterWidget 0) <++ br
        <|> wlink () << p << "exit"
    where
@@ -33,6 +40,3 @@           "i" -> counterWidget (n + 1)                       
           "d" -> counterWidget (n - 1)
 
-
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation "" $ transientNav counter
Demos/Dialog.hs view
@@ -1,12 +1,12 @@ 
 module Dialog (wdialog1) where
 
-import MFlow.Wai.Blaze.Html.All+import MFlow.Wai.Blaze.Html.All hiding(page) import Menu
 
 wdialog1= do
-   askm   wdialogw
-   askm  (wlink () << "out of the page flow, press here to go to the menu")
+   page   wdialogw
+   page  (wlink () << "out of the page flow, press here to go to the menu")
 
 wdialogw= pageFlow "diag" $ do
    r <- wform $ p << "please enter your name" ++> getString (Just "your name") <** submitButton "ok"
@@ -17,5 +17,5 @@                       else  wlink () << b << "thanks, press here to exit from the page Flow"
 
 
--- to run it alone, change askm by ask and uncomment this:
+-- to run it alone, change page by ask and uncomment this:
 --main= runNavigation "" $ transientNav wdialog1
Demos/Grid.hs view
@@ -1,19 +1,26 @@-
+{-# OPTIONS  -XCPP #-}
 module Grid ( grid) where
 
-import MFlow.Wai.Blaze.Html.All
-import Menu
 import Data.String
-import Text.Blaze.Html5.Attributes as At hiding (step)
+import Text.Blaze.Html5.Attributes as At hiding (step) 
+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav grid+#else+import MFlow.Wai.Blaze.Html.All hiding(retry, page)+import Menu+#endif+
 attr= fromString
 
 grid = do
-  r <- askm  $   addLink
+  r <- page  $   addLink
            ++> wEditList table  row ["",""] "wEditListAdd"
            <** submitButton "submit"
            
-  askm  $   p << (show r ++ " returned")
+  page  $   p << (show r ++ " returned")
       ++> wlink () (p <<  " back to menu")
       
   where
@@ -31,5 +38,3 @@              
   tdborder= td ! At.style  (attr "border: solid 1px")
 
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation "" $ transientNav grid
Demos/IncreaseInt.hs view
@@ -1,7 +1,7 @@ 
 module IncreaseInt ( clickn) where
 
-import MFlow.Wai.Blaze.Html.All
+import MFlow.Wai.Blaze.Html.All hiding(page)
 import Menu 
 -- |+| add a widget before and after another and return both results.
@@ -9,13 +9,13 @@  clickn :: Int -> FlowM Html IO ()
 clickn n= do
-   r <- askm  $ p << b <<  "increase an Int"
+   r <- page  $ p << b <<  "increase an Int"
             ++> wlink "menu"  << p <<  "menu"      
             |+| getInt (Just n)  <* submitButton "submit"
 
    case r of
-    (Just _,_) -> return ()  --  askm  $ wlink () << p << "thanks"
+    (Just _,_) -> return ()  --  page  $ wlink () << p << "thanks"
     (_, Just n') -> clickn $ n'+1
 
--- to run it alone, change askm by askm  and uncomment this:
+-- to run it alone, change page by page  and uncomment this:
 --main= runNavigation "" $ transientNav sumWidget
Demos/IncreaseString.hs view
@@ -1,17 +1,21 @@-
+{-# OPTIONS  -XCPP #-}
 module IncreaseString ( clicks) where
 
-import MFlow.Wai.Blaze.Html.All
+import MFlow.Wai.Blaze.Html.All hiding(page)
+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav grid+#else+import MFlow.Wai.Blaze.Html.All hiding(retry, page) import Menu+#endif 
-clicks s= do
-   s' <- askm  $  p << b <<  "increase a String"
+clicks s= do+   s' <- page  $  p << b <<  "increase a String"
              ++> p << b <<  "press the back button to go back to the menu"
              ++>(getString (Just s)
              <* submitButton "submit")
              `validate` (\s -> return $ if length s   > 5 then Just (b << "length must be < 5") else Nothing )
    clicks $ s'++ "1"
 
-
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation "" $ transientNav clicks "1"
Demos/ListEdit.hs view
@@ -1,22 +1,29 @@-{-# LANGUAGE OverloadedStrings #-}
+{-# LANGUAGE OverloadedStrings, CPP #-}
 module ListEdit ( wlistEd) where
 
-import MFlow.Wai.Blaze.Html.All
-import Menu
 import Text.Blaze.Html5 as El
 import Text.Blaze.Html5.Attributes as At hiding (step)
-import Data.String
+import Data.String+-- #define ALONE+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav wlistEd+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif 
 
 
+
 wlistEd= do
-   r <-  askm   $   addLink
+   r <-  page   $   addLink
               ++> br
               ++> (wEditList El.div getString1   ["hi", "how are you"] "wEditListAdd")
               <++ br
               <** submitButton "send"
 
-   askm  $   p << (show r ++ " returned")
+   page  $   p << (show r ++ " returned")
        ++> wlink () (p " back to menu")
 
 
@@ -29,6 +36,6 @@                     ! onclick  "this.parentNode.parentNode.removeChild(this.parentNode)"
    getString1 mx= El.div  <<< delBox ++> getString  mx <++ br
 
--- to run it alone, change askm by ask and uncomment this:
+-- to run it alone, change page by ask and uncomment this:
 --main= runNavigation "" $ transientNav wListEd
 
Demos/LoginSample.hs view
@@ -1,30 +1,33 @@-
+{-# OPTIONS -XCPP #-} 
 module LoginSample ( loginSample) where
 
-import MFlow.Wai.Blaze.Html.All
 import Data.Monoid
-import Menu
--- to run it alone, comment import Menu and uncomment this:
---main= runNavigation "" $ transientNav loginSample
---askm= ask
+-- #define ALONE to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav autocomplete1+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif
 
 loginSample= do
     userRegister "user" "user"
-    r <- askm  $   p <<  "Please login with user/user"
+    r <- page  $   p <<  "Please login with user/user"
                ++> userWidget Nothing userLogin
                <|> wlink "exit" << p << "or exit"
         
     if r == "exit" then return () else do
         user <- getCurrentUser
     
-        r <- askm  $   b <<  ("user logged as " <>  user)
+        r <- page  $   b <<  ("user logged as " <>  user)
                    ++> wlink True  << p <<  "logout"
                    <|> wlink False << p <<  "or exit"
 
         if r
           then do
              logout
-             askm  $ p << "logged out" ++> wlink () << "press here to exit"
+             page  $ p << "logged out" ++> wlink () << "press here to exit"
           else return ()
   
 
Demos/MCounter.hs view
@@ -1,15 +1,23 @@+{-# OPTIONS  -XCPP #-} module MCounter (
 mcounter
 ) where
-import MFlow.Wai.Blaze.Html.All
-import Menu
 import Data.Monoid
-import Data.String
+import Data.String+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav grid+#else+import MFlow.Wai.Blaze.Html.All hiding(retry, page)+import Menu+#endif 
 
 
+
 mcounter  = do 
- (op,n) <- step . askm $ do
+ (op,n) <- step . page $ do
               n <- getSessionData  `onNothing` return (0 :: Int) -- get Int data from the session
               op <- h2 << show n    
                      ++> wlink "i" << b << " ++ "
@@ -22,8 +30,4 @@           "d" -> setSessionData  (n - 1)
 
  mcounter
-
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation ""  mcounter
-
 
Demos/Multicounter.hs view
@@ -1,17 +1,23 @@-
+{-# OPTIONS -XCPP #-} 
 module Multicounter ( multicounter) where
 
-import MFlow.Wai.Blaze.Html.All
-import Menu
 import Data.Monoid 
 import Data.String
-import Counter(counterWidget)
+import Counter(counterWidget)+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav multicounter+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif
 
 text= fromString
 attr= fromString
 
 multicounter=
- askm  $ explain
+ page  $ explain
      ++> add (counterWidget 0) [1..4]
      <|> wlink () << p << "exit"
 
@@ -26,6 +32,3 @@ 
  add widget list= firstOf [autoRefresh $ pageFlow (show i) widget <++ hr | i <- list]
 
-
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation "" $ transientNav multicounter
Demos/Options.hs view
@@ -1,20 +1,26 @@-
+{-# OPTIONS -XCPP #-} 
 module Options (options) where
 
-import MFlow.Wai.Blaze.Html.All
+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav options+#else+import MFlow.Wai.Blaze.Html.All hiding(page) import Menu+#endif 
 options= do
-   r <- askm  $ getSelect (setSelectedOption ""  (p <<  "select a option") <|>
+   r <- page  $ getSelect (setSelectedOption ""  (p <<  "select a option") <|>
                          setOption "red"  (b <<  "red")                  <|>
                          setOption "blue" (b <<  "blue")                 <|>
                          setOption "Green"  (b <<  "Green")  )
                          <! dosummit
-   askm  $ p << (r ++ " selected") ++> wlink () (p <<  " menu")
+   page  $ p << (r ++ " selected") ++> wlink () (p <<  " menu")
 
 
    where
    dosummit= [("onchange","this.form.submit()")]
 
--- to run it alone, change askm by ask and uncomment this:
+-- to run it alone, change page by ask and uncomment this:
 --main= runNavigation "" $ transientNav options
Demos/PreventGoingBack.hs view
@@ -1,22 +1,29 @@-
+{-# OPTIONS -XCPP #-} 
 module PreventGoingBack ( preventBack) where
-import MFlow.Wai.Blaze.Html.All-import Menu
 import System.IO.Unsafe
-import Control.Concurrent.MVar
+import Control.Concurrent.MVar++-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav preventBack+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif
 
 rpaid= unsafePerformIO $ newMVar (0 :: Int)
 
 
 preventBack= do
-    askm  $ wlink "don't care" << b << "press here to pay 100000 $ "
+    page  $ wlink "don't care" << b << "press here to pay 100000 $ "
     payIt
     paid  <- liftIO $ readMVar rpaid
-    preventGoingBack . askm  $ p << "You already paid 100000 before"
+    preventGoingBack . page  $ p << "You already paid 100000 before"
                            ++> p << "you can not go back until the end of the buy process"
                            ++> wlink () << p << "Please press here to continue"
                            
-    askm  $   p << ("you paid "++ show paid)
+    page  $   p << ("you paid "++ show paid)
         ++> wlink () << p << "Press here to go to the menu or press the back button to verify that you can not pay again"
     where
     payIt= liftIO $ do
@@ -24,5 +31,5 @@       paid <- takeMVar  rpaid
       putMVar rpaid $ paid + 100000
 
--- to run it alone, change askm by ask and uncomment this:
+-- to run it alone, change page by ask and uncomment this:
 --main= runNavigation "" $ transientNav preventBack
Demos/PushDecrease.hs view
@@ -1,15 +1,18 @@-{-# OPTIONS -XQuasiQuotes #-}
+{-# OPTIONS -XQuasiQuotes  -XCPP #-}
 module PushDecrease ( pushDecrease) where
 
-import MFlow.Wai.Blaze.Html.All
-
 import Control.Concurrent.STM
 import Text.Hamlet
 import Control.Concurrent
 
-import Menu
--- to run it alone, comment "import menu" and uncomment:
---main= runNavigation "" $ transientNav pushDecrease
+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav pushDecrease+#else+import MFlow.Wai.Blaze.Html.All hiding(page)+import Menu+#endif
 
 
 atomic= liftIO . atomically
@@ -17,13 +20,13 @@ pushDecrease= do
  tv <- liftIO $ newTVarIO 10
 
- pagem $
+ page $
       [shamlet|
        <div>
            <h2> Maxwell Smart push counter
-           <p> This example shows a reverse counter
-           <p> To avoid unnecessary load, the push process will be killed when reaching 0
-           <p> The last push message will be an script that will redirect to the menu"
+           <p>  This example shows a reverse counter
+           <p>  To avoid unnecessary load, the push process will be killed when reaching 0
+           <p>  The last push message will be an script that will redirect to the menu"
            <h3> This message will be autodestroyed within ...
 
       |] ++> counter tv <++  b << "seconds"
Demos/PushSample.hs view
@@ -1,48 +1,54 @@-
-module PushSample (pushSample) where
-
-import MFlow.Wai.Blaze.Html.All hiding (retry)-import Menu 
-import Control.Concurrent.STM 
+{-# OPTIONS -XQuasiQuotes  -XCPP #-}
+module PushSample (pushSample) where 
+import Control.Concurrent.STM+import System.IO.Unsafe
++-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav pushSample+#else+import MFlow.Wai.Blaze.Html.All hiding(retry, page)+import Menu+#endif 
+++lastLine = unsafePerformIO $ newTVarIO $ "The content will be appended here"+  
 pushSample=  do
-  tv <- liftIO $ newTVarIO $ Just "The content will be appended here"
-  pagem $   h2 << "Push example"
-       ++> p << "The content of the text box will be appended to the push widget above."
-       ++> p << "A push widget can have links and form fields."
-       ++> p << "Since they are asynchronous, the communucation must be trough mutable variables"
-       ++> p << "The input box is configured with autoRefresh"
+  last <- liftIO $ newTVarIO ""
+  page  $ h2 << "Basic Chat as a push example"
        ++> hr
-
-       ++> pageFlow "push" (push Append 5000 (disp tv) <** input tv)
+       ++> pageFlow "push" (push Append 1000 (disp last ) <** input )
        **> br
        ++> br
        ++> wlink () << b << "exit"
 
   where
   -- the widget being pushed:
-  disp tv= do
-      setTimeouts 100 0
-      line <- tget tv
+  disp last = do
+      setTimeouts 100 0  -- after 100 seconds of inactivity , kill itself, but restart if needed
+      line <- tget last
       p <<  line ++> noWidget
 
-  input tv= autoRefresh  $ do
+  input = autoRefresh  $ do
       line <- getString Nothing <** submitButton "Enter"
-      tput tv line
+      tput lastLine line
 
 
-  tput tv x = atomic $ writeTVar  tv ( Just x)
+  tput tv x = atomic $ writeTVar  tv  x
 
-  tget tv= atomic $ do
-      mr <- readTVar tv
-      case mr of
-         Nothing -> retry
-         Just r -> do
-          writeTVar tv Nothing
-          return r
+  tget last = atomic $ do
+      msg <- readTVar lastLine+      lastmsg <- readTVar last
+      case lastmsg == msg of
+         False ->  do+            writeTVar last msg+            return msg
+         True -> retry+           
 
 atomic= liftIO . atomically
 
--- to run it alone, change askm by ask and uncomment this:
---main= runNavigation "" $ transientNav pushSample
Demos/Radio.hs view
@@ -1,14 +1,20 @@-
+{-# OPTIONS  -XCPP #-}
 module Radio ( radio) where
 
-import MFlow.Wai.Blaze.Html.All
+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav grid+#else+import MFlow.Wai.Blaze.Html.All hiding(retry, page) import Menu+#endif 
 radio = do
-   r <- askm $   p << b <<  "Radio buttons"
+   r <- page $   p << b <<  "Radio buttons"
             ++> getRadio [\n -> fromStr v ++> setRadioActive v n | v <- ["red","green","blue"]]
 
-   askm $ p << ( show r ++ " selected")  ++> wlink ()  << p <<  " menu"
+   page $ p << ( show r ++ " selected")  ++> wlink ()  << p <<  " menu"
 
--- to run it alone, change askm by ask and uncomment this:
+-- to run it alone, change page by ask and uncomment this:
 --main= runNavigation "" $ transientNav radio
Demos/ShopCart.hs view
@@ -1,22 +1,20 @@-
-{-# OPTIONS  -XDeriveDataTypeable #-}
+{-# OPTIONS  -XDeriveDataTypeable -XCPP #-}
 module ShopCart ( shopCart) where
-
-import MFlow.Wai.Blaze.Html.All-
 import Data.Typeable
 import qualified Data.Vector as V
 import Text.Blaze.Html5 as El
 import Text.Blaze.Html5.Attributes as At hiding (step)
 import Data.Monoid
 import Data.String
-import Data.Typeable
-+import Data.Typeable+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav grid+#else+import MFlow.Wai.Blaze.Html.All hiding(retry, page) import Menu-
--- to run it alone, comment import Menu and uncomment the code below
---main= runNavigation ""   shopCart-
--askm= ask+#endif 
 data ShopOptions= IPhone | IPod | IPad deriving (Bounded, Enum, Show,Read , Typeable)
 
@@ -30,7 +28,7 @@      setHeader  stdheader 
 --     setTimeouts 200 $ 60*60   
      prod <--        step . askm $ do
+        step . page $ do
              Cart cart <- getSessionData `onNothing` return  emptyCart
 
              moreexplain
@@ -60,12 +58,12 @@     linkHome= a ! href  (attr $ "/" ++ noScript) << b <<  "home"
     attr= fromString     moreexplain= do-     p $ El.span <<
-         "A persistent flow  (uses step). The process is killed after the timeout set by setTimeouts \
-         \but it is restarted automatically. Event If you restart the whole server, it remember the shopping cart\n\n \-         \The shopping cart is not logged, just the products bought returned by step are logged. The shopping cart\-         \is rebuild from the events (that is an example of event sourcing.\n\n\
-         \.Defines a table with links that return ints and a link to the menu, that abandon this flow.\n\
-         \.The cart state is not stored, Only the history of events is saved. The cart is recreated by running the history of events."
+     p $ El.span <<(
+         "A persistent flow  (uses step). The process is killed after the timeout set by setTimeouts "++
+         "but it is restarted automatically. Event If you restart the whole server, it remember the shopping cart "+++         " The shopping cart is not logged, just the products bought returned by step are logged. The shopping cart "+++         " is rebuild from the events (that is an example of event sourcing."++
+         " .Defines a table with links that return ints and a link to the menu, that abandon this flow. "++
+         " .The cart state is not stored, Only the history of events is saved. The cart is recreated by running the history of events.")
       p << "The second parameter of \"setTimeout\" is the time during which the cart is recorded"
Demos/SumView.hs view
@@ -1,12 +1,18 @@-
+{-# OPTIONS  -XCPP #-}
 module SumView (sumInView) where
 
-import MFlow.Wai.Blaze.Html.All
+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav grid+#else+import MFlow.Wai.Blaze.Html.All hiding(retry, page) import Menu+#endif 
-sumInView= askm $ p << "ask for three numbers in the same page and display the result.\
-                      \It is possible to modify the inputs and the sum will reflect it"
-               ++> sumWidget
+sumInView= page $ p << "ask for three numbers in the same page and display the result."
+              ++> p << "It is possible to modify the inputs and the sum will reflect it"
+              ++> sumWidget
                
 sumWidget=   pageFlow "sum" $ do
       n <- do
@@ -21,5 +27,5 @@       p <<  ("The result is: "++show n)  ++>  wlink () << b << " menu"
       <++ p << "you can change the numbers in the boxes to see how the result changes"
 
--- to run it alone, replace askm by ask and uncomment the following line
+-- to run it alone, replace page by ask and uncomment the following line
 --main= runNavigation "" $ transientNav sumWidget
Demos/TestREST.hs view
@@ -1,9 +1,16 @@-
+{-# OPTIONS  -XCPP #-}
 module TestREST where
-import MFlow.Wai.Blaze.Html.All
 import Menu
 import Data.Monoid
 import Data.String
+-- #define ALONE -- to execute it alone, uncomment this+#ifdef ALONE+import MFlow.Wai.Blaze.Html.All+main= runNavigation "" $ transientNav grid+#else+import MFlow.Wai.Blaze.Html.All hiding(retry, page)+import Menu+#endif 
 -- A menu with two branches, each one is a sucession of pages
 
@@ -17,24 +24,22 @@ 
 
 testREST= do
---  setTimeouts 120 0
-
-  option <- pagem $  h2 << "Choose between:"
+  option <- page $   h2 << "Choose between:"
                  ++> wlink "a" << b << "letters " <++ i << " or "
                  <|> wlink "1" << b << "numbers"
 
   case option of
     "1" -> do
-          pagem $ wlink "2" << contentFor "1" 
-          pagem $ wlink "3" << contentFor "2"
-          pagem $ wlink "4" << contentFor "3"
-          pagem $ wlink ()  << "menu"
+          page $ wlink "2" << contentFor "1" 
+          page $ wlink "3" << contentFor "2"
+          page $ wlink "4" << contentFor "3"
+          page $ wlink ()  << "menu"
 
     "a" -> do
-          pagem $ wlink "b" << contentFor "a"
-          pagem $ wlink "c" << contentFor "b"
-          pagem $ wlink "d" << contentFor "c"
-          pagem $ wlink ()  << "menu"
+          page $ wlink "b" << contentFor "a"
+          page $ wlink "c" << contentFor "b"
+          page $ wlink "d" << contentFor "c"
+          page $ wlink ()  << "menu"
 
 
 contentFor x= do
Demos/TraceSample.hs view
@@ -1,12 +1,16 @@ {-# OPTIONS -F -pgmF MonadLoc #-}
 module TraceSample ( traceSample) where
 
-import MFlow.Wai.Blaze.Html.All
-import Menu
+import MFlow.Wai.Blaze.Html.All hiding (page)
 import Control.Monad.Loc
++import Menu+-- to run it alone, remove import menu and uncomment the following line
+--main= runNavigation "" $ transientNav traceSample
+ 
 traceSample= do
-  pagem $  h2 << "Error trace example"
+  page $  h2 << "Error trace example"
        ++> p << "MFlow now produces execution traces in case of error by making use of the backtracking mechanism"
        ++> p << "It is more detailed than a call stack"
        ++> p << "this example has a deliberate error"
@@ -14,14 +18,12 @@        ++> p << "You must be logged as admin to see the trace"
        ++> wlink () << p << "pres here"
 
-  pagem $   p <<  "Please login with admin/admin"
+  page $   p <<  "Please login with admin/admin"
         ++> userWidget (Just "admin") userLogin
 
   u <- getCurrentUser
-  pagem $   p << "The trace will appear after you press the link. press one of the options available at the bottom of the pagem"
+  page $   p << "The trace will appear after you press the link. press one of the options available at the bottom of the pagem"
         ++> p << ("user="++ u) ++> br
         ++> wlink () << "press here"
-  pagem $   error $ "this is the error"
+  page $   error $ "this is the error"
 
--- to run it alone, replace askm by ask and uncomment the following line
---main= runNavigation "" $ transientNav traceSample
Demos/demos-blaze.hs view
@@ -1,4 +1,4 @@-{-# OPTIONS  -XDeriveDataTypeable -XQuasiQuotes -XOverloadedStrings -F -pgmF MonadLoc #-}
+{-# OPTIONS  -XDeriveDataTypeable -XQuasiQuotes -XOverloadedStrings #-}
 module Main where
 import MFlow.Wai.Blaze.Html.All hiding (name)
 import Text.Blaze.Html5 as El
@@ -14,7 +14,7 @@ -- For error traces
 import Control.Monad.Loc
 -import Menu
+import Menu hiding (page)
 import TestREST
 import Actions
 import IncreaseInt
@@ -41,13 +41,14 @@ import MCounter import Database import MFlowPersistent-import RuntimeTemplates
-
-import Debug.Trace+import RuntimeTemplates+import TraceSample ---(!>)= flip trace
-
---attr= fromString+import Data.TCache.DefaultPersistence+import Data.ByteString.Lazy.Char8 hiding (index)+instance Serializable Int where+  serialize= pack . show+  deserialize= read . unpack   @@ -58,14 +59,14 @@    userRegister edadmin edadmin    userRegister "edituser" "edituser"
    syncWrite  $ Asyncronous 120 defaultCheck  1000---   addMessageFlows[("wiki", transient $ runFlow $ ask  wiki)] 
+
    setFilesPath "Demos/"    runNavigation "" $ do        setHeader $ stdheader 
        setTimeouts 400 $ 60 * 60 
-       r <- step . ask $   tFieldEd edadmin "head" "set Header" <++ hr-                       **> topLogin+       r <- step . page $   tFieldEd edadmin "head" "set Header" <++ hr+                       **> (El.div ! At.style "float:right" <<< autoRefresh wlogin )                        **> (divmenu  <<< br ++>  mainMenu) 
                        <** (El.div ! At.style "float:right;width:65%;overflow:auto;"                             <<< tFieldEd edadmin "intro" "enter intro text")
@@ -103,38 +104,4 @@   -wiki =  do-  pag <- getRestParam `onNothing` return "Index"-  askm $-   (docTypeHtml $ do
-       El.head $ do-        El.title $ fromString pag)-        ++> (El.div ! At.style "float:right" <<< autoRefresh wlogin )-        **> ( h1 ! At.style "text-align:center" <<<  tFieldEd "editor" (wikip ++pag ++ "title.html") (fromString pag))-        **> tFieldEd "editor" (wikip ++ pag ++ "body.html") "Enter the body"-        **> noWidget--wikip="wiki/"----- | to run it on heroku, traceSample is included since heroku does not run the monadloc preprocessor
-traceSample= do
-  pagem $ h2  "Error trace example"
-       ++> p  "MFlow now produces execution traces in case of error by making use of the backtracking mechanism"
-       ++> p  "It is more detailed than a call stack"
-       ++> p  "this example has a deliberate error"
-       ++> br
-       ++> p "You must be logged as admin to see the trace"
-       ++> wlink () << p "pres here"
-
-  pagem $   p "Please login with admin/admin"
-        ++> userWidget (Just "admin") userLogin
-
-  u <- getCurrentUser
-  pagem $  p "The trace will appear after you press the link. press one of the options available at the bottom of the page"
-       ++> p << ("user="++ u) ++> br
-       ++> wlink () "press here"
-  pagem $  error $ "this is the error"
-
-
 
MFlow.cabal view
@@ -1,5 +1,5 @@ name: MFlow
-version: 0.3.2.0
+version: 0.3.3
 cabal-version: >=1.8
 build-type: Simple
 license: BSD3
@@ -45,18 +45,22 @@              Bindings for hack, and hsp >= 0.8,  are not compiled by Hackage, and do not appear, but are included in the package files. To use them, add then to the exported modules and execute cabal install
              .              .-             This version 0.3.2 add runtime templates http://haskell-web.blogspot.com.es/2013/11/more-composable-elements-for-single.html+             This version 0.3.3 run with wai 2.0+             .+             The version 0.3.2 add runtime templates. It also add witerate and dField, two modifiers for single page+             development. dField creates a placeholder for a widget that is updated via implicit AJAX by witerate.+             http://haskell-web.blogspot.com.es/2013/11/more-composable-elements-for-single.html              .
              The version 0.3.1 included:
              .
-             - Push widgets: http://haskell-web.blogspot.com.es/2013/07/maxwell-smart-push-counter.html
+             - Push widgets: 'http://haskell-web.blogspot.com.es/2013/07/maxwell-smart-push-counter.html'
              .
-             - Complete execution traces for errors: http://haskell-web.blogspot.com.es/2013/07/automatic-error-trace-generation-in.html
+             - Complete execution traces for errors: 'http://haskell-web.blogspot.com.es/2013/07/automatic-error-trace-generation-in.html'
              .
              The version 0.3 added:
-             - RESTful URLs: http://haskell-web.blogspot.com.es/2013/07/the-web-navigation-monad.html
+             - RESTful URLs: 'http://haskell-web.blogspot.com.es/2013/07/the-web-navigation-monad.html'
              .
-             - Automatic independent refreshing of widgets via Ajax. (see http://haskell-web.blogspot.com.es/2013/06/and-finally-widget-auto-refreshing.html)
+             - Automatic independent refreshing of widgets via Ajax. (see 'http://haskell-web.blogspot.com.es/2013/06/and-finally-widget-auto-refreshing.html')
              .
              - Page flows: Monadic widgets that can express his own behaviour and can run its own independent page flow. (see http://haskell-web.blogspot.com.es/2013/06/the-promising-land-of-monadic-formlets.html)
              .
@@ -77,7 +81,7 @@              .
              -Clustering
              .
-             In this release, runtime templates is e
+
 category: Web, Application Server
 author: Alberto Gómez Corona
 data-dir: ""
@@ -104,7 +108,7 @@                    TCache -any, stm >2, old-time -any, vector -any,
                    directory -any, utf8-string -any, wai -any, case-insensitive -any,
                    http-types -any, conduit -any, text -any, parsec -any, warp -any,
-                   random -any, blaze-html -any, blaze-markup -any, monadloc -any,
+                   random -any, blaze-html -any, blaze-markup -any, monadloc -any, 
                    hamlet -any
     exposed-modules: MFlow MFlow.Wai.Blaze.Html.All MFlow.Forms
                      MFlow.Forms.Admin MFlow.Cookies MFlow.Wai MFlow.Wai.XHtml.All
@@ -112,22 +116,23 @@                      MFlow.Forms.Widgets MFlow.Forms.Internals
     exposed: True
     buildable: True
-    hs-source-dirs: src .
+    hs-source-dirs: src .+    ghc-options: 
     other-modules:  MFlow.Wai.Response
 
---executable demos-blaze
---    build-depends: MFlow -any, RefSerialize -any, TCache -any,
+-- executable demos-blaze
+--    build-depends: MFlow -any, RefSerialize -any, TCache -any, tcache-AWS -any,
 --                   directory -any ,  Workflow -any, base -any, blaze-html -any,
 --                   bytestring, containers -any, mtl -any, old-time -any,
 --                   stm -any, text -any, transformers -any, vector -any, hamlet -any,
---                   monadloc -any, monadloc-pp -any, aws -any, network -any, hscolour -any,
+--                   monadloc -any,aws -any, network -any, hscolour -any,
 --                   persistent-template, persistent-sqlite, persistent,
 --                   conduit, http-conduit, monad-logger
 --
 --
---    main-is: demos-blaze.Loc.hs
+--    main-is: demos-blaze.hs
 --    buildable: True
 --    hs-source-dirs: Demos
 --    other-modules: MFlowPersistent MCounter
---    ghc-options: -iDemos -threaded -rtsopts
+--    ghc-options: -O -iDemos -threaded -rtsopts
 
src/MFlow.hs view
@@ -63,7 +63,7 @@ ,flushRec, receive, receiveReq, receiveReqTimeout, send, sendFlush, sendFragment
 , sendEndFragment, sendToMF
 -- * Flow configuration
-,addMessageFlows,getMessageFlows,delMessageFlow, transient, stateless,anonymous
+,setNoScript,addMessageFlows,getMessageFlows,delMessageFlow, transient, stateless,anonymous
 ,noScript,hlog, setNotFoundResponse,getNotFoundResponse,
 -- * ByteString tags
 -- | very basic but efficient bytestring tag formatting
@@ -229,8 +229,16 @@ anonymous= "anon#"
 
 -- | It is the path of the root flow
-noScript = "noscript"
+noScriptRef= unsafePerformIO $ newIORef "noscript" 
+noScript= unsafePerformIO $ readIORef noScriptRef
++-- | set the flow to be executed when the URL has no path. The home page.+--+-- By default it is "noscript".+-- Although it is changed by `runNavigation` to his own flow name.+setNoScript scr= writeIORef noScriptRef scr
+
 {-
 instance  (Monad m, Show a) => Traceable (Workflow m a) where
        debugf iox str = do
@@ -385,9 +393,10 @@         case r of
           Left NotFound -> do
                  (sendFlush token =<<  serveFile  (pwfname x))
-                    `CE.catch`\(e:: CE.SomeException) -> showError wfname token (show e)
---               sendFlush token (Error NotFound $ "Not found: " <> pack wfname)
-                 deleteTokenInList token
+                    `CE.catch` \(e:: CE.SomeException) -> do+                       showError wfname token (show e)
+--                     sendFlush token (Error NotFound $ "Not found: " <> pack wfname)
+                       deleteTokenInList token 
 
           Left AlreadyRunning -> return ()                    -- !> ("already Running " ++ wfname)
 
src/MFlow/Forms.hs view
@@ -111,6 +111,7 @@ be combined as such.  * NEW IN THIS RELEASE+ [@Runtime templates@]  'template', 'edTemplate', 'witerate' and 'dField' permit the edition of the widget content at runtime, and the management of placeholders with input fields and data fields within the template with no navigation in the client, little bandwidth usage and little server load. Enven less@@ -578,7 +579,7 @@                  ,  Monad m)
                    => T.Text                  ->  View view m T.Text
-getMultilineText nvalue = View $ do
+getMultilineText nvalue = View $ do 
     tolook <- genNewId     env <- gets mfEnv     r <- getParam1 tolook env@@ -600,7 +601,7 @@ -- | Display a dropdown box with the two values (second (true) and third parameter(false)) -- . With the value of the first parameter selected.                  
 getBool :: (FormInput view,
-      Monad m, Functor m) =>
+      Monad m, Functor m) => 
       Bool -> String -> String -> View view m Bool
 getBool mv truestr falsestr= do    r <- getSelect $   setOption truestr (fromStr truestr)  <! (if mv then [("selected","true")] else [])@@ -785,7 +786,9 @@   --- | Empty widget that return Nothing. May be used as \"empty boxes\" inside larger widgets+-- | Empty widget that return Nothing. May be used as \"empty boxes\" inside larger widgets.+--+-- It returns a non valid value. noWidget ::  (FormInput view,
      Monad m) =>
      View view m a@@ -797,11 +800,11 @@      a -> View view m a wrender x = (fromStr $ show x) ++> return x --- | Render raw view formatting. It is useful for displaying information+-- | Render raw view formatting. It is useful for displaying information. wraw :: Monad m => view -> View view m () wraw x= View . return . FormElm [x] $ Just () --- To display some rendering and return  non valid+-- To display some rendering and return  a no valid value notValid :: Monad m => view -> View view m a notValid x= View . return $ FormElm [x] Nothing @@ -1056,12 +1059,12 @@                             True -> length (mfPath st') -1                             False -> mfPIndex st'          }-         breturn x                                        -- !> "RETURN"+         breturn x                                       -- !> "BRETURN" 
        Nothing ->          if  not (inSync st')  && not (newAsk st') --                                                        !> ("pageIndex="++ show (mfPageIndex st'))---                                                        !> ("insinc="++show (inSync st'))+--                                                        !> ("insync="++show (inSync st')) --                                                        !> ("newask="++show (newAsk st')) --                                                        !> ("mfPIndex="++ show( mfPIndex st'))           then do@@ -1202,7 +1205,7 @@ wform x = View $ do
      FormElm form mr <- (runView $   x )      st <- get-     verb <- getWFName
+     verb  <- getWFName
      form1 <- formPrefix (mfPIndex st) verb st form True      put st{needForm=False}
      return $ FormElm [form1] mr
src/MFlow/Forms/Internals.hs view
@@ -57,8 +57,8 @@ import Control.Concurrent
 import Control.Monad.Loc
 
-import Debug.Trace
-(!>) = flip trace
+--import Debug.Trace
+--(!>) = flip trace 
 
 
 data FailBack a = BackPoint a | NoBack a | GoBack   deriving (Show,Typeable)
@@ -112,8 +112,8 @@ fromFailBack (NoBack  x)   = x
 fromFailBack (BackPoint  x)= x
 toFailBack x= NoBack x
-
-
++ -- | the FlowM monad executes the page navigation. It perform Backtracking when necessary to syncronize
 -- when the user press the back button or when the user enter an arbitrary URL. The instruction pointer
 -- is moved to the right position within the procedure to handle the request.
@@ -121,7 +121,7 @@ -- However this is transparent to the programmer, who codify in the style of a console application.
 newtype FlowM v m a= FlowM {runFlowM :: FlowMM v m a} deriving (Monad,MonadIO,Functor,MonadState(MFlowState v))
 flowM= FlowM
---runFlowM= runView
+--runFlowM= runView 
 {-# NOINLINE breturn  #-}
 
@@ -373,11 +373,11 @@      Nothing -> return $ FormElm form1 Nothing
 
 --clear :: Monad m => View v m ()
---clear=  View $ do
---   modify $ \s -> s{mfClear= True}
---   return . FormElm [] $ Just ()
-
-clear :: Monad m => View v m ()
+--clear=  View $ do+--   modify $ \s -> s{mfClear= True}+--   return . FormElm [] $ Just ()++clear :: Monad m => View v m () clear = wcallback (return()) (const $ return()) 
 
 --incLink :: MonadState (MFlowState view) m => m()
@@ -437,7 +437,7 @@ --  Usually this check is nos necessary unless conditional code make it necessary
 --
 -- @menu= do
---       mop <- getGoStraighTo
+--       mop <- getGoStraighTo 
 --       case mop of
 --        Just goop -> goop
 --        Nothing -> do
@@ -463,7 +463,7 @@ --
 -- However this is very specialized. Normally the back button detection is not necessary.
 -- In a persistent flow (with step) even this default entry option would be completely automatic,
--- since the process would restar at the last page visited. No setting is necessary.
+-- since the process would restart at the last page visited.
 goingBack :: MonadState (MFlowState view) m => m Bool
 goingBack = do
     st <- get
@@ -777,7 +777,7 @@         let((FormElm  _ mx2), s2)  = execute $ runStateT  ( runView mf)    s{mfSeqCache= sec,mfCached=True}
         let s''=  s{inSync = inSync s2
                    ,mfRequirements=mfRequirements s2
-                   ,mfPath= mfPath s2
+                   ,mfPath= mfPath s2                    ,needForm= needForm s2
                    ,mfPIndex= mfPIndex s2
                    ,mfPageIndex= mfPageIndex s2
@@ -1078,31 +1078,31 @@ 
 
 data ParamResult v a= NoParam | NotValidated String v | Validated a deriving (Read, Show)
-
-valToMaybe (Validated x)= Just x
-valToMaybe _= Nothing
-
-isValidated (Validated x)= True
-isValidated _= False
-
-fromValidated (Validated x)= x
-fromValidated NoParam= error $ "fromValidated : NoParam"
-fromValidated (NotValidated s err)= error $ "fromValidated: NotValidated "++ s
-
++valToMaybe (Validated x)= Just x+valToMaybe _= Nothing++isValidated (Validated x)= True+isValidated _= False++fromValidated (Validated x)= x+fromValidated NoParam= error $ "fromValidated : NoParam"+fromValidated (NotValidated s err)= error $ "fromValidated: NotValidated "++ s+ 
 getParam1 :: (Monad m, MonadState (MFlowState v) m, Typeable a, Read a, FormInput v)
           => String -> Params ->  m (ParamResult v a)
 getParam1 par req =   case lookup  par req of
-    Just x1 -> readParam x1
-    Nothing  -> return  NoParam
-
-readParam :: (Monad m, MonadState (MFlowState v) m, Typeable a, Read a, FormInput v)
-           => String -> m (ParamResult v a)
-readParam x1 = r
- where
+    Just x1 -> readParam x1 
+    Nothing  -> return  NoParam++readParam :: (Monad m, MonadState (MFlowState v) m, Typeable a, Read a, FormInput v)+           => String -> m (ParamResult v a)+readParam x1 = r+ where  r= do
      modify $ \s -> s{inSync= True}
-     maybeRead x1
+     maybeRead x1       
  getType ::  m (ParamResult v a) -> a
  getType= undefined
@@ -1225,7 +1225,7 @@   let s =  jsRequirements $ sort rs
 
   return $ ftag "script" (fromStrNoEncode  s)
-
+ 
 jsRequirements  []= ""
 
@@ -1288,6 +1288,20 @@                         return ('#':anchor, (ftag "a") mempty  `attrs` [("name",anchor)])
                False -> return (mempty,mempty)
      return $ formAction (path ++ anchor ) $  mconcat ( anchorf:form)  -- !> anchor
++-- | insert a form tag if the widget has form input fields. If not, it does nothing+insertForm w=View $ do+    FormElm forms mx <- runView w+    st <- get+    cont <- case needForm st of+                      True ->  do+                               frm <- formPrefix (mfPIndex st) (twfname $ mfToken st ) st forms False+                               put st{needForm= False}+                               return   frm+                      _    ->  return $ mconcat  forms++    return $ FormElm [cont] mx+ 
 currentPath insInBackTracking index lpath verb =
     (if null lpath then verb
@@ -1325,4 +1339,4 @@     True  -> do
       let n = mfSeqCache st
       return $  'c' : (show n)
-
+
src/MFlow/Forms/Widgets.hs view
@@ -64,18 +64,19 @@ import Control.Monad.Identity import Control.Workflow(killWF) import Unsafe.Coerce+import Control.Exception   readyJQuery="ready=function(){if(!window.jQuery){return setTimeout(ready,100)}};" -jqueryScript1= "http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"-jqueryScript="http://code.jquery.com/jquery-1.9.1.js"+jqueryScript= "//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"+jqueryScript1="//code.jquery.com/jquery-1.9.1.js" -jqueryCSS1= "http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css"-jqueryCSS= "http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css"+jqueryCSS1= "//code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css"+jqueryCSS= "//code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" -jqueryUI1= "http://code.jquery.com/ui/1.9.1/jquery-ui.js"-jqueryUI= "http://code.jquery.com/ui/1.10.3/jquery-ui.js"+jqueryUI1= "//code.jquery.com/ui/1.9.1/jquery-ui.js"+jqueryUI= "//code.jquery.com/ui/1.10.3/jquery-ui.js"  ------- User Management ------ @@ -122,7 +123,7 @@ --
 -- normally to be used with autoRefresh and pageFlow when used with other widgets.
 wlogin :: (MonadIO m,Functor m,FormInput v) => View v m ()
-wlogin=  do
+wlogin= insertForm $ do
    username <- getCurrentUser
    if username /= anonymous
          then return username
@@ -442,15 +443,30 @@   instance Serializable TField where-    serialize (TField k content)  = B.pack $ "TField "++show k ++ " " ++ show (B.unpack content)-- B.pack . show-    deserialize bs=-                let ('T':'F':'i':'e':'l':'d':' ':s)= B.unpack bs -- read . B.unpack-                    [(k,rest)] =  readsPrec 0 s-                    [(content,_)] = readsPrec 0 $ tail rest-                in TField k (B.pack content)+    serialize (TField k content)  = content+    deserialKey k content= TField k content -- applyDeserializers [des1,des2] k bs++--       where++--       des1 _ bs=+--          let s= B.unpack bs -- read . B.unpack+--          in case s of+--               ('T':'F':'i':'e':'l':'d':' ':s)  ->+--                  let+--                      [(k,rest)] =  readsPrec 0 s+--                      [(content,_)] = readsPrec 0 $ tail rest+--                  in TField k (B.pack content)+--               _ -> error "not match"     setPersist =   \_ -> Just filePersist  +--applyDeserializers [] k str = x where+--     x= error $ "can not deserialize "++ B.unpack str++" to type: "++ show (typeOf x)+--+--applyDeserializers (d:ds) k str=  unsafePerformIO $+--      (return $! d k str) `catch` (\(_ :: SomeException)-> return (applyDeserializers ds k str))++ writetField k s= atomically $ writeDBRef (getDBRef k) $ TField k $ toByteString s  @@ -458,7 +474,7 @@    let ref = getDBRef k    mr <- readDBRef ref    case mr of-    Just (TField k v) -> return $ fromStrNoEncode $ B.unpack v+    Just (TField k v) -> if v /= mempty then return $ fromStrNoEncode $ B.unpack v else return text     Nothing -> return text  @@ -478,7 +494,7 @@   requires [JScriptFile nicEditUrl [installHtmlField,install]]   w <! [("id",id)] -nicEditUrl= "http://js.nicedit.com/nicEdit-latest.js"+nicEditUrl= "//js.nicedit.com/nicEdit-latest.js"   -- | A widget that display the content of an  html, But if the user has edition privileges,@@ -520,7 +536,7 @@             ,ServerProc  ("_texts",  transient getTexts)]     (ftag "div" mempty `attrs` [("id",ipanel)]) ++>-    wraw (ftag "span" content `attrs` [("id", name)])+    notValid (ftag "span" content `attrs` [("id", name)])   @@ -559,7 +575,7 @@        -> View v m () tField k = wfreeze k 0 $ do     content <- liftIO $ readtField (fromStrNoEncode "not found")  k-    wraw content+    notValid content  -- | A multilanguage version of tFieldEd. For a field with @key@ it add a suffix with the -- two characters of the language used.@@ -917,22 +933,10 @@      (ftag "div" <<< insertForm w) <! [("id",id),("title", title)] --- | insert a form tag if the widget has form input fields. If not, it does nothing-insertForm w=View $ do-    FormElm forms mx <- runView w-    st <- get  -    cont <- case needForm st of-                      True ->  do-                               frm <- formPrefix (mfPIndex st) (twfname $ mfToken st ) st forms False-                               return   frm-                      _    ->  return $ mconcat  forms-    put st{needForm= False}-    return $ FormElm [cont] mx  - -- | Capture the form submissions and the links of the enclosed widget and send them via jQuery AJAX. -- The response is the new presentation of the widget, that is updated. No new page is generated -- but the functionality is equivalent. Only the activated widget is executed in the server and updated@@ -1019,10 +1023,6 @@          FormElm form mr <- runView $ insertForm w          st <- get          let HttpData ctype c s= toHttpData $ method <> " " <> toByteString (mconcat form)---                                            "$('#"<> B.pack id <>"')." <> method---                                            <> "('" <> toByteString (mconcat form) <> "');"---                                            <> "ajaxGetLink('" <> B.pack id  <> "');"---                                            <> "ajaxPostForm('" <> B.pack id  <> "');"          liftIO . sendFlush t $ HttpData (ctype ++ ("Cache-Control", "no-cache, no-store"):mfHttpHeaders st) (mfCookies st ++ c) s          put st{mfAutorefresh=True,inSync=True}          return $ FormElm [] mr@@ -1110,8 +1110,8 @@ -- STM semantics for waiting updates using 'retry'. -- -- Widgets in a push can have links and forms, but since they are asunchonous, they can not--- return validated inputs. but they can modify the server state.--- push ever return invalid to the calling widget, so it never+-- return inputs. but they can modify the server state.+-- push ever return an invalid response to the calling widget, so it never -- triggers the advance of the navigation. -- --@@ -1212,7 +1212,7 @@     \       },\n\     \       error: function (xhr, status, error) {\n\     \            cnt= cnt + 1;\n\-    \            if (cnt > 6)\n\+    \            if  (false) \n\     \               idstatus.html('no more retries');\n\     \            else {\n\     \               idstatus.html('waiting');\n\@@ -1226,6 +1226,60 @@     \ }\n\     \ ajaxPush1();\n\   \}"++--    let r= lookup ("auto"++id) $ mfEnv st           -- !> ("TIMEOUT="++ show t)+--    case r of+--      Nothing -> do+--         requires [+--                  JScript $ ajaxPush method,+--                  JScriptFile jqueryScript [installscript]]+--         (ftag "div" <<< insertForm w) <! [("id",id)]  
+--+--      Just sind -> View $ do+--         let t= mfToken st+--         FormElm form mr <- runView $ insertForm w+--         st <- get+--         let HttpData ctype c s= toHttpData $ B.pack method <> " " <> toByteString (mconcat form)+--         liftIO . sendFlush t $ HttpData (ctype ++ ("Cache-Control", "no-cache, no-store"):mfHttpHeaders st) (mfCookies st ++ c) s+--         put st{mfAutorefresh=True,inSync=True}+--         return $ FormElm [] mr+--+-- ajaxPush method =" function ajaxPush(id,verb,waititime){\n\+--    \var cnt=0; \n\+--    \var id1= $('#'+id);\n\+--    \var idstatus= $('#'+id+'status');\n\+--    \var ida= $('#'+id+' a');\n\+--    \var actionurl = './';\n\+--    \var dialogOpts = {\n\+--    \       cache: false,\n\+--    \       type: 'GET',\n\+--    \       url: actionurl+'?bustcache='+ new Date().getTime()+'&auto'+id+'=true',\n\+--    \       data: '',\n\+--    \       success: function (resp) {\n\+--    \         idstatus.html('')\n\+--    \         cnt=0;\n\+--    \         id1."++method++"(resp);\n\+--    \         ajaxPush1();\n\+--    \       },\n\+--    \       error: function (xhr, status, error) {\n\+--    \            cnt= cnt + 1;\n\+--    \            if  (false) \n\+--    \               idstatus.html('no more retries');\n\+--    \            else {\n\+--    \               idstatus.html('waiting');\n\+--    \               setTimeout(function() { idstatus.html('retrying');ajaxPush1(); }, waititime);\n\+--    \            }\n\+--    \       }\n\+--    \   };\n\+--    \function ajaxPush1(){\n\+--    \   $.ajax(dialogOpts);\n\+--    \   return false;\n\+--    \ }\n\+--    \ ajaxPush1();\n\+--  \}"+--++  -- | show the jQuery spinner widget. the first parameter is the configuration . Use \"()\" by default. -- See http://jqueryui.com/spinner
src/MFlow/Wai.hs view
@@ -1,4 +1,5 @@ {-# LANGUAGE  UndecidableInstances
+             , CPP
              , TypeSynonymInstances
              , MultiParamTypeClasses
              , DeriveDataTypeable
@@ -47,8 +48,6 @@ import qualified Data.Text as T 
 
 
-
-
 --import Debug.Trace
 --(!>) = flip trace
 
@@ -89,7 +88,7 @@        in   (tail $ reverse path, reverse mod, reverse ext)
 
 
-waiMessageFlow  ::  Request ->  ResourceT IO Response
+waiMessageFlow  ::  Application
 waiMessageFlow req1=   do
      let httpreq1= requestHeaders  req1 
 
@@ -110,7 +109,11 @@ 
      input <- case parseMethod $ requestMethod req1  of
               Right POST -> do
+#if MIN_VERSION_wai(2, 0, 0)
+                   inp <- liftIO $ requestBody req1 $$ CList.consume
+#else
                    inp <- liftIO $ runResourceT (requestBody req1 $$ CList.consume)
+#endif
                    return . parseSimpleQuery $ SB.concat inp
 
                   
src/MFlow/Wai/Blaze/Html/All.hs view
@@ -43,14 +43,15 @@ import Control.Workflow (Workflow, unsafeIOtoWF)
 
 
-import Control.Applicative
+import Control.Applicative+import Control.Monad(when)
 import Control.Monad.IO.Class
 import System.Environment
 import Data.Maybe(fromMaybe)
 import Data.Char(isNumber)
 
--- | The port is read from the first exectution parameter
--- if no parameter, it is read from the PORT environment variable.
+-- | The port is read from the first exectution parameter.
+-- If no parameter, it is read from the PORT environment variable.
 -- if this does not exist, the port 80 is used.
 getPort= do
     args <- getArgs
@@ -65,12 +66,14 @@     print porti
     return porti
 
--- | run a persistent flow. The port is read from the first exectution parameter
--- if no parameter, it is read from the PORT environment variable.
--- if this does not exist, the port 80 is used.
+-- | run a persistent flow. It uses `getPort` to get the port+-- The first parameter is the first element in the URL path.+-- It also set the home page
 runNavigation :: String -> FlowM Html (Workflow IO) () -> IO Bool
-runNavigation n f= do
-    addMessageFlows[(n, runFlow f)]
+runNavigation n f= do+    when(not $ null n) $ setNoScript n
+    addMessageFlows[(n, runFlow f)] 
     porti <- getPort
-    wait $ run porti waiMessageFlow
+    wait $ run porti waiMessageFlow+    --runSettings defaultSettings{settingsTimeout = 20, settingsPort= porti} waiMessageFlow