1
1
Fork 0
mirror of https://code.mensbeam.com/MensBeam/Arsse.git synced 2024-12-22 21:22:40 +00:00

Change favicon to icon_url and add icon_id

This commit is contained in:
J. King 2021-01-15 23:15:22 -05:00
parent 2536c9fe03
commit e74b44cc39
7 changed files with 26 additions and 24 deletions

View file

@ -762,7 +762,8 @@ class Database {
* - "url": The URL of the newsfeed, after discovery and HTTP redirects * - "url": The URL of the newsfeed, after discovery and HTTP redirects
* - "title": The title of the newsfeed * - "title": The title of the newsfeed
* - "source": The URL of the source of the newsfeed i.e. its parent Web site * - "source": The URL of the source of the newsfeed i.e. its parent Web site
* - "favicon": The URL of an icon representing the newsfeed or its source * - "icon_id": The numeric identifier of an icon representing the newsfeed or its source
* - "icon_url": The URL of an icon representing the newsfeed or its source
* - "folder": The numeric identifier (or null) of the subscription's folder * - "folder": The numeric identifier (or null) of the subscription's folder
* - "top_folder": The numeric identifier (or null) of the top-level folder for the subscription * - "top_folder": The numeric identifier (or null) of the top-level folder for the subscription
* - "pinned": Whether the subscription is pinned * - "pinned": Whether the subscription is pinned
@ -795,7 +796,8 @@ class Database {
f.updated as updated, f.updated as updated,
f.modified as edited, f.modified as edited,
s.modified as modified, s.modified as modified,
i.url as favicon, i.id as icon_id,
i.url as icon_url,
t.top as top_folder, t.top as top_folder,
coalesce(s.title, f.title) as title, coalesce(s.title, f.title) as title,
coalesce((articles - hidden - marked), articles) as unread coalesce((articles - hidden - marked), articles) as unread

View file

@ -181,7 +181,7 @@ class V1_2 extends \JKingWeb\Arsse\REST\AbstractHandler {
'added' => "added", 'added' => "added",
'pinned' => "pinned", 'pinned' => "pinned",
'link' => "source", 'link' => "source",
'faviconLink' => "favicon", 'faviconLink' => "icon_url",
'folderId' => "top_folder", 'folderId' => "top_folder",
'unreadCount' => "unread", 'unreadCount' => "unread",
'ordering' => "order_type", 'ordering' => "order_type",

View file

@ -256,7 +256,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
// prepare data for each subscription; we also add unread counts for their host categories // prepare data for each subscription; we also add unread counts for their host categories
foreach (Arsse::$db->subscriptionList($user) as $f) { foreach (Arsse::$db->subscriptionList($user) as $f) {
// add the feed to the list of feeds // add the feed to the list of feeds
$feeds[] = ['id' => (string) $f['id'], 'updated' => Date::transform($f['updated'], "iso8601", "sql"),'counter' => (int) $f['unread'], 'has_img' => (int) (strlen((string) $f['favicon']) > 0)]; // ID is cast to string for consistency with TTRSS $feeds[] = ['id' => (string) $f['id'], 'updated' => Date::transform($f['updated'], "iso8601", "sql"),'counter' => (int) $f['unread'], 'has_img' => (int) (strlen((string) $f['icon_url']) > 0)]; // ID is cast to string for consistency with TTRSS
// add the feed's unread count to the global unread count // add the feed's unread count to the global unread count
$countAll += $f['unread']; $countAll += $f['unread'];
// add the feed's unread count to its category unread count // add the feed's unread count to its category unread count
@ -441,7 +441,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
'name' => $s['title'], 'name' => $s['title'],
'id' => "FEED:".$s['id'], 'id' => "FEED:".$s['id'],
'bare_id' => (int) $s['id'], 'bare_id' => (int) $s['id'],
'icon' => $s['favicon'] ? "feed-icons/".$s['id'].".ico" : false, 'icon' => $s['icon_url'] ? "feed-icons/".$s['id'].".ico" : false,
'error' => (string) $s['err_msg'], 'error' => (string) $s['err_msg'],
'param' => Date::transform($s['updated'], "iso8601", "sql"), 'param' => Date::transform($s['updated'], "iso8601", "sql"),
'unread' => 0, 'unread' => 0,
@ -794,7 +794,7 @@ class API extends \JKingWeb\Arsse\REST\AbstractHandler {
'unread' => (int) $s['unread'], 'unread' => (int) $s['unread'],
'cat_id' => (int) $s['folder'], 'cat_id' => (int) $s['folder'],
'feed_url' => $s['url'], 'feed_url' => $s['url'],
'has_icon' => (bool) $s['favicon'], 'has_icon' => (bool) $s['icon_url'],
'last_updated' => (int) Date::transform($s['updated'], "unix", "sql"), 'last_updated' => (int) Date::transform($s['updated'], "unix", "sql"),
'order_id' => $order, 'order_id' => $order,
]; ];

View file

@ -22,12 +22,12 @@ class TestOPML extends \JKingWeb\Arsse\Test\AbstractTest {
['id' => 1, 'parent' => null, 'children' => 1, 'feeds' => 1, 'name' => "Science"], ['id' => 1, 'parent' => null, 'children' => 1, 'feeds' => 1, 'name' => "Science"],
]; ];
protected $subscriptions = [ protected $subscriptions = [
['id' => 3, 'folder' => 1, 'top_folder' => 1, 'unread' => 2, 'updated' => "2016-05-23 06:40:02", 'err_msg' => 'argh', 'title' => 'Ars Technica', 'url' => "http://localhost:8000/3", 'favicon' => 'http://localhost:8000/3.png'], ['id' => 3, 'folder' => 1, 'top_folder' => 1, 'unread' => 2, 'updated' => "2016-05-23 06:40:02", 'err_msg' => 'argh', 'title' => 'Ars Technica', 'url' => "http://localhost:8000/3", 'icon_url' => 'http://localhost:8000/3.png'],
['id' => 4, 'folder' => 6, 'top_folder' => 3, 'unread' => 6, 'updated' => "2017-10-09 15:58:34", 'err_msg' => '', 'title' => 'CBC News', 'url' => "http://localhost:8000/4", 'favicon' => 'http://localhost:8000/4.png'], ['id' => 4, 'folder' => 6, 'top_folder' => 3, 'unread' => 6, 'updated' => "2017-10-09 15:58:34", 'err_msg' => '', 'title' => 'CBC News', 'url' => "http://localhost:8000/4", 'icon_url' => 'http://localhost:8000/4.png'],
['id' => 6, 'folder' => null, 'top_folder' => null, 'unread' => 0, 'updated' => "2010-02-12 20:08:47", 'err_msg' => '', 'title' => 'Eurogamer', 'url' => "http://localhost:8000/6", 'favicon' => 'http://localhost:8000/6.png'], ['id' => 6, 'folder' => null, 'top_folder' => null, 'unread' => 0, 'updated' => "2010-02-12 20:08:47", 'err_msg' => '', 'title' => 'Eurogamer', 'url' => "http://localhost:8000/6", 'icon_url' => 'http://localhost:8000/6.png'],
['id' => 1, 'folder' => 2, 'top_folder' => 1, 'unread' => 5, 'updated' => "2017-09-15 22:54:16", 'err_msg' => '', 'title' => 'NASA JPL', 'url' => "http://localhost:8000/1", 'favicon' => null], ['id' => 1, 'folder' => 2, 'top_folder' => 1, 'unread' => 5, 'updated' => "2017-09-15 22:54:16", 'err_msg' => '', 'title' => 'NASA JPL', 'url' => "http://localhost:8000/1", 'icon_url' => null],
['id' => 5, 'folder' => 6, 'top_folder' => 3, 'unread' => 12, 'updated' => "2017-07-07 17:07:17", 'err_msg' => '', 'title' => 'Ottawa Citizen', 'url' => "http://localhost:8000/5", 'favicon' => ''], ['id' => 5, 'folder' => 6, 'top_folder' => 3, 'unread' => 12, 'updated' => "2017-07-07 17:07:17", 'err_msg' => '', 'title' => 'Ottawa Citizen', 'url' => "http://localhost:8000/5", 'icon_url' => ''],
['id' => 2, 'folder' => 5, 'top_folder' => 3, 'unread' => 10, 'updated' => "2011-11-11 11:11:11", 'err_msg' => 'oops', 'title' => 'Toronto Star', 'url' => "http://localhost:8000/2", 'favicon' => 'http://localhost:8000/2.png'], ['id' => 2, 'folder' => 5, 'top_folder' => 3, 'unread' => 10, 'updated' => "2011-11-11 11:11:11", 'err_msg' => 'oops', 'title' => 'Toronto Star', 'url' => "http://localhost:8000/2", 'icon_url' => 'http://localhost:8000/2.png'],
]; ];
protected $tags = [ protected $tags = [
['id' => 1, 'name' => "Canada", 'subscription' => 2], ['id' => 1, 'name' => "Canada", 'subscription' => 2],

View file

@ -273,9 +273,9 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
public function testListFeeds(): void { public function testListFeeds(): void {
\Phake::when(Arsse::$db)->subscriptionList(Arsse::$user->id)->thenReturn(new Result([ \Phake::when(Arsse::$db)->subscriptionList(Arsse::$user->id)->thenReturn(new Result([
['id' => 1, 'feed' => 5, 'title' => "Ankh-Morpork News", 'url' => "http://example.com/feed", 'source' => "http://example.com/", 'edited' => "2019-01-01 21:12:00", 'favicon' => "http://example.com/favicon.ico"], ['id' => 1, 'feed' => 5, 'title' => "Ankh-Morpork News", 'url' => "http://example.com/feed", 'source' => "http://example.com/", 'edited' => "2019-01-01 21:12:00", 'icon_url' => "http://example.com/favicon.ico"],
['id' => 2, 'feed' => 9, 'title' => "Ook, Ook Eek Ook!", 'url' => "http://example.net/feed", 'source' => "http://example.net/", 'edited' => "1988-06-24 12:21:00", 'favicon' => ""], ['id' => 2, 'feed' => 9, 'title' => "Ook, Ook Eek Ook!", 'url' => "http://example.net/feed", 'source' => "http://example.net/", 'edited' => "1988-06-24 12:21:00", 'icon_url' => ""],
['id' => 3, 'feed' => 1, 'title' => "The Last Soul", 'url' => "http://example.org/feed", 'source' => "http://example.org/", 'edited' => "1991-08-12 03:22:00", 'favicon' => "http://example.org/favicon.ico"], ['id' => 3, 'feed' => 1, 'title' => "The Last Soul", 'url' => "http://example.org/feed", 'source' => "http://example.org/", 'edited' => "1991-08-12 03:22:00", 'icon_url' => "http://example.org/favicon.ico"],
])); ]));
\Phake::when(Arsse::$db)->tagSummarize(Arsse::$user->id)->thenReturn(new Result([ \Phake::when(Arsse::$db)->tagSummarize(Arsse::$user->id)->thenReturn(new Result([
['id' => 1, 'name' => "Fascinating", 'subscription' => 1], ['id' => 1, 'name' => "Fascinating", 'subscription' => 1],

View file

@ -28,7 +28,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
[ [
'id' => 2112, 'id' => 2112,
'url' => 'http://example.com/news.atom', 'url' => 'http://example.com/news.atom',
'favicon' => 'http://example.com/favicon.png', 'icon_url' => 'http://example.com/favicon.png',
'source' => 'http://example.com/', 'source' => 'http://example.com/',
'folder' => null, 'folder' => null,
'top_folder' => null, 'top_folder' => null,
@ -43,7 +43,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
[ [
'id' => 42, 'id' => 42,
'url' => 'http://example.org/news.atom', 'url' => 'http://example.org/news.atom',
'favicon' => 'http://example.org/favicon.png', 'icon_url' => 'http://example.org/favicon.png',
'source' => 'http://example.org/', 'source' => 'http://example.org/',
'folder' => 12, 'folder' => 12,
'top_folder' => 8, 'top_folder' => 8,
@ -58,7 +58,7 @@ class TestV1_2 extends \JKingWeb\Arsse\Test\AbstractTest {
[ [
'id' => 47, 'id' => 47,
'url' => 'http://example.net/news.atom', 'url' => 'http://example.net/news.atom',
'favicon' => 'http://example.net/favicon.png', 'icon_url' => 'http://example.net/favicon.png',
'source' => 'http://example.net/', 'source' => 'http://example.net/',
'folder' => null, 'folder' => null,
'top_folder' => null, 'top_folder' => null,

View file

@ -40,12 +40,12 @@ class TestAPI extends \JKingWeb\Arsse\Test\AbstractTest {
['id' => 1, 'parent' => null, 'children' => 1, 'feeds' => 1, 'name' => "Science"], ['id' => 1, 'parent' => null, 'children' => 1, 'feeds' => 1, 'name' => "Science"],
]; ];
protected $subscriptions = [ protected $subscriptions = [
['id' => 3, 'folder' => 1, 'top_folder' => 1, 'unread' => 2, 'updated' => "2016-05-23 06:40:02", 'err_msg' => 'argh', 'title' => 'Ars Technica', 'url' => " http://example.com/3", 'favicon' => 'http://example.com/3.png'], ['id' => 3, 'folder' => 1, 'top_folder' => 1, 'unread' => 2, 'updated' => "2016-05-23 06:40:02", 'err_msg' => 'argh', 'title' => 'Ars Technica', 'url' => " http://example.com/3", 'icon_url' => 'http://example.com/3.png'],
['id' => 4, 'folder' => 6, 'top_folder' => 3, 'unread' => 6, 'updated' => "2017-10-09 15:58:34", 'err_msg' => '', 'title' => 'CBC News', 'url' => " http://example.com/4", 'favicon' => 'http://example.com/4.png'], ['id' => 4, 'folder' => 6, 'top_folder' => 3, 'unread' => 6, 'updated' => "2017-10-09 15:58:34", 'err_msg' => '', 'title' => 'CBC News', 'url' => " http://example.com/4", 'icon_url' => 'http://example.com/4.png'],
['id' => 6, 'folder' => null, 'top_folder' => null, 'unread' => 0, 'updated' => "2010-02-12 20:08:47", 'err_msg' => '', 'title' => 'Eurogamer', 'url' => " http://example.com/6", 'favicon' => 'http://example.com/6.png'], ['id' => 6, 'folder' => null, 'top_folder' => null, 'unread' => 0, 'updated' => "2010-02-12 20:08:47", 'err_msg' => '', 'title' => 'Eurogamer', 'url' => " http://example.com/6", 'icon_url' => 'http://example.com/6.png'],
['id' => 1, 'folder' => 2, 'top_folder' => 1, 'unread' => 5, 'updated' => "2017-09-15 22:54:16", 'err_msg' => '', 'title' => 'NASA JPL', 'url' => " http://example.com/1", 'favicon' => null], ['id' => 1, 'folder' => 2, 'top_folder' => 1, 'unread' => 5, 'updated' => "2017-09-15 22:54:16", 'err_msg' => '', 'title' => 'NASA JPL', 'url' => " http://example.com/1", 'icon_url' => null],
['id' => 5, 'folder' => 6, 'top_folder' => 3, 'unread' => 12, 'updated' => "2017-07-07 17:07:17", 'err_msg' => '', 'title' => 'Ottawa Citizen', 'url' => " http://example.com/5", 'favicon' => ''], ['id' => 5, 'folder' => 6, 'top_folder' => 3, 'unread' => 12, 'updated' => "2017-07-07 17:07:17", 'err_msg' => '', 'title' => 'Ottawa Citizen', 'url' => " http://example.com/5", 'icon_url' => ''],
['id' => 2, 'folder' => 5, 'top_folder' => 3, 'unread' => 10, 'updated' => "2011-11-11 11:11:11", 'err_msg' => 'oops', 'title' => 'Toronto Star', 'url' => " http://example.com/2", 'favicon' => 'http://example.com/2.png'], ['id' => 2, 'folder' => 5, 'top_folder' => 3, 'unread' => 10, 'updated' => "2011-11-11 11:11:11", 'err_msg' => 'oops', 'title' => 'Toronto Star', 'url' => " http://example.com/2", 'icon_url' => 'http://example.com/2.png'],
]; ];
protected $labels = [ protected $labels = [
['id' => 3, 'articles' => 100, 'read' => 94, 'unread' => 6, 'name' => "Fascinating"], ['id' => 3, 'articles' => 100, 'read' => 94, 'unread' => 6, 'name' => "Fascinating"],