Title: | Wrapper for 'hypothes.is' |
---|---|
Description: | Add, share and manage annotations for 'Shiny' applications and R Markdown documents via 'hypothes.is'. |
Authors: | Krystian Igras [cre, aut], Adam ForyĆ [ctb], Hypothes.is Project and contributors [cph] (hi_embed.js) |
Maintainer: | Krystian Igras <[email protected]> |
License: | MIT + file LICENSE |
Version: | 1.1.0 |
Built: | 2025-02-10 03:28:40 UTC |
Source: | https://github.com/cran/hypothesis |
Operate with annotation
annotation( annotation_id, action = c("fetch", "update", "delete", "flag", "hide", "show", "create"), ..., api_path = get_hs_host(), api_key = NULL )
annotation( annotation_id, action = c("fetch", "update", "delete", "flag", "hide", "show", "create"), ..., api_path = get_hs_host(), api_key = NULL )
annotation_id |
Annotation ID |
action |
Action to process, Default: 'fetch' Hide and show action needs moderator permissions. |
... |
Parameters for update annotation action, more information in hypothesis documentation |
api_path |
The hypothesis API path, can be specify by 'hypothesis.api.api_path' option or 'HYPOTHESIS_API_PATH' environment variable. Default: 'https://hypothes.is/api/'. |
api_key |
User api key, generated on the platform. |
https://h.readthedocs.io/en/latest/api-reference/v1/
## Not run: annotation("annotation_id") annotation("annotation_id", action = "update", text = "updated text") annotation("annotation_id", action = "flag") annotation("annotation_id", action = "hide") annotation("annotation_id", action = "show") annotation( action = "create", uri = "https://r-world-devs.github.io/hypothesis/articles/hypothesis-api.html", text = "test" ) ## End(Not run)
## Not run: annotation("annotation_id") annotation("annotation_id", action = "update", text = "updated text") annotation("annotation_id", action = "flag") annotation("annotation_id", action = "hide") annotation("annotation_id", action = "show") annotation( action = "create", uri = "https://r-world-devs.github.io/hypothesis/articles/hypothesis-api.html", text = "test" ) ## End(Not run)
Request parameters
api_path |
The hypothesis API path, can be specify by 'hypothesis.api.api_path' option or 'HYPOTHESIS_API_PATH' environment variable. Default: 'https://hypothes.is/api/'. |
endpoint |
API request endpoint |
type |
API request type |
api_key |
User api key, generated on the platform. |
Allows to include raw JS code in JSON object.
as_json(x)
as_json(x)
x |
Character storing JS code or object. |
Along with json_verbatim = TRUE
argument of toJSON
makes passing the code to JSON object possible.
A character of class 'json'. The output can be used to store bare JS element withing JSON object.
# Function stored as text jsonlite::toJSON( list(fun = "function(x) {console.log(x);}"), auto_unbox = TRUE, json_verbatim = TRUE ) # Function stored as raw JS object jsonlite::toJSON( list(fun = as_json("function(x) {console.log(x);}")), auto_unbox = TRUE, json_verbatim = TRUE )
# Function stored as text jsonlite::toJSON( list(fun = "function(x) {console.log(x);}"), auto_unbox = TRUE, json_verbatim = TRUE ) # Function stored as raw JS object jsonlite::toJSON( list(fun = as_json("function(x) {console.log(x);}")), auto_unbox = TRUE, json_verbatim = TRUE )
Get a list of groups
get_groups( authority = NULL, document_uri = NULL, expand = NULL, api_path = get_hs_host(), api_key = NULL )
get_groups( authority = NULL, document_uri = NULL, expand = NULL, api_path = get_hs_host(), api_key = NULL )
authority |
Filter returned groups to this authority. Default: main instance authority. |
document_uri |
Document URI - only retrieve public (i.e. non-private) groups that apply to a given document URI. |
expand |
One or more relations to expand for a group resource Optional: 'organization, scopes' |
api_path |
The hypothesis API path, can be specify by 'hypothesis.api.api_path' option or 'HYPOTHESIS_API_PATH' environment variable. Default: 'https://hypothes.is/api/'. |
api_key |
User api key, generated on the platform. |
https://h.readthedocs.io/en/latest/api-reference/v1/
Fetch profile information for the currently-authenticated user.
get_profile(api_path = get_hs_host(), api_key = NULL)
get_profile(api_path = get_hs_host(), api_key = NULL)
api_path |
The hypothesis API path, can be specify by 'hypothesis.api.api_path' option or 'HYPOTHESIS_API_PATH' environment variable. Default: 'https://hypothes.is/api/'. |
api_key |
User api key, generated on the platform. |
Fetch the groups for which the currently-authenticated user is a member.
get_profile_groups(api_path = get_hs_host(), api_key = NULL)
get_profile_groups(api_path = get_hs_host(), api_key = NULL)
api_path |
The hypothesis API path, can be specify by 'hypothesis.api.api_path' option or 'HYPOTHESIS_API_PATH' environment variable. Default: 'https://hypothes.is/api/'. |
api_key |
User api key, generated on the platform. |
Operate with group
group( group_id, action = c("fetch", "update", "fetch_members"), ..., api_path = get_hs_host(), api_key = NULL )
group( group_id, action = c("fetch", "update", "fetch_members"), ..., api_path = get_hs_host(), api_key = NULL )
group_id |
Group ID |
action |
Action to process, Default: 'fetch' |
... |
Parameters for update group information, more details can be found in hypothesis documentation. |
api_path |
The hypothesis API path, can be specify by 'hypothesis.api.api_path' option or 'HYPOTHESIS_API_PATH' environment variable. Default: 'https://hypothes.is/api/'. |
api_key |
User api key, generated on the platform. |
https://h.readthedocs.io/en/latest/api-reference/v1/
## Not run: group("group_id") group("group_id", action = "update", name = "updated text", description = "desc") group("group_id", action = "fetch_members") ## End(Not run)
## Not run: group("group_id") group("group_id", action = "update", name = "updated text", description = "desc") group("group_id", action = "fetch_members") ## End(Not run)
Handle hypothesis request
hs_api_handler( ..., api_path = get_hs_host(), endpoint = NULL, type = NULL, api_key = NULL )
hs_api_handler( ..., api_path = get_hs_host(), endpoint = NULL, type = NULL, api_key = NULL )
... |
Parameter for request function |
api_path |
The hypothesis API path, can be specify by 'hypothesis.api.api_path' option or 'HYPOTHESIS_API_PATH' environment variable. Default: 'https://hypothes.is/api/'. |
endpoint |
API request endpoint |
type |
API request type |
api_key |
User api key, generated on the platform. |
Configuration for custom annotations branding. See more at: branding.
hypothesisBranding( accentColor, appBackgroundColor, ctaBackgroundColor, ctaTextColor, selectionFontFamily, annotationFontFamily )
hypothesisBranding( accentColor, appBackgroundColor, ctaBackgroundColor, ctaTextColor, selectionFontFamily, annotationFontFamily )
accentColor |
Css-valid color value defining sidebar accent. |
appBackgroundColor |
Css-valid color value defining sidebar background. |
ctaBackgroundColor |
Css-valid color value defining main call-to-action button background. |
ctaTextColor |
Css-valid color value defining font color used inside of the call-to-action buttons. |
selectionFontFamily |
Css-valid color value defining font family used for annotation selection popup. |
annotationFontFamily |
Css-valid color value defining font family used for annotation popup. |
Named list object storing provided arguments.
Generates button that allows to turn on and turn off annotations tool.
hypothesisOnOff( initShow = TRUE, labelShow = "Enable Annotations", labelHide = "Disable Annotations" )
hypothesisOnOff( initShow = TRUE, labelShow = "Enable Annotations", labelHide = "Disable Annotations" )
initShow |
Define initial state of annotations. When FALSE, annotations are turned off. |
labelShow , labelHide
|
Label to be shown in the button when annotations are hidden and shown respectively. |
A 'button' shiny.tag object, responsible for enabling/disabling of the package functionality.
A list of alternative annotation services which the client should connect. For more information visit: services.
hypothesisServices( apiUrl, authority, grantToken, allowLeavingGroups, enableShareLinks, groups, icon, onLoginRequest, onLogoutRequest, onSignupRequest, onProfileRequest, onHelpRequest )
hypothesisServices( apiUrl, authority, grantToken, allowLeavingGroups, enableShareLinks, groups, icon, onLoginRequest, onLogoutRequest, onSignupRequest, onProfileRequest, onHelpRequest )
apiUrl , authority , grantToken , allowLeavingGroups , enableShareLinks , groups , icon , onLoginRequest , onLogoutRequest , onSignupRequest , onProfileRequest , onHelpRequest
|
Arguments defining external hypothesis services. |
Named list object storing provided arguments.
Search for annotations
search_annotations( limit = 20L, sort = c("updated", "created", "group", "id", "user"), search_after = NULL, offset = 0, order = c("desc", "asc"), uri = NULL, uri.parts = NULL, wildcard_uri = NULL, user = NULL, group = NULL, tags = NULL, any = NULL, quote = NULL, references = NULL, text = NULL, api_path = get_hs_host(), api_key = NULL )
search_annotations( limit = 20L, sort = c("updated", "created", "group", "id", "user"), search_after = NULL, offset = 0, order = c("desc", "asc"), uri = NULL, uri.parts = NULL, wildcard_uri = NULL, user = NULL, group = NULL, tags = NULL, any = NULL, quote = NULL, references = NULL, text = NULL, api_path = get_hs_host(), api_key = NULL )
limit |
The maximum number of annotations to return. |
sort |
Available values : updated, created, group, id, user, Default: 'updated' |
search_after |
Define a start point for a subset (page) of annotation search results. Example: 2023-01-01T10:00:00.000000+00:00 |
offset |
The number of initial annotations to skip in the result set. |
order |
The order in which the results should be sorted. Default: 'desc' |
uri |
Limit the results to annotations matching the specific URI or equivalent URIs. URI can be a URL (a web page address) or a URN representing another kind of resource such as DOI (Digital Object Identifier) or a PDF fingerprint. |
uri.parts |
Limit the results to annotations containing the given keyword (tokenized chunk) in the URI. |
wildcard_uri |
Limit the results to annotations whose URIs match the wildcard pattern. |
user |
Limit the results to annotations made by the specified user. Example: 'user=acct:[email protected]' |
group |
Limit the results to annotations made in the specified group (by group ID). |
tags |
Limit the results to annotations tagged with the specified value. Example: tags=artificial,intelligence |
any |
Limit the results to annotations who contain the indicated keyword in any of the following field: 'quote, tags, text, url' |
quote |
Limit the results to annotations that contain this text inside the text that was annotated. |
references |
Returns annotations that are replies to this parent annotation ID. |
text |
Limit the results to annotations that contain this text in their textual body. |
api_path |
The hypothesis API path, can be specify by 'hypothesis.api.api_path' option or 'HYPOTHESIS_API_PATH' environment variable. Default: 'https://hypothes.is/api/'. |
api_key |
User api key, generated on the platform. |
https://h.readthedocs.io/en/latest/api-reference/v1/
Function used to initialize hypothesis annotations in Shiny app or R Markdown document.
useHypothesis( openSidebar = TRUE, showHighlights = c("whenSidebarOpen", "always", "never"), theme = c("classic", "clean"), branding = hypothesisBranding(), sidebarAppUrl = NULL, onLayoutChange = as_json("tryHideHypothesis"), services = hypothesisServices(), enableExperimentalNewNoteButton = NULL, usernameUrl = NULL, externalContainerSelector = NULL, focus = NULL, requestConfigFromFrame = NULL, assetRoot = NULL, notebookAppUrl = NULL, enableShareLinks = FALSE, ... )
useHypothesis( openSidebar = TRUE, showHighlights = c("whenSidebarOpen", "always", "never"), theme = c("classic", "clean"), branding = hypothesisBranding(), sidebarAppUrl = NULL, onLayoutChange = as_json("tryHideHypothesis"), services = hypothesisServices(), enableExperimentalNewNoteButton = NULL, usernameUrl = NULL, externalContainerSelector = NULL, focus = NULL, requestConfigFromFrame = NULL, assetRoot = NULL, notebookAppUrl = NULL, enableShareLinks = FALSE, ... )
openSidebar |
Set to TRUE if annotations sidebar should be opened in initial state. |
showHighlights |
Configure when annotated text should be highlighted. "whenSidebarOpen" highlights content only when annotations sidebar is open (default). The remaining options are "always" and "never". |
theme |
Annotations sidebar theme. Available options "classic" (default) and "clean". |
branding |
Configure annotations tool branding (e.g. sidebar background). See hypothesisBranding for possible options. |
sidebarAppUrl , onLayoutChange , services , enableExperimentalNewNoteButton , usernameUrl , externalContainerSelector , focus , requestConfigFromFrame , assetRoot , notebookAppUrl , enableShareLinks
|
Extra arguments used for external services configuration and assets configuration. Visit config for more details. |
... |
Extra arguments passed to client configuration. |
A list of class 'shiny.tag.list' storing the package JS/CSS dependencies.