Просмотр исходного кода

Merge branch 'dev' into shortcuts

Ajoute le défilement automatique de l'article quand le partage est sélectionné.

Conflicts:
	p/scripts/main.js
Alexis Degrugillier 12 лет назад
Родитель
Сommit
aa63f9f64f
6 измененных файлов с 56 добавлено и 11 удалено
  1. 1 0
      CHANGELOG
  2. 1 0
      README.md
  3. 6 3
      app/Controllers/feedController.php
  4. 1 1
      app/Models/Feed.php
  5. 26 3
      lib/SimplePie/SimplePie.php
  6. 21 4
      p/scripts/main.js

+ 1 - 0
CHANGELOG

@@ -3,6 +3,7 @@
 ## 2014-0x-xx FreshRSS 0.8
 ## 2014-0x-xx FreshRSS 0.8
 
 
 * Mise à jour des flux plus rapide grâce à une meilleure utilisation du cache
 * Mise à jour des flux plus rapide grâce à une meilleure utilisation du cache
+	* Utilisation d’une signature MD5 du contenu intéressant pour les flux n’implémentant pas les requêtes conditionnelles
 
 
 
 
 ## 2014-01-29 FreshRSS 0.7
 ## 2014-01-29 FreshRSS 0.7

+ 1 - 0
README.md

