Commit 8b6cd807 authored by Floreal Cabanettes's avatar Floreal Cabanettes
Browse files

Better fix of headers link

parent 8c92c3f8
...@@ -22,3 +22,4 @@ babel.js -o dgenies.result.min.js --compact --minified dgenies.result.js dgenies ...@@ -22,3 +22,4 @@ babel.js -o dgenies.result.min.js --compact --minified dgenies.result.js dgenies
babel.js -o jquery.fileupload.min.js --compact --minified jquery.fileupload.js jquery.fileupload-process.js jquery.fileupload-validate.js babel.js -o jquery.fileupload.min.js --compact --minified jquery.fileupload.js jquery.fileupload-process.js jquery.fileupload-validate.js
babel.js -o dgenies.run.min.js --compact --minified dgenies.run.js babel.js -o dgenies.run.min.js --compact --minified dgenies.run.js
babel.js -o dgenies.status.min.js --compact --minified dgenies.status.js babel.js -o dgenies.status.min.js --compact --minified dgenies.status.js
babel.js -o dgenies.documentation.min.js --compact --minified dgenies.documentation.js
...@@ -283,12 +283,3 @@ class Functions: ...@@ -283,12 +283,3 @@ class Functions:
def query_fasta_file_exists(res_dir): def query_fasta_file_exists(res_dir):
fasta_file = os.path.join(res_dir, ".query") fasta_file = os.path.join(res_dir, ".query")
return os.path.exists(fasta_file) and os.path.isfile(fasta_file) return os.path.exists(fasta_file) and os.path.isfile(fasta_file)
@staticmethod
def replace_headers(text):
headers = re.findall("<h\d id=\"[^\"]+\">", text)
for header in headers:
id_header = re.search("id=\"([^\"]+)\"", header).group(1)
text = text.replace(header, "<span class=\"anchor\" id=\"%s\"></span>%s" %
(id_header, re.sub(r"id=\"[^\"]+\"", "class=\"section\"", header)))
return text
if (!dgenies) {
throw "dgenies wasn't included!"
}
dgenies.documentation = {};
dgenies.documentation.init = function () {
$("table").addClass("table table-striped");
dgenies.documentation.fix_links_headers();
};
dgenies.documentation.fix_links_headers = function() {
$("#plan").on("click", "a", function (e) {
e.preventDefault();
dgenies.documentation.goto(this);
})
};
dgenies.documentation.goto = function (elem) {
let top = $($(elem).attr("href")).offset()["top"];
$(window).scrollTop(top-55);
$(elem).blur();
};
\ No newline at end of file
if(!dgenies){throw"dgenies wasn't included!"}dgenies.documentation={};dgenies.documentation.init=function(){$("table").addClass("table table-striped");dgenies.documentation.fix_links_headers()};dgenies.documentation.fix_links_headers=function(){$("#plan").on("click","a",function(e){e.preventDefault();dgenies.documentation.goto(this)})};dgenies.documentation.goto=function(elem){let top=$($(elem).attr("href")).offset()["top"];$(window).scrollTop(top-55);$(elem).blur()};
{% extends 'base.html' %} {% extends 'base.html' %}
{% block scripts %} {% block scripts %}
{{ super() }} {{ super() }}
{% if debug %}
<script src="{{ url_for('static', filename='js/dgenies.documentation.js') }}" type="text/JavaScript"></script>
{% else %}
<script src="{{ url_for('static', filename='js/dgenies.documentation.min.js') }}" type="text/JavaScript"></script>
{% endif %}
<style> <style>
#plan-back, #body { #plan-back, #body {
display: inline-block; display: inline-block;
...@@ -45,12 +50,10 @@ ...@@ -45,12 +50,10 @@
} }
{% endif %} {% endif %}
</style> </style>
{% endblock %}
<script type="text/javascript"> {% block onload %}
$(document).ready(function() { {{ super() }}
$("table").addClass("table table-striped"); dgenies.documentation.init();
});
</script>
{% endblock %} {% endblock %}
{% block content %} {% block content %}
......
...@@ -347,7 +347,7 @@ def documentation_run(): ...@@ -347,7 +347,7 @@ def documentation_run():
content = template.render(mode=MODE, version=version, size=max_upload_file_size, size_unc=max_upload_size, content = template.render(mode=MODE, version=version, size=max_upload_file_size, size_unc=max_upload_size,
size_ava=max_upload_size_ava) size_ava=max_upload_size_ava)
md = Markdown(extensions=[TocExtension(baselevel=1)]) md = Markdown(extensions=[TocExtension(baselevel=1)])
content = Functions.replace_headers(str(Markup(md.convert(content)))) content = Markup(md.convert(content))
toc = Markup(md.toc) toc = Markup(md.toc)
return render_template("documentation.html", menu="documentation", content=content, toc=toc) return render_template("documentation.html", menu="documentation", content=content, toc=toc)
...@@ -358,7 +358,7 @@ def documentation_result(): ...@@ -358,7 +358,7 @@ def documentation_result():
encoding='utf-8') as install_instr: encoding='utf-8') as install_instr:
content = install_instr.read() content = install_instr.read()
md = Markdown(extensions=[TocExtension(baselevel=1)]) md = Markdown(extensions=[TocExtension(baselevel=1)])
content = Functions.replace_headers(str(Markup(md.convert(content)))) content = Markup(md.convert(content))
toc = Markup(md.toc) toc = Markup(md.toc)
return render_template("documentation.html", menu="documentation", content=content, toc=toc) return render_template("documentation.html", menu="documentation", content=content, toc=toc)
...@@ -369,7 +369,7 @@ def documentation_formats(): ...@@ -369,7 +369,7 @@ def documentation_formats():
encoding='utf-8') as install_instr: encoding='utf-8') as install_instr:
content = install_instr.read() content = install_instr.read()
md = Markdown(extensions=[TocExtension(baselevel=1), TableExtension()]) md = Markdown(extensions=[TocExtension(baselevel=1), TableExtension()])
content = Functions.replace_headers(str(Markup(md.convert(content)))) content = Markup(md.convert(content))
toc = Markup(md.toc) toc = Markup(md.toc)
return render_template("documentation.html", menu="documentation", content=content, toc=toc) return render_template("documentation.html", menu="documentation", content=content, toc=toc)
...@@ -380,7 +380,7 @@ def documentation_dotplot(): ...@@ -380,7 +380,7 @@ def documentation_dotplot():
encoding='utf-8') as install_instr: encoding='utf-8') as install_instr:
content = install_instr.read() content = install_instr.read()
md = Markdown(extensions=[TocExtension(baselevel=1)]) md = Markdown(extensions=[TocExtension(baselevel=1)])
content = Functions.replace_headers(str(Markup(md.convert(content)))) content = Markup(md.convert(content))
toc = Markup(md.toc) toc = Markup(md.toc)
return render_template("documentation.html", menu="documentation", content=content, toc=toc) return render_template("documentation.html", menu="documentation", content=content, toc=toc)
...@@ -395,7 +395,7 @@ def install(): ...@@ -395,7 +395,7 @@ def install():
template = env.from_string(content) template = env.from_string(content)
content = template.render(version=latest.latest, win32=latest.win32) content = template.render(version=latest.latest, win32=latest.win32)
md = Markdown(extensions=[TocExtension(baselevel=1)]) md = Markdown(extensions=[TocExtension(baselevel=1)])
content = Functions.replace_headers(str(Markup(md.convert(content)))) content = Markup(md.convert(content))
toc = Markup(md.toc) toc = Markup(md.toc)
return render_template("documentation.html", menu="install", content=content, toc=toc) return render_template("documentation.html", menu="install", content=content, toc=toc)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment