[#8249] Refactor markup to jinja a macro :rocket:
diff --git a/Allura/allura/templates/jinja_master/dialog_macros.html b/Allura/allura/templates/jinja_master/dialog_macros.html
new file mode 100644
index 0000000..82f3a35
--- /dev/null
+++ b/Allura/allura/templates/jinja_master/dialog_macros.html
@@ -0,0 +1,40 @@
+{#-
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-#}
+
+{#
+Each macro is wrapped with an 'if' clause so that a custom theme may extend this file and override individual macros
+http://stackoverflow.com/questions/26582731/redefining-imported-jinja-macros
+#}
+
+{% if not revert_confirmation_dialog %}
+{%- macro revert_confirmation_dialog(version) %}
+ <div class="confirmation_dialog_{{version}}" style="display:none">
+ {{ g.icons['close'].render(tag='b', extra_css='close') }}
+ <h1>Confirm revert to version {{version}}</h1>
+ <p>
+ Do you really want to revert page to version {{version}}?
+ You can undo it later by reverting changes made by this revert.
+ </p>
+ <p>
+ <button class="continue_confirm" href="./revert?version={{version}}">Yes</button>
+ <input type="button" value="Cancel" class="cancel_confirmation close">
+ </p>
+ </div>
+{%- endmacro %}
+{% endif %}
\ No newline at end of file
diff --git a/ForgeBlog/forgeblog/templates/blog/post_history.html b/ForgeBlog/forgeblog/templates/blog/post_history.html
index 136d52e..de41bda 100644
--- a/ForgeBlog/forgeblog/templates/blog/post_history.html
+++ b/ForgeBlog/forgeblog/templates/blog/post_history.html
@@ -17,7 +17,7 @@
under the License.
-#}
{% extends g.theme.master %}
-
+{% import 'allura:templates/jinja_master/dialog_macros.html' as dialog_macros with context %}
{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / {{title}}{% endblock %}
{% block header %}{{title}}{% endblock %}
@@ -45,18 +45,7 @@
<a href="./?version={{p.version}}" class="btn">View Revision</a>
{% if loop.index0 != 0 and h.has_access(p, 'edit')() %}
<a href="#" class="btn post-link" data-dialog-id="{{p.version}}">Revert to version {{p.version}}</a>
- <div class="confirmation_dialog_{{p.version}}" style="display:none">
- {{ g.icons['close'].render(tag='b', extra_css='close') }}
- <h1>Confirm revert to version {{p.version}}</h1>
- <p>
- Do you really want to revert page to version {{p.version}}?
- You can undo it later by reverting changes made by this revert.
- </p>
- <p>
- <button class="continue_confirm" href="./revert?version={{p.version}}">Yes</button>
- <input type="button" value="Cancel" class="cancel_confirmation close">
- </p>
- </div>
+ {{ dialog_macros.revert_confirmation_dialog(p.version) }}
{% endif %}
</td>
</tr>
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_history.html b/ForgeWiki/forgewiki/templates/wiki/page_history.html
index 02f385d..8b73362 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_history.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_history.html
@@ -18,6 +18,7 @@
-#}
{% extends 'forgewiki:templates/wiki/master.html' %}
{% from 'allura:templates/jinja_master/lib.html' import abbr_date with context %}
+{% import 'allura:templates/jinja_master/dialog_macros.html' as dialog_macros with context %}
{% block title %}{{c.project.name}} / {{c.app.config.options.mount_label}} / {{title}}{% endblock %}
@@ -55,18 +56,7 @@
extra_css='post-link',
title='Revert to version {}'.format(p.version),
**{'data-dialog-id': p.version}) }}
- <div class="confirmation_dialog_{{p.version}}" style="display:none">
- {{ g.icons['close'].render(tag='b', extra_css='close') }}
- <h1>Confirm revert to version {{p.version}}</h1>
- <p>
- Do you really want to revert page to version {{p.version}}?
- You can undo it later by reverting changes made by this revert.
- </p>
- <p>
- <button class="continue_confirm" href="./revert?version={{p.version}}">Yes</button>
- <input type="button" value="Cancel" class="cancel_confirmation close">
- </p>
- </div>
+ {{ dialog_macros.revert_confirmation_dialog(p.version) }}
{% endif %}
{{ g.icons['eye'].render(href='./?version={}'.format(p.version), title='View Revision') }}
</td>