55 lines
1.7 KiB
Markdown
55 lines
1.7 KiB
Markdown
#
|
|
|
|
[Official docs page for external renderers](https://docs.gitea.com/next/administration/external-renderers)
|
|
|
|
## [kicanvas](https://kicanvas.org/)
|
|
|
|
[Adding kicanvas to gitea](https://www.reddit.com/r/KiCad/comments/1d2ngvh/comment/l65fuij/)
|
|
|
|
First I set the renderer for KiCad files as a powershell echo of "kicanvas here".
|
|
I do this so Gitea creates an extra element with the class "file-view markup kicad".
|
|
The echo text can be anything, it get's deleted before the page loads anyway.
|
|
|
|
Added in app.ini:
|
|
|
|
```app.ini
|
|
[markup.kicad]
|
|
ENABLED = true
|
|
FILE_EXTENSIONS = .kicad_sch,.kicad_pcb
|
|
RENDER_COMMAND = powershell echo "kicanvas here"
|
|
Then I edited the "footer.tmpl" to look for an element with the "file-view markup
|
|
kicad" class. If it finds that class it edits the innerHTML of it to remove the
|
|
"kicanvas here" text and appends a "kicanvas-embed" child element.
|
|
```
|
|
|
|
footer.tmpl:
|
|
|
|
```tmpl
|
|
<script>
|
|
function lS(src) {
|
|
return new Promise(function (resolve, reject) {
|
|
let s = document.createElement("script");
|
|
s.src = src;
|
|
s.addEventListener("load", () => {
|
|
resolve();
|
|
});
|
|
document.body.appendChild(s);
|
|
});
|
|
}
|
|
|
|
if (document.getElementsByClassName("file-view markup kicad").length) {
|
|
Promise.all([
|
|
lS("/assets/kicanvas.js"),
|
|
]).then(function () {
|
|
let s = document.createElement("kicanvas-embed");
|
|
s.src = location.pathname.replace("/src/","/raw/");
|
|
s.controls = "full";
|
|
s.theme = "kicad";
|
|
s.controlslist = "nooverlay";
|
|
document.body.getElementsByClassName("file-view markup kicad")[0].innerHTML = "";
|
|
document.body.getElementsByClassName("file-view markup kicad")[0].appendChild(s);
|
|
});
|
|
}
|
|
</script>
|
|
```
|