Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
46c25dd
Got rid of Bower and implemented Article View
matthewgertner Jun 18, 2015
b8e2116
Show title in article view
matthewgertner Jun 24, 2015
8906f16
Delete implemented + Add/Remove star started. (problem with not refre…
novellizator Aug 30, 2015
570a2db
Rename main.js -> background.js to unify the whole thing a little.
novellizator Aug 30, 2015
2f09dd1
Completely change main.js into background.js. Add helper functions fo…
novellizator Aug 30, 2015
06af33a
Add/Remove Star functionality added.
novellizator Aug 31, 2015
b75d65c
Add archiveBookmarks. Clean up other bookmark editing (via updateBook…
novellizator Sep 1, 2015
128f46e
Read given tags.
novellizator Sep 1, 2015
be1d72f
Place article view toolbar in a iframe.
novellizator Sep 2, 2015
e84f679
Functionality for adding/removing tags.
novellizator Sep 2, 2015
af3c8db
FIX: Empty the tag adding field after adding the tag.
novellizator Sep 2, 2015
f5dcf30
Updated gitignore.
novellizator Sep 3, 2015
eb6c86a
add ionic framework gitignore exception
novellizator Sep 3, 2015
fd86d25
Add ionic library - and old version that is compatible with pocket.
novellizator Sep 3, 2015
8473b23
Fixed gruntfile. Generates dist/Pocket.crx
novellizator Sep 3, 2015
5d2db3b
button bar in reading view
Sep 7, 2015
c78e8f8
added meta to ensure correct zoom level
Sep 7, 2015
643c92c
make sure the content doesnt break layout by overflowing
Sep 7, 2015
cf3e281
disable user scalable
Sep 7, 2015
5c656ff
added indication of state on buttons
Sep 7, 2015
6e28880
content overflow protection improvement
Sep 8, 2015
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
15 changes: 8 additions & 7 deletions Gruntfile.coffee
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
module.exports = (grunt) ->

path = require 'path'

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Death to trailing whitespace!

# PATH where to store unzipped build
BUILD = "build"

# PATH where to store final zip
DIST = "dist"

# Common JS globals
globals =
document: false
Expand All @@ -22,7 +22,7 @@ module.exports = (grunt) ->
localStorage: false
XMLHttpRequest: false


# --------------------
# Load task
grunt.loadNpmTasks "grunt-contrib-jshint"
Expand All @@ -35,7 +35,7 @@ module.exports = (grunt) ->
grunt.loadNpmTasks 'grunt-s3'

grunt.initConfig

pkg: grunt.file.readJSON('package.json')
manifest: grunt.file.readJSON('src/manifest.json')

Expand Down Expand Up @@ -65,6 +65,7 @@ module.exports = (grunt) ->
{src: 'src/js/bookmarkList.js', dest: "#{BUILD}/js/bookmarkList.js"}
{src: 'src/js/auth.js', dest: "#{BUILD}/js/auth.js"}
{src: 'src/js/main.js', dest: "#{BUILD}/js/main.js"}
{src: 'src/js/content.js', dest: "#{BUILD}/js/content.js"}
]
options:
transform: ['cssify']
Expand Down Expand Up @@ -107,7 +108,7 @@ module.exports = (grunt) ->
},{
expand: yes
src: ['fonts/*.*']
cwd: 'src/vendor/ionic'
cwd: 'node_modules/ionic-framework/release'
dest: BUILD
},{
}
Expand Down Expand Up @@ -138,7 +139,7 @@ module.exports = (grunt) ->

grunt.registerTask "generateCrx", ['crx:main']


grunt.registerTask "default", ['jshint', 'clean', 'browserify:dist', 'copy', 'generateCrx']
grunt.registerTask "dev", ['jshint', 'clean', 'browserify:dev', 'copy', 'generateCrx', 'watch']

