forked from blallo/rss-bridge
[bridges] Use caching with applicable bridges
This commit is contained in:
parent
e4b314f78a
commit
78f6757622
5 changed files with 25 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
class JapanExpoBridge extends BridgeAbstract{
|
class JapanExpoBridge extends HttpCachingBridgeAbstract {
|
||||||
|
|
||||||
public function loadMetadatas() {
|
public function loadMetadatas() {
|
||||||
$this->maintainer = 'Ginko';
|
$this->maintainer = 'Ginko';
|
||||||
|
@ -64,7 +64,10 @@ class JapanExpoBridge extends BridgeAbstract{
|
||||||
|
|
||||||
if ($fullcontent) {
|
if ($fullcontent) {
|
||||||
if ($count < 5) {
|
if ($count < 5) {
|
||||||
$article_html = $this->getSimpleHTMLDOM($url) or $this->returnServerError('Could not request JapanExpo: '.$url);
|
if($this->get_cached_time($url) <= strtotime('-24 hours'))
|
||||||
|
$this->remove_from_cache($url);
|
||||||
|
|
||||||
|
$article_html = $this->get_cached($url) or $this->returnServerError('Could not request JapanExpo: '.$url);
|
||||||
$header = $article_html->find('header.pageHeadBox', 0);
|
$header = $article_html->find('header.pageHeadBox', 0);
|
||||||
$timestamp = strtotime($header->find('time', 0)->datetime);
|
$timestamp = strtotime($header->find('time', 0)->datetime);
|
||||||
$title_html = $header->find('div.section', 0)->next_sibling();
|
$title_html = $header->find('div.section', 0)->next_sibling();
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
class KununuBridge extends BridgeAbstract{
|
class KununuBridge extends HttpCachingBridgeAbstract {
|
||||||
public function loadMetadatas(){
|
public function loadMetadatas(){
|
||||||
$this->maintainer = "logmanoriginal";
|
$this->maintainer = "logmanoriginal";
|
||||||
$this->name = "Kununu Bridge"; /* This will be replaced later! */
|
$this->name = "Kununu Bridge"; /* This will be replaced later! */
|
||||||
|
@ -248,7 +248,10 @@ class KununuBridge extends BridgeAbstract{
|
||||||
*/
|
*/
|
||||||
private function extract_full_description($uri){
|
private function extract_full_description($uri){
|
||||||
// Load full article
|
// Load full article
|
||||||
$html = $this->getSimpleHTMLDOM($uri);
|
if($this->get_cached_time($uri) <= strtotime('-24 hours'))
|
||||||
|
$this->remove_from_cache($uri);
|
||||||
|
|
||||||
|
$html = $this->get_cached($uri);
|
||||||
if($html === false)
|
if($html === false)
|
||||||
$this->returnServerError('Could not load full description!');
|
$this->returnServerError('Could not load full description!');
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
class LichessBridge extends BridgeAbstract
|
class LichessBridge extends HttpCachingBridgeAbstract
|
||||||
{
|
{
|
||||||
public function loadMetadatas()
|
public function loadMetadatas()
|
||||||
{
|
{
|
||||||
|
@ -36,7 +36,10 @@ class LichessBridge extends BridgeAbstract
|
||||||
|
|
||||||
private function retrieve_lichess_post($blog_post_uri)
|
private function retrieve_lichess_post($blog_post_uri)
|
||||||
{
|
{
|
||||||
$blog_post_html = $this->getSimpleHTMLDOM($blog_post_uri);
|
if($this->get_cached_time($blog_post_uri) <= strtotime('-24 hours'))
|
||||||
|
$this->remove_from_cache($blog_post_uriuri);
|
||||||
|
|
||||||
|
$blog_post_html = $this->get_cached($blog_post_uri);
|
||||||
$blog_post_div = $blog_post_html->find('#lichess_blog', 0);
|
$blog_post_div = $blog_post_html->find('#lichess_blog', 0);
|
||||||
|
|
||||||
$post_chapo = $blog_post_div->find('.shortlede', 0)->innertext;
|
$post_chapo = $blog_post_div->find('.shortlede', 0)->innertext;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?php
|
<?php
|
||||||
class NumeramaBridge extends BridgeAbstract{
|
class NumeramaBridge extends HttpCachingBridgeAbstract {
|
||||||
|
|
||||||
public function loadMetadatas() {
|
public function loadMetadatas() {
|
||||||
|
|
||||||
|
@ -31,7 +31,10 @@ class NumeramaBridge extends BridgeAbstract{
|
||||||
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
|
$item['timestamp'] = strtotime($element->find('pubDate', 0)->plaintext);
|
||||||
|
|
||||||
$article_url = NumeramaStripCDATA($element->find('guid', 0)->plaintext);
|
$article_url = NumeramaStripCDATA($element->find('guid', 0)->plaintext);
|
||||||
$article_html = $this->getSimpleHTMLDOM($article_url) or $this->returnServerError('Could not request Numerama: '.$article_url);
|
if($this->get_cached_time($article_url) <= strtotime('-24 hours'))
|
||||||
|
$this->remove_from_cache($article_url);
|
||||||
|
|
||||||
|
$article_html = $this->get_cached($article_url) or $this->returnServerError('Could not request Numerama: '.$article_url);
|
||||||
$contents = $article_html->find('section[class=related-article]', 0)->innertext = ''; // remove related articles block
|
$contents = $article_html->find('section[class=related-article]', 0)->innertext = ''; // remove related articles block
|
||||||
$contents = '<img alt="" style="max-width:300px;" src="'.$article_html->find('meta[property=og:image]', 0)->getAttribute('content').'">'; // add post picture
|
$contents = '<img alt="" style="max-width:300px;" src="'.$article_html->find('meta[property=og:image]', 0)->getAttribute('content').'">'; // add post picture
|
||||||
$contents = $contents.$article_html->find('article[class=post-content]', 0)->innertext; // extract the post
|
$contents = $contents.$article_html->find('article[class=post-content]', 0)->innertext; // extract the post
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
define('WORDPRESS_TYPE_ATOM', 1); // Content is of type ATOM
|
define('WORDPRESS_TYPE_ATOM', 1); // Content is of type ATOM
|
||||||
define('WORDPRESS_TYPE_RSS', 2); // Content is of type RSS
|
define('WORDPRESS_TYPE_RSS', 2); // Content is of type RSS
|
||||||
class WordPressBridge extends BridgeAbstract {
|
class WordPressBridge extends HttpCachingBridgeAbstract {
|
||||||
|
|
||||||
private $url;
|
private $url;
|
||||||
public $sitename; // Name of the site
|
public $sitename; // Name of the site
|
||||||
|
@ -95,7 +95,10 @@ class WordPressBridge extends BridgeAbstract {
|
||||||
$item['timestamp'] = strtotime($article->find('updated', 0)->innertext);
|
$item['timestamp'] = strtotime($article->find('updated', 0)->innertext);
|
||||||
}
|
}
|
||||||
|
|
||||||
$article_html = $this->getSimpleHTMLDOM($item['uri']);
|
if($this->get_cached_time($item['uri']) <= strtotime('-24 hours'))
|
||||||
|
$this->remove_from_cache($item['uri']);
|
||||||
|
|
||||||
|
$article_html = $this->get_cached($item['uri']);
|
||||||
|
|
||||||
// Attempt to find most common content div
|
// Attempt to find most common content div
|
||||||
if(!isset($item['content'])){
|
if(!isset($item['content'])){
|
||||||
|
|
Loading…
Reference in a new issue