-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
21 changed files
with
2,311 additions
and
317 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.