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

master
Jason Schwarzenberger 4 years ago
parent 943a1cfa4f
commit 0374794536
  1. 11
      apiserver/feeds/news.py
  2. 4
      webclient/src/Feed.js
  3. 8
      webclient/src/Results.js
  4. 14
      webclient/src/utils.js

@ -139,6 +139,17 @@ class _Base:
s['url'] = ref s['url'] = ref
s['date'] = 0 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) data = extruct.extract(markup)
s = parse_extruct(s, data) s = parse_extruct(s, data)
if s['date']: if s['date']:

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

@ -1,7 +1,7 @@
import React from 'react'; import React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import { Helmet } from 'react-helmet'; import { Helmet } from 'react-helmet';
import { sourceLink, infoLine, logos } from './utils.js'; import { sourceLink, infoLine, getLogoUrl } from './utils.js';
import AbortController from 'abort-controller'; import AbortController from 'abort-controller';
class Results extends React.Component { class Results extends React.Component {
@ -68,7 +68,7 @@ class Results extends React.Component {
<div className='item' key={x.id}> <div className='item' key={x.id}>
<div className='title'> <div className='title'>
<Link className='link' to={'/' + x.id}> <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> </Link>
<span className='source'> <span className='source'>
@ -79,12 +79,12 @@ class Results extends React.Component {
{infoLine(x)} {infoLine(x)}
</div> </div>
) )
: :
<p>none</p> <p>none</p>
} }
</div> </div>
</> </>
: :
<p>loading...</p> <p>loading...</p>
} }
</div> </div>

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save