Skip to content

Commit

Permalink
Merge pull request #192 from airbnb/nray_add_easy_link_to_webpost
Browse files Browse the repository at this point in the history
[KR] Add easy link to webeditor
  • Loading branch information
NiharikaRay committed Jan 12, 2017
2 parents 9e2690d + be73bbd commit 63fa1be
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 7 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_webpost = False
if web_editor_prefixes:
is_webpost = any(prefix for prefix in web_editor_prefixes if path.startswith(prefix))

rendered = render_template(tmpl,
html=html,
post_id=post.id,
Expand All @@ -115,7 +120,8 @@ def render():
total_likes=post.vote_count,
tags_list=tags_list,
user_subscriptions=user_subscriptions,
webeditor_buttons=False,
show_webeditor_button=is_webpost and is_author,
webeditor_buttons=is_webpost,
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 show_webeditor_button %}
<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 63fa1be

Please sign in to comment.