Skip to content
This repository has been archived by the owner on Mar 24, 2024. It is now read-only.

Readability pull request #61

Merged
merged 9 commits into from
May 2, 2016
Merged
Show file tree
Hide file tree
Changes from 7 commits
Commits
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
7 changes: 7 additions & 0 deletions plugins/Readability/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Readability plugin for QupZilla
-------------------------------------------------
This plugin allows modify web page to easily reading.

![example](http://i.imgur.com/SnQNfQl.png)

You will find more information about usage of this plugin in the [wiki](https://github.com/QupZilla/qupzilla-plugins/wiki/Readability).
15 changes: 15 additions & 0 deletions plugins/Readability/Readability.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
TARGET = $$qtLibraryTarget(ReadabilityPlugin)

SOURCES += readability.cpp
HEADERS += readability.h
RESOURCES += readability.qrc


PLUGIN_DIR = $$PWD
srcdir = $$(QUPZILLA_SRCDIR)
equals(srcdir, "") {
include(../../plugins.pri)
}
else {
include($$srcdir/src/plugins.pri)
}
118 changes: 118 additions & 0 deletions plugins/Readability/data/Call.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/* ============================================================
* QupZilla - WebKit based browser
* Copyright (C) 2016 Jaroslav Bambas <jar.bambas@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
* ============================================================ */

%1
Copy link
Member

Choose a reason for hiding this comment

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

Also missing copyright.


%2

function callReadability(){
var loc = document.location;
var uri = {
spec: loc.href,
host: loc.host,
prePath: loc.protocol + "//" + loc.host,
scheme: loc.protocol.substr(0, loc.protocol.indexOf(":")),
pathBase: loc.protocol + "//" + loc.host + loc.pathname.substr(0, loc.pathname.lastIndexOf("/") + 1)
};
var article = new Readability(uri, document).parse();
renderPage(article);
}

function readabilityHead(article){
var head = document.createElement('head');
document.documentElement.appendChild(head);

var title = document.createElement('title');
title.innerHTML = article.title;
head.appendChild(title);

var css = document.createElement('style');
Copy link
Member

Choose a reason for hiding this comment

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

Please fix indentation. Somewhere you use tabs and somewhere spaces, I would prefer to use only spaces.

css.innerHTML = '%3';
head.appendChild(css);

var meta = document.createElement('meta');
meta.content = "text/html; charset=UTF-8";
meta.httpEquiv = 'content-type';
head.appendChild(meta);
meta = document.createElement('meta');
meta.name = 'viewport';
meta.content = 'width=device-width, user-scalable=0';
head.appendChild(meta);
}

function readablilityBody(article){
var body = document.createElement('body');
body.className = 'loaded sans-serif sepia';
document.documentElement.appendChild(body);

var container = document.createElement('div');
container.className = 'container font-size5';
container.id = 'container';
body.appendChild(container);

var header = document.createElement('div');
header.className = 'header';
header.id = 'reader-header';
header.style.display = 'block';
container.appendChild(header);

var domain = document.createElement('a');
domain.id = 'reader-domain';
domain.className = 'domain';
domain.href = article.uri.spec;
domain.innerHTML = article.uri.host;
header.appendChild(domain);

var h1 = document.createElement('h1');
h1.id = 'reader-title';
h1.innerHTML = article.title;
header.appendChild(h1);

var credit = document.createElement('div');
credit.id = 'reader-credits';
credit.className = 'credits';
credit.innerHTML = article.byline;
header.appendChild(credit);

var content = document.createElement('div');
content.className = 'content';
container.appendChild(content);

var reader_content = document.createElement('div');
reader_content.id = 'moz-reader-content';
reader_content.style.display = 'block';
reader_content.innerHTML = article.content;
content.appendChild(reader_content);
}

function renderPage(article){
var element = document.documentElement;
if(element && !!article && !!article.content){
element.removeChild(document.body);
element.removeChild(document.head);

readabilityHead(article);
readablilityBody(article);

readablilityToolbar();
} else {
alert("No content to transform.");
}
}

callReadability();
Binary file added plugins/Readability/data/RM-Delete-24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugins/Readability/data/RM-Minus-24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugins/Readability/data/RM-Plus-24x24.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions plugins/Readability/data/RM-Type-Controls-Arrow.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugins/Readability/data/RM-close-hover.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added plugins/Readability/data/RM-close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading