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
9168aa5b
Commit
9168aa5b
authored
Jun 12, 2021
by
David Davó
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Widgets: Metadata now carries version of widget
parent
4e1a2a13
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
27 additions
and
5 deletions
+27
-5
.gitignore
.gitignore
+3
-0
ChangeLog.md
ihaskell-display/ihaskell-widgets/ChangeLog.md
+3
-0
MsgSpec.md
ihaskell-display/ihaskell-widgets/MsgSpec.md
+2
-0
ihaskell-widgets.cabal
ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
+1
-1
IntSlider.hs
.../src/IHaskell/Display/Widgets/Int/BoundedInt/IntSlider.hs
+1
-0
Types.hs
...ay/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
+0
-1
Widgets.hs
src/IHaskell/Eval/Widgets.hs
+3
-2
Types.hs
src/IHaskell/Types.hs
+14
-1
No files found.
.gitignore
View file @
9168aa5b
...
@@ -24,3 +24,6 @@ cabal.sandbox.config
...
@@ -24,3 +24,6 @@ cabal.sandbox.config
.tmp3
.tmp3
stack.yaml.lock
stack.yaml.lock
result
result
default.nix
dist-*/
cabal.project.local
\ No newline at end of file
ihaskell-display/ihaskell-widgets/ChangeLog.md
View file @
9168aa5b
# ChangeLog for `ihaskell-widgets`
# ChangeLog for `ihaskell-widgets`
## `v0.3.0.0`
> Revamped to be compatible with Widget Messaging Protocol, version 2
## `v0.2.2.1`
## `v0.2.2.1`
+
The
`properties`
function now prints types associated with widget fields.
+
The
`properties`
function now prints types associated with widget fields.
...
...
ihaskell-display/ihaskell-widgets/MsgSpec.md
View file @
9168aa5b
...
@@ -14,6 +14,8 @@ the widget.
...
@@ -14,6 +14,8 @@ the widget.
> The comm should be opened with a `target_name` of `"ipython.widget"`.
> The comm should be opened with a `target_name` of `"ipython.widget"`.
> The comm_open message's metadata gives the version of the widget messaging protocol, i.e., `{'version': '2.0.0'}`
Any
*numeric*
property initialized with the empty string is provided the default value by the
Any
*numeric*
property initialized with the empty string is provided the default value by the
frontend. Some numbers need to be sent as actual numbers (when non-null), whereas the ones representing
frontend. Some numbers need to be sent as actual numbers (when non-null), whereas the ones representing
lengths in CSS units need to be sent as strings.
lengths in CSS units need to be sent as strings.
...
...
ihaskell-display/ihaskell-widgets/ihaskell-widgets.cabal
View file @
9168aa5b
...
@@ -10,7 +10,7 @@ name: ihaskell-widgets
...
@@ -10,7 +10,7 @@ name: ihaskell-widgets
-- PVP summary: +-+------- breaking API changes
-- PVP summary: +-+------- breaking API changes
-- | | +----- non-breaking API additions
-- | | +----- non-breaking API additions
-- | | | +--- code changes with no API change
-- | | | +--- code changes with no API change
version: 0.
2.3.3
version: 0.
3.0.0
-- A short (one-line) description of the package.
-- A short (one-line) description of the package.
synopsis: IPython standard widgets for IHaskell.
synopsis: IPython standard widgets for IHaskell.
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Int/BoundedInt/IntSlider.hs
View file @
9168aa5b
...
@@ -62,6 +62,7 @@ instance IHaskellDisplay IntSlider where
...
@@ -62,6 +62,7 @@ instance IHaskellDisplay IntSlider where
instance
IHaskellWidget
IntSlider
where
instance
IHaskellWidget
IntSlider
where
getCommUUID
=
uuid
getCommUUID
=
uuid
getVersion
_
=
"2.0.0"
comm
widget
val
_
=
comm
widget
val
_
=
case
nestedObjectLookup
val
[
"sync_data"
,
"value"
]
of
case
nestedObjectLookup
val
[
"sync_data"
,
"value"
]
of
Just
(
Number
value
)
->
do
Just
(
Number
value
)
->
do
...
...
ihaskell-display/ihaskell-widgets/src/IHaskell/Display/Widgets/Types.hs
View file @
9168aa5b
...
@@ -13,7 +13,6 @@
...
@@ -13,7 +13,6 @@
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ConstraintKinds #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE ExistentialQuantification #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE GADTs #-}
{-# LANGUAGE AutoDeriveTypeable #-}
{-# LANGUAGE CPP #-}
{-# LANGUAGE CPP #-}
-- | This module houses all the type-trickery needed to make widgets happen.
-- | This module houses all the type-trickery needed to make widgets happen.
...
...
src/IHaskell/Eval/Widgets.hs
View file @
9168aa5b
...
@@ -109,7 +109,8 @@ handleMessage send replyHeader state msg = do
...
@@ -109,7 +109,8 @@ handleMessage send replyHeader state msg = do
else
do
else
do
-- Send the comm open, with the initial state
-- Send the comm open, with the initial state
hdr
<-
dupHeader
replyHeader
CommOpenMessage
hdr
<-
dupHeader
replyHeader
CommOpenMessage
send
$
CommOpen
hdr
target_name
target_module
uuid
value
let
hdrV
=
setVersion
hdr
$
getVersion
widget
send
$
CommOpen
hdrV
target_name
target_module
uuid
value
-- Send anything else the widget requires.
-- Send anything else the widget requires.
open
widget
communicate
open
widget
communicate
...
@@ -189,7 +190,7 @@ instance ToJSON IPythonMessage where
...
@@ -189,7 +190,7 @@ instance ToJSON IPythonMessage where
object
object
[
"header"
.=
replyHeader
[
"header"
.=
replyHeader
,
"parent_header"
.=
str
""
,
"parent_header"
.=
str
""
,
"metadata"
.=
str
"{}"
,
"metadata"
.=
object
[]
,
"content"
.=
val
,
"content"
.=
val
,
"msg_type"
.=
(
toJSON
.
showMessageType
$
mtype
)
,
"msg_type"
.=
(
toJSON
.
showMessageType
$
mtype
)
]
]
...
...
src/IHaskell/Types.hs
View file @
9168aa5b
...
@@ -11,6 +11,7 @@ module IHaskell.Types (
...
@@ -11,6 +11,7 @@ module IHaskell.Types (
MessageHeader
(
..
),
MessageHeader
(
..
),
MessageType
(
..
),
MessageType
(
..
),
dupHeader
,
dupHeader
,
setVersion
,
Username
,
Username
,
Metadata
,
Metadata
,
replyType
,
replyType
,
...
@@ -41,8 +42,10 @@ module IHaskell.Types (
...
@@ -41,8 +42,10 @@ module IHaskell.Types (
import
IHaskellPrelude
import
IHaskellPrelude
import
Data.Aeson
(
ToJSON
(
..
),
Value
,
(
.=
),
object
)
import
qualified
Data.HashMap.Strict
as
HashMap
import
Data.Aeson
(
ToJSON
(
..
),
Value
,
(
.=
),
object
,
Object
,
Value
(
String
))
import
Data.Function
(
on
)
import
Data.Function
(
on
)
import
Data.Text
(
pack
)
import
Data.Serialize
import
Data.Serialize
import
GHC.Generics
import
GHC.Generics
...
@@ -73,6 +76,9 @@ class IHaskellDisplay a => IHaskellWidget a where
...
@@ -73,6 +76,9 @@ class IHaskellDisplay a => IHaskellWidget a where
-- UUID during initialization.
-- UUID during initialization.
getCommUUID
::
a
->
UUID
getCommUUID
::
a
->
UUID
-- | Get the version for this widget. Sent as metadata during comm_open.
getVersion
::
a
->
String
-- | Called when the comm is opened. Allows additional messages to be sent after comm open.
-- | Called when the comm is opened. Allows additional messages to be sent after comm open.
open
::
a
-- ^ Widget to open a comm port with.
open
::
a
-- ^ Widget to open a comm port with.
->
(
Value
->
IO
()
)
-- ^ A function for sending messages.
->
(
Value
->
IO
()
)
-- ^ A function for sending messages.
...
@@ -125,6 +131,7 @@ instance IHaskellWidget Widget where
...
@@ -125,6 +131,7 @@ instance IHaskellWidget Widget where
targetName
(
Widget
widget
)
=
targetName
widget
targetName
(
Widget
widget
)
=
targetName
widget
targetModule
(
Widget
widget
)
=
targetModule
widget
targetModule
(
Widget
widget
)
=
targetModule
widget
getCommUUID
(
Widget
widget
)
=
getCommUUID
widget
getCommUUID
(
Widget
widget
)
=
getCommUUID
widget
getVersion
(
Widget
widget
)
=
getVersion
widget
open
(
Widget
widget
)
=
open
widget
open
(
Widget
widget
)
=
open
widget
comm
(
Widget
widget
)
=
comm
widget
comm
(
Widget
widget
)
=
comm
widget
close
(
Widget
widget
)
=
close
widget
close
(
Widget
widget
)
=
close
widget
...
@@ -277,6 +284,12 @@ dupHeader hdr messageType = do
...
@@ -277,6 +284,12 @@ dupHeader hdr messageType = do
uuid
<-
liftIO
random
uuid
<-
liftIO
random
return
hdr
{
mhMessageId
=
uuid
,
mhMsgType
=
messageType
}
return
hdr
{
mhMessageId
=
uuid
,
mhMsgType
=
messageType
}
-- | Modyfies a header and appends the version as metadata
setVersion
::
MessageHeader
-- ^ The header to modify
->
String
-- ^ The version to set
->
MessageHeader
-- ^ The modified header
setVersion
hdr
v
=
hdr
{
mhMetadata
=
Metadata
(
HashMap
.
fromList
[(
"version"
,
String
$
pack
v
)])
}
-- | Whether or not an error occurred.
-- | Whether or not an error occurred.
data
ErrorOccurred
=
Success
data
ErrorOccurred
=
Success
|
Failure
|
Failure
...
...
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