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

Offline Support for thingler #9

Open
wants to merge 32 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
f92d33b
Adding deps make target to install node deps via npm
Sep 30, 2010
c72ffbd
Small blurb to readme for getting devs up to speed
Sep 30, 2010
5ef127b
Merge branch 'docs'
Sep 30, 2010
8f34aa4
Updating css from production until I figurte out why lessc is complai…
Sep 30, 2010
81abaad
Adding manifest attribute to public index file
Sep 30, 2010
4924588
Using absolute path for manifest file
Sep 30, 2010
d44a018
Adding ability to dynamically generate application manifest (will alw…
Sep 30, 2010
c88890f
Adding .gitignore
Sep 30, 2010
a25f1e7
Allowing customization of cache section. Reenabling fallback session.…
Oct 1, 2010
dac0666
Adding wildcard character for appcache manifest network section and o…
Oct 1, 2010
d552f0d
Automatically swap to latest cache version when app cache updated. Ad…
Oct 1, 2010
493b6c7
Merge branch 'manifest'
Oct 1, 2010
0fb77d2
Adding lawnchair (cross-browser offline storage lib)
Oct 2, 2010
b36e457
Adding preliminary support for offline storage (untested)
Oct 2, 2010
74022dc
Added offline support
Oct 5, 2010
b12b3dd
Ensure we replay local changes after initialising the room when online
Oct 5, 2010
08d1206
Updating lawnchair to not remove stored object's 'key' property (rath…
Oct 5, 2010
e21c3c2
Adding logging for router requests
Oct 5, 2010
40682e2
Adding dummy event listeners for testing online/offline events (not a…
Oct 5, 2010
d3fa941
Adding timeout to pilgrim. TODO: all this may not be necessary. Need …
Oct 5, 2010
ae6abd9
NodeList in opera doesn't expose an array-like interface. Convert to …
Oct 5, 2010
9a8b54b
Adding headers to avoid caching of xhr requests in IE
Oct 6, 2010
394978f
Indicating thingler is offline in title
Oct 6, 2010
eff3682
Unminifying lawnchair to aid in debugging
Oct 6, 2010
9d54385
Adding cache-control headers to pilgrim requests. Mark a response as …
Oct 6, 2010
fefab3c
Adding checks for doc/data objects to stop opera/IE whining
Oct 6, 2010
1c7faa0
On each request for the cache manifest check wether changed before re…
Oct 7, 2010
a9404fb
Add debug statement in dev env for cahce manifest. Add etag and cache…
Oct 7, 2010
d0ae4e3
Add onreadystatechange handler to xhr.onload if firefox. Handles weir…
Oct 7, 2010
3281505
Added client global debug variable to easily switch on/off log state…
Oct 7, 2010
8915560
Added metatag to enforce latest rendering engine in IE or use chrome …
Oct 7, 2010
a91c3e3
Merge branch 'offlinestorage'
Oct 7, 2010
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub/application.manifest
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,9 @@ css:

crontab:
sudo crontab etc/thingler.cron -u couchdb

deps:
test -e $(which npm) && echo 'npm already installed.' || curl http://npmjs.org/install.sh | sh
test -e $(which npm) && npm install cradle || echo 'npm not installed. install via "curl http://npmjs.org/install.sh | sh"'
test -e $(which npm) && npm install journey || echo 'npm not installed. install via "curl http://npmjs.org/install.sh | sh"'
test -e $(which npm) && npm install node-static || echo 'npm not installed. install via "curl http://npmjs.org/install.sh | sh"'
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@ thingler

> Hello, I am [Thingler](http://thingler.com), and this is my source code. Feel free to browse.

forkers
=======

If you want to hack on Thingler, install couchdb, node.js (I recommend following this gist: http://gist.github.com/579814)
Then run make deps.


License
-------

Expand Down
88 changes: 60 additions & 28 deletions pub/css/thingler.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion pub/index.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
<!doctype html>
<html lang="en">
<html lang="en" manifest="/application.manifest">
<head>
<title>Thingler</title>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<meta name="description" content="Thingler is a real-time collaborative todo list.">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">

<!-- mobile specific -->
<meta name="viewport" content="width=device-width; initial-scale=1.0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">

<link rel="stylesheet" type="text/css" href="/css/thingler.css">
<link rel="icon" type="image/gif" href="/favicon.gif">
</head>
Expand Down
84 changes: 84 additions & 0 deletions pub/js/appcache.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// usage: log('inside coolFunc',this,arguments);
// paulirish.com/2009/log-a-lightweight-wrapper-for-consolelog/
thingler_debug = false;

window.log = function(){
log.history = log.history || []; // store logs to an array for reference
if (thingler_debug) {
log.history.push(arguments);

if(this.console){
console.log( Array.prototype.slice.call(arguments) );
}
}
};

//app cache event handling
var cache = window.applicationCache;
var progressCount = 0;
var cacheStatusValues = {
0: 'uncached',
1: 'idle',
2: 'checking',
3: 'downloading',
4: 'updateready',
5: 'obsolete',
6: 'error',
7: 'cached',
8: 'progress',
9: 'noupdate'
};

function logAppCacheEvent(e) {
var online, status, type, message;
online = (navigator.onLine) ? 'yes' : 'no';
status = cacheStatusValues[cache.status];
type = e.type;
message = 'online: ' + online;
message+= ', event: ' + type;
message+= ', status: ' + status;
if (type == 'error' && navigator.onLine) {
message+= ' (probably a syntax error in the manifest)';
}
log(message);
}

for (var k in cacheStatusValues) {
if (['idle', 'uncached'].indexOf(cacheStatusValues[k]) == -1) {
cache.addEventListener(cacheStatusValues[k], logAppCacheEvent, false);
}
}

cache.addEventListener('error', function(e) {
log( 'Error: Cache failed to update : ' + progressCount );
}, false);
cache.addEventListener('progress', function(e) {progressCount++;}, false);
cache.addEventListener(
'updateready',
function(){
//automatically swap the cache to the latest version when new cache is ready
window.applicationCache.swapCache();
log('swap cache has been called');
},
false
);

// setInterval(function(){cache.update()}, 10000);

//onoffline/online events
var onoffline = function () {
log('Now offline...');
};

var ononline = function () {
log('Now online...');
};

if (window.addEventListener) {
document.body.addEventListener("offline", onoffline, false);
document.body.addEventListener("online", ononline, false);
}
else {
document.body.onoffline = onoffline;
document.body.ononline = ononline;
}
2 changes: 1 addition & 1 deletion pub/js/index.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"files": ["pilgrim.js", "domdom.js", "domdom-tokenizing.js", "thingler.js"],
"files": ["pilgrim.js", "domdom.js", "domdom-tokenizing.js", "lawnchair.min.js", "appcache.js", "thingler.js"],
"minify": false
}
Loading