diff options
author | Antoine GIRARD <sapk@users.noreply.github.com> | 2020-04-22 19:02:54 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-22 20:02:54 +0300 |
commit | 316db0fe79a5d0e48c5171c937e56ef6b6b8a3e1 (patch) | |
tree | 4bfc7214e32b101b49fc360a7bd4b9cfb59719b1 /docs | |
parent | fcc8cdd446d99a822d835c6d36e8abc4b5ac42a6 (diff) | |
download | gitea-316db0fe79a5d0e48c5171c937e56ef6b6b8a3e1.tar.gz gitea-316db0fe79a5d0e48c5171c937e56ef6b6b8a3e1.zip |
Add documentation to display STL preview (#11181)
* Update customizing-gitea.en-us.md
* Update customizing-gitea.en-us.md
* only load assets when needed
* remove useless var
* fix missing 'i' modifier
Diffstat (limited to 'docs')
-rw-r--r-- | docs/content/doc/advanced/customizing-gitea.en-us.md | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/docs/content/doc/advanced/customizing-gitea.en-us.md b/docs/content/doc/advanced/customizing-gitea.en-us.md index 2c06de67b5..b52a713e40 100644 --- a/docs/content/doc/advanced/customizing-gitea.en-us.md +++ b/docs/content/doc/advanced/customizing-gitea.en-us.md @@ -180,6 +180,89 @@ You can then add blocks like the following to your markdown: The script will detect tags with `class="language-plantuml"`, but you can change this by providing a second argument to `parsePlantumlCodeBlocks`. +#### Example: STL Preview + +You can display STL file directly in Gitea by adding: +```html +<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($('.view-raw>a[href$=".stl" i]').length){ + $('body').append('<link href="/Madeleine.js/src/css/Madeleine.css" rel="stylesheet">'); + Promise.all([lS("/Madeleine.js/src/lib/stats.js"),lS("/Madeleine.js/src/lib/detector.js"), lS("/Madeleine.js/src/lib/three.min.js"), lS("/Madeleine.js/src/Madeleine.js")]).then(function() { + $('.view-raw').attr('id', 'view-raw').attr('style', 'padding: 0;margin-bottom: -10px;'); + new Madeleine({ + target: 'view-raw', + data: $('.view-raw>a[href$=".stl" i]').attr('href'), + path: '/Madeleine.js/src' + }); + $('.view-raw>a[href$=".stl"]').remove() + }); +} +</script> +``` +to the file `templates/custom/footer.tmpl` + +You also need to download the content of the library [Madeleine.js](https://jinjunho.github.io/Madeleine.js/) and place it under `custom/public/` folder. + +You should end-up with a folder structucture similar to: +``` +custom/templates +-- custom + `-- footer.tmpl +custom/public +-- Madeleine.js + |-- LICENSE + |-- README.md + |-- css + | |-- pygment_trac.css + | `-- stylesheet.css + |-- examples + | |-- ajax.html + | |-- index.html + | `-- upload.html + |-- images + | |-- bg_hr.png + | |-- blacktocat.png + | |-- icon_download.png + | `-- sprite_download.png + |-- models + | |-- dino2.stl + | |-- ducati.stl + | |-- gallardo.stl + | |-- lamp.stl + | |-- octocat.stl + | |-- skull.stl + | `-- treefrog.stl + `-- src + |-- Madeleine.js + |-- css + | `-- Madeleine.css + |-- icons + | |-- logo.png + | |-- madeleine.eot + | |-- madeleine.svg + | |-- madeleine.ttf + | `-- madeleine.woff + `-- lib + |-- MadeleineConverter.js + |-- MadeleineLoader.js + |-- detector.js + |-- stats.js + `-- three.min.js +``` + +Then restart gitea and open a STL file on your gitea instance. + ## Customizing Gitea mails The `custom/templates/mail` folder allows changing the body of every mail of Gitea. |