Skip to content
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

Merged
merged 12 commits into from Jul 6, 2018
Merged

Mobwrite #198

merged 12 commits into from Jul 6, 2018

Conversation

NeilFraser
Copy link
Member

No description provided.

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.
@NeilFraser NeilFraser requested a review from cpcallen June 27, 2018 23:24
@@ -26,7 +26,7 @@
* Class containing the diff, match and patch methods.
* @constructor
*/
function diff_match_patch() {
var diff_match_patch = function() {
Copy link
Collaborator

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…)

Copy link
Member Author

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;
Copy link
Collaborator

@cpcallen cpcallen Jun 28, 2018

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.

Copy link
Member Author

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;
Copy link
Collaborator

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.

Copy link
Member Author

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;
Copy link
Collaborator

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.

Copy link
Member Author

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.

Copy link
Collaborator

@cpcallen cpcallen left a 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 least pylint) 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.""”).

@@ -0,0 +1,1842 @@
#!/usr/bin/python2.4
Copy link
Collaborator

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;
Copy link
Collaborator

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.

@@ -0,0 +1,471 @@
#!/usr/bin/python2.4
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See above.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,83 @@
#!/usr/bin/python2.4
Copy link
Collaborator

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.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -0,0 +1,33 @@
; ---------------------
; Settings for MobWrite
; ---------------------
Copy link
Collaborator

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).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

if (Code.Editor.currentEditor) {
value = Code.Editor.currentEditor.getSource() || '';
}
// Numeric data should use overwrite mode.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why?

Copy link
Member Author

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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Creating subclass prototype object"?

Copy link
Member Author

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;
Copy link
Collaborator

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.

Copy link
Member Author

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);
Copy link
Collaborator

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?

Copy link
Member Author

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.

typeof mobwrite === 'undefined' ||
typeof Code.mobwriteShare === 'undefined') {
// Not loaded, try again later.
setTimeout(Code.Editor.waitMobWrite_, 50, callback);
Copy link
Collaborator

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.)

Copy link
Member Author

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.

@cpcallen
Copy link
Collaborator

cpcallen commented Jul 4, 2018

I am approving this, but not your python style. Filed #201 to address this at an appropriate future date.

@NeilFraser NeilFraser merged commit 24dc821 into master Jul 6, 2018
@NeilFraser NeilFraser deleted the mobwrite branch July 6, 2018 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants