aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Corentin Garcia <corenting@gmail.com> 2018-09-09 21:30:29 +0200
committerGravatar Teromene <teromene@teromene.fr> 2018-09-09 20:30:29 +0100
commit111c45d0100b5f11a544c47b7bc020ac5342b6eb (patch)
tree7533d888e7bd714092a2268b8457c5bd98f3afc8
parent55b36b0455e5f2b808e927c553b880a9eb78cf0a (diff)
downloadrss-bridge-111c45d0100b5f11a544c47b7bc020ac5342b6eb.tar.gz
rss-bridge-111c45d0100b5f11a544c47b7bc020ac5342b6eb.tar.zst
rss-bridge-111c45d0100b5f11a544c47b7bc020ac5342b6eb.zip
[GithubSearchBridge] Fix content parsing, add tags if present (#803)
* [GithubSearchBridge] Fix content parsing, add tags if present * [GithubSearchBridge] Add categories (from tags)
-rw-r--r--bridges/GithubSearchBridge.php24
1 files changed, 20 insertions, 4 deletions
diff --git a/bridges/GithubSearchBridge.php b/bridges/GithubSearchBridge.php
index d3a615b5..fe8a721a 100644
--- a/bridges/GithubSearchBridge.php
+++ b/bridges/GithubSearchBridge.php
@@ -34,13 +34,29 @@ class GithubSearchBridge extends BridgeAbstract {
$title = $element->find('h3', 0)->plaintext;
$item['title'] = $title;
- if (count($element->find('p')) == 2) {
- $content = $element->find('p', 0)->innertext;
+ // Description
+ if (count($element->find('p.d-inline-block')) != 0) {
+ $content = $element->find('p.d-inline-block', 0)->innertext;
} else{
- $content = '';
+ $content = 'No description';
+ }
+
+ // Tags
+ $content = $content . '<br />';
+ $tags = $element->find('a.topic-tag');
+ $tags_array = array();
+ if (count($tags) != 0) {
+ $content = $content . 'Tags : ';
+ foreach($tags as $tag_element) {
+ $tag_link = 'https://github.com' . $tag_element->href;
+ $tag_name = trim($tag_element->innertext);
+ $content = $content . '<a href="' . $tag_link . '">' . $tag_name . '</a> ';
+ array_push($tags_array, $tag_element->innertext);
+ }
}
- $item['content'] = $content;
+ $item['categories'] = $tags_array;
+ $item['content'] = $content;
$date = $element->find('relative-time', 0)->datetime;
$item['timestamp'] = strtotime($date);