ambhtmx
ambhtmx copied to clipboard
Build a Full-stack R App with ambiorix and htmx.
THIS IS A WORK IN PROGRESS, DO NOT USE
ambhtmx
Build a Full-stack R App with ambiorix and htmx.
Installation
You can install all the requeriments to run the examples:
if(!"rlang" %in% installed.packages()){
if(!interactive()) { stop("The package \"rlang\" is required.") }
cat("The package \"rlang\" is required.\n✖ Would you like to install it?\n\n1: Yes\n2: No\n\nSelection:")
if (readLines(n = 1) == "1"){
install.packages("rlang")
}
}
rlang::check_installed("remotes")
remotes::install_github("jrosell/ambhtmx", force = 1)
rlang::check_installed("ambiorix", action = \(pkg, ... ) remotes::install_github("devOpifex/ambiorix"))
rlang::check_installed("scilis", action = \(pkg, ... ) remotes::install_github("devOpifex/scilis"))
rlang::check_installed("signaculum", action = \(pkg, ... ) remotes::install_github("devOpifex/signaculum"))
rlang::check_installed("tidyverse")
rlang::check_installed("zeallot")
rlang::check_installed("glue")
rlang::check_installed("htmltools")
rlang::check_installed("this.path")
Furthermore, you may want to create a .Renviron file with the following variables:
AMBHTMX_USER=<your user>
AMBHTMX_PASSWORD=<your password>
AMBHTMX_SECRET=<a secret key to make cookies safer>
GITHUB_PAT=<an optional token to install github repos safely>
AMBHTMX_PROTOCOL=<default http but you may want to use https>
AMBHTMX_HOST=<to change host default 127.0.0.1>
AMBHTMX_PORT=<to change port default 3000>
R_SHARE_DIR=/usr/share/R/share/ # change it if required
Code examples
Incrementing a counter
Updating a ggplot2
Interacting with an slider
Using SQLite to build a TODO app
Live Reloading using npm and nodemon
Single user and password autentication
Password protected CRUD (Create, Read, Update, and Delete) example with ambhtmx
Cleaner and shorter code hx_ to hx- replacement
Customizable web components in R: Port to R of card3d from FastHTML
- Python implementation. Original python code credit to AnswerDotAI/fasthtml, Design credit: https://codepen.io/markmiro/pen/wbqMPa
Customizable web components in R: Tone.js, Web Audio framework for creating interactive music in the browser
Customizable web components in R: Artyom.js, Speech recognition from the browser to R
Deployment examples
If you create a Dockerfile you can deploy your ambhtmx app to HuggingFace Spaces, Digital Ocean, Google Cloud, etc.
I deployed some examples:
- ambhtmx.crud (on HuggingFace Spaces)
- ambhtmx.card3d (on HuggingFace Spaces)
- [ambhtmx.tonejs]https://huggingface.co/spaces/jrosell/ambhtmx.tonejs) (on HuggingFace Spaces)
- [ambhtmx.artyom]https://huggingface.co/spaces/jrosell/ambhtmx.artyom) (on HuggingFace Spaces)
If you want to deploy yours, when creating your user and space in HuggingFace Spaces for your repo, select a blank Dockerfile:

Troubleshooting
Known issues:
- Are you trying to autenticate from 0.0.0.0 host? Cookies don't work from 0.0.0.0 host, try 127.0.0.1 or a domain name instead (/etc/hosts or DNS).
- Are you trying an app without including all the required packages in the Dockerfile? Please, check the logs and edit the Dockerfile and try again. It could be that Github API have reach the limit. You need to configure the environment variable GITHUB_PAT.
Another issue? Please, let me know.










