diff --git a/src/Gargantext/Components/Nodes/Home.purs b/src/Gargantext/Components/Nodes/Home.purs index 04036737280e815412f8d39d0b0e5db715cf3cbf..b468f6509fe43959c1a713c9789286a85a51b0b6 100644 --- a/src/Gargantext/Components/Nodes/Home.purs +++ b/src/Gargantext/Components/Nodes/Home.purs @@ -1,17 +1,19 @@ module Gargantext.Components.Nodes.Home where -import Prelude +import Data.Array (replicate) +import Data.Foldable (foldl) import Data.Newtype (class Newtype) import Effect (Effect) +import Gargantext.Components.Data.Landing (BlockText(..), BlockTexts(..), Button(..), LandingData(..)) +import Gargantext.Components.Lang (LandingLang(..)) +import Gargantext.Components.Lang.Landing.EnUS as En +import Gargantext.Components.Lang.Landing.FrFR as Fr +import Gargantext.Components.Nodes.Home.Public (PublicData(..), publicLayout) +import Gargantext.License (license) +import Gargantext.Prelude (Unit, bind, map, pure, unit, void, ($), (<>)) import Reactix as R import Reactix.DOM.HTML as H import Routing.Hash (setHash) -import Gargantext.License (license) -import Gargantext.Components.Lang.Landing.EnUS as En -import Gargantext.Components.Lang.Landing.FrFR as Fr -import Gargantext.Components.Data.Landing - (BlockText(..), BlockTexts(..), Button(..), LandingData(..)) -import Gargantext.Components.Lang (LandingLang(..)) type Props = () @@ -48,15 +50,27 @@ homeLayout lang = R.createElement homeLayoutCpt {landingData} [] where landingData = langLandingData lang homeLayoutCpt :: R.Component ( landingData :: LandingData ) -homeLayoutCpt = R.staticComponent "LayoutLanding" cpt +homeLayoutCpt = R.hooksComponent "LayoutLanding" cpt where - cpt {landingData} _ = - H.span {} - [ H.div { className: "container1" } [ jumboTitle landingData false ] - , H.div { className: "container1" } [] -- TODO put research form - , H.div { className: "container1" } [ blocksRandomText' landingData ] - , license - ] + cpt {landingData} _ = do + pds <- R.useState' ( replicate 6 (PublicData { title: "Title" + , abstract : foldl (<>) "" $ replicate 100 "abstract " + , img: "images/Gargantextuel-212x300.jpg" + , url : "https://.." + , date: "YY/MM/DD" + , database: "database" + , author : "Author" + } + ) + ) + + pure $ H.span {} + [ H.div { className: "container1" } [ jumboTitle landingData false ] + , H.div { className: "container1" } [] -- TODO put research form + , H.div { className: "container1" } [ blocksRandomText' landingData ] + , H.div { className: "container1" } [ publicLayout {publicDatas:pds} ] + , license + ] ------------------------------------------------------------------------ @@ -89,6 +103,8 @@ docButton (Button b) = , H.text b.text ] +-- | TODO +-- <img src='logo.png' onmouseover="this.src='gargantextuel.png';" onmouseout="this.src='logo.png';" /> jumboTitle :: LandingData -> Boolean -> R.Element jumboTitle (LandingData hd) b = H.div {className: jumbo} diff --git a/src/Gargantext/Components/Nodes/Home/Public.purs b/src/Gargantext/Components/Nodes/Home/Public.purs new file mode 100644 index 0000000000000000000000000000000000000000..10bb9ecd23f44a37373890432d62d361595d6fe3 --- /dev/null +++ b/src/Gargantext/Components/Nodes/Home/Public.purs @@ -0,0 +1,84 @@ +module Gargantext.Components.Nodes.Home.Public where + +import Data.String (take) +import Gargantext.Prelude +import Data.Tuple.Nested ((/\)) +import Data.Newtype (class Newtype) +import Effect (Effect) +import Reactix as R +import Reactix.DOM.HTML as H +import Gargantext.Sessions (Session(..)) + + +type PublicProps = (publicDatas :: R.State (Array PublicData) + -- , session :: Session + ) + +newtype PublicData = PublicData + { title :: String + , abstract :: String + , img :: String + , url :: String + , date :: String + , database :: String + , author :: String + } + + +publicLayout :: Record PublicProps -> R.Element +publicLayout props = R.createElement publicLayoutCpt props [] + +publicLayoutCpt :: R.Component PublicProps +publicLayoutCpt = R.staticComponent "[G.C.N.H.Public.publicLayout" cpt + where + cpt {publicDatas} _ = + H.span {} + [ H.div { className: "container1" } [ H.h2 {} [H.text "Public Maps"]] + -- | TODO browse maps + -- | TODO random maps + , album pds + ] + where + (pds /\ _setPublicData) = publicDatas + +album :: Array PublicData -> R.Element +album pd = H.div {className: "album py-5 bg-light"} + [ H.div { className: "container" } + [ H.div { className : "row" } + (map (\tab -> H.div {className : "col-md-6 content"} [tableau tab]) pd ) + ] + ] + + +tableau :: PublicData -> R.Element +tableau (PublicData {title, abstract, img, url, date, database, author}) = + H.div {className: "card mb-6 box-shadow"} + [ H.a { target: "_blank", href: url } [ H.div { className:"center"} + [H.img { src: img + , width: "50%" + } + ] + ] + , H.div { className : "card-body"} + [ H.h3 {} [H.text title] + , H.p { className: "card-text"} [H.text $ (take 252 abstract) <> "..."] + , H.div { className: "center justify-content-between align-items-center"} + [ H.div { className: "btn-group" } + [ H.button { className : "btn btn-default flex-between" + , href : url + , role : "button" + } [ H.text "View the map" ] +{- TODO + , H.button { className : "btn btn-default flex-start" + , href : url + , role : "button" + } [ H.text "More like this" ] +-} + ] + , H.div { className : "small text-muted flex-end" } [ H.text $ "Made by " <> author + <> " on " <> date + <> " with " <> database + ] + ] + ] + ] diff --git a/src/Gargantext/Components/Nodes/Home/RandomText.purs b/src/Gargantext/Components/Nodes/Home/RandomText.purs index a68446e1506461cfc375b48e614a4eb035c44c0a..2708858cf4ebe00634db8d410845c6b87e531ca2 100644 --- a/src/Gargantext/Components/Nodes/Home/RandomText.purs +++ b/src/Gargantext/Components/Nodes/Home/RandomText.purs @@ -50,10 +50,12 @@ randomChars word = case (length (toCharArray word)) >= 5 of ------------------------------------------------------------------- words :: String -> Array String -words sentence = filter ((/=) "") $ split (Pattern " ") sentence +words sentence = filter ((/=) "") + $ split (Pattern " ") sentence sentences :: String -> Array String -sentences paragraph = filter ((/=) "") $ split (Pattern ".") paragraph +sentences paragraph = filter ((/=) "") + $ split (Pattern ".") paragraph ------------------------------------------------------------------- @@ -63,7 +65,8 @@ data RandomWheel a = RandomWheel { before :: Array a } randomPart :: forall b. Array b -> Effect (Array b) -randomPart array = randomArrayPoly middle >>= \(middle') -> pure ( start <> middle' <> end) +randomPart array = randomArrayPoly middle + >>= \(middle') -> pure ( start <> middle' <> end) where start = take 2 array middle = dropEnd 2 $ drop 2 array @@ -93,7 +96,7 @@ randomArray array = unsafePartial $ do case maybeDuring of Nothing -> - crash "[ERROR] It should never happen." + crash "[G.C.N.H.R.RandomText ERROR] It should never happen." Just during -> pure $ RandomWheel { before : remove n array , during : during diff --git a/src/Gargantext/Ends.purs b/src/Gargantext/Ends.purs index 6b2e76de00de47a6d702f37f6b0f824d352efeb6..b30bb474b6ed8ccbf7a9d087c22a05cc0df6101d 100644 --- a/src/Gargantext/Ends.purs +++ b/src/Gargantext/Ends.purs @@ -24,7 +24,8 @@ newtype Backend = Backend { name :: String , baseUrl :: String , prePath :: String - , version :: ApiVersion } + , version :: ApiVersion + } backend :: ApiVersion -> String -> String -> String -> Backend backend version prePath baseUrl name = Backend { name, version, prePath, baseUrl }