mirror of
https://github.com/GNS3/gns3-registry.git
synced 2025-02-20 17:22:48 +00:00
Base64 the device payload
This commit is contained in:
parent
c414b2fa09
commit
930d35f4cd
3
build.py
3
build.py
@ -20,6 +20,7 @@ import sys
|
||||
import json
|
||||
import shutil
|
||||
import copy
|
||||
import base64
|
||||
|
||||
from jinja2 import Environment, FileSystemLoader
|
||||
|
||||
@ -48,7 +49,7 @@ def render(template_file, out, **kwargs):
|
||||
log.info('Build %s', out)
|
||||
env = Environment(loader=FileSystemLoader('templates'))
|
||||
env.filters['jsonify'] = json.dumps
|
||||
env.filters['escape_quote'] = lambda x: x.replace('"','\\"')
|
||||
env.filters['b64encode'] = lambda s: base64.b64encode(s.encode()).decode("utf-8")
|
||||
template = env.get_template(template_file)
|
||||
template.stream(**kwargs).dump(os.path.join('build', out))
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
{% endif %}
|
||||
{% for version in device["versions"] | reverse %}
|
||||
<h2>{{ device["name"] }} {{version["name"]}}</h2>
|
||||
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.install("{{device|jsonify|escape_quote}}", "{{version["name"]}}")'>Install</button>
|
||||
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.install("{{device|jsonify|b64encode}}", "{{version["name"]}}")'>Install</button>
|
||||
<h3>Require files</h3>
|
||||
{% for image in version.images.values() %}
|
||||
<h4>{{image["filename"]}}</h4>
|
||||
@ -27,7 +27,7 @@
|
||||
Download url: <a href="{{image["download_url"]}}">{{image["download_url"]}}</a><br />
|
||||
{% if "direct_download_url" in image %}
|
||||
Direct download url: <a href="{{image["direct_download_url"]}}">{{image["direct_download_url"]}}</a><br />
|
||||
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.download("{{device|jsonify|escape_quote}}", "{{image["md5sum"]}}")'>Download</button>
|
||||
<button class="btn btn-primary btn-lg" type="button" onclick='gns3.download("{{device|jsonify|b64encode}}", "{{image["md5sum"]}}")'>Download</button>
|
||||
{% endif %}
|
||||
<hr />
|
||||
{% endfor %}
|
||||
|
Loading…
x
Reference in New Issue
Block a user