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
Mobwrite #198
Mobwrite #198
Conversation
The open-source repo is dead, we are adopting the codebase and forking it. This is not third-party code.
It is commented out, but all editors share with the same key, ‘Code’.
Thus MobWrite can set source without indicating that the new source is saved.
- Only load MobWrite on demand. - Generate unique sharing key. - Add sharing dialog to enable/disable sharing. - Place sharing key on URL.
Previously they filled the more restrictive HTML ID limits.
@@ -26,7 +26,7 @@ | |||
* Class containing the diff, match and patch methods. | |||
* @constructor | |||
*/ | |||
function diff_match_patch() { | |||
var diff_match_patch = function() { |
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.
If this is a class, shouldn't it be called DiffMatchPatch? (I am aware that it is not feasible to change it now…)
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.
Yes, the name was chosen pre-Google. Stuck with it now.
etc/cc-dev.conf
Outdated
client_max_body_size 10m; | ||
client_body_buffer_size 128k; | ||
|
||
proxy_connect_timeout 90; |
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.
Isn't 90s kind of long? The manual says "It should be noted that this timeout cannot usually exceed 75 seconds." The default is 60s; is there any reason to increase it? (I'd probably reduce it to 10s or something, so users get a nice nginx-generated error page instead of just waiting.
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.
Done.
etc/cc-dev.conf
Outdated
|
||
proxy_connect_timeout 90; | ||
proxy_send_timeout 90; | ||
proxy_read_timeout 90; |
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.
It looks like nginx can take a units suffix (at least for seconds). If that's correct, lets write all these timeouts as as 90s
(or whatever value is chosen) for clarity.
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.
Done.
etc/cc-dev.conf
Outdated
@@ -26,9 +21,6 @@ server { | |||
proxy_pass http://localhost:7781/login; | |||
proxy_redirect off; | |||
|
|||
proxy_set_header Host $host; | |||
proxy_set_header X-Real-IP $remote_addr; | |||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |||
proxy_max_temp_file_size 0; | |||
|
|||
client_max_body_size 10m; |
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.
Let's not cargo-cult this stuff either.
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.
The defaults for most of these settings seems fine, so I've deleted a bunch of them.
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.
I’ve not reviewed DMP, since it’s third_party. As far as MobWrite goes:
- Have you run
gpylint
(or at leastpylint
) on all the.py
files? - Many python functions / methods missing docstrings. These can be omitted for ones which are "not externally visible, very short and obvious" (but note that any internal names should begin with
_
). Where they are included, do note:
The docstring should be descriptive (
"""Fetches rows from a Bigtable."""
) rather than imperative ("""Fetch rows from a Bigtable.""”
).
mobwrite/diff_match_patch.py
Outdated
@@ -0,0 +1,1842 @@ | |||
#!/usr/bin/python2.4 |
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.
File should be symlinked to existing copy.
# Things we'll probably want later: | ||
# proxy_set_header Host $host; | ||
# proxy_set_header X-Real-IP $remote_addr; | ||
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_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.
Agree with removing this for privacy reasons as discussed, but maybe replace with a comment pointing out the importance of not sending any unnecessary info to server.
mobwrite/mobwrite_server.py
Outdated
@@ -0,0 +1,471 @@ | |||
#!/usr/bin/python2.4 |
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.
See above.
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.
Done.
mobwrite/mobwrite_core_test.py
Outdated
@@ -0,0 +1,83 @@ | |||
#!/usr/bin/python2.4 |
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.
Styleguide:
Start the main file of a non-google3 non-prod program with
#!/usr/bin/python
with an optional single digit 2 or 3 suffix per PEP-394.
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.
Done.
mobwrite/mobwrite_config.txt
Outdated
@@ -0,0 +1,33 @@ | |||
; --------------------- | |||
; Settings for MobWrite | |||
; --------------------- |
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.
This file ought to be named mobwrite.cfg
or the like, rather than being a .txt
(since it is not merely arbitrary human-readable text).
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.
Done.
static/code/editor.js
Outdated
if (Code.Editor.currentEditor) { | ||
value = Code.Editor.currentEditor.getSource() || ''; | ||
} | ||
// Numeric data should use overwrite mode. |
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.
Why?
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.
if (mobwrite.debug) { | ||
window.console.info('Creating shareObj: "' + id + '"'); | ||
} | ||
if (!id) return; // Creating prototype object. |
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.
"Creating subclass prototype object"?
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.
Done.
*/ | ||
this.lastSavedSource_ = null; | ||
this.lastSavedSource = null; |
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.
Like most of the properties you create on Code.Editor.protoype
, this should be created instead in the Code.Editor
constructor.
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.
Huh? It is.
for (var i = 0; i < files.length; i++) { | ||
var script = document.createElement('script'); | ||
script.src = 'mobwrite/' + files[i]; | ||
document.head.appendChild(script); |
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.
Doesn't this actually load the script synchronously, in contradiction to the JSDoc above?
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.
Injecting a script is synchronous if it is placed ahead of the loading wave-front. In this case the document is fully-loaded (which is the point of lazy-loading), so everything is async.
static/code/editor.js
Outdated
typeof mobwrite === 'undefined' || | ||
typeof Code.mobwriteShare === 'undefined') { | ||
// Not loaded, try again later. | ||
setTimeout(Code.Editor.waitMobWrite_, 50, callback); |
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.
Is polling really the only way to do this? Surely these scripts could check the value of a well-known global variable and, if it is a function, call it? (That would entail the ugliness of a global variable, yes, but better than polling.)
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.
The scripts could be loaded in any order. It would be inappropriate for mobwrite_core.js or dmp.js to have that sort of hook.
I am approving this, but not your python style. Filed #201 to address this at an appropriate future date. |
# Conflicts: # .gitignore
No description provided.