Skip to content

Commit

Permalink
[KR] Add easy link to webeditor
Browse files Browse the repository at this point in the history
  • Loading branch information
Niharika Ray committed Jan 12, 2017
1 parent 9e2690d commit 1a6f817
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
7 changes: 6 additions & 1 deletion knowledge_repo/app/routes/render.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ def render():

is_author = user_id in [author.id for author in post.authors]

web_editor_prefixes = current_app.config['WEB_EDITOR_PREFIXES']
is_webeditor = []
if web_editor_prefixes:
is_webeditor = [prefix for prefix in web_editor_prefixes if prefix in path]

rendered = render_template(tmpl,
html=html,
post_id=post.id,
Expand All @@ -115,7 +120,7 @@ def render():
total_likes=post.vote_count,
tags_list=tags_list,
user_subscriptions=user_subscriptions,
webeditor_buttons=False,
webeditor_buttons=(len(is_webeditor) != 0),
web_uri=post.kp.web_uri,
table_id=None,
is_private=(post.private == 1),
Expand Down
9 changes: 9 additions & 0 deletions knowledge_repo/app/templates/markdown-base.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@
<button type="button" class="btn btn-default btn-raw">
View Raw Markdown
</button>
{% if is_author and webeditor_buttons %}
<button type="button" class="btn btn-default btn-webeditor">
View post in webeditor
</button>
{% endif %}
</div>
</div>
<div class="col-md-2">
Expand Down Expand Up @@ -89,6 +94,10 @@
$(".btn-raw").on("click", function(){
document.location.href = "/raw?markdown=" + encodeURI(post_path);
})

$(".btn-webeditor").on("click", function(){
document.location.href = "/posteditor?path=" + encodeURI(post_path);
})
});

</script>
Expand Down

0 comments on commit 1a6f817

Please sign in to comment.