allura-commits mailing list archives

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


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

Branch: refs/heads/master
Commit: 6084c2b77d0fbe6d60c732d09cad6475b448ab7e
Parents: 1c2b26d
Author: Shalitha <shalithasuranga@gmail.com>
Authored: Tue Oct 9 21:51:14 2018 +0530
Committer: Dave Brondsema <dbrondsema@slashdotmedia.com>
Committed: Mon Oct 15 15:50:29 2018 +0000

----------------------------------------------------------------------
 .../forgewiki/templates/wiki/page_view.html     | 24 +++++++++++++++++++-
 ForgeWiki/forgewiki/wiki_main.py                | 24 ++++++++++++++++++++
 2 files changed, 47 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/allura/blob/6084c2b7/ForgeWiki/forgewiki/templates/wiki/page_view.html
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/templates/wiki/page_view.html b/ForgeWiki/forgewiki/templates/wiki/page_view.html
index b4d3f8a..f1eda91 100644
--- a/ForgeWiki/forgewiki/templates/wiki/page_view.html
+++ b/ForgeWiki/forgewiki/templates/wiki/page_view.html
@@ -71,7 +71,7 @@
 {% endblock %}
 
 {% block wiki_content %}
-{{page.html_text}}
+<div class="active-md" data-markdownlink="">{{page.html_text}}</div>
 {% endblock %}
 
 {% block wiki_meta %}
@@ -119,3 +119,25 @@
   {% endif %}
   {{c.confirmation.display(content='')}}
 {% endblock %}
+
+{% block wiki_extra_js %}
+    {% if h.has_access(page, '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/6084c2b7/ForgeWiki/forgewiki/wiki_main.py
----------------------------------------------------------------------
diff --git a/ForgeWiki/forgewiki/wiki_main.py b/ForgeWiki/forgewiki/wiki_main.py
index f7c1eca..64aaf8b 100644
--- a/ForgeWiki/forgewiki/wiki_main.py
+++ b/ForgeWiki/forgewiki/wiki_main.py
@@ -770,6 +770,30 @@ class PageController(BaseController, FeedController):
                  .encode('utf-8') + ('/' if not name_conflict else '/edit'))
 
     @without_trailing_slash
+    @expose('json:')
+    @require_post()
+    def update_markdown(self, text=None, **kw):  
+        if has_access(self.page, 'edit'):
+            self.page.text = text
+            self.page.commit()
+            g.spam_checker.check(text, artifact=self.page,
+                user=c.user, content_type='wiki')
+            g.director.create_activity(c.user, 'modified', self.page,
+                related_nodes=[c.project], tags=['wiki'])
+            return {
+                'status' : 'success'
+            }
+        else:
+            return {
+                'status' : 'no_permission'
+            }
+
+    @without_trailing_slash
+    @expose()
+    def get_markdown(self):  
+        return self.page.text
+
+    @without_trailing_slash
     @expose()
     @require_post()
     def attach(self, file_info=None, **kw):


Mime
View raw message