This repository has been archived by the owner on Mar 24, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 22
Readability pull request #61
Merged
Merged
Changes from 7 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
13d57e8
Added initial files of Readability plugin.
jbambas be75604
Modified rendering of readability view.
jbambas 1179e2a
Added Readablility side Toolbar.
jbambas 1602af1
Code refactoring of JS functions.
jbambas 7775ee4
Added README, fixed bug of readability with any types of pages.
jbambas 8174995
Incorporation of comments from pull request.
jbambas c7ac591
Added copyright, deleted unused file.
jbambas 22ebdfb
Replacement methods split() and join() for method remove(), code refa…
jbambas f2e876a
Deleted unused method.
jbambas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
|
||
%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'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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(); |
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.
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.
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.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also missing copyright.