Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

Commit

Permalink
Merge branch 'development'
Browse files Browse the repository at this point in the history
  • Loading branch information
Jian-Long Huang committed Jul 26, 2015
2 parents e2be022 + d5db49d commit d184edc
Show file tree
Hide file tree
Showing 11 changed files with 48 additions and 14 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
*~
\#*\#
*.crx
*.pem
.tern-port
.module-cache
node_modules
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
## BookPocket

BookPocket is a Chrome extension, which allows you to bookmark your web pages to Pocket.

## Demo

![demo](docs/demo.gif)

## How to build

BookPocket requires [npm](https://www.npmjs.com/) to install library dependencies, and [gulp](http://gulpjs.com/) for building tasks.

```
$ cd bookpocket
$ npm intall
$ gulp
```

To build the production version which files are minified, just replace `gulp` with `gulp prod` in the last step.

## License

BookPocket is released under the [MIT license](http://www.opensource.org/licenses/MIT).
10 changes: 5 additions & 5 deletions app/manifest.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{
"manifest_version": 2,
"name": "LetPocket",
"short_name": "LetPocket",
"description": "Save the page to Pocket as a bookmark",
"version": "0.1",
"name": "BookPocket",
"short_name": "BookPocket",
"description": "Bookmark your web pages to Pocket",
"version": "1.0",
"author": "Jian-Long Huang",
"minimum_chrome_version": "38",
"icons": {
Expand All @@ -20,7 +20,7 @@
"19": "assets/images/icon_grey_19.png",
"38": "assets/images/icon_grey_38.png"
},
"default_title": "LetPocket",
"default_title": "BookPocket",
"default_popup": "popup.html"
},
"permissions": [
Expand Down
2 changes: 1 addition & 1 deletion app/src/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ chrome.webNavigation.onCommitted.addListener(function(details) {
var matchedItem = client.urlMatch(details.url, pocketItem);
if (matchedItem) {
common.displaySavedIcon(details.tabId);
common.itemCache.set(matchedItem);
common.itemCache.set(details.url, matchedItem);
} else {
common.displayUnsavedIcon(details.tabId);
}
Expand Down
4 changes: 2 additions & 2 deletions app/src/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ var displayUnsavedIcon = function(tabId, callback) {
};

var itemCache = {
set: function(item) {
set: function(url, item) {
var data = {
item_id: item.item_id,
resolved_title: item.resolved_title,
Expand All @@ -52,7 +52,7 @@ var itemCache = {
};

try {
window.localStorage.setItem(item.resolved_url, JSON.stringify(data));
window.localStorage.setItem(url, JSON.stringify(data));
} catch(e) {
if (e.code == 22) {
console.log('Local storage is full.');
Expand Down
2 changes: 1 addition & 1 deletion app/src/oauth.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ var client = new PocketClient(config.pocket);

var checkAuthResult = function() {
if (window.localStorage.accessToken) {
document.write("You have authorized LetPocket to access Your Pocket account.");
document.write("You have authorized BookPocket to access Your Pocket account.");
} else {
if (window.localStorage.requestToken) {
client.getAccessToken(window.localStorage.requestToken, function(details) {
Expand Down
2 changes: 1 addition & 1 deletion app/src/pocket_client.js
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ var PocketClient = function(config) {
var matchedItem;
if (item.status === 0 || item.status === 1) {
for (var k in item.list) {
if (item.list[k].resolved_url === url) {
if (item.list[k].given_url === url || item.list[k].resolved_url === url) {
found = true;
matchedItem = item.list[k];
break;
Expand Down
4 changes: 2 additions & 2 deletions app/src/popup.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ var AuthorizeContent = React.createClass({
<div>
<div style={{fontSize: "14px", display: "flex", justifyContent: "space-beteen"}}>
<p>
Please click below to authorize LetPocket to access your Pocket account.
Please click below to authorize BookPocket to access your Pocket account.
This is a one-time process.
</p>
</div>
Expand Down Expand Up @@ -181,7 +181,7 @@ var PocketItemContent = React.createClass({
common.displaySavedIcon(self.props.tabId, function() {
self.setState(self.parseItemToState(item));
self.setState({isRetrieved: true});
common.itemCache.set(item);
common.itemCache.set(self.props.url, item);
if (success) {
success();
}
Expand Down
Binary file added docs/demo.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 8 additions & 0 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify');
var uglify = require('gulp-uglify');
var source = require('vinyl-source-stream');
var dist = 'app/assets/javascripts';

Expand Down Expand Up @@ -28,10 +29,17 @@ gulp.task('oauth', function() {
.pipe(gulp.dest(dist))
});

gulp.task('build_prod', ['build'], function() {
gulp.src('app/assets/javascripts/*.bundle.js')
.pipe(uglify())
.pipe(gulp.dest('app/assets/javascripts'));
});

gulp.task('build', ['background', 'popup', 'oauth']);

gulp.task('watch', function() {
gulp.watch(['app/src/*.js', 'app/src/*.jsx'], ['build']);
});

gulp.task('default', ['watch', 'build']);
gulp.task('prod', ['build_prod']);
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
{
"name": "letpocket",
"version": "0.1.0",
"name": "bookpocket",
"version": "1.0.0",
"devDependencies": {
"URIjs": "^1.15.2",
"browserify": "^11.0.0",
"gulp": "^3.9.0",
"gulp-uglify": "^1.2.0",
"material-ui": "^0.10.1",
"react": "^0.13.3",
"react-tap-event-plugin": "^0.1.7",
Expand Down

0 comments on commit d184edc

Please sign in to comment.