Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
9c7cea98
Commit
9c7cea98
authored
Jul 29, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[iframe] improve searx support
Related to #179
parent
3d865bb1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
91 additions
and
56 deletions
+91
-56
Frame.purs
...text/Components/Forest/Tree/Node/Action/Search/Frame.purs
+88
-53
SearchBar.purs
.../Components/Forest/Tree/Node/Action/Search/SearchBar.purs
+1
-1
SearchField.purs
...omponents/Forest/Tree/Node/Action/Search/SearchField.purs
+2
-2
No files found.
src/Gargantext/Components/Forest/Tree/Node/Action/Search/Frame.purs
View file @
9c7cea98
...
@@ -11,14 +11,15 @@ import Data.Nullable (Nullable)
...
@@ -11,14 +11,15 @@ import Data.Nullable (Nullable)
import Data.String (toLower)
import Data.String (toLower)
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (DataField(..), Search, isIsTex_Advanced)
import Gargantext.Prelude (discard, identity, pure, unit, ($), (<>), (==), class Show, show)
import Gargantext.Utils.Reactix as R2
import Reactix as R
import Reactix as R
import Reactix.DOM.HTML as H
import Reactix.DOM.HTML as H
import URI.Extra.QueryPairs as NQP
import URI.Extra.QueryPairs as NQP
import URI.Query as Query
import URI.Query as Query
import Gargantext.Components.Forest.Tree.Node.Action.Search.Types (DataField(..), Search, isIsTex_Advanced)
import Gargantext.Prelude (discard, identity, pure, unit, ($), (<>), (==), class Show, show)
import Gargantext.Utils.Reactix as R2
--------------------
--------------------
data FrameSource = Istex | Searx
data FrameSource = Istex | Searx
...
@@ -30,37 +31,56 @@ instance showFrameSource :: Show FrameSource where
...
@@ -30,37 +31,56 @@ instance showFrameSource :: Show FrameSource where
--------------------
--------------------
-- | Iframes
-- | Iframes
searchIframes :: R.State Search
-> R.Ref (Nullable DOM.Element)
type SearchIFramesProps = (
-> R.Element
iframeRef :: R.Ref (Nullable DOM.Element)
searchIframes search@(search' /\ _) iframeRef =
, search :: R.State Search
if isIsTex_Advanced search'.datafield
)
then divIframe Istex search iframeRef
searchIframes :: Record SearchIFramesProps -> R.Element
searchIframes props = R.createElement searchIframesCpt props []
searchIframesCpt :: R.Component SearchIFramesProps
searchIframesCpt = R.hooksComponent "G.C.F.T.N.A.S.F.searchIframes" cpt
where
cpt { iframeRef, search: search@(search' /\ _) } _ = do
pure $ if isIsTex_Advanced search'.datafield
then divIframe { frameSource: Istex, iframeRef, search }
else
else
if Just Web == search'.datafield
if Just Web == search'.datafield
then divIframe Searx search iframeRef
then divIframe { frameSource: Searx, iframeRef, search }
else H.div {} []
else H.div {} []
divIframe :: FrameSource
-> R.State Search
-> R.Ref (Nullable DOM.Element)
-> R.Element
divIframe frameSource search@(search' /\ _) iframeRef =
H.div { className: "frame-search panel panel-default" }
[ iframeWith (frameUrl frameSource)search iframeRef ]
frameUrl :: FrameSource -> String
type IFrameProps = (
frameUrl frameSource = frameUrl' (toLower $ show frameSource)
frameSource :: FrameSource
, iframeRef :: R.Ref (Nullable DOM.Element)
, search :: R.State Search
)
divIframe :: Record IFrameProps -> R.Element
divIframe props = R.createElement divIframeCpt props []
divIframeCpt :: R.Component IFrameProps
divIframeCpt = R.hooksComponent "G.C.F.T.N.A.S.F.divIframe" cpt
where
where
frameUrl' s = "https://" <> s <> ".frame.gargantext.org"
cpt { frameSource, iframeRef, search: search@(search' /\ _) } _ = do
pure $ H.div { className: "frame-search panel panel-default" }
[ iframeWith { frameSource, iframeRef, search } ]
frameUrl :: FrameSource -> String
frameUrl Istex = "https://istex.frame.gargantext.org"
frameUrl Searx = "http://192.168.1.4:8080"
iframeWith :: Record IFrameProps -> R.Element
iframeWith props = R.createElement iframeWithCpt props []
iframeWith :: String
iframeWithCpt :: R.Component IFrameProps
-> R.State Search
iframeWithCpt = R.hooksComponent "G.C.F.T.N.A.S.F.iframeWith" cpt
-> R.Ref (Nullable DOM.Element)
where
-> R.Element
cpt { frameSource, iframeRef, search: (search /\ setSearch) } _ =
iframeWith url (search /\ setSearch) iframeRef =
pure $ H.iframe { src: src frameSource search.term
H.iframe { src: isTexTermUrl search.term
, width: "100%"
, width: "100%"
, height: "100%"
, height: "100%"
, ref: iframeRef
, ref: iframeRef
...
@@ -70,14 +90,18 @@ iframeWith url (search /\ setSearch) iframeRef =
...
@@ -70,14 +90,18 @@ iframeWith url (search /\ setSearch) iframeRef =
}
}
} []
} []
where
where
url :: String
url = frameUrl frameSource
changeSearchOnMessage :: String -> Callback MessageEvent
changeSearchOnMessage :: String -> Callback MessageEvent
changeSearchOnMessage url' =
changeSearchOnMessage url' =
callback $ \m -> if R2.getMessageOrigin m == url'
callback $ \m -> if R2.getMessageOrigin m == url' then do
then do
let {url'', term} = R2.getMessageData m
let {url'', term} = R2.getMessageData m
setSearch $ _ {url = url'', term = term}
setSearch $ _ {url = url'', term = term}
else
else
pure unit
pure unit
isTexTermUrl :: String -> String
isTexTermUrl term = url <> query
isTexTermUrl term = url <> query
where
where
query = Query.print $ NQP.print identity identity qp
query = Query.print $ NQP.print identity identity qp
...
@@ -86,3 +110,14 @@ iframeWith url (search /\ setSearch) iframeRef =
...
@@ -86,3 +110,14 @@ iframeWith url (search /\ setSearch) iframeRef =
(Just (NQP.valueFromString term))
(Just (NQP.valueFromString term))
]
]
searxTermUrl :: String -> String
searxTermUrl term = url <> query
where
query = Query.print $ NQP.print identity identity qp
qp = NQP.QueryPairs [ Tuple (NQP.keyFromString "q")
(Just $ NQP.valueFromString term)
]
src :: FrameSource -> String -> String
src Istex term = isTexTermUrl term
src Searx term = searxTermUrl term
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchBar.purs
View file @
9c7cea98
...
@@ -23,7 +23,7 @@ searchBar :: Record Props -> R.Element
...
@@ -23,7 +23,7 @@ searchBar :: Record Props -> R.Element
searchBar props = R.createElement searchBarCpt props []
searchBar props = R.createElement searchBarCpt props []
searchBarCpt :: R.Component Props
searchBarCpt :: R.Component Props
searchBarCpt = R.hooksComponent "G.C.
Node.SearchBar
.searchBar" cpt
searchBarCpt = R.hooksComponent "G.C.
F.T.N.A.S.SB
.searchBar" cpt
where
where
cpt {langs, onSearch, search: search@(s /\ _), session} _ = do
cpt {langs, onSearch, search: search@(s /\ _), session} _ = do
--onSearchChange session s
--onSearchChange session s
...
...
src/Gargantext/Components/Forest/Tree/Node/Action/Search/SearchField.purs
View file @
9c7cea98
...
@@ -47,7 +47,7 @@ searchField p = R.createElement searchFieldComponent p []
...
@@ -47,7 +47,7 @@ searchField p = R.createElement searchFieldComponent p []
--searchFieldComponent :: R.Memo Props
--searchFieldComponent :: R.Memo Props
--searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) eqProps
--searchFieldComponent = R.memo (R.hooksComponent "SearchField" cpt) eqProps
searchFieldComponent :: R.Component Props
searchFieldComponent :: R.Component Props
searchFieldComponent = R.hooksComponent "G.C.
S.S
earchField" cpt
searchFieldComponent = R.hooksComponent "G.C.
F.T.N.A.S.SF.s
earchField" cpt
where
where
cpt props@{onSearch, search: search@(s /\ _)} _ = do
cpt props@{onSearch, search: search@(s /\ _)} _ = do
iframeRef <- R.useRef null
iframeRef <- R.useRef null
...
@@ -75,7 +75,7 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt
...
@@ -75,7 +75,7 @@ searchFieldComponent = R.hooksComponent "G.C.S.SearchField" cpt
then componentCNRS search
then componentCNRS search
else H.div {} []
else H.div {} []
, H.div {} [ searchIframes
search iframeRef
]
, H.div {} [ searchIframes
{ iframeRef, search }
]
, if needsLang s.datafield
, if needsLang s.datafield
then langNav search props.langs
then langNav search props.langs
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment