Skip to content

Commit

Permalink
Merge pull request #761 from wallabag/dev
Browse files Browse the repository at this point in the history
1.7.1
  • Loading branch information
nicosomb committed Jul 15, 2014
2 parents a9f5e57 + 26452f8 commit 0f6273c
Show file tree
Hide file tree
Showing 17 changed files with 191 additions and 166 deletions.
8 changes: 7 additions & 1 deletion inc/3rdparty/libraries/PHPePub/EPub.php
Expand Up @@ -41,6 +41,8 @@ class EPub {

private $bookVersion = EPub::BOOK_VERSION_EPUB2;

private $debugInside = FALSE;

public $maxImageWidth = 768;
public $maxImageHeight = 1024;

Expand Down Expand Up @@ -132,10 +134,14 @@ class EPub {
*
* @return void
*/
function __construct($bookVersion = EPub::BOOK_VERSION_EPUB2, $languageCode = "en", $writingDirection = EPub::DIRECTION_LEFT_TO_RIGHT) {
function __construct($bookVersion = EPub::BOOK_VERSION_EPUB2, $debugInside = FALSE, $languageCode = "en", $writingDirection = EPub::DIRECTION_LEFT_TO_RIGHT) {
include_once("Zip.php");
include_once("Logger.php");

if (!$debugInside) {
error_reporting(E_ERROR | E_PARSE);
}

$this->bookVersion = $bookVersion;
$this->writingDirection = $writingDirection;
$this->languageCode = $languageCode;
Expand Down
1 change: 1 addition & 0 deletions inc/3rdparty/libraries/feedwriter/FeedWriter.php
Expand Up @@ -2,6 +2,7 @@
define('RSS2', 1, true);
define('JSON', 2, true);
define('JSONP', 3, true);
define('ATOM', 4, true);

/**
* Univarsel Feed Writer class
Expand Down
17 changes: 15 additions & 2 deletions inc/3rdparty/libraries/readability/Readability.php 100644 → 100755
Expand Up @@ -679,6 +679,7 @@ protected function grabArticle($page=null) {
} else {
$topCandidate->innerHTML = $page->documentElement->innerHTML;
$page->documentElement->innerHTML = '';
$this->reinitBody();
$page->documentElement->appendChild($topCandidate);
}
} else {
Expand Down Expand Up @@ -794,8 +795,7 @@ protected function grabArticle($page=null) {
{
// TODO: find out why element disappears sometimes, e.g. for this URL http://www.businessinsider.com/6-hedge-fund-etfs-for-average-investors-2011-7
// in the meantime, we check and create an empty element if it's not there.
if (!isset($this->body->childNodes)) $this->body = $this->dom->createElement('body');
$this->body->innerHTML = $this->bodyCache;
$this->reinitBody();

if ($this->flagIsActive(self::FLAG_STRIP_UNLIKELYS)) {
$this->removeFlag(self::FLAG_STRIP_UNLIKELYS);
Expand Down Expand Up @@ -1134,5 +1134,18 @@ public function addFlag($flag) {
public function removeFlag($flag) {
$this->flags = $this->flags & ~$flag;
}

/**
* Will recreate previously deleted body property
*
* @return void
*/
protected function reinitBody() {
if (!isset($this->body->childNodes)) {
$this->body = $this->dom->createElement('body');
$this->body->innerHTML = $this->bodyCache;
}
}

}
?>
8 changes: 6 additions & 2 deletions inc/3rdparty/makefulltextfeed.php
Expand Up @@ -28,7 +28,7 @@
// Request this file passing it a web page or feed URL in the querystring: makefulltextfeed.php?url=example.org/article
// For more request parameters, see http://help.fivefilters.org/customer/portal/articles/226660-usage

error_reporting(E_ALL ^ E_NOTICE);
//error_reporting(E_ALL ^ E_NOTICE);
ini_set("display_errors", 1);
@set_time_limit(120);

Expand Down Expand Up @@ -671,7 +671,11 @@
$html .= $item->get_description();
} else {
$readability->clean($content_block, 'select');
if ($options->rewrite_relative_urls) makeAbsolute($effective_url, $content_block);
// get base URL
$base_url = get_base_url($readability->dom);
if (!$base_url) $base_url = $effective_url;
// rewrite URLs
if ($options->rewrite_relative_urls) makeAbsolute($base_url, $content_block);
// footnotes
if (($links == 'footnotes') && (strpos($effective_url, 'wikipedia.org') === false)) {
$readability->addFootnotes($content_block);
Expand Down
10 changes: 10 additions & 0 deletions inc/3rdparty/makefulltextfeedHelpers.php
Expand Up @@ -377,3 +377,13 @@ function debug($msg) {
flush();
}
}

function get_base_url($dom) {
$xpath = new DOMXPath($dom);
$base_url = @$xpath->evaluate('string(//head/base/@href)', $dom);
if ($base_url !== '') {
return $base_url;
} else {
return false;
}
}

0 comments on commit 0f6273c

Please sign in to comment.