-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
htmltools rendered #92
base: master
Are you sure you want to change the base?
Conversation
Now it supports href! woohoo. library(ambiorix)
library(plotly)
library(calcite)
library(echarts4r)
library(htmltools)
library(highcharter)
data(penguins, package = "palmerpenguins")
page <- function(...) {
tags$html(
tags$head(
tags$title("The page title!"),
),
tags$body(...)
)
}
# core app
app <- Ambiorix$new()
app$get("/", \(req, res){
shell <- calcite_shell(
calcite_navigation(
slot = "header",
calcite_navigation_logo(
slot = "logo",
heading = "Snow Plow Map",
description = "City of AcmeCo"
),
calcite_menu(
slot = "content-end",
calcite_menu_item(text = "Drivers", `icon-start` = "license", `text-enabled` = TRUE),
calcite_menu_item(text = "Routes", `icon-start` = "road-sign", `text-enabled` = TRUE),
calcite_menu_item(text = "Forecast", `icon-start` = "snow", `text-enabled` = TRUE)
),
calcite_navigation(
slot = "navigation-secondary",
calcite_menu(
slot = "content-start",
calcite_menu_item(breadcrumb = TRUE, text = "All Routes", `icon-start` = "book", `text-enabled` = TRUE),
calcite_menu_item(breadcrumb = TRUE, text = "South Hills", `icon-start` = "apps", `text-enabled` = TRUE, active = TRUE)
)
),
calcite_navigation_user(slot = "user", `full-name` = "Wendell Berry", username = "w_berry")
)
)
ec <- cars |>
echarts4r::e_charts(speed) |>
echarts4r::e_scatter(dist)
pl <- plot_ly(midwest, x = ~percollege, color = ~state, type = "box")
hc <- hchart(
penguins,
"scatter",
hcaes(x = flipper_length_mm, y = bill_length_mm, group = species)
)
p <- page(
h1("Dashboard"),
shell,
div(
class = "grid",
tags$article(pl),
tags$article(ec),
tags$article(hc)
)
)
res$send(p)
})
app$start() |
# htmltools::renderDependencies(..., srcType = "href") | ||
# does not work | ||
rendered_deps <- htmltools::renderDependencies(deps) | ||
href_deps <- grep("http", strsplit(rendered_deps, "\n")[[1]], value = TRUE) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We only take href here so you should not see this in your console, can you make sure you're on the latest?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it's still happening. haven't figured out what's causing the requests to be sent on inspect.
i'm on the latest, or do i need to install ambiorix? currently using devtools::load_all()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get it too now, boooh!
I've never had this before, the inspector triggers GET
requests, excuse me?
Note added some things to collect Websocket clients so we can broadcast on sockets. Bit of a mess, sorry. |
This is a first draft at fully rendering htmltools.
The core of it sits here:
ambiorix/R/response.R
Line 89 in 981339f
The idea is to check whether the tags contain an
<html>
tag, if found it treats it like a "page" and attempts to render a full HTML document.Otherwise, it works as it currently does.
Then it becomes real easy to create something that resembles a more "traditional" shiny app.
What do you think? @kennedymwavu