Sitemap and Category to get favicon into icon property of story.

This commit is contained in:
Jason Schwarzenberger 2020-11-10 15:22:27 +13:00
parent 943a1cfa4f
commit 0374794536
4 changed files with 26 additions and 11 deletions

View File

@ -139,6 +139,17 @@ class _Base:
s['url'] = ref
s['date'] = 0
soup = BeautifulSoup(markup, features='html.parser')
icon32 = soup.find_all('link', rel="icon", href=True, sizes="32x32")
icon16 = soup.find_all('link', rel="icon", href=True, sizes="16x16")
favicon = soup.find_all('link', rel="shortcut icon", href=True)
others = soup.find_all('link', rel="icon", href=True)
icons = icon32 + icon16 + favicon + others
icons = list(set([i.get('href') for i in icons]))
if icons:
s['icon'] = icons[0]
data = extruct.extract(markup)
s = parse_extruct(s, data)
if s['date']:

View File

@ -2,7 +2,7 @@ import React from 'react';
import { Link } from 'react-router-dom';
import { Helmet } from 'react-helmet';
import localForage from 'localforage';
import { sourceLink, infoLine, logos } from './utils.js';
import { sourceLink, infoLine, getLogoUrl } from './utils.js';
class Feed extends React.Component {
constructor(props) {
@ -62,7 +62,7 @@ class Feed extends React.Component {
<div className='item' key={x.id}>
<div className='title'>
<Link className='link' to={'/' + x.id}>
<img className='source-logo' src={logos[x.source] || logos[x.source.split(' ')[0]]} alt='source logo' /> {x.title}
<img className='source-logo' src={getLogoUrl(x)} alt='source logo' /> {x.title}
</Link>
<span className='source'>

View File

@ -1,7 +1,7 @@
import React from 'react';
import { Link } from 'react-router-dom';
import { Helmet } from 'react-helmet';
import { sourceLink, infoLine, logos } from './utils.js';
import { sourceLink, infoLine, getLogoUrl } from './utils.js';
import AbortController from 'abort-controller';
class Results extends React.Component {
@ -68,7 +68,7 @@ class Results extends React.Component {
<div className='item' key={x.id}>
<div className='title'>
<Link className='link' to={'/' + x.id}>
<img className='source-logo' src={logos[x.source]} alt='source logo' /> {x.title}
<img className='source-logo' src={getLogoUrl(x)} alt='source logo' /> {x.title}
</Link>
<span className='source'>

File diff suppressed because one or more lines are too long