@@ -80,6 +80,7 @@ mysqldump -u utilisateur -p --databases freshrss > freshrss.sql
 * [php-http-304](http://alexandre.alapetite.fr/doc-alex/php-http-304/)
 * [php-http-304](http://alexandre.alapetite.fr/doc-alex/php-http-304/)
 * [jQuery](http://jquery.com/)
 * [jQuery](http://jquery.com/)
 * [keyboard_shortcuts](http://www.openjs.com/scripts/events/keyboard_shortcuts/)
 * [keyboard_shortcuts](http://www.openjs.com/scripts/events/keyboard_shortcuts/)
+* [flotr2](http://www.humblesoftware.com/flotr2)
 
 
 ## Uniquement pour certaines options
 ## Uniquement pour certaines options
 * [bcrypt.js](https://github.com/dcodeIO/bcrypt.js)
 * [bcrypt.js](https://github.com/dcodeIO/bcrypt.js)

+ 6 - 3
app/Controllers/feedController.php

@@ -14,15 +14,15 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 				);
 				);
 			}
 			}
 		}
 		}
-
-		$this->catDAO = new FreshRSS_CategoryDAO ();
-		$this->catDAO->checkDefault ();
 	}
 	}
 
 
 	public function addAction () {
 	public function addAction () {
 		@set_time_limit(300);
 		@set_time_limit(300);
 
 
 		if (Minz_Request::isPost ()) {
 		if (Minz_Request::isPost ()) {
+			$this->catDAO = new FreshRSS_CategoryDAO ();
+			$this->catDAO->checkDefault ();
+
 			$url = Minz_Request::param ('url_rss');
 			$url = Minz_Request::param ('url_rss');
 			$cat = Minz_Request::param ('category', false);
 			$cat = Minz_Request::param ('category', false);
 			if ($cat === false) {
 			if ($cat === false) {
@@ -309,6 +309,9 @@ class FreshRSS_feed_Controller extends Minz_ActionController {
 	public function massiveImportAction () {
 	public function massiveImportAction () {
 		@set_time_limit(300);
 		@set_time_limit(300);
 
 
+		$this->catDAO = new FreshRSS_CategoryDAO ();
+		$this->catDAO->checkDefault ();
+
 		$entryDAO = new FreshRSS_EntryDAO ();
 		$entryDAO = new FreshRSS_EntryDAO ();
 		$feedDAO = new FreshRSS_FeedDAO ();
 		$feedDAO = new FreshRSS_FeedDAO ();
 
 

+ 1 - 1
app/Models/Feed.php

@@ -218,7 +218,7 @@ class FreshRSS_Feed extends Minz_Model {
 				}
 				}
 
 
 				if (($mtime === true) || ($mtime > $this->lastUpdate)) {
 				if (($mtime === true) || ($mtime > $this->lastUpdate)) {
-					syslog(LOG_DEBUG, 'FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate);
+					syslog(LOG_DEBUG, 'FreshRSS no cache ' . $mtime . ' > ' . $this->lastUpdate . ' for ' . $subscribe_url);
 					$this->loadEntries($feed);	// et on charge les articles du flux
 					$this->loadEntries($feed);	// et on charge les articles du flux
 				} else {
 				} else {
 					syslog(LOG_DEBUG, 'FreshRSS use cache for ' . $subscribe_url);
 					syslog(LOG_DEBUG, 'FreshRSS use cache for ' . $subscribe_url);

+ 26 - 3
lib/SimplePie/SimplePie.php

@@ -1212,6 +1212,10 @@ class SimplePie
 		$this->item_limit = (int) $limit;
 		$this->item_limit = (int) $limit;
 	}
 	}
 
 
+	function cleanMd5($rss) {	//FreshRSS
+		return md5(preg_replace(array('#<(lastBuildDate|pubDate|updated|feedDate|dc:date|slash:comments)>[^<]+</\\1>#', '#<!--.+?-->#s'), '', $rss));
+	}
+
 	/**
 	/**
 	 * Initialize the feed object
 	 * Initialize the feed object
 	 *
 	 *
@@ -1305,6 +1309,10 @@ class SimplePie
 			}
 			}
 
 
 			list($headers, $sniffed) = $fetched;
 			list($headers, $sniffed) = $fetched;
+
+			if (isset($this->data['md5'])) {	//FreshRSS
+				$md5 = $this->data['md5'];
+			}
 		}
 		}
 
 
 		// Set up array of possible encodings
 		// Set up array of possible encodings
@@ -1387,6 +1395,7 @@ class SimplePie
 					}
 					}
 					$this->data['build'] = SIMPLEPIE_BUILD;
 					$this->data['build'] = SIMPLEPIE_BUILD;
 					$this->data['mtime'] = time();	//FreshRSS
 					$this->data['mtime'] = time();	//FreshRSS
+					$this->data['md5'] = empty($md5) ? $this->cleanMd5($this->raw_data) : $md5;	//FreshRSS
 
 
 					// Cache the file if caching is enabled
 					// Cache the file if caching is enabled
 					if ($cache && !$cache->save($this))
 					if ($cache && !$cache->save($this))
@@ -1462,7 +1471,7 @@ class SimplePie
 				elseif ($cache->mtime() + $this->cache_duration < time())
 				elseif ($cache->mtime() + $this->cache_duration < time())
 				{
 				{
 					// If we have last-modified and/or etag set
 					// If we have last-modified and/or etag set
-					if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))
+					//if (isset($this->data['headers']['last-modified']) || isset($this->data['headers']['etag']))	//FreshRSS removed
 					{
 					{
 						$headers = array(
 						$headers = array(
 							'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
 							'Accept' => 'application/atom+xml, application/rss+xml, application/rdf+xml;q=0.9, application/xml;q=0.8, text/xml;q=0.8, text/html;q=0.7, unknown/unknown;q=0.1, application/unknown;q=0.1, */*;q=0.1',
@@ -1476,7 +1485,7 @@ class SimplePie
 							$headers['if-none-match'] = $this->data['headers']['etag'];
 							$headers['if-none-match'] = $this->data['headers']['etag'];
 						}
 						}
 
 
-						$file = $this->registry->create('File', array($this->feed_url, $this->timeout/10, 5, $headers, $this->useragent, $this->force_fsockopen));
+						$file = $this->registry->create('File', array($this->feed_url, $this->timeout, 5, $headers, $this->useragent, $this->force_fsockopen));	//FreshRSS
 
 
 						if ($file->success)
 						if ($file->success)
 						{
 						{
@@ -1488,7 +1497,20 @@ class SimplePie
 						}
 						}
 						else
 						else
 						{
 						{
-							unset($file);
+							$this->error = $file->error;	//FreshRSS
+							return !empty($this->data);	//FreshRSS
+							//unset($file);	//FreshRSS removed
+						}
+					}
+					{	//FreshRSS
+						$md5 = $this->cleanMd5($file->body);
+						if ($this->data['md5'] === $md5) {
+							syslog(LOG_DEBUG, 'SimplePie MD5 cache match for ' . $this->feed_url);
+							$cache->touch();
+							return true;	//Content unchanged even though server did not send a 304
+						} else {
+							syslog(LOG_DEBUG, 'SimplePie MD5 cache no match for ' . $this->feed_url);
+							$this->data['md5'] = $md5;
 						}
 						}
 					}
 					}
 				}
 				}
@@ -1557,6 +1579,7 @@ class SimplePie
 				{
 				{
 					$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
 					$this->data = array('url' => $this->feed_url, 'feed_url' => $file->url, 'build' => SIMPLEPIE_BUILD);
 					$this->data['mtime'] = time();	//FreshRSS
 					$this->data['mtime'] = time();	//FreshRSS
+					$this->data['md5'] = empty($md5) ? $this->cleanMd5($file->body) : $md5;	//FreshRSS
 					if (!$cache->save($this))
 					if (!$cache->save($this))
 					{
 					{
 						trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);
 						trigger_error("$this->cache_location is not writeable. Make sure you've set the correct relative or absolute path, and that the location is server-writable.", E_USER_WARNING);

+ 21 - 4
p/scripts/main.js

@@ -20,6 +20,16 @@ function redirect(url, new_tab) {
 	}
 	}
 }
 }
 
 
+function needsScroll($elem) {
+	var $win = $(window),
+		winTop = $win.scrollTop(),
+		winHeight = $win.height(),
+		winBottom = winTop + winHeight,
+		elemTop = $elem.offset().top,
+		elemBottom = elemTop + $elem.outerHeight();
+	return (elemTop < winTop || elemBottom > winBottom) ? elemTop - (winHeight / 2) : 0;
+}
+
 function str2int(str) {
 function str2int(str) {
 	if (str == '') {
 	if (str == '') {
 		return 0;
 		return 0;
@@ -172,12 +182,14 @@ function mark_favorite(active) {
 }
 }
 
 
 function toggleContent(new_active, old_active) {
 function toggleContent(new_active, old_active) {
-	old_active.removeClass("active").removeClass("current");
+	old_active.removeClass("active");
 
 
 	if (new_active.length === 0) {
 	if (new_active.length === 0) {
 		return;
 		return;
 	}
 	}
 
 
+	old_active.removeClass("current");
+
 	if (does_lazyload) {
 	if (does_lazyload) {
 		new_active.find('img[data-original], iframe[data-original]').each(function () {
 		new_active.find('img[data-original], iframe[data-original]').each(function () {
 			this.setAttribute('src', this.getAttribute('data-original'));
 			this.setAttribute('src', this.getAttribute('data-original'));
@@ -322,6 +334,11 @@ function auto_share(key) {
 		}
 		}
 		// Display the share div
 		// Display the share div
 		window.location.hash = share.attr('id');
 		window.location.hash = share.attr('id');
+		// Force scrolling to the share div
+		var scroll = needsScroll(share.closest('.bottom'));
+		if (scroll !== 0) {
+			$('html,body').scrollTop(scroll);
+		}
 		// Force the key value if there is only one action, so we can trigger it automatically
 		// Force the key value if there is only one action, so we can trigger it automatically
 		if (shares.length === 1) {
 		if (shares.length === 1) {
 			key = 1;
 			key = 1;
@@ -553,7 +570,7 @@ function init_shortcuts() {
 
 
 function init_stream(divStream) {
 function init_stream(divStream) {
 	divStream.on('click', '.flux_header', function (e) {	//flux_header_toggle
 	divStream.on('click', '.flux_header', function (e) {	//flux_header_toggle
-		if ($(e.target).closest('.item.website > a').length > 0) {
+		if ($(e.target).closest('.item.website, .item.link').length > 0) {
 			return;
 			return;
 		}
 		}
 		var old_active = $(".flux.current"),
 		var old_active = $(".flux.current"),
@@ -580,7 +597,7 @@ function init_stream(divStream) {
 		return false;
 		return false;
 	});
 	});
 
 
-	divStream.on('click', '.item.title>a', function (e) {
+	divStream.on('click', '.item.title > a', function (e) {
 		if (e.ctrlKey) {
 		if (e.ctrlKey) {
 			return true;	//Allow default control-click behaviour such as open in backround-tab
 			return true;	//Allow default control-click behaviour such as open in backround-tab
 		}
 		}
@@ -593,7 +610,7 @@ function init_stream(divStream) {
 	});
 	});
 
 
 	if (auto_mark_site) {
 	if (auto_mark_site) {
-		divStream.on('click', '.flux .link a', function () {
+		divStream.on('click', '.flux .link > a', function () {
 			mark_read($(this).parent().parent().parent(), true);
 			mark_read($(this).parent().parent().parent(), true);
 		});
 		});
 	}
 	}