Skip to content

Commit

Permalink
Add form (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
bollwyvl authored Dec 3, 2023
1 parent a784b9d commit 811c76a
Show file tree
Hide file tree
Showing 21 changed files with 2,311 additions and 317 deletions.
4 changes: 3 additions & 1 deletion .binder/conda-linux-64.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Generated by conda-lock.
# platform: linux-64
# input_hash: d590a6f1af5b3bf72a3b889d1bf03c4b2d69937757baa840cc0b841a898e956b
# input_hash: 6d5e923fdf0849ccdceed869afeeb7be9753e20caf1c32130dc84bdc218f0412
@EXPLICIT
https://conda.anaconda.org/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2#d7c89558ba9fa0495403155b64376d81
https://conda.anaconda.org/conda-forge/linux-64/ca-certificates-2023.11.17-hbcca054_0.conda#01ffc8d36f9eba0ce0b3c1955fa780ee
Expand Down Expand Up @@ -242,7 +242,9 @@ https://conda.anaconda.org/conda-forge/noarch/jupyterlab_server-2.25.2-pyhd8ed1a
https://conda.anaconda.org/conda-forge/noarch/nbconvert-7.11.0-pyhd8ed1ab_0.conda#e492b36cbea1c83d1663fa73a8abff9b
https://conda.anaconda.org/conda-forge/noarch/notebook-shim-0.2.3-pyhd8ed1ab_0.conda#67e0fe74c156267d9159e9133df7fd37
https://conda.anaconda.org/conda-forge/label/jupyterlab_alpha/noarch/jupyterlab-4.1.0a4-pyhd9494c6_0.conda#937116905e11106b9bcf4e5cc05b6793
https://conda.anaconda.org/conda-forge/label/jupyterlab_fonts_alpha/noarch/jupyterlab-fonts-3.0.0a3-pyheae6aa3_0.conda#14b6ea3738c1e800a610f1e1df155548
https://conda.anaconda.org/conda-forge/label/notebook_alpha/noarch/notebook-7.1.0a0-pyhdf78bca_0.conda#aa9e88daa0d394a944f48ffbea1c7556
https://conda.anaconda.org/conda-forge/label/jupyterlab_deck_alpha/noarch/jupyterlab-deck-0.2.0a0-pyha661375_0.conda#6e6bf18dc450f5b33d9ec9b47abbfea1
https://conda.anaconda.org/conda-forge/noarch/myst-parser-2.0.0-pyhd8ed1ab_0.conda#70699181909e468875f12076e1b0a8a9
https://conda.anaconda.org/conda-forge/noarch/myst-nb-1.0.0-pyhd8ed1ab_0.conda#fe4a9aa4a900dc509fcb5e6210184fa3
https://conda.anaconda.org/conda-forge/noarch/pydata-sphinx-theme-0.14.4-pyhd8ed1ab_0.conda#c79b8443908032263ffb40ee6215e9e4
Expand Down
6 changes: 5 additions & 1 deletion .binder/environment.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
channels:
- conda-forge
- conda-forge/label/jupyterlab_alpha
- conda-forge/label/notebook_alpha
- conda-forge/label/jupyterlab_fonts_alpha
- conda-forge/label/jupyterlab_deck_alpha
- conda-forge
- nodefaults
platforms:
- linux-64
Expand All @@ -14,6 +16,8 @@ dependencies:
- notebook >=7.1.0a0,<8
# images
- imagemagick
# demo
- jupyterlab-deck >=0.2.0a0
### .github/environment.yml ###
# fix
- ruff
Expand Down
40 changes: 34 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# jupyak

> get a JupyterLite preview of pull requests across the Jupyter stack
> get a statically-hosted JupyterLite preview of pull requests from across the
> Jupyter stack
## what does it do?

Expand Down Expand Up @@ -29,6 +30,10 @@ This repo accepts [pull requests](#how-does-it-work) that build static [preview
- PR-based [preview site](#how-do-i-get-a-preview-site)
- preview of the docs for the site itself

> The above works on at least _one_ Ubuntu 22.03 LTS machine, but little care has
> been taken to make _anything_ run on any other system, and likely won't be tested
> anywhere else.
## how does it work?

Delivering a preview site uses a few different GitHub Actions workflows and ReadTheDocs.
Expand All @@ -38,7 +43,12 @@ Delivering a preview site uses a few different GitHub Actions workflows and Read
[repos](#what-can-it-build).
- Clicking the _submit_ button will open a "new file" GitHub page against this repo
- Click _Commit Changes..._
- Follow the Pull Request template and submit
- Follow the _Pull Request_ template and submit
- A GitHub Action job will create a link to the current site
- This will initially return `404`, as the site isn't built yet
- Clicking instead on the ReadTheDocs check at the bottom of the Pull Request
will show build logs, but these are _intentionally_ sparse, capturing most output
as logs to present in the built site.
- ReadTheDocs will check out the PR and build a preview JupyterLite site on a custom
domain
- If the preview site **fails** to build, the built RTD site will contain
Expand All @@ -47,11 +57,11 @@ Delivering a preview site uses a few different GitHub Actions workflows and Read

## what can it build?

`jupyak` understand how to work with one or more human-readable HTML URLs of the forms:
`jupyak` understand how to work with one or more human-readable URLs fragments of the forms:

- `{:repo}/pull/{:pull-id}`
- `{:repo}/tree/{:branch}`
- `{:repo}/releases/tag/{:tag}`
- `/pull/{:pull-id}`
- `/tree/{:branch}`
- `/releases/tag/{:tag}`
- > note that the `/tree/{:tag}` form will fail loudly
...from the following repos:
Expand All @@ -69,5 +79,23 @@ Delivering a preview site uses a few different GitHub Actions workflows and Read
- https://github.com/jupyterlite/jupyterlite
- https://github.com/jupyterlite/pyodide-kernel

Additionally, a single GitHub gist can be used as the contents of the preview site,
and can further configure the build- and runtime behavior of JupyterLite by providing
a custom `jupyter_lite_config.json` and/or `jupyter-lite.json`.

## what does it _not_ build?

A few more things _could_ be built, and might be interesting to evaluate
a PR stack, ar note. However, each of these would come at the expense of a lower
chance of a usable JupyterLite site at the end of each PR build. These include:

- test reports
- examples
- per-project documentation
- lint reports
- anything that doesn't work in the browser
- anything that requires a `c`/`rust`/`emscripten` compiler or other heavy dependencies
such as `pandas`

[issues]: https://github.com/deathbeds/jupyak/issues
[pulls]: https://github.com/deathbeds/jupyak/pulls
4 changes: 2 additions & 2 deletions docs/.readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ build:
pre_build:
- git config --global user.email "jupyak@example.com"
- git config --global user.name "jupyak"
- JPYK_ALLOW_NO_CONFIG=1 doit bootstrap || echo 'ok'
- JPYK_ALLOW_NO_CONFIG=1 doit bootstrap || echo 'ok'
# check out everything
- JPYK_LOG_NAME=git doit shave:git:* || echo 'ok'
# prepare the work conda env
Expand All @@ -19,7 +19,7 @@ build:
- JPYK_LOG_NAME=shave doit shave || echo 'ok'
- JPYK_LOG_NAME=shave2 doit shave || echo 'ok'
- doit self:docs:deploy:work || echo 'ok'
- JPYK_ALLOW_NO_CONFIG=1 doit self:docs:graph || echo 'ok'
- JPYK_ALLOW_NO_CONFIG=1 doit self:docs:graph || echo 'ok'

sphinx:
builder: html
Expand Down
67 changes: 60 additions & 7 deletions docs/_static/css/theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
--jpyk-color-jupyter-orange: #f37726;
}

html[data-theme="light"],
html[data-theme="dark"] {
--pst-color-primary: #9556cf;
}

html[data-theme="dark"] {
--pst-color-border: #444;
}
Expand Down Expand Up @@ -106,7 +101,7 @@ table.jsonschema h2 {

#task-graph-legend {
position: fixed;
top: 100px;
bottom: 100px;
right: 0;
pointer-events: none;
opacity: 0.75;
Expand All @@ -118,7 +113,65 @@ input[id*="svg-zoom-2"]:checked ~ svg { width: 200%; transition: width 0.5s;}
input[id*="svg-zoom-4"]:checked ~ svg { width: 400%; transition: width 0.5s;}
input[id*="svg-zoom-8"]:checked ~ svg { width: 800%; transition: width 0.5s;}

/* work */
/* form sidebar*/

form#propose button {
width: 100%;
margin: 0.5rem 0 1rem;
}
form#propose textarea {
width: 100%;
min-height: 10rem;
}
form#propose textarea:placeholder-shown ~ button {
display: none;
}
/* form main */
.show-repo-label {
padding-right: 1rem;
}

form#new input[type="text"] {
width: 100%;
}

