diff options
| author | 2016-10-30 20:15:11 +0100 | |
|---|---|---|
| committer | 2016-10-30 20:15:11 +0100 | |
| commit | 1d3e5bdee069434fd65c2717ae8fcce8c54fe81d (patch) | |
| tree | 39b0ae9ac0b0d1ed7fa11c747a0523cb3faa384b /app/Models/Feed.php | |
| parent | 17c8c039df675b3b0f8d88d14f7316a240eabe76 (diff) | |
| parent | 29e1f048159b7a580bdf1bab184e928f11d104b4 (diff) | |
Merge pull request #1346 from FreshRSS/dev1.6.0
Merge 1.6.0-dev in master
Diffstat (limited to 'app/Models/Feed.php')
| -rw-r--r-- | app/Models/Feed.php | 41 |
1 files changed, 29 insertions, 12 deletions
diff --git a/app/Models/Feed.php b/app/Models/Feed.php index 6104b1e31..97cb1c47e 100644 --- a/app/Models/Feed.php +++ b/app/Models/Feed.php @@ -131,13 +131,26 @@ class FreshRSS_Feed extends Minz_Model { return $this->nbNotRead; } public function faviconPrepare() { - $file = DATA_PATH . '/favicons/' . $this->hash() . '.txt'; - if (!file_exists($file)) { - $t = $this->website; - if ($t == '') { - $t = $this->url; + global $favicons_dir; + require_once(LIB_PATH . '/favicons.php'); + $url = $this->website; + if ($url == '') { + $url = $this->url; + } + $txt = $favicons_dir . $this->hash() . '.txt'; + if (!file_exists($txt)) { + file_put_contents($txt, $url); + } + if (FreshRSS_Context::$isCli) { + $ico = $favicons_dir . $this->hash() . '.ico'; + $ico_mtime = @filemtime($ico); + $txt_mtime = @filemtime($txt); + if ($txt_mtime != false && + ($ico_mtime == false || $ico_mtime < $txt_mtime || ($ico_mtime < time() - (14 * 86400)))) { + // no ico file or we should download a new one. + $url = file_get_contents($txt); + download_favicon($url, $ico) || touch($ico); } - file_put_contents($file, $t); } } public static function faviconDelete($hash) { @@ -216,7 +229,7 @@ class FreshRSS_Feed extends Minz_Model { $this->nbEntries = intval($value); } - public function load($loadDetails = false) { + public function load($loadDetails = false, $noCache = false) { if ($this->url !== null) { if (CACHE_PATH === false) { throw new Minz_FileNotExistException( @@ -268,7 +281,7 @@ class FreshRSS_Feed extends Minz_Model { $this->_url($clean_url); } - if (($mtime === true) || ($mtime > $this->lastUpdate)) { + if (($mtime === true) || ($mtime > $this->lastUpdate) || $noCache) { //Minz_Log::debug('FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate . ' for ' . $clean_url); $this->loadEntries($feed); // et on charge les articles du flux } else { @@ -309,11 +322,11 @@ class FreshRSS_Feed extends Minz_Model { $elinks[$elink] = '1'; $mime = strtolower($enclosure->get_type()); if (strpos($mime, 'image/') === 0) { - $content .= '<br /><img lazyload="" postpone="" src="' . $elink . '" alt="" />'; + $content .= '<p class="enclosure"><img src="' . $elink . '" alt="" /></p>'; } elseif (strpos($mime, 'audio/') === 0) { - $content .= '<br /><audio lazyload="" postpone="" preload="none" src="' . $elink . '" controls="controls" />'; + $content .= '<p class="enclosure"><audio preload="none" src="' . $elink . '" controls="controls"></audio> <a download="" href="' . $elink . '">💾</a></p>'; } elseif (strpos($mime, 'video/') === 0) { - $content .= '<br /><video lazyload="" postpone="" preload="none" src="' . $elink . '" controls="controls" />'; + $content .= '<p class="enclosure"><video preload="none" src="' . $elink . '" controls="controls"></video> <a download="" href="' . $elink . '">💾</a></p>'; } else { unset($elinks[$elink]); } @@ -340,6 +353,10 @@ class FreshRSS_Feed extends Minz_Model { $this->entries = $entries; } + function cacheModifiedTime() { + return @filemtime(CACHE_PATH . '/' . md5($this->url) . '.spc'); + } + function lock() { $this->lockPath = TMP_PATH . '/' . $this->hash() . '.freshrss.lock'; if (file_exists($this->lockPath) && ((time() - @filemtime($this->lockPath)) > 3600)) { @@ -460,7 +477,7 @@ class FreshRSS_Feed extends Minz_Model { CURLOPT_URL => $this->hubUrl, CURLOPT_FOLLOWLOCATION => true, CURLOPT_RETURNTRANSFER => true, - CURLOPT_USERAGENT => _t('gen.freshrss') . '/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ')', + CURLOPT_USERAGENT => 'FreshRSS/' . FRESHRSS_VERSION . ' (' . PHP_OS . '; ' . FRESHRSS_WEBSITE . ')', CURLOPT_POSTFIELDS => 'hub.verify=sync' . '&hub.mode=' . ($state ? 'subscribe' : 'unsubscribe') . '&hub.topic=' . urlencode($this->selfUrl) |
