Skip to content

Commit

Permalink
Remove support for Readability API
Browse files Browse the repository at this point in the history
The web parser API has been officially discontinued
  • Loading branch information
Muffo committed Dec 17, 2016
1 parent 65ae73e commit b5caa51
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 138 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ With FullyFeedly you can load the full content of the articles inside Feedly, al

## Features

* Seamless integration with Readability
* Seamless integration with Mercury API
* Super fast keyboard shortcut
* Works perfectly with HTTPS connection
* Works great with HTTPS connection

## Usage

Expand Down Expand Up @@ -38,4 +38,5 @@ Thanks a lot to the following developers for their help and contributions:
The text of the article is extracted using the web API provided by:

* [Boilerpipe](http://boilerpipe-web.appspot.com/): free to use, limited quota
* [Readability](http://www.readability.com): free for non-commercial use, API key required
* [Mercury](https://mercury.postlight.com/): free for non-commercial use, API key required
* [Readability](http://www.readability.com): free for non-commercial use *(no longer supported)*
2 changes: 1 addition & 1 deletion app/_locales/en/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "The name of the application"
},
"appDescription": {
"message": "Add Readability to Feedly and show the full content of articles",
"message": "Add Mercury to Feedly and show the full content of articles",
"description": "The description of the application"
},
"articleNotLoaded": {
Expand Down
2 changes: 1 addition & 1 deletion app/_locales/es/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "El nombre de la aplicación"
},
"appDescription": {
"message": "Integra Readability en Feedly y muestra el contenido completo de los artículos",
"message": "Integra Mercury en Feedly y muestra el contenido completo de los artículos",
"description": "La descripción de la aplicación"
},
"articleNotLoaded": {
Expand Down
26 changes: 13 additions & 13 deletions app/_locales/it/messages.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Nome dell'applicazione"
},
"appDescription": {
"message": "Integra Readability in Feedly e mostra il contenuto completo degli articoli",
"message": "Mostra il contenuto completo degli articoli in Feedly.com",
"description": "Descrizione dell'applicazione"
},
"articleNotLoaded": {
Expand Down Expand Up @@ -63,8 +63,8 @@
"message": "API per l'elaborazione dell'articolo",
"description": "Label in the option page for select type of API"
},
"optionsReadabilityApiKey": {
"message": "Chiave per Readability API",
"optionsMercuryApiKey": {
"message": "Chiave per Mercury API",
"description": "Label in the option page for set the readbility api key"
},
"optionsHelp": {
Expand Down Expand Up @@ -92,35 +92,35 @@
"description": "Close the help popup"
},
"optionsSetupReadbilityApiKey": {
"message" : "Configura la tua Readability Key in due semplici step",
"description": "Readability Help / first line : Setup your Readability API key in two easy steps"
"message" : "Configura la tua Mercury Key in due semplici step",
"description": "Mercury Help / first line : Setup your Mercury API key in two easy steps"
},
"optionsStepOne": {
"message" : "1. Crea un account gratuito per Readability",
"description": "Readability Help / first step / Title : 1. Create a free Readability account"
"message" : "1. Crea un account gratuito per Mercury",
"description": "Mercury Help / first step / Title : 1. Create a free Mercury account"
},
"optionsVisit": {
"message" : "Visita il sito",
"description": "Readability Help / first step : Visit"
"description": "Mercury Help / first step : Visit"
},
"optionsCreateFreeAccount": {
"message" : "e crea un account gratuito",
"description": "Readability Help / first step : and create your free account."
"description": "Mercury Help / first step : and create your free account."
},
"optionsLoginFacebook": {
"message" : "E' anche possibile effettuare il login utilizzando Facebook",
"description": "Readability Help / first step / Facebook : You can also login using Facebook."
"description": "Mercury Help / first step / Facebook : You can also login using Facebook."
},
"optionsStepTwo": {
"message" : "2. Recuperate la vostra API Key",
"description": "Readability Help / second step / Title : 2. Get your API key"
"description": "Mercury Help / second step / Title : 2. Get your API key"
},
"optionsYourApiKeyAvailableIn": {
"message" : "La vostra key personale è disponibile nelle",
"description": "Readability Help / second step / Text : Your personal API key is available in your"
"description": "Mercury Help / second step / Text : Your personal API key is available in your"
},
"optionsAccountSettings": {
"message" : "impostazioni account (Settings/Account)",
"description": "Readability Help / second step / Link : account settings."
"description": "Mercury Help / second step / Link : account settings."
}
}
1 change: 0 additions & 1 deletion app/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@
"activeTab",
"storage",
"https://boilerpipe-web.appspot.com/*",
"https://www.readability.com/api/*",
"https://mercury.postlight.com/*"
],
"options_page": "options.html"
Expand Down
37 changes: 0 additions & 37 deletions app/options.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,8 @@ <h1 data-message="appName">FullyFeedly</h1>
<select class="form-control input-lg" id="extractionAPI">
<option>Boilerpipe</option>
<option>Mercury</option>
<option>Readability</option>
</select>
</div>
<div class="form-group" id="readabilityKeyForm">
<label for="readabilityAPIKey" data-message="optionsReadabilityApiKey">Readability API key </label>
<a class="pull-right" data-toggle="modal" data-target="#readabilityHelp" href="#" data-message="optionsHelp">
Help
</a>
<input type="text" class="form-control input-lg" id="readabilityAPIKey" placeholder="Readability API Key">
</div>
<div class="form-group" id="mercuryKeyForm">
<label for="mercuryAPIKey" data-message="optionsMercuryApiKey">Mercury API key </label>
<a class="pull-right" data-toggle="modal" data-target="#mercuryHelp" href="#" data-message="optionsHelp">
Expand Down Expand Up @@ -70,35 +62,6 @@ <h1 data-message="appName">FullyFeedly</h1>
</div>
</div>
</div>
<!-- Readability help div -->
<div class="modal fade" id="readabilityHelp" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
<span aria-hidden="true">&times;</span>
<span class="sr-only" data-message="optionsClose">Close</span>
</button>
<h3 class="modal-title" id="readabilityHelpTitle">
<img src="images/readability-logo.png" style="height: 30px;" />
<span data-message="optionsReadabilityApiKey">Readability API key</span>
</h3>
</div>
<div class="modal-body">
<span data-message="optionsSetupReadbilityApiKey">Setup your Readability API key in two easy steps</span>:
<h4 data-message="optionsStepOne">1. Create a free Readability account</h4>
<span data-message="optionsVisit">Visit</span> <a href="http://readability.com" target="_blank">Readability.com</a>
<span data-message="optionsCreateFreeAccount">and create your free account</span>.</br>
<span data-message="optionsLoginFacebook">You can also login using Facebook</span>.</span>

<h4 data-message="optionsStepTwo">2. Get your API key </h4>
<span data-message="optionsYourApiKeyAvailableIn">Your personal API key is available in your</span>
<a href="https://www.readability.com/settings/account" target="_blank" data-message="optionsAccountSettings">account settings</a>.</br>
<img src="images/readability-help.png" />
</div>
</div>
</div>
</div>
<!-- Mercury help div -->
<div class="modal fade" id="mercuryHelp" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
Expand Down
62 changes: 4 additions & 58 deletions app/scripts/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
/* ===================== Options ===================== */
var options = {
extractionAPI: 'Boilerpipe',
readabilityAPIKey: '',
mercuryAPIKey: '',
enableShortcut: false
};
Expand Down Expand Up @@ -209,11 +208,11 @@ function boilerpipeRequest(xhr, overlay) {
};
}

/* ===================== Readability/Mercury ===================== */
/* ===================== Mercury ===================== */
/**
* Process the content of the article and add it to the page
*/
function onMercuryReadabilityArticleExtracted(data, overlay) {
function onMercuryArticleExtracted(data, overlay) {

// Check if the API failed to extract the text
if (data.content === null) {
Expand Down Expand Up @@ -243,21 +242,6 @@ function onMercuryReadabilityArticleExtracted(data, overlay) {
var articlePreviewHTML = contentElement.innerHTML;
contentElement.innerHTML = articleContent;

// Add warning message if user is still using the Readability API
if (options.extractionAPI === 'Readability') {
var optionsUrl = chrome.extension.getURL("options.html");
var warningDiv = '<div class="migrationWarning"> \
<b>FullyFeedly: Readability API Migration</b><br/> \
The Readability API you are currently using will stop working on the 10th of December. See the \
<a href="https://medium.com/@readability/the-readability-bookmarking-service-will-shut-down-on-september-30-2016-1641cc18e02b#.e2aunrmow" \
target="_blank"> official announcement</a>.<br/> \
Please, go to the <a href="' + optionsUrl + '" target="_blank">options page of FullyFeedly</a> and select\
the new <a href="https://mercury.postlight.com/web-parser/" target="_blank">Mercury API</a>.<br/>\
Thanks a lot for using FullyFeedly :) \
</div>';
contentElement.innerHTML = warningDiv + contentElement.innerHTML;
}

// Clear image styles to fix formatting of images with class/style/width information in article markup
Array.prototype.slice.call(contentElement.querySelectorAll('img')).forEach(function(el) {
el.removeAttribute('class');
Expand All @@ -276,39 +260,14 @@ function onMercuryReadabilityArticleExtracted(data, overlay) {
addUndoButton(articlePreviewHTML);
}

/* ===================== Readability ===================== */
function readabilityRequest(xhr, overlay) {
return function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
// Operation succeded
var data = JSON.parse(xhr.responseText);
onMercuryReadabilityArticleExtracted(data, overlay);
} else if (xhr.status === 400) {
console.log('[FullyFeedly] Readability API Bad request: ' +
'The server could not understand your request. ' +
'Verify that request parameters (and content, if any) are valid.');
failOverlay('APIBadRequest', overlay);
} else if (xhr.status === 403) {
console.log('[FullyFeedly] Readability API Authorization Required: ' +
'Authentication failed or was not provided.');
failOverlay('APIAuthorizationRequired', overlay);
} else {
console.log('[FullyFeedly] Readability API Unknown error');
failOverlay('APIUnknownError', overlay);
}
}
};
}

/* ===================== Mercury ===================== */
function mercuryRequest(xhr, overlay) {
return function() {
if (xhr.readyState === 4) {
if (xhr.status === 200) {
// Operation succeded
var data = JSON.parse(xhr.responseText);
onMercuryReadabilityArticleExtracted(data, overlay);
onMercuryArticleExtracted(data, overlay);
} else if (xhr.status === 400) {
console.log('[FullyFeedly] Mercury API Bad request: ' +
'The server could not understand your request. ' +
Expand Down Expand Up @@ -359,19 +318,6 @@ function fetchPageContent() {

xhr.onreadystatechange = boilerpipeRequest(xhr, overlay);
}
else if (options.extractionAPI === 'Readability') {
// Check if the key is set
if (options.readabilityAPIKey === '') {
failOverlay('APIMissingKey', overlay);
return;
}

// Prepare the request to Readability
url = 'https://www.readability.com/api/content/v1/parser?url=' +
encodedPageUrl + '&token=' + options.readabilityAPIKey;

xhr.onreadystatechange = readabilityRequest(xhr, overlay);
}
else if (options.extractionAPI === 'Mercury') {
if (options.mercuryAPIKey === '') {
failOverlay('APIMissingKey', overlay);
Expand All @@ -387,7 +333,7 @@ function fetchPageContent() {
return;
}
xhr.open('GET', url, true);
if (options.extractionAPI === 'Mercury' && options.mercuryAPIKey !== '') {
if (options.extractionAPI === 'Mercury') {
xhr.setRequestHeader('x-api-key', options.mercuryAPIKey);
}
xhr.send();
Expand Down
29 changes: 5 additions & 24 deletions app/scripts/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@
function updateForm() {
var extractionAPI = $('#extractionAPI').val();

if (extractionAPI === 'Readability') {
$('#readabilityKeyForm').show();
}
else {
$('#readabilityKeyForm').hide();
}

if (extractionAPI === 'Mercury') {
$('#mercuryKeyForm').show();
}
Expand All @@ -32,24 +25,11 @@ function onKeyboardShortcut() {
// Saves options to chrome.storage
function saveOptions() {
var extractionAPI = $('#extractionAPI').val();
var readabilityAPIKey = $('#readabilityAPIKey').val();
var mercuryAPIKey = $('#mercuryAPIKey').val();
var enableShortcut = $('#enableShortcut').prop('checked');
var status = $('#status');

// Check optional paramenters
if (extractionAPI === 'Readability') {
if (readabilityAPIKey === '') {
// Show the error message
status.text('Missing Readability API key');
$('#readabilityKeyForm').addClass('has-error');
setTimeout(function() {
status.text('');
$('#readabilityKeyForm').removeClass('has-error');
}, 2000);
return;
}
}
if (extractionAPI === 'Mercury') {
if (mercuryAPIKey === '') {
// Show the error message
Expand All @@ -65,7 +45,6 @@ function saveOptions() {

chrome.storage.sync.set({
extractionAPI: extractionAPI,
readabilityAPIKey: readabilityAPIKey,
mercuryAPIKey: mercuryAPIKey,
enableShortcut: enableShortcut
}, function() {
Expand All @@ -79,15 +58,17 @@ function saveOptions() {

// Restores the options using the preferences stored in chrome.storage.
function restoreOptions() {
// Use default value extractionAPI = 'red' and readabilityAPIKey = ''
// Use default value extractionAPI = 'Boilerpipe' and mercuryAPIKey = ''
chrome.storage.sync.get({
extractionAPI: 'Boilerpipe',
readabilityAPIKey: '',
mercuryAPIKey: '',
enableShortcut: false
}, function(items) {
// In case the user has not switched to Mercury yet...
if (items.extractionAPI === "Readability")
items.extractionAPI = "Boilerpipe";

$('#extractionAPI').val(items.extractionAPI);
$('#readabilityAPIKey').val(items.readabilityAPIKey);
$('#mercuryAPIKey').val(items.mercuryAPIKey);
$('#enableShortcut').prop('checked', items.enableShortcut);
updateForm();
Expand Down

0 comments on commit b5caa51

Please sign in to comment.