-
Notifications
You must be signed in to change notification settings - Fork 685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[KR] Add easy link to webeditor #192
Conversation
1a6f817
to
21a845b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this small change, LGTM. Thanks Nikki.
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] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix in path
is a little too loose here, since sometimes a prefix could appear within the path at some other location than the beginning; e.g.: projects/webposts/why_you_should_use_git.kp
.
Given that you are using it as a boolean indicator, perhaps you could simplify the code here by just doing:
show_webeditor_buttons = any(path.startswith(prefix) for prefix in current_app.config['WEB_EDITOR_PREFIXES'])
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Way cleaner! Fixed.
@@ -15,6 +15,11 @@ | |||
<button type="button" class="btn btn-default btn-raw"> | |||
View Raw Markdown | |||
</button> | |||
{% if is_author and webeditor_buttons %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: I think the server should completely control the logic of whether or not to show the button - so I'd have this bit of logic live in render.py
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simplified to move the boolean logic into the python file. This whole file could use some of that simplification.
@@ -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); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we be using url_for
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good point. But since there are other links with the same problem, let's resolve this in a different PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, totally agree! I believe the reason that it's done this way was that it's bad practice to mix jinja templating code with JS (which I did above for some reason, and should also be fixed). We should be able to take this out and replace it with a url_for in another PR.
21a845b
to
cb532f3
Compare
cb532f3
to
be73bbd
Compare
Description of changeset: If you're the author of the webpost, you now get a button on top of the rendered post to quickly take you to the webeditor
![screen shot 2017-01-11 at 4 18 48 pm](https://cloud.githubusercontent.com/assets/4268311/21871916/1f5414b6-d81a-11e6-846e-19e502ddca7a.png)
Test Plan:
Auto-reviewers: @matthewwardrop @earthmancash @danfrankj