-
Notifications
You must be signed in to change notification settings - Fork 4.9k
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
Adds edit and view buttons #1905
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
482ea4b
Adds edit and view buttons, #1752
a7387b8
Revise https://github.com/jupyter/notebook/pull/1755
gnestor b7dcae6
Update View and Edit conditions
gnestor 0034f2a
Create `/view` route, handler, and template
gnestor 224294c
Use `/view` route for HTML files
gnestor 3cbb570
Add `test_view_html`
gnestor acf4fa8
Clean up
gnestor File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE HTML> | ||
<html> | ||
|
||
<head> | ||
<meta charset="utf-8"> | ||
<title>{{page_title}}</title> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
</head> | ||
|
||
<body> | ||
<style type="text/css"> | ||
html, body, #container { | ||
height: 100%; | ||
} | ||
body, #container { | ||
overflow: hidden; | ||
margin: 0; | ||
} | ||
#iframe { | ||
width: 100%; | ||
height: 100%; | ||
border: none; | ||
} | ||
</style> | ||
<div id="container"> | ||
<iframe id="iframe" sandbox="allow-scripts" src="/files/{{file_path}}"></iframe> | ||
</div> | ||
</body> | ||
|
||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#encoding: utf-8 | ||
"""Tornado handlers for viewing HTML files.""" | ||
|
||
# Copyright (c) Jupyter Development Team. | ||
# Distributed under the terms of the Modified BSD License. | ||
|
||
from tornado import web | ||
from ..base.handlers import IPythonHandler, path_regex | ||
from ..utils import url_escape | ||
|
||
class ViewHandler(IPythonHandler): | ||
"""Render HTML files within an iframe.""" | ||
@web.authenticated | ||
def get(self, path): | ||
path = path.strip('/') | ||
if not self.contents_manager.file_exists(path): | ||
raise web.HTTPError(404, u'File does not exist: %s' % path) | ||
|
||
basename = path.rsplit('/', 1)[-1] | ||
self.write( | ||
self.render_template('view.html', file_path=url_escape(path), page_title=basename) | ||
) | ||
|
||
default_handlers = [ | ||
(r"/view%s" % path_regex, ViewHandler), | ||
] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Do we want to whitelist/blacklist files for editability? E.g. you can't open a png in the text editor.
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.
We could use a regex pattern like above to include/exclude specific extensions. I just opened a PNG in the text editor and it's pretty useless and harmless, so I'm neutral.
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 was what I was thinking. :-) I'd probably go for a blacklist. Maybe there are too many types to be worth trying to list them all, though. Do we have mimetypes here? Maybe we could block edit on
image/*
, with an exception forimage/svg+xml
.