You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@allura.apache.org by ke...@apache.org on 2018/10/26 20:39:54 UTC

[1/3] allura git commit: [#8249] Fix ForgeBlog revert issue and add confirmation dialog

Repository: allura
Updated Branches:
  refs/heads/master ab13d4799 -> 889363784


[#8249] Fix ForgeBlog revert issue and add confirmation dialog


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

Branch: refs/heads/master
Commit: f554fa53beedb078e46d3cdaf07279085daef053
Parents: ab13d47
Author: Shalitha <sh...@gmail.com>
Authored: Sun Oct 21 13:31:45 2018 +0530
Committer: Kenton Taylor <kt...@slashdotmedia.com>
Committed: Fri Oct 26 20:31:22 2018 +0000

----------------------------------------------------------------------
 ForgeBlog/forgeblog/main.py                     |  8 +++-
 .../forgeblog/templates/blog/post_history.html  | 40 +++++++++++++++++++-
 2 files changed, 45 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/f554fa53/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index db79cd3..066c238 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -70,6 +70,9 @@ class W:
     edit_post_form = widgets.EditPostForm()
     view_post_form = widgets.ViewPostForm()
     attachment_list = ffw.AttachmentList()
+    confirmation = ffw.Lightbox(name='confirm',
+                            trigger='a.post-link',
+                            options="{ modalCSS: { minHeight: 0, width: 'inherit', top: '150px'}}")
     preview_post_form = widgets.PreviewPostForm()
     subscribe_form = SubscribeForm(thing='post')
     search_results = SearchResults()
@@ -391,6 +394,7 @@ class PostController(BaseController, FeedController):
     @without_trailing_slash
     @expose('jinja:forgeblog:templates/blog/post_history.html')
     def history(self, **kw):
+        c.confirmation = W.confirmation
         posts = self.post.history()
         return dict(title=self.post.title, posts=posts)
 
@@ -449,14 +453,14 @@ class PostController(BaseController, FeedController):
 
     @without_trailing_slash
     @require_post()
-    @expose()
+    @expose('json:')
     def revert(self, version, **kw):
         require_access(self.post, 'write')
         orig = self._get_version(version)
         if orig:
             self.post.text = orig.text
         self.post.commit()
-        redirect('.')
+        return dict(location='.')
 
     @expose('json:')
     @require_post()

http://git-wip-us.apache.org/repos/asf/allura/blob/f554fa53/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 fd1efbf..136d52e 100644
--- a/ForgeBlog/forgeblog/templates/blog/post_history.html
+++ b/ForgeBlog/forgeblog/templates/blog/post_history.html
@@ -44,7 +44,19 @@
                   <td>
                     <a href="./?version={{p.version}}" class="btn">View Revision</a>
                     {% if loop.index0 != 0 and h.has_access(p, 'edit')() %}
-                    <a href="./revert?version={{p.version}}" class="btn">Revert to version {{p.version}}</a>
+                    <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>
                     {% endif %}
                   </td>
                 </tr>
@@ -52,4 +64,30 @@
               </tbody>
             </table>
           </form>
+{{c.confirmation.display(content='')}}
+{% block extra_js %}
+    <script type="text/javascript">
+        $('.post-link').click(function () {
+            var dialog_text;
+            var version = $(this).data("dialog-id");
+            if (version) {
+                dialog_text = $(".confirmation_dialog_" + version);
+            } else {
+                dialog_text = $(".confirmation_dialog");
+            }
+
+            var modal = $('#lightbox_confirm');
+            modal.html(dialog_text.html());
+
+            modal.find('.continue_confirm').click(function (evt) {
+                var cval = $.cookie('_session_id');
+                evt.preventDefault();
+                $.post($(this).attr('href'), {_session_id: cval}, function (val) {
+                    window.location = val.location;
+                }, 'json');
+            });
+        });
+    </script>
+{% endblock %}
+
 {% endblock %}


[3/3] allura git commit: [#8249] Refactor markup to jinja a macro :rocket:

Posted by ke...@apache.org.
[#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 <sh...@gmail.com>
Authored: Wed Oct 24 01:50:29 2018 +0530
Committer: Kenton Taylor <kt...@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>


[2/3] allura git commit: [#8249] Add test for ForgeBlog revert

Posted by ke...@apache.org.
[#8249] Add test for ForgeBlog revert


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

Branch: refs/heads/master
Commit: 0c1bab6f951e17dfc93dcdc1ea7e6fd689b0af7e
Parents: f554fa5
Author: Shalitha <sh...@gmail.com>
Authored: Sun Oct 21 13:32:48 2018 +0530
Committer: Kenton Taylor <kt...@slashdotmedia.com>
Committed: Fri Oct 26 20:31:23 2018 +0000

----------------------------------------------------------------------
 ForgeBlog/forgeblog/tests/functional/test_root.py | 11 +++++++++++
 1 file changed, 11 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/0c1bab6f/ForgeBlog/forgeblog/tests/functional/test_root.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/tests/functional/test_root.py b/ForgeBlog/forgeblog/tests/functional/test_root.py
index 26c5149..8a94537 100644
--- a/ForgeBlog/forgeblog/tests/functional/test_root.py
+++ b/ForgeBlog/forgeblog/tests/functional/test_root.py
@@ -1,3 +1,5 @@
+# -*- coding: utf-8 -*-
+
 #       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
@@ -232,6 +234,15 @@ class Test(TestController):
         assert '<script>alert' not in response
         assert '<ins> &lt;script&gt;alert' in response
 
+    def test_post_revert(self):
+        self._post()
+        d = self._blog_date()
+        self._post('/%s/my-post' % d, text='sometést')
+        response = self.app.post('/blog/%s/my-post/revert' % d, params=dict(version='1'))
+        assert '.' in response.json['location']
+        response = self.app.get('/blog/%s/my-post/' % d)
+        assert 'Nothing to see here' in response
+
     def test_invalid_lookup(self):
         r = self.app.get('/blog/favicon.ico', status=404)