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

vNext #9

Open
wants to merge 96 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
96 commits
Select commit Hold shift + click to select a range
d25c600
use yepnope.js instead of the discontinued LABjs
joscha Oct 4, 2012
a561c83
make jquery-bbq a submodule
joscha Oct 4, 2012
8aa57d5
use external jQuery
joscha Oct 4, 2012
f311d47
fix canvas and body definitions
joscha Oct 4, 2012
be4521c
remove ba=bbq file - its a submodule now
joscha Oct 4, 2012
74b369e
pull in a fix
joscha Oct 4, 2012
7970718
fix unknown count
joscha Oct 4, 2012
54bb33b
add some more debugging
joscha Oct 4, 2012
6fc143f
draft handling
joscha Oct 4, 2012
057892a
remove unneeded insertCss method
joscha Oct 4, 2012
951f575
fix emailAddress find
joscha Oct 4, 2012
59d49d6
remove hint to the insertCss method
joscha Oct 4, 2012
bf4469d
composition/reply/save draft/discard draft details
joscha Oct 4, 2012
99b28ff
fix unread count with new GMail and make it work also when count chan…
joscha Oct 4, 2012
ea97635
detect unread and read markings
joscha Oct 4, 2012
805da15
fix array transformation for multi-message handling
joscha Oct 4, 2012
694e2f4
clean up unread change observer
joscha Oct 4, 2012
76c7c02
Refine status message
joscha Oct 4, 2012
34b11f3
starring and unstarring detection
joscha Oct 4, 2012
63f10a0
viewThread event
joscha Oct 4, 2012
6b6017e
switch to CoffeeScript
joscha Oct 5, 2012
1a46ec8
* prevent multiple invocations of Gmailr.init
joscha Oct 5, 2012
85a7033
remove generated JS
joscha Oct 5, 2012
6b1ab0b
Example on how to observe the switching to a thread
joscha Oct 5, 2012
b61e553
add missing variable
joscha Oct 5, 2012
21eb146
ignore generated JS files
joscha Oct 5, 2012
d7b241f
refine loader and add documentation
joscha Oct 5, 2012
c6308a3
Switch jQuery BBQ to 1.2.1 and yepnope.js to 1.5.4
joscha Oct 5, 2012
693ed2c
clean up loader code
joscha Oct 5, 2012
800fbcf
Clean markdown files
joscha Oct 5, 2012
c39fbfe
make email details parse the emails for "to", "cc" and "bcc" recipien…
joscha Oct 5, 2012
841d62a
code formatting
joscha Oct 5, 2012
e7f561c
ignore DOM events for inserted elements by default
joscha Oct 5, 2012
935dc0c
remove outdated documentation from observe method
joscha Oct 5, 2012
a707667
fix unread count method
joscha Oct 5, 2012
b45267e
make unread change event work again
joscha Oct 5, 2012
6d22d67
email address find
joscha Oct 5, 2012
e450319
don't return console
joscha Oct 16, 2012
88ea142
fix bootstrapping
joscha Oct 16, 2012
de31338
make it work with Gmail set to German
joscha Oct 16, 2012
b19080c
refresh example
joscha Oct 16, 2012
ab1cdf9
refresh inbox documentation
joscha Oct 16, 2012
5dbb95e
remove mark read event
joscha Oct 16, 2012
61df843
Loaded event
joscha Oct 16, 2012
dcce417
use unless and clean up canvas find
joscha Oct 22, 2012
2581bb9
clean up manifest
joscha Oct 22, 2012
5fa6c67
introduce "any" meta-event
joscha Oct 22, 2012
f9c6e62
Deactivated Google+ selector as it sometimes also returns the name in…
joscha Oct 30, 2012
4668dfd
Generic inbox link detection independent of language
joscha Feb 10, 2013
8581f8e
German was special…once again...
joscha Feb 10, 2013
ed400d3
switch to jQuery 1.9
joscha Feb 28, 2013
8e979ab
Add log source
joscha Feb 28, 2013
4227c0e
speed up detection
joscha Feb 28, 2013
d4ad740
add comment
joscha Mar 1, 2013
93990fc
Fix for usage of minified BBQ version
joscha Mar 9, 2013
d026015
Remove whitespace
Aug 13, 2013
418437a
Only attempt to trigger EVENT_ANY listeners if we have any
Aug 13, 2013
9440110
Merge pull request #1 from mwildehahn/master
joscha Sep 9, 2013
97ffe31
Update license
joscha Nov 19, 2014
c8d0a41
Fix indentation
joscha Nov 19, 2014
3ac8f54
remove comment block
joscha Nov 19, 2014
37b32d4
remove old build file
joscha Nov 19, 2014
0693f28
remove submodules
joscha Nov 19, 2014
2de93ee
ignore common directories
joscha Nov 19, 2014
090cffc
make node module
joscha Nov 19, 2014
db2e837
move to grunt
joscha Nov 19, 2014
37631f6
first grunt build
joscha Nov 19, 2014
734471b
make main component a bower component
joscha Nov 19, 2014
dfffa68
get rid of coffee dependency for sample
joscha Nov 19, 2014
e0318b8
make chrome extension sample a private bower component
joscha Nov 19, 2014
5b9b418
add travis instructions
joscha Nov 19, 2014
248c681
add read me for sample
joscha Nov 19, 2014
4275608
add jQuery dependency
joscha Nov 19, 2014
85728eb
exclude more stuff
joscha Nov 19, 2014
0c4c90c
Update sample to use bower
joscha Nov 19, 2014
f59ffe4
add travis badge
joscha Nov 20, 2014
09241d9
add quickstart shortcut
joscha Nov 20, 2014
351ade6
Install and quick start hints
joscha Nov 20, 2014
086630e
update jQuery
joscha Dec 2, 2014
3290911
add grunt-bump
joscha Dec 2, 2014
abe3a93
update jQuery and allow jQuery minor updates
joscha Dec 2, 2014
27b81fc
fix main file and add test script
joscha Dec 2, 2014
374fd80
Release v0.0.3
joscha Dec 2, 2014
b710ec4
update task config
joscha Dec 2, 2014
3d731c3
fix version
joscha Dec 2, 2014
b27ccad
Release v0.0.4
joscha Dec 2, 2014
6d12435
email address fallback
joscha Dec 5, 2014
f3090f7
Release v0.0.5
joscha Dec 5, 2014
3185324
Add new email selector
joscha Dec 14, 2014
00df43b
Release v0.0.6
joscha Dec 14, 2014
0814e9e
only extract text content, not nested tags
joscha Dec 14, 2014
17a6378
Release v0.0.7
joscha Dec 14, 2014
e9566fa
Fix email detection for non G+ accounts
joscha Dec 22, 2014
489d3c6
Release v0.0.8
joscha Dec 22, 2014
3dd1b3d
fix chrome extension and user mutation observer
joscha Dec 28, 2014
d685b20
Release v0.0.9
joscha Dec 28, 2014
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
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
.DS_Store
chrome/lib/bootstrap.js
chrome/lib/gmailr.js
bower_components
node_modules
6 changes: 6 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
language: node_js
node_js:
- '0.11'
before_install:
- npm install -g grunt-cli
- npm install -g bower
62 changes: 62 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
module.exports = function(grunt) {

grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
uglify: {
options: {
banner: '/*! <%= pkg.name %> <%= pkg.version %> - <%= grunt.template.today("yyyy-mm-dd") %> */\n',
sourceMap: true,
sourceMapIncludeSources: true,
sourceMapIn: 'build/<%= pkg.name %>.js.map',
},
build: {
src: 'build/<%= pkg.name %>.js',
dest: 'build/<%= pkg.name %>.min.js'
}
},

coffee: {
compile: {
options: {
sourceMap: true
},
files: {
'build/<%= pkg.name %>.js': 'src/index.coffee'
}
}
},

bump: {
options: {
files: ['package.json', 'bower.json'],
updateConfigs: ['pkg'],
commit: true,
commitMessage: 'Release v%VERSION%',
commitFiles: ['package.json', 'bower.json', 'build/**'],
createTag: true,
tagName: 'v%VERSION%',
tagMessage: 'Version %VERSION%',
push: true,
pushTo: 'origin',
gitDescribeOptions: '--tags --always --abbrev=1 --dirty=-d',
globalReplace: false
}
}
});

grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-coffee');
grunt.loadNpmTasks('grunt-bump');

grunt.registerTask('build', ['coffee:compile', 'uglify']);
grunt.registerTask('default', 'build');
grunt.registerTask('travis', 'build');

grunt.registerTask('release', 'Bump, build and release.', function(type) {
grunt.task.run([
'bump-only:' + (type || 'patch'),
'build',
'bump-commit'
]);
});
};
4 changes: 2 additions & 2 deletions LICENSE → LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License

Copyright (c) 2011 James Yu
Copyright (c) 2011 James Yu, 2014 Joscha Feth

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand All @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE.
78 changes: 49 additions & 29 deletions readme.markdown → README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Gmailr: A Gmail Javascript API
[![Build Status](https://travis-ci.org/joscha/gmailr.svg)](https://travis-ci.org/joscha/gmailr) Gmailr: A Gmail Javascript API
==============================

Gmailr is a javascript library that lets you interact and get data from the Gmail interface. It is meant to be injected into the Gmail DOM directly, usually through a browser plugin.
Expand All @@ -12,19 +12,22 @@ The library is packaged here as a Chrome extension that presents some status inf

To install the extension, clone the repo and:

1. Open Chrome and go to chrome://extensions
2. If the Developer Mode toggle is set to "-", click it to go into Developer Mode.
3. Click "Load unpacked extension..."
4. Choose the `chrome` directory in this repo.
5. Enable the newly added extension.
6. Head to your Gmail account, and you should now see a blue Gmailr bar above the top bar.

- Run an `npm install`, then an `npm install bower -g` and then an `npm run quickstart`.
- Open Chrome and go to chrome://extensions
- If the Developer Mode toggle is set to "-", click it to go into Developer Mode.
- Click "Load unpacked extension..."
- Choose the `chrome` directory in this repo.
- Enable the newly added extension.
- Head to your Gmail account, and you should now see a blue Gmailr bar above the top bar.

Try archiving or deleting an email, and you'll see the status bar display the action.

Creating Your Own Extension
===========================

To create your own extension using Gmailr, simply change main.js to implement your functionality.
You can add more resources to load in init.coffee - simply add files to the array - if they are local files coming from the extension, you need to make them web-accessible in the `manifest.json`

Extension Architecture
----------------------
Expand All @@ -33,7 +36,8 @@ You'll notice that the extension does a lot of roundabout loading of the js file

Thus, we have to manually inject the scripts into the head of the Gmail DOM.

`bootstrap.js` is first loaded like a normal content script, and it injects `lab.js` and `init.js`. Then, `init.js` loads the rest of the js files using LAB, and finally `main.js` is loaded with access to the Gmailr API.
`bootstrap.js` is first loaded like a normal content script, and it loads all other files needed for Gmailr.
Finally `main.js` is loaded with access to the Gmailr API.

Development Notes
-----------------
Expand Down Expand Up @@ -62,14 +66,44 @@ The elements hash holds some interesting elements inside Gmail. Currently, there

This method will observe to various actions that the user does in Gmail, and will call a callback based on those actions. The available types are (with the callback arguments):

* 'archive' - callback(count)
* 'numUnreadChange' - callback(currentVal, previousVal)
* 'delete' - callback(count)
* 'spam' - callback(count)
* 'compose' - no args
* 'viewChanged' - no args
* `EVENT_LOADED`:
* `EVENT_VIEW_THREAD`: threadId
* `EVENT_ARCHIVE`: count, [messageId, ...]
* `EVENT_APPLY_LABEL`: label, count, [messageId, ...]
* `EVENT_DELETE`: count, [messageId, ...]
* `EVENT_COMPOSE`: emailProperties
* `EVENT_REPLY`: emailProperties
* `EVENT_SPAM`: count, [messageId, ...]
* `EVENT_DRAFT_DISCARD`:
* `EVENT_DRAFT_SAVE`: emailProperties
* `EVENT_MARK_UNREAD`: count, [messageId, ...]

* `EVENT_MARK_READ`: count, [messageId, ...]* `EVENT_STAR`: count, [messageId, ...]
* `EVENT_UNSTAR`: count, [messageId, ...]
* `EVENT_UNREAD_CHANGE`: current, previous
* `EVENT_INBOX_COUNT_CHANGE`: current, previous
* `EVENT_REFRESH_INBOX`:
* `EVENT_VIEW_CHANGED`: type (either `VIEW_THREADED` or `VIEW_CONVERSATION`)
* `EVENT_ANY`: type, arguments - this meta event gets fired on any of the events above with `type` being one of `Gmailr.EVENT_*` and the second argument an array of parameters

If `count` is `-1` that means the user made a bulk event which affects more than only the visible emails on the current page.

Contents of the `emailProperties` object are:

* `inReplyTo`: (message id of the email that this is in reply to, or `null` if not in reply to anything)
* `body`: String (or `null` if not defined)
* `subject`: String (or `null` if not defined)
* `bcc`: Array
* `to`: Array
* `from`: String (the email address you are sending from)
* `isHTML`: (boolean)
* `cc`: Array
* `fromDraft`: (message id of the draft or `null` if there was no draft)

`to`, `cc` and `bcc` are Arrays of name, email tuple objects, e.g. `{name: 'Name', email: '[email protected]' }`

---

Currently, you won't get any information about the contents of the email messages.

G.insertTop(el)

Expand All @@ -79,10 +113,6 @@ Inserts a DOM element on the top of Gmail's interface.

Provides a jQuery selector so you can select elements in the Gmail interface.

G.insertCss(path)

Inserts a CSS file into the Gmail DOM.

G.numUnread()

Number of unread emails.
Expand All @@ -94,13 +124,3 @@ The email address of the current Gmail user.
G.currentView()

Returns whether the current view is a threaded or conversation view.


TODOs
=====

There are much more TODOs than I have time for :)

* More stability and accuracy for various events.
* Ability to add DOM elements in various places in Gmail, like the sidebar, etc.
* Ability to get more information about emails that are archived, composed, etc.
37 changes: 37 additions & 0 deletions bower.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
{
"name": "gmailr",
"version": "0.0.9",
"homepage": "https://github.com/joscha/gmailr",
"authors": [
"Joscha Feth <[email protected]>",
"James Yu"
],
"description": "A Gmail Javascript API",
"main": "build/gmailr.min.js",
"moduleType": [
"globals"
],
"keywords": [
"gmail",
"api",
"javascript",
"google",
"mail"
],
"license": "MIT",
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests",
"chrome",
"src",
"Gruntfile.js",
"*.md"
],
"dependencies": {
"jquery-deparam": "https://gist.github.com/1025817.git",
"jquery": "~1.11.1"
}
}
Loading