form#new select {
width: 100%;
height: 2rem;
}

form#new code {
text-wrap: nowrap;
}

form#new input[id*="merge_with"] {
word-wrap: break-word;
word-break: break-all;
}

form#new table {
width: 100%;
}

form#new table label {
display: block;
}

form#new input[pattern]:invalid {
border: solid 1px var(--jpyk-color-jupyter-orange);
color: solid 1px var(--jpyk-color-jupyter-orange);
}

form#new input[pattern]:not(:invalid) ~ label {
display: none;
}

form#new th,
form#new td {
vertical-align: top;
}

/* work sidebar */
.work-sidebar {
border: solid 2px var(--jpyk-color-wasm-purple);
padding: 0;
Expand Down
2 changes: 1 addition & 1 deletion docs/_templates/demo.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<div class="work-sidebar {% if not lite_links %}work-sidebar-fail{% endif %}">
<div class="work-sidebar-header">
<i class="fas fa-{% if lite_links %}square-arrow-up-right{% else %}bomb{% endif %}"></i>
Preview Site
current preview site
</div>
<div class="work-sidebar-content">
<blockquote>
Expand Down
82 changes: 82 additions & 0 deletions docs/_templates/new-form.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
<style>
.bd-main .bd-content .bd-article-container .bd-article {
padding: 0;
}
.bd-sidebar-primary {
padding-bottom: 0;
}
</style>

<div class="work-sidebar">
<div class="work-sidebar-header">
<i class="fas fa-code-pull-request"></i>
start pull request
</div>
<div class="work-sidebar-content">
<form id="propose" method="get" action="https://github.com/deathbeds/jupyak/new/main" target="_blank">
<label for="toml-preview"><code>jupyak_config.toml</code> contents</label>
<textarea
required="true"
id="toml-preview"
name="value"
spellcheck="false"
placeholder="# make choices in the form"
></textarea>
<input type="hidden" name="filename" value="jupyak_config.toml"/>
<br/>
<button class="btn btn-success" form="propose">
<i class="fas fa-code-pull-request"></i> New Pull Request
</button>
</form>
</div>
</div>
<script type="importmap">
{
"imports": {
"json2toml": "https://cdn.skypack.dev/pin/json2toml@v6.0.0-d8Y8va9lNUE85BZ5GSQ2/mode=imports,min/optimized/json2toml.js"
}
}
</script>
<script type="module">
document.addEventListener('DOMContentLoaded', async function(){
const form = document.querySelector('form#new');
const preview = document.querySelector('#toml-preview');
const selector = 'form#new input[type="text"], form#new select';
const inputs = [...document.querySelectorAll(selector)];
const split_fields = ['merge_with', 'merge_options'];
async function update() {
const json2toml = (await import('json2toml')).default;
const config = find_config();
preview.value = json2toml(config);
}
function find_config() {
const config = {};
const data = new FormData(form);
for (const [name, value] of data.entries()) {
if(document.querySelector(`input[name="${name}"]:invalid`)) {
continue
}
let bits = name.split("|");
if(value.trim() === "" || bits.length == 1){
continue;
}
let current = config;
for(const bit of bits.slice(0, -1)) {
if(!current[bit]) {
current[bit] = {};
}
current = current[bit];
}
let last_bit = bits[bits.length - 1];
current[last_bit] = (
split_fields.includes(last_bit) ?
value.split(/[\s\n]+/):
value
);
}
return config;
}
inputs.map((input) => input.addEventListener('input', update))
})

</script>
10 changes: 4 additions & 6 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@

# sphinx config
extensions = [
"sphinx.ext.intersphinx",
"sphinx.ext.viewcode",
"myst_nb",
"sphinx.ext.autosectionlabel",
Expand All @@ -55,10 +54,6 @@
autosectionlabel_prefix_document = True
myst_heading_anchors = 3

intersphinx_mapping = {
"python": ("https://docs.python.org/3", None),
}

mermaid_version = ""
mermaid_init_js = "false"

Expand Down Expand Up @@ -99,7 +94,10 @@

html_context = {}
rediraffe_redirects = {}
html_sidebars = {"*": ["page-toc", "edit-this-page", "sourcelink"], "graph": []}
html_sidebars = {
"*": ["page-toc", "edit-this-page", "sourcelink"],
"graph": [],
}

if REPO_INFO is not None:
html_context = {**REPO_INFO.groupdict(), "doc_path": "docs"}
Expand Down
Loading

0 comments on commit 811c76a

Please sign in to comment.