axiom 0.4.5 → 0.4.6
raw patch · 4 files changed
+38/−36 lines, 4 filesdep ~transientdep ~transient-universePVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependency ranges changed: transient, transient-universe
API changes (from Hackage documentation)
- GHCJS.HPlay.View: addSData :: (MonadState EventF m, Typeable a, Monoid a) => a -> m ()
- GHCJS.HPlay.View: runWidget' :: Widget b -> Elem -> Widget b
+ GHCJS.HPlay.View: instance GHC.Show.Show GHCJS.HPlay.View.AlternativeBranch
+ GHCJS.HPlay.View: instance Internal.Perch.Attributable (Internal.Perch.Perch -> GHCJS.HPlay.View.Widget a)
+ GHCJS.HPlay.View: staticNav :: TransIO b -> TransIO b
- GHCJS.HPlay.Cell: get :: Cell x -> TransIO x
+ GHCJS.HPlay.Cell: get :: Cell a -> TransIO a
Files
- README.md +5/−6
- axiom.cabal +3/−3
- src/GHCJS/HPlay/Cell.hs +1/−8
- src/GHCJS/HPlay/View.hs +29/−19
README.md view
@@ -1,11 +1,10 @@+ +========== [](http://hackage.haskell.org/package/ghcjs-hplay) [](http://stackage.org/lts/package/ghcjs-hplay) [](http://stackage.org/nightly/package/ghcjs-hplay) -[](https://travis-ci.org/transient-haskell/axiom) +[](https://travis-ci.org/transient-haskell/axiom) -Axiom (ghcjs-hplay) -========== - For some examples, see the [transient-examples](https://github.com/transient-haskell/transient-examples) repository: [distributedApps.hs](https://github.com/transient-haskell/transient-examples/blob/master/distributedApps.hs) and [webapp.hs](https://github.com/transient-haskell/transient-examples/blob/master/webapp.hs) @@ -13,7 +12,7 @@ [](https://gitter.im/Transient-Transient-Universe-HPlay/Lobby?utm_source=share-link&utm_medium=link&utm_campaign=share-link) -Axiom (the new name of ghcjs-hplay) is also the Web user interface of [Transient](https://github.com/agocorona/transient). The Web functionality of transient will be called **Axiom**, like the cruise starship of Wall-e. Axiom is made to let you navigate the universe of nodes in the cloud trough your browser while you are comfortably seated in your [hoverchair](https://www.youtube.com/watch?v=uOL2W9JQmo8). +Axiom (the new name of ghcjs-hplay) is also the Web user interface of [Transient](https://github.com/agocorona/transient). The Web functionality of transient will be called **Axiom**, like the cruise starship of Wall-e. Axiom is made to let you navigate the universe of nodes in the cloud through your browser while you are comfortably seated in your [hoverchair](https://www.youtube.com/watch?v=uOL2W9JQmo8). Unlike his predecessor, [hplayground](http://github.com/agocorona/hplayground), Axiom has full integration with Transient and can run widgets that run code on the server, the client or both. @@ -21,7 +20,7 @@ To see how it integrates with Transient and how to create client-server applications, see the web paragraphs of the [transient tutorial](https://github.com/agocorona/transient/wiki/Transient-tutorial). -To see how to create client side applications and widgets (with no server code integration), look for [hplayground](https://github.com/agocorona/hplayground) package. [Tutorial](https://www.airpair.com/haskell-tutorial/intro-to-haskell-web-apps) +To see how to create client side applications and widgets (with no server code integration), look for [hplayground](https://github.com/agocorona/hplayground) package. [Tutorial](https://www.airpair.com/haskell-tutorial/intro-to-haskell-web-apps) How it works ============
axiom.cabal view
@@ -1,6 +1,6 @@ name: axiom -version: 0.4.5 +version: 0.4.6 cabal-version: >=1.10 build-type: Simple @@ -29,8 +29,8 @@ build-depends: base > 4.0 && <6.0 , transformers -any , containers -any - , transient >= 0.5.4 - , transient-universe >= 0.4.1 + , transient >= 0.5.9.2 + , transient-universe >= 0.4.6.1 , mtl -any , ghcjs-perch >= 0.3.3
src/GHCJS/HPlay/Cell.hs view
@@ -13,22 +13,15 @@ ----------------------------------------------------------------------------- {-# LANGUAGE TypeSynonymInstances, FlexibleInstances, OverloadedStrings, CPP, ScopedTypeVariables #-} module GHCJS.HPlay.Cell(Cell(..),boxCell,bcell,(.=),get,mkscell,scell, gcell, calc) where -import Transient.Base -import Transient.Move -import Transient.Internals (runTransState) -import Transient.Backtrack +import Transient.Internals import GHCJS.HPlay.View import Data.Typeable import Unsafe.Coerce import qualified Data.Map as M hiding ((!)) -import System.IO.Unsafe import Control.Monad.IO.Class import Control.Monad -import Data.Maybe -import Control.Exception import Data.List -import GHCJS.Perch import Control.Exception #ifdef ghcjs_HOST_OS
src/GHCJS/HPlay/View.hs view
@@ -15,8 +15,6 @@ , runBody , addHeader , render - , runWidget' - , addSData -- * Widget Combinators and Modifiers , (<<) , (<<<) @@ -59,6 +57,7 @@ , wbutton , wlink , tlink + , staticNav , noWidget , wraw , rawHtml @@ -144,8 +143,7 @@ import GHCJS.Foreign.Callback.Internal (Callback(..)) import GHCJS.Marshal -import GHCJS.Perch hiding (JsEvent (..), eventName, - option,head,map) +import GHCJS.Perch hiding (JsEvent (..), eventName, option,head,map) import GHCJS.Types import Transient.Move hiding (pack) @@ -201,7 +199,7 @@ #ifdef ghcjs_HOST_OS elemBySeq id= do IdLine _ id1 <- getData `onNothing` error ("not found: " ++ show id) -- return (IdLine "none") - return () -- !> ("elemBySeq",id1, id) + return () !> ("elemBySeq",id1, id) liftIO $ do re <- elemBySeqDOM id1 $ JS.takeWhile (/='p') id fromJSVal re @@ -374,7 +372,7 @@ getParam1 par = do isTemplate <- liftIO $ readIORef execTemplate if isTemplate then return NoParam else do - me <- elemBySeq par + me <- elemBySeq par !> par -- !> ("looking for " ++ show par) case me of Nothing -> return NoParam @@ -623,7 +621,6 @@ tolook <- case look of Nothing -> genNewId Just n -> return n - let nvalue x = case x of Nothing -> mempty Just v -> @@ -647,12 +644,12 @@ -> Widget String getMultilineText nvalue = res where res= Widget. Transient $ do - tolook <- genNewId + tolook <- genNewId !> "GETMULTI" r <- getParam1 tolook `asTypeOf` typef res case r of - Validated x -> do addSData (ftextarea tolook $ toJSString x :: Perch); return $ Just x - NotValidated s err -> do addSData (ftextarea tolook (toJSString s) :: Perch); return Nothing - NoParam -> do setData WasParallel;addSData (ftextarea tolook nvalue :: Perch); return Nothing + Validated x -> do addSData (ftextarea tolook $ toJSString x :: Perch); return $ Just x !> "VALIDATED" + NotValidated s err -> do addSData (ftextarea tolook (toJSString s) :: Perch); return Nothing !> "NOTVALIDATED" + NoParam -> do setData WasParallel;addSData (ftextarea tolook nvalue :: Perch); return Nothing !> "NOTHING" where typef :: Widget String -> StateIO (ParamResult Perch String) typef = undefined @@ -678,7 +675,7 @@ getSelect opts = res where res= Widget . Transient $ do tolook <- genNewId - st <- get + -- st <- get -- setData HasElems r <- getParam1 tolook `asTypeOf` typef res -- setData $ fmap MFOption $ valToMaybe r @@ -797,8 +794,12 @@ data Path= Path [JSString] --pathLength= unsafePerformIO $ newIORef 0 --- | Present a link. Return the first parameter when clicked +-- | avoid that a recursive widget with links may produce long paths. It is equivalent to tail call elimination +staticNav x= do + Path paths <- getState <|> return (Path []) + x <*** setState (Path paths) + -- | template link. Besides the wlink behaviour, it loads the page from the server if there is any -- -- the page many have been saved with `edit` @@ -1079,6 +1080,9 @@ jsval <- firstChild e' fromJSValUnchecked jsval +instance Attributable (Perch -> Widget a) where + w ! attr = \p -> w p ! attr + mspan id cont= Perch $ \e -> do n <- liftIO $ getName e -- alert $ toJSString $ show n @@ -1505,10 +1509,14 @@ -- | add a header in the <header> tag addHeader :: Perch -> IO () +#ifdef ghcjs_HOST_OS addHeader format= do head <- getHead build format head return () +#else +addHeader _ = return () +#endif -- | run the widget as the body of the HTML. It adds the rendering to the body of the document. @@ -1520,7 +1528,7 @@ runWidget w body -data AlternativeBranch= Alternative deriving (Typeable, Eq) +data AlternativeBranch= Alternative deriving (Typeable, Eq, Show) -- | executes the computation and add the effect of "hanging" the generated rendering from the one generated by the -- previous `render` sentence, or from the body of the document, if there isn't any. If an event happens within @@ -1531,7 +1539,7 @@ render :: Widget a -> TransIO a #ifdef ghcjs_HOST_OS render mx = Transient $ do - isTemplate <- liftIO $ readIORef execTemplate + isTemplate <- liftIO $ readIORef execTemplate !> "RENDER" idline1@(IdLine level id1') <- getData `onNothing` do id1 <- genNewId -- !> "ONNOTHING" @@ -1545,13 +1553,15 @@ ma <- getData - id1 <- if (ma == Just Alternative) + mw <- getData + + id1 <- if (ma == Just Alternative || mw == Just WasParallel) !> (ma,mw) then do id3 <- do - id3 <- genNewId + id3 <- genNewId !> "ALTERNATIVE" -- create id3 hanging from id1 parent if (not isTemplate) then do - liftIO $ withElem id1' $ build $ this `goParent` (span ! id id3 $ noHtml) + liftIO $ withElem id1' $ build $ this `goParent` (span ! atr "ALTERNATIVE" "" ! id id3 $ noHtml) return id3 else do -- template look for real id3 @@ -1618,7 +1628,7 @@ return $ Just ()) if(isJust r) then delData Alternative >> setData (IdLine (level +1) id2 ) -- !> ("setDataAl",id2) - else setData Alternative + else setData Alternative !> "SETDATA ALTERNATIVE" return r