Calendar app - wip #1677

Merged
merged 43 commits into from Jun 13, 2012

Projects

None yet

2 participants

@lightsofapollo

Work in progress version of calender, you can't add events via the ui, there is still some unused code in here from the initial work that was done on calender that will be transitioned into the app later on.

lightsofapollo added some commits May 4, 2012
@lightsofapollo lightsofapollo Basic calender layout (month view calender only) 8bc644f
@lightsofapollo lightsofapollo Busy indicators. 40da1a3
@lightsofapollo lightsofapollo past styling 55b8d4d
@lightsofapollo lightsofapollo header size tweak 43659bf
@lightsofapollo lightsofapollo selected day 64a1f35
@lightsofapollo lightsofapollo more spacing tweaks a8c261f
@lightsofapollo lightsofapollo Improved scalable calendar ui 352157e
@lightsofapollo lightsofapollo Updating ui to be more flexible on different screen sizes 2557a1d
@lightsofapollo lightsofapollo Fixed bug where navigator is marked as a new global because of its lazy
eval
208bd35
@lightsofapollo lightsofapollo Added initial time calculations, string formatter for templates, resp…
…onder for event handling, and month view
9d60721
@lightsofapollo lightsofapollo Adding base rendering logic for initial month view c56c63e
@lightsofapollo lightsofapollo working calendar without nav f0d3dfd
@lightsofapollo lightsofapollo Adding guesture events, controller and navigation controls 755f739
@lightsofapollo lightsofapollo Demo version 98dac34
@lightsofapollo lightsofapollo Removing demo fixtures 761e6b7
@lightsofapollo lightsofapollo Removing orig index-orig.html 6892154
@lightsofapollo lightsofapollo Rename manifest for calendar 702a287
@lightsofapollo lightsofapollo Update tests to new locations 9bcedaa
@lightsofapollo lightsofapollo v1 of template b129a7e
@lightsofapollo lightsofapollo Altering template to handle {dust|s} syntax. Which I will probably th…
…row away to use some dom derived templating anyway...
929b951
@lightsofapollo lightsofapollo Adding testSupport.template helper to load html into unit tests. 3233259
@lightsofapollo lightsofapollo Models will now emit add/remove events bc7c7c4
@lightsofapollo lightsofapollo Month view now uses new template engine + various refactoring 1ded60b
@lightsofapollo lightsofapollo Merge branch 'master' of github.com:mozilla-b2g/gaia into calendar-app 68a0d81
@lightsofapollo lightsofapollo templates are now all static. Refactored Day view to use templates 73019f4
@lightsofapollo lightsofapollo Actually adding day template... Renaming day view to months_day to make
room for the actual day view. Removed some console.log garbage
c9a50c7
@lightsofapollo lightsofapollo lint fix 1109d93
@lightsofapollo lightsofapollo Merge branch 'master' of github.com:mozilla-b2g/gaia into calendar-app 601eef8
@lightsofapollo lightsofapollo Improved / fixed bugs in relative state calculation 219feaa
@lightsofapollo lightsofapollo minor cleanup 86dd294
@davidflanagan

I'm reviewing this.

@davidflanagan davidflanagan and 1 other commented on an outdated diff Jun 12, 2012
apps/calendar/index.html
+ <link rel="stylesheet" type="text/css" href="./style/events.css">
+ <link rel="stylesheet" type="text/css" href="./style/hacks.css">
+ <title>Gaia Calendar</title>
+</head>
+<body>
+
+<section id="top-toolbar">
+ <header class="toolbar">
+ <a data-l10n-id="buttons.accounts" role="button" class="accounts" href="#accounts">
+ Accounts
+ </a>
+
+ <h3 id="current-month-year">
+ <span class="month">MAY</month>
+ <span class="year">2012</month>
+ </h3>
@davidflanagan
davidflanagan Jun 12, 2012

Strange to have MAY 2012 hardcoded here

@lightsofapollo
lightsofapollo Jun 12, 2012

lol, yeah its replaced automatically but I will get rid of it nice catch

@davidflanagan davidflanagan commented on an outdated diff Jun 12, 2012
apps/calendar/index.html
+ </menu>
+</section>
+
+<script src="/js/calc.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/format.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/template.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/templates/month.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/responder.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/models/busytime.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/models/events.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/gesture_detector.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/views/month.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/views/months_day.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/controller.js" type="text/javascript" charset="utf-8"></script>
+<script src="/js/index.js" type="text/javascript" charset="utf-8"></script>
+
@davidflanagan
davidflanagan Jun 12, 2012

we've been putting scripts up in the head with the defer attribute in other apps.
Are you going for backward compatibility for this one so it runs on older browsers?

