allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [07/16] allura git commit: [#8230] Add interactive checkbox support for ForgeBlog
Date Mon, 15 Oct 2018 16:02:31 GMT
[#8230] Add interactive checkbox support for ForgeBlog


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

Branch: refs/heads/master
Commit: 3689f90fbd671191c088b921156eae24259bddd5
Parents: bd9b080
Author: Shalitha Suranga <shalithasuranga@gmail.com>
Authored: Wed Oct 10 12:00:51 2018 +0530
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Oct 15 15:50:29 2018 +0000

----------------------------------------------------------------------
 ForgeBlog/forgeblog/main.py                     | 22 ++++++++++++++++++++
 ForgeBlog/forgeblog/templates/blog/post.html    | 22 ++++++++++++++++++++
 .../templates/blog_widgets/view_post.html       |  2 +-
 3 files changed, 45 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/3689f90f/ForgeBlog/forgeblog/main.py
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/main.py b/ForgeBlog/forgeblog/main.py
index bf4c3ec..db79cd3 100644
--- a/ForgeBlog/forgeblog/main.py
+++ b/ForgeBlog/forgeblog/main.py
@@ -426,6 +426,28 @@ class PostController(BaseController, FeedController):
         redirect('.')
 
     @without_trailing_slash
+    @expose('json:')
+    @require_post()
+    def update_markdown(self, text=None, **kw):  
+        if has_access(self.post, 'edit'):
+            self.post.text = text
+            self.post.commit()
+            g.spam_checker.check(text, artifact=self.post,
+                user=c.user, content_type='blog-post')
+            return {
+                'status' : 'success'
+            }
+        else:
+            return {
+                'status' : 'no_permission'
+            }
+
+    @expose()
+    @without_trailing_slash
+    def get_markdown(self):
+        return self.post.text
+
+    @without_trailing_slash
     @require_post()
     @expose()
     def revert(self, version, **kw):

http://git-wip-us.apache.org/repos/asf/allura/blob/3689f90f/ForgeBlog/forgeblog/templates/blog/post.html
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/templates/blog/post.html b/ForgeBlog/forgeblog/templates/blog/post.html
index 1b91176..e565de6 100644
--- a/ForgeBlog/forgeblog/templates/blog/post.html
+++ b/ForgeBlog/forgeblog/templates/blog/post.html
@@ -44,3 +44,25 @@
     </div>
     {% endif %}
 {% endblock %}
+
+{% block extra_js %}
+    {% if h.has_access(post, 'edit') %}
+        <script>
+                new Checklists(".active-md", function(checkbox, callback) {
+                var uri = $(checkbox).closest('.active-md').data('markdownlink');
+                $.get(uri + 'get_markdown', callback);
+            }, function(markdown, checkbox, callback) {
+                var uri = $(checkbox).closest('.active-md').data('markdownlink');
+                $.ajax({
+                    type: 'post',
+                    url: uri + 'update_markdown',
+                    data: {
+                        'text' : markdown,
+                        '_session_id' : $.cookie('_session_id')
+                    },
+                    success: callback
+                });
+            });
+        </script>
+    {% endif %}
+{% endblock %}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/allura/blob/3689f90f/ForgeBlog/forgeblog/templates/blog_widgets/view_post.html
----------------------------------------------------------------------
diff --git a/ForgeBlog/forgeblog/templates/blog_widgets/view_post.html b/ForgeBlog/forgeblog/templates/blog_widgets/view_post.html
index 66b92c5..e428989 100644
--- a/ForgeBlog/forgeblog/templates/blog_widgets/view_post.html
+++ b/ForgeBlog/forgeblog/templates/blog_widgets/view_post.html
@@ -18,7 +18,7 @@
 -#}
 {% import 'allura:templates/jinja_master/lib.html' as lib with context %}
 
-{{value.html_text|safe}}
+<div class="active-md" data-markdownlink="">{{value.html_text|safe}}</div>
 {{lib.related_artifacts(value)}}
 <em class="grid-19">
   Posted by {{lib.user_link(base_post.author(), avatar=True)}} {{lib.abbr_date(value.timestamp)}}


Mime
View raw message