diff --git a/bridges/LinuxBlogBridge.php b/bridges/LinuxBlogBridge.php new file mode 100644 index 00000000..129ef31b --- /dev/null +++ b/bridges/LinuxBlogBridge.php @@ -0,0 +1,64 @@ +find('ul.display-posts-listing li.listing-item'); + + if (!$articles) { + returnServerError('Failed to retrieve articles'); + } + + foreach ($articles as $article) { + if ($count >= self::MAX_ARTICLES) { + break; + } + + $element = $article->find('a.title', 0); + + if (!$element || empty($element->plaintext) || empty($element->href)) { + continue; + } + + $timestamp = null; + $url = $element->href; + $date = $article->find('span.date', 0); + + if ($date && $date->plaintext) { + $timestamp = strtotime($date->plaintext . ' 00:00:00 GMT'); + } + + $this->items[] = [ + 'content' => $this->constructContent($url), + 'timestamp' => $timestamp, + 'title' => trim($element->plaintext), + 'uid' => $url, + 'uri' => $url, + ]; + + $count++; + } + } + + private function constructContent($url) + { + $dom = getSimpleHTMLDOMCached($url); + $article = $dom->find('section.entry.fix', 0); + + if (!$article) { + return 'Content Not Found'; + } + + return $article->innertext; + } +}