Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext-ihaskell
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
gargantext
gargantext-ihaskell
Commits
339473ea
Commit
339473ea
authored
Jun 22, 2021
by
David Davó
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed hardcoded ViewModuleVersion
parent
ea63b65f
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
MsgSpec.md
ihaskell-display/ihaskell-widgets/MsgSpec.md
+2
-0
Types.hs
...ay/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
+11
-4
No files found.
ihaskell-display/ihaskell-widgets/MsgSpec.md
View file @
339473ea
...
...
@@ -40,6 +40,8 @@ the kernel.
The creation of a widget does not display it. To display a widget, the kernel sends a display
message to the frontend on the widget's iopub, with a custom mimetype instead of text/plain.
You can also send the ViewModuleVersion in the two fields
`version_major`
and
`verison_minor`
.
Only the
`model_id`
is required.
```
json
method
=
"display_data"
,
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
View file @
339473ea
...
...
@@ -67,7 +67,8 @@ import Control.Applicative ((<$>))
import
qualified
Control.Exception
as
Ex
import
Data.Typeable
(
Typeable
,
TypeRep
,
typeOf
)
import
Data.IORef
(
IORef
,
readIORef
,
modifyIORef
)
import
Data.Text
(
Text
,
pack
)
import
Data.Text
(
Text
,
pack
,
splitOn
)
import
Data.Text.Read
(
decimal
)
import
System.IO.Error
import
System.Posix.IO
import
Text.Printf
(
printf
)
...
...
@@ -917,10 +918,16 @@ triggerDisplay = triggerEvent DisplayHandler
-- | Every IHaskellWidget widget has the same IHaskellDisplay instance, for this
-- reason we need to use FlexibleContexts. The display implementation can still
-- be overriden per widget
instance
IHaskellWidget
(
IPythonWidget
w
)
=>
IHaskellDisplay
(
IPythonWidget
w
)
where
instance
(
'S
.
ViewModuleVersion
∈
WidgetFields
w
,
IHaskellWidget
(
IPythonWidget
w
)
)
=>
IHaskellDisplay
(
IPythonWidget
w
)
where
display
b
=
do
widgetSendView
b
-- Keeping compatibility with classic notebook
(
version_major
,
version_minor
)
<-
versionToInteger
<$>
getField
b
ViewModuleVersion
return
$
Display
[
widgetdisplay
$
unpack
$
decodeUtf8
$
encode
$
object
[
"model_id"
.=
getCommUUID
b
,
"version_major"
.=
toInteger
2
,
"version_minor"
.=
toInteger
0
]
]
"version_major"
.=
version_major
,
"version_minor"
.=
version_minor
]
]
where
versionToInteger
::
Text
->
(
Int
,
Int
)
versionToInteger
str
=
toTuple
(
fmap
(
val
.
decimal
)
(
splitOn
"."
str
))
toTuple
(
x
:
y
:
_
)
=
(
x
,
y
)
val
(
Right
(
v
,
_
))
=
v
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