@davidflanagan davidflanagan and 1 other commented on an outdated diff Jun 12, 2012
apps/calendar/js/calendar.js
@@ -0,0 +1,264 @@
+/* -*- Mode: Java; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
@davidflanagan
davidflanagan Jun 12, 2012

I can't see anywhere that this file is used. Remove it?

@lightsofapollo
lightsofapollo Jun 12, 2012

This was the original "calender app" (with the ical parser) which Andreas wrote. I would like to keep it around for a little while longer until I extract out the parser into the new library I am writing.

@davidflanagan davidflanagan commented on the diff Jun 12, 2012
apps/calendar/js/gesture_detector.js
@@ -0,0 +1,804 @@
+// GestureDetector.js: generate events for one and two finger gestures
+//
@davidflanagan
davidflanagan Jun 12, 2012

I'm happy that you're using this. Dale is using it for the browser app, too.

I wonder if we should start a convention of putting shared files like this in js/lib/ or something.
Every app can still have its own static copy of the file so we don't have version skew problems, but maybe a convention to show which code is shared?

@davidflanagan davidflanagan commented on an outdated diff Jun 12, 2012
apps/calendar/js/index.js
@@ -0,0 +1,27 @@
+(function(window) {
+ var controller = new Calendar.Controller({
@davidflanagan
davidflanagan Jun 12, 2012

This file looks like it is the main entry point to the app. Is index.js a conventional name for that? If not, and if that other calendar.js file is deleted, you could rename this to be calendar.js.

@davidflanagan davidflanagan commented on the diff Jun 12, 2012
apps/calendar/js/template.js
@@ -0,0 +1,105 @@
+(function(window) {
+ if (typeof(Calendar) === 'undefined') {
+ Calendar = {};
+ }
+
+ var FORMAT_REGEX = /\{([a-zA-Z0-9\-\_\.]+)\|?([a-z]{1,1})?\}/g,
+ POSSIBLE_HTML = /[&<>"'`]/,
+ BAD_CHARS = /&(?!\w+;)|[<>"'`]/g,
@davidflanagan
davidflanagan Jun 12, 2012

I don't know if I've ever seen a negative lookahead assertion in the wild before! How about a comment for this pretty obscure regexp.

Actually, looks like it is unused, so you can delete it.

@lightsofapollo
lightsofapollo Jun 13, 2012

Nice catch, regex I ended up not using.

@davidflanagan davidflanagan commented on the diff Jun 12, 2012
apps/calendar/js/template.js
+ Template.prototype = {
+ DEFAULT_KEY: 'value',
+ QUOTE: /"/g,
+ NEWLINES: /\n/g,
+
+ _compiled: null,
+
+ compile: function(str) {
+ var i = 0, fnStr, fn,
+ fnInst = '';
+
+ str = str.replace(this.QUOTE, '\\"');
+ str = str.replace(this.NEWLINES, '\\n');
+
+
+ fn = 'var h = Calendar.Template.handlers;';
@davidflanagan
davidflanagan Jun 12, 2012

just a nit, but I'd call this prolog or something different than fnStr

@davidflanagan davidflanagan commented on the diff Jun 12, 2012
apps/calendar/js/template.js
+
+ if (type === 's') {
+ return '" + String((a["' + name + '"] || "")) + "';
+ } else {
+ return '" + h["' + type + '"]((a["' + name + '"] || "")) + "';
+ }
+
+ });
+
+ fnStr = fn + 'return "' + fnStr + '";';
+
+ return new Function('a', fnStr);
+ },
+
+ render: function(args) {
+ this.render = this.compile(this.template);
@davidflanagan
davidflanagan Jun 12, 2012

Do you really need to do the lazy compilation here? Unless you actually have a startup time issue, I'd just compile in the constructor.

The (minor) problem with this kind of clever thing is that it changes the "shape" of the object and confuses the JIT. (Though my understanding of these matters is rudimentary, so I could be wrong about that.)

@lightsofapollo
lightsofapollo Jun 13, 2012

Never thought about that, in the future I want to move this whole step out a makefile so I can just import the pre-compiled templates.

@davidflanagan davidflanagan and 1 other commented on an outdated diff Jun 12, 2012
apps/calendar/js/templates/day.js
+ Calendar.Templates = {};
+ }
+
+ var Day = Calendar.Template.create({
+ hour: [
+ '<section>',
+ '<h4>{hour}</h4>',
+ '<ol class="events">',
+ '{items|s}',
+ '</ol>',
+ '</section>'
+ ].join(''),
+
+ attendee: [
+ '<span class="attendee">{value}</span>'
+ ].join(' '),
@davidflanagan
davidflanagan Jun 12, 2012

above you join with the empty string. Here, and below you use a space. Is that intentional?

@lightsofapollo
lightsofapollo Jun 12, 2012

err no I refactored it and left this as an array it should really just be a string...

@davidflanagan davidflanagan commented on an outdated diff Jun 12, 2012
apps/calendar/js/templates/month.js
@@ -0,0 +1,50 @@
+(function(window) {
+ if (typeof(Calendar.Templates) === 'undefined') {
+ Calendar.Templates = {};
+ }
+
+ var Month = Calendar.Template.create({
+ busy: '<span class="busy-{value}">&nbsp;</span>',
+
+ currentMonth: [
+ '<span class="month">{month}</span>',
+ '<span class="year">{year}</span>'
+ ].join(' '),
@davidflanagan
davidflanagan Jun 12, 2012

space vs. empty string argument to join(). Intentional?

@lightsofapollo

/botio lint

@ghost

From: Bot.io (Main)


Received

Command cmd_lint from @lightsofapollo received. Current queue size: 0

Live output at: http://50.116.11.35:8000/ad993e1739cc134/output.txt

@lightsofapollo

/botio test

@ghost

From: Bot.io (Main)


Received

Command cmd_test from @lightsofapollo received. Current queue size: 1

Live output at: http://50.116.11.35:8000/8231c050521b3c6/output.txt

@ghost

From: Bot.io (Main)


Success

Full output at http://50.116.11.35:8000/ad993e1739cc134/output.txt

Total script time: 0.82 mins

  • Lint: Passed
@ghost

From: Bot.io (Main)


Failed

Full output at http://50.116.11.35:8000/8231c050521b3c6/output.txt

Total script time: 1.86 mins

@lightsofapollo

=/ something is weird maybe I am polluting some global.
Tests pass locally.

/botio test

@ghost

From: Bot.io (Main)


Received

Command cmd_test from @lightsofapollo received. Current queue size: 0

Live output at: http://50.116.11.35:8000/a0c3f8152bc4326/output.txt

@ghost

From: Bot.io (Main)


Failed

Full output at http://50.116.11.35:8000/a0c3f8152bc4326/output.txt

Total script time: 1.82 mins

@lightsofapollo

/botio test

One more shot before I dig into the why

@ghost

From: Bot.io (Main)


Received

Command cmd_test from @lightsofapollo received. Current queue size: 0

Live output at: http://50.116.11.35:8000/8cb980add44b343/output.txt

@ghost

From: Bot.io (Main)


Failed

Full output at http://50.116.11.35:8000/8cb980add44b343/output.txt

Total script time: 1.65 mins

@lightsofapollo

/botio test

@ghost

From: Bot.io (Main)


Received

Command cmd_test from @lightsofapollo received. Current queue size: 0

Live output at: http://50.116.11.35:8000/fdbfbf38b5636d0/output.txt

@ghost

From: Bot.io (Main)


Failed

Full output at http://50.116.11.35:8000/fdbfbf38b5636d0/output.txt

Total script time: 2.13 mins

@lightsofapollo

/botio test

@ghost

From: Bot.io (Main)


Received

Command cmd_test from @lightsofapollo received. Current queue size: 0

Live output at: http://50.116.11.35:8000/a234dbb3bc08429/output.txt

@ghost

From: Bot.io (Main)


Failed

Full output at http://50.116.11.35:8000/a234dbb3bc08429/output.txt

Total script time: 1.66 mins

@lightsofapollo

OK, the issue is with the test runner. Its not waiting for all the files to load because I am using a nested require (require a helper script which then requires app files). Works locally must be something wrong /w the CI setup or my config options for gaia prefs. I am going to change the tests so they use the long way to load/require files and land this later tonight /w the tests passing.

@lightsofapollo

/botio test

@ghost

From: Bot.io (Main)


Received

Command cmd_test from @lightsofapollo received. Current queue size: 0

Live output at: http://50.116.11.35:8000/a2720e15ea33625/output.txt

@ghost

From: Bot.io (Main)


Failed

Full output at http://50.116.11.35:8000/a2720e15ea33625/output.txt

Total script time: 1.87 mins

@lightsofapollo

/botio test

Awesome that botio uncovered problem in test agent's require fn (by discovered by finding a race condition in my loader code). "expected Fri, 01 Jun 2012 06:49:35 GMT to equal Fri, 01 Jun 2012 06:49:35 GMT" is the last error in the botio run of the tests. ...

@ghost

From: Bot.io (Main)


Received

Command cmd_test from @lightsofapollo received. Current queue size: 0

Live output at: http://50.116.11.35:8000/a2ba7eeb68bd1b6/output.txt

@ghost

From: Bot.io (Main)


Success

Full output at http://50.116.11.35:8000/a2ba7eeb68bd1b6/output.txt

Total script time: 2.69 mins

@lightsofapollo

good enough for me, if there is some timing issue in the tests I will fix it in a follow up.

@lightsofapollo lightsofapollo merged commit 25460ae into mozilla-b2g:master Jun 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment