allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From kentontay...@apache.org
Subject [3/3] allura git commit: [#8249] Refactor markup to jinja a macro :rocket:
Date Fri, 26 Oct 2018 20:39:56 GMT
[#8249] Refactor markup to jinja a macro :rocket:


Project: http://git-wip-us.apache.org/repos/asf/allura/repo
Commit: http://git-wip-us.apache.org/repos/asf/allura/commit/88936378
Tree: http://git-wip-us.apache.org/repos/asf/allura/tree/88936378
Diff: http://git-wip-us.apache.org/repos/asf/allura/diff/88936378

Branch: refs/heads/master
Commit: 8893637845d48acc032818e798f1b16bc747f9bd
Parents: 0c1bab6
Author: Shalitha <shalithasuranga@gmail.com>
Authored: Wed Oct 24 01:50:29 2018 +0530
Committer: Kenton Taylor <ktaylor@slashdotmedia.com>
Committed: Fri Oct 26 20:31:23 2018 +0000

----------------------------------------------------------------------
 .../templates/jinja_master/dialog_macros.html   | 40 ++++++++++++++++++++
 .../forgeblog/templates/blog/post_history.html  | 15 +-------
 .../forgewiki/templates/wiki/page_history.html  | 14 +------
 3 files changed, 44 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/88936378/Allura/allura/templates/jinja_master/dialog_macros.html
----------------------------------------------------------------------
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

http://git-wip-us.apache.org/repos/asf/allura/blob/88936378/ForgeBlog/forgeblog/templates/blog/post_history.html
----------------------------------------------------------------------
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>

http://git-wip-us.apache.org/repos/asf/allura/blob/88936378/ForgeWiki/forgewiki/templates/wiki/page_history.html
----------------------------------------------------------------------
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>


Mime
View raw message