diff options
author | ArthurHoaro <arthur@hoa.ro> | 2019-02-09 14:13:08 +0100 |
---|---|---|
committer | ArthurHoaro <arthur@hoa.ro> | 2019-02-24 12:25:50 +0100 |
commit | a8e7da01146455f13ef06b151a7dafedd3acf769 (patch) | |
tree | b8278b8fb78fd40183e4273e880b85555358c6de /application | |
parent | 905f8675a728841b03b300d2c7dc909a1c4f7f03 (diff) | |
download | Shaarli-a8e7da01146455f13ef06b151a7dafedd3acf769.tar.gz Shaarli-a8e7da01146455f13ef06b151a7dafedd3acf769.tar.zst Shaarli-a8e7da01146455f13ef06b151a7dafedd3acf769.zip |
Do not try to retrieve thumbnails for internal link
Also adds a helper function to determine if a link is a note and apply it across multiple files.
Diffstat (limited to 'application')
-rw-r--r-- | application/api/ApiUtils.php | 2 | ||||
-rw-r--r-- | application/bookmark/LinkUtils.php | 13 | ||||
-rw-r--r-- | application/feed/FeedBuilder.php | 4 | ||||
-rw-r--r-- | application/netscape/NetscapeBookmarkUtils.php | 2 |
4 files changed, 17 insertions, 4 deletions
diff --git a/application/api/ApiUtils.php b/application/api/ApiUtils.php index 1824b5d0..1e3ac02e 100644 --- a/application/api/ApiUtils.php +++ b/application/api/ApiUtils.php | |||
@@ -59,7 +59,7 @@ class ApiUtils | |||
59 | { | 59 | { |
60 | $out['id'] = $link['id']; | 60 | $out['id'] = $link['id']; |
61 | // Not an internal link | 61 | // Not an internal link |
62 | if ($link['url'][0] != '?') { | 62 | if (! is_note($link['url'])) { |
63 | $out['url'] = $link['url']; | 63 | $out['url'] = $link['url']; |
64 | } else { | 64 | } else { |
65 | $out['url'] = $indexUrl . $link['url']; | 65 | $out['url'] = $indexUrl . $link['url']; |
diff --git a/application/bookmark/LinkUtils.php b/application/bookmark/LinkUtils.php index de5b61cb..9e9d4f0a 100644 --- a/application/bookmark/LinkUtils.php +++ b/application/bookmark/LinkUtils.php | |||
@@ -220,3 +220,16 @@ function link_small_hash($date, $id) | |||
220 | { | 220 | { |
221 | return smallHash($date->format(LinkDB::LINK_DATE_FORMAT) . $id); | 221 | return smallHash($date->format(LinkDB::LINK_DATE_FORMAT) . $id); |
222 | } | 222 | } |
223 | |||
224 | /** | ||
225 | * Returns whether or not the link is an internal note. | ||
226 | * Its URL starts by `?` because it's actually a permalink. | ||
227 | * | ||
228 | * @param string $linkUrl | ||
229 | * | ||
230 | * @return bool true if internal note, false otherwise. | ||
231 | */ | ||
232 | function is_note($linkUrl) | ||
233 | { | ||
234 | return isset($linkUrl[0]) && $linkUrl[0] === '?'; | ||
235 | } | ||
diff --git a/application/feed/FeedBuilder.php b/application/feed/FeedBuilder.php index b66f2f91..fec0452b 100644 --- a/application/feed/FeedBuilder.php +++ b/application/feed/FeedBuilder.php | |||
@@ -147,8 +147,8 @@ class FeedBuilder | |||
147 | protected function buildItem($link, $pageaddr) | 147 | protected function buildItem($link, $pageaddr) |
148 | { | 148 | { |
149 | $link['guid'] = $pageaddr . '?' . $link['shorturl']; | 149 | $link['guid'] = $pageaddr . '?' . $link['shorturl']; |
150 | // Check for both signs of a note: starting with ? and 7 chars long. | 150 | // Prepend the root URL for notes |
151 | if ($link['url'][0] === '?' && strlen($link['url']) === 7) { | 151 | if (is_note($link['url'])) { |
152 | $link['url'] = $pageaddr . $link['url']; | 152 | $link['url'] = $pageaddr . $link['url']; |
153 | } | 153 | } |
154 | if ($this->usePermalinks === true) { | 154 | if ($this->usePermalinks === true) { |
diff --git a/application/netscape/NetscapeBookmarkUtils.php b/application/netscape/NetscapeBookmarkUtils.php index 2fb1a4a6..28665941 100644 --- a/application/netscape/NetscapeBookmarkUtils.php +++ b/application/netscape/NetscapeBookmarkUtils.php | |||
@@ -54,7 +54,7 @@ class NetscapeBookmarkUtils | |||
54 | $link['timestamp'] = $date->getTimestamp(); | 54 | $link['timestamp'] = $date->getTimestamp(); |
55 | $link['taglist'] = str_replace(' ', ',', $link['tags']); | 55 | $link['taglist'] = str_replace(' ', ',', $link['tags']); |
56 | 56 | ||
57 | if (startsWith($link['url'], '?') && $prependNoteUrl) { | 57 | if (is_note($link['url']) && $prependNoteUrl) { |
58 | $link['url'] = $indexUrl . $link['url']; | 58 | $link['url'] = $indexUrl . $link['url']; |
59 | } | 59 | } |
60 | 60 | ||