Expand Down
41 changes: 27 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pocket",
"version": "1.13.0",
"version": "1.14.0",
"description": "Kitt Pocket extension.",
"private": "true",
"scripts": {
Expand All @@ -17,26 +17,39 @@
},
"homepage": "https://github.com/realyze/watchpocket",
"devDependencies": {
"bower-installer": "0.7.1",
"browserify": "~10.2.0",
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I got rid of Bower, just using npm and Browserify now.

"cssify": "0.7.0",
"grunt": "0.4.5",
"grunt-browserify": "3.8.0",
"grunt-bumpup": "0.5.2",
"grunt-cli": "0.1.13",
"grunt-contrib-clean": "0.5.0",
"grunt-contrib-concat": "0.4.0",
"grunt-contrib-copy": "0.5.0",
"grunt-contrib-jshint": "0.10.0",
"grunt-contrib-watch": "0.6.1",
"grunt-crx": "oncletom/grunt-crx",
"grunt-exec": "0.4.5",
"grunt-s3": "0.2.0-alpha.3",
"grunt-usemin": "2.1.1",
"grunt-contrib-copy": "0.5.0",
"grunt-contrib-concat": "0.4.0",
"grunt-bumpup": "0.5.2",
"grunt-crx": "0.3.3",
"browserify": "3.38.1",
"grunt-browserify": "2.0.3",
"cssify": "0.5.0",
"uglifyify": "2.1.1",
"grunt-contrib-clean": "0.5.0",
"watchify": "0.6.4",
"grunt-contrib-watch": "0.6.1",
"grunt-s3": "0.2.0-alpha.3"
"watchify": "3.2.2"
},
"dependencies": {
"minilog": "^2.0.4"
"angular": "^1.3.16",
"angular-animate": "^1.3.16",
"angular-moment": "^0.10.1",
"angular-truncate-2": "^0.1.2",
"ionic-framework": "^1.0.0-beta.13.2",
"jquery": "^2.1.4",
"minilog": "^2.0.4",
"moment": "^2.10.3",
"q": "^1.4.1",
"underscore": "^1.8.3"
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.

I would rather use tilde(~) then caret(^).

},
"browserify": {
"transform": [
"cssify"
]
}
}
4 changes: 2 additions & 2 deletions src/bookmarksList.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@

<body ng-controller="bookmarksCtrl">

<div class="bar bar-footer bar-calm item-input-inset">
<div class="bar bar-header bar-calm item-input-inset">
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No idea why it was bar-footer before since I always remember the bar being a header. Maybe something to do with me upgrading Ionic but it started actually appearing as a footer, and changing it to bar-header fixed that (amazing, isn't it?).

<button class="button ion-ios7-close" ng-click="wipeCache()" ng-show="debugMode"></button>
<label class="item-input-wrapper">
<i class="icon ion-ios7-search placeholder-icon"></i>
<input type="search" placeholder="Search" ng-model="searchText">
</label>
<button class="button ion-plus" ng-click="addCurrent()"></button>
<button id="add-or-article-view" class="button ion-ios7-plus" ng-click="addCurrentOrArticleView()"></button>
</div>


Expand Down
13 changes: 4 additions & 9 deletions src/js/auth.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var $ = require('../vendor/jquery/jquery');
var $ = require('jquery');

require('../css/auth.css');

Expand All @@ -8,7 +8,6 @@ var waitForChrome = function(callback) {
window.setTimeout(function() {
waitForChrome(callback);
}, 250);
return;
} else {
callback();
}
Expand All @@ -17,7 +16,6 @@ var waitForChrome = function(callback) {
$(function() {
waitForChrome(function() {

var token = null;
var url = null;

var search = window.location.search;
Expand All @@ -33,9 +31,6 @@ $(function() {
var key = terms[i].split('=')[0];
var value = terms[i].split('=')[1];

if (key === 'token') {
token = value;
}
if (key === 'url') {
// This is only way, which I managed to get URL with symbols like (=,?,...) through login process
url = decodeURIComponent(window.atob(value));
Expand All @@ -46,16 +41,16 @@ $(function() {
// The tab originally had no URL
url = 'about:blank';
}
console.log('Response with ' + token + ' and ' + url);
console.log('Response with ' + url);

if (token === 'MyLittlePinkPony' && url) {
if (url) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I guess no one knows what the deal was with "MyLittlePinkPony"... farewell.

chrome.runtime.sendMessage({command: 'getOauthRequestToken'}, function(err, reqToken) {
chrome.runtime.sendMessage({command: 'getOauthAccessToken'}, function(err, accessToken) {
if (err) {
console.warn('Could not authenticate with pocket: ' + JSON.stringify(err));
return;
}
console.log('Authentication to pocket successfull.');
console.log('Authentication to pocket successful.');
window.location.href = url;
});
});
Expand Down
65 changes: 43 additions & 22 deletions src/js/bookmarkList.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
var _ = require('../vendor/underscore/underscore');
require('../vendor/ionic/ionic.bundle');
require('../vendor/angular-truncate/angular-truncate');
require('../vendor/moment/moment');
require('../vendor/angular-moment/angular-moment');
require('../vendor/ngAnimate-animate.css/animate');

require('../vendor/ionic/css/ionic.css');
var _ = require('underscore');
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

One nice thing about moving to npm is that we can require the packages without the full path. I also removed a bunch of stuff since it doesn't seem to me like it is being used anywhere.

require('ionic-framework');

require('../../node_modules/ionic-framework/release/css/ionic.css');
require('../vendor/animate.css/animate.css');
require('../css/pocket.css');

var Minilog = require("../../node_modules/minilog");
var Minilog = require('minilog');
var common = require('./common');

var log = Minilog('app');
Expand All @@ -22,10 +18,6 @@ var CLEAN_CACHE_SEARCH_STRING = 'salsa:ccache';

window.angular.module('pocket', [
'ionic',
'truncate',
'angularMoment',
'ngAnimate',
'ngAnimate-animate.css'
])

.controller('bookmarksCtrl', function($scope, $ionicLoading) {
Expand All @@ -35,12 +27,25 @@ window.angular.module('pocket', [

$scope.bookmarks = [];
$scope.allResultsFetched = false;
$scope.pagePocketed = false;

$scope.$watch('bookmarks', function(newVal, oldVal) {
if (newVal !== oldVal && newVal === []) {
$scope.allResultsFetched = false;
$scope.loadNextPage();
}
// Change add button to article view if page has already been pocketed
// or back to add button if it has been removed
common.getActiveTab().then(function(tab) {
var item = _.findWhere($scope.bookmarks, {url: tab.url});
if (item && !$scope.pagePocketed) {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What used to be just an "add this page" button now does double duty. When the page is already in pocket, it turns into an "Article View" button (see https://getpocket.com/developer/docs/v3/article-view). So we need to keep track of whether the page was already in Pocket so we can tell whether we need to change the button.

document.getElementById('add-or-article-view').setAttribute('class', 'button ion-ios7-paper');
}
else if (!item && $scope.pagePocketed) {
document.getElementById('add-or-article-view').setAttribute('class', 'button ion-ios7-plus');
}
$scope.pagePocketed = !!item;
});
}, true);

$scope.loadNextPage = function() {
Expand Down Expand Up @@ -147,7 +152,6 @@ window.angular.module('pocket', [
count: count,
})
}, function(response) {
log.debug('reponse', response);
if ( ! response) {
window.close();
return;
Expand All @@ -172,15 +176,32 @@ window.angular.module('pocket', [
});
};

$scope.addCurrent = function() {
$scope.addCurrentOrArticleView = function() {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since the button now does double duty, this function does double duty as well.

common.getActiveTab().then(function(tab) {
chrome.runtime.sendMessage(null, {
command: 'addBookmark',
url: tab.url
}, function() {
window.close();
$scope.$apply();
});
if ($scope.pagePocketed) {
chrome.runtime.sendMessage(null, {
command: 'requestArticleView',
url: tab.url
}, function(response) {
common.getActiveTab().then(function(tab) {
chrome.tabs.sendMessage(tab.id, {
command: 'showArticleView',
title: response.title,
html: response.article
});
window.close();
});
});
}
else {
chrome.runtime.sendMessage(null, {
command: 'addBookmark',
url: tab.url
}, function() {
window.close();
$scope.$apply();
});
}
});
};

Expand Down
2 changes: 1 addition & 1 deletion src/js/common.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
var Q = require('../vendor/q/q');
var Q = require('q');

var getActiveTab = function() {
var defer = Q.defer();
Expand Down
5 changes: 3 additions & 2 deletions src/js/constants.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module.exports = {
consumerKey: '28148-433066734282d2aef4f9aafe',
pocket_api_endpoint: 'https://getpocket.com/v3'
consumerKey: '38767-70f457996273e97445b7e8f4',
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Changed the consumer key since I had to set up a new app and request access to the Article View API.

pocket_api_endpoint: 'https://getpocket.com/v3',
article_view_endpoint: 'http://text.getpocket.com/v3/text'
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Article View API has its own endpoint.

};
7 changes: 6 additions & 1 deletion src/js/content.js
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@

chrome.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if (request.command === 'showArticleView') {
document.head.innerHTML = '<style>img { max-width: 100% }</style>';
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Make sure images fit.

document.body.innerHTML = '<h1>' + request.title + '</h1>' + request.html;
}
});
Loading