Skip to content

firetactoe pull request#558

Closed
mogar1980 wants to merge 1 commit intoGoogleCloudPlatform:masterfrom
mogar1980:mh-pull-request
Closed

firetactoe pull request#558
mogar1980 wants to merge 1 commit intoGoogleCloudPlatform:masterfrom
mogar1980:mh-pull-request

Conversation

@mogar1980
Copy link
Copy Markdown
Contributor

Here's the pull request. Includes all the python and html source files for firetactoe

@googlebot
Copy link
Copy Markdown

Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll verify. Thanks.


  • If you've already signed a CLA, it's possible we don't have your GitHub username or you're using a different email address. Check your existing CLA data and verify that your email is set on your git commits.
  • If you signed the CLA as a corporation, please let us know the company's name.

@googlebot googlebot added the cla: no This human has *not* signed the Contributor License Agreement. label Oct 5, 2016
var config = {
apiKey: "AIzaSyB_pwNiBi8Q3iakJitkQHtEQ5SZWmp9EiY",
authDomain: "imposing-mind-131903.firebaseapp.com",
databaseURL: "https://imposing-mind-131903.firebaseio.com"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

probably best to put placeholders here, preferably put all this stuff in a single file that gets pulled in somehow.

@mogar1980
Copy link
Copy Markdown
Contributor Author

I signed it!

On Wed, Oct 5, 2016 at 4:15 PM, googlebot notifications@github.com wrote:

Thanks for your pull request. It looks like this may be your first
contribution to a Google open source project. Before we can look at your
pull request, you'll need to sign a Contributor License Agreement (CLA).

📝 Please visit https://cla.developers.google.com/
https://cla.developers.google.com/ to sign.

Once you've signed, please reply here (e.g. I signed it!) and we'll

verify. Thanks.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#558 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AUBaDkVde1YCvfDwQx1iozze1_d8QVpVks5qxC9-gaJpZM4KPYyz
.

@googlebot
Copy link
Copy Markdown

CLAs look good, thanks!

@googlebot googlebot added cla: yes This human has signed the Contributor License Agreement. and removed cla: no This human has *not* signed the Contributor License Agreement. labels Oct 5, 2016
@waprin
Copy link
Copy Markdown
Contributor

waprin commented Oct 5, 2016

Assuming there's more context for this PR someone else knows about?

@mogar1980
Copy link
Copy Markdown
Contributor Author

Absolutely! I work at Google, actually. Keys/secrets are in there so that
DPE folks can get everything to work while they test, debug, etc. The final
version of the sample definitely won't include these.

On Wed, Oct 5, 2016 at 4:34 PM, Bill Prin notifications@github.com wrote:

Assuming there's more context for this PR someone else knows about?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#558 (comment),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AUBaDk1HWLPWUrCcO5uEamOVPYIvJmGCks5qxDQPgaJpZM4KPYyz
.

@@ -0,0 +1,288 @@
#!/usr/bin/python2.4
#
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

needs license header

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

applies to every file

@waprin
Copy link
Copy Markdown
Contributor

waprin commented Oct 5, 2016

Ok cool. I would still refactor out all the config and secrets and add a README on how to generate them. We will need that anyway, so no good reason not to do it now before merge.


<style type='text/css'>
body {
font-family: 'Helvetica';
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

think we should also factor out css and js into separate files.

var square = document.getElementById(i);
square.innerHTML = state.board[i];
if (state.winner != '' && state.winningBoard != '') {
if (state.winningBoard[i] == state.board[i]) {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Believe we should be using triple =. Have you run this through jslint?

@mogar1980
Copy link
Copy Markdown
Contributor Author

All good points. Is there any way you can hand my review over to jonwayne@
who's going to be taking over this code sample?

Thanks!
Morgan

On Wed, Oct 5, 2016 at 4:43 PM, Bill Prin notifications@github.com wrote:

@waprin commented on this pull request.

In appengine/standard/firebase/firetactoe/fire_index.html
#558 (review)
:

  • <script type='text/javascript'>
  •  var state = {
    
  •    game_key: '{{ game_key }}',
    
  •    me: '{{ me }}'
    
  •  };
    
  •  // This is our Firebase realtime DB path that we'll listen to for updates
    
  •  // We'll initialize this later in openChannel()
    
  •  var channel = null;
    
  •  updateGame = function() {
    
  •    for (i = 0; i < 9; i++) {
    
  •      var square = document.getElementById(i);
    
  •      square.innerHTML = state.board[i];
    
  •      if (state.winner != '' && state.winningBoard != '') {
    
  •        if (state.winningBoard[i] == state.board[i]) {
    

Believe we should be using triple =. Have you run this through jslint?


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
#558 (review),
or mute the thread
https://github.com/notifications/unsubscribe-auth/AUBaDvWIj1eHIvVwFlDXxh7uj_PPuF2mks5qxDYXgaJpZM4KPYyz
.

@theacodes
Copy link
Copy Markdown
Contributor

All good points. Is there any way you can hand my review over to jonwayne@
who's going to be taking over this code sample?

Yep, I'm here. Bill just beat me to the punch. 👍 I'm gonna add some comments but definite want you to address what bill has mentioned as well.

@theacodes theacodes self-assigned this Oct 6, 2016
Copy link
Copy Markdown
Contributor

@theacodes theacodes left a comment

Choose a reason for hiding this comment

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

Finished first pass, please ping me when you're ready for the next round of review.

@@ -0,0 +1,11 @@
runtime: python27
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

(Github won't let me comment on a binary file): Please remove .DS_Store. I'd recommend adding it to your global gitignore.


libraries:
- name: pycrypto
version: latest No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Always use explicit versions. Latest sometimes isn't the latest, and even if it were we don't want the sample to suddenly break.

<head>

<script src="https://www.gstatic.com/firebasejs/3.3.2/firebase.js"></script>
<!-- <script src="https://www.gstatic.com/firebasejs/3.3.0/firebase-database.js"></script> -->
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If this isn't necessary, remove it.


<script src="https://www.gstatic.com/firebasejs/3.3.2/firebase.js"></script>
<!-- <script src="https://www.gstatic.com/firebasejs/3.3.0/firebase-database.js"></script> -->
<script>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please move all this to a separate .js file.

</style>
</head>
<body>
<script type='text/javascript'>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Please move this to a js file, probably can combine it with the snippet above.

game = GameFromRequest(self.request).get_game()
user = users.get_current_user()
if game and user:
FireChannel(fire_url).send_message(u_id=user.user_id() + game.key().id_or_name(),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hanging indents are really unreadable, please line break after send_message(.

method_type = urlfetch.PATCH
# always using patch in this example for writes
# because it updates or creates but never overwrites
result = urlfetch.fetch(
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

urlfetch is rough, why not use requests? We have a sample here.

json_data = simplejson.loads(result.content)
logging.info(json_data.get("message"))
return result.content
except urlfetch.Error:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

In samples, it's better to let the exception raise all the way up so that the user can see the stacktrace. This helps us figure out what's wrong if they report issues.

game.userO = user
game.put()

game_link = 'http://localhost:8080/?g=' + game_key
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Hardcoded URL?

('/move', MovePage)], debug=True)


def main():
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This isn't needed for app engine.

@jerjou
Copy link
Copy Markdown
Contributor

jerjou commented Oct 6, 2016

Oh whoops. I'm totally working on a refactor of this -_-;
Opened up #560 with the refactor. It addresses most of the comments from this PR.
How would you like to proceed, @mogar1980?

@theacodes theacodes closed this Oct 10, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants