Viewing historical versions of pages now works, and show historical version of partials as well
This commit is contained in:
parent
f47af0ecae
commit
f34eabd7df
|
@ -23,7 +23,7 @@
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script>
|
<script>
|
||||||
$(function(){
|
$(function(){
|
||||||
$("#page-content").html(MDR.convert({{ page.data|tojson|safe }}, {{ partials|tojson|safe }})).show();
|
$("#page-content").html(MDR.convert({{ page.data|tojson|safe }}, {{ partials|d([])|tojson|safe }})).show();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
|
@ -23,7 +23,9 @@ def commit(name, sha):
|
||||||
if not data:
|
if not data:
|
||||||
abort(404)
|
abort(404)
|
||||||
|
|
||||||
return render_template('wiki/page.html', name=name, page=data, commit=sha)
|
partials = _partials(data.imports, sha=sha)
|
||||||
|
|
||||||
|
return render_template('wiki/page.html', name=name, page=data, commit=sha, partials=partials)
|
||||||
|
|
||||||
|
|
||||||
@blueprint.route(r"/_compare/<path:name>/<regex('\w+'):fsha><regex('\.{2,3}'):dots><regex('\w+'):lsha>")
|
@blueprint.route(r"/_compare/<path:name>/<regex('\w+'):fsha><regex('\.{2,3}'):dots><regex('\w+'):lsha>")
|
||||||
|
@ -118,14 +120,14 @@ def edit(name):
|
||||||
sha=page.sha)
|
sha=page.sha)
|
||||||
|
|
||||||
|
|
||||||
def _partials(imports):
|
def _partials(imports, sha='HEAD'):
|
||||||
page_queue = collections.deque(imports)
|
page_queue = collections.deque(imports)
|
||||||
partials = collections.OrderedDict()
|
partials = collections.OrderedDict()
|
||||||
while page_queue:
|
while page_queue:
|
||||||
page_name = page_queue.popleft()
|
page_name = page_queue.popleft()
|
||||||
if page_name in partials:
|
if page_name in partials:
|
||||||
continue
|
continue
|
||||||
page = g.current_wiki.get_page(page_name)
|
page = g.current_wiki.get_page(page_name, sha=sha)
|
||||||
try:
|
try:
|
||||||
partials[page_name] = page.data
|
partials[page_name] = page.data
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
|
Loading…
Reference in a new issue