mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Replace picture with image
This commit is contained in:
parent
c5eb223c07
commit
4969391d4c
9 changed files with 32 additions and 17 deletions
|
|
@ -62,6 +62,9 @@ export enum PageType {
|
|||
Unknown = 'UNKNOWN',
|
||||
Website = 'WEBSITE',
|
||||
Highlights = 'HIGHLIGHTS',
|
||||
TWEET = 'TWEET',
|
||||
VIDEO = 'VIDEO',
|
||||
IMAGE = 'IMAGE',
|
||||
}
|
||||
|
||||
export enum ArticleSavingRequestStatus {
|
||||
|
|
|
|||
|
|
@ -1683,7 +1683,7 @@ export enum PageType {
|
|||
Book = 'BOOK',
|
||||
File = 'FILE',
|
||||
Highlights = 'HIGHLIGHTS',
|
||||
Picture = 'PICTURE',
|
||||
Image = 'IMAGE',
|
||||
Profile = 'PROFILE',
|
||||
Tweet = 'TWEET',
|
||||
Unknown = 'UNKNOWN',
|
||||
|
|
|
|||
|
|
@ -1219,7 +1219,7 @@ enum PageType {
|
|||
BOOK
|
||||
FILE
|
||||
HIGHLIGHTS
|
||||
PICTURE
|
||||
IMAGE
|
||||
PROFILE
|
||||
TWEET
|
||||
UNKNOWN
|
||||
|
|
|
|||
|
|
@ -311,7 +311,7 @@ const schema = gql`
|
|||
UNKNOWN
|
||||
TWEET
|
||||
VIDEO
|
||||
PICTURE
|
||||
IMAGE
|
||||
}
|
||||
|
||||
type Page {
|
||||
|
|
|
|||
|
|
@ -1,29 +1,29 @@
|
|||
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
||||
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
||||
/* eslint-disable @typescript-eslint/no-unused-vars */
|
||||
import { preParseContent } from '@omnivore/content-handler'
|
||||
import { Readability } from '@omnivore/readability'
|
||||
import createDOMPurify, { SanitizeElementHookEvent } from 'dompurify'
|
||||
import { PageType, PreparedDocumentInput } from '../generated/graphql'
|
||||
import { buildLogger, LogRecord } from './logger'
|
||||
import { createImageProxyUrl } from './imageproxy'
|
||||
import addressparser from 'addressparser'
|
||||
import axios from 'axios'
|
||||
import createDOMPurify, { SanitizeElementHookEvent } from 'dompurify'
|
||||
import * as hljs from 'highlightjs'
|
||||
import { decode } from 'html-entities'
|
||||
import * as jwt from 'jsonwebtoken'
|
||||
import { parseHTML } from 'linkedom'
|
||||
import { getRepository } from '../entity/utils'
|
||||
import { User } from '../entity/user'
|
||||
import { NodeHtmlMarkdown } from 'node-html-markdown'
|
||||
import { ILike } from 'typeorm'
|
||||
import { promisify } from 'util'
|
||||
import { v4 as uuid } from 'uuid'
|
||||
import addressparser from 'addressparser'
|
||||
import { preParseContent } from '@omnivore/content-handler'
|
||||
import { User } from '../entity/user'
|
||||
import { getRepository } from '../entity/utils'
|
||||
import { env } from '../env'
|
||||
import { PageType, PreparedDocumentInput } from '../generated/graphql'
|
||||
import {
|
||||
EmbeddedHighlightData,
|
||||
findEmbeddedHighlight,
|
||||
} from './highlightGenerator'
|
||||
import { NodeHtmlMarkdown } from 'node-html-markdown'
|
||||
import { promisify } from 'util'
|
||||
import * as jwt from 'jsonwebtoken'
|
||||
import { env } from '../env'
|
||||
import { createImageProxyUrl } from './imageproxy'
|
||||
import { buildLogger, LogRecord } from './logger'
|
||||
|
||||
const logger = buildLogger('utils.parse')
|
||||
const signToken = promisify(jwt.sign)
|
||||
|
|
@ -118,12 +118,20 @@ const parseOriginalContent = (document: Document): PageType => {
|
|||
return PageType.Profile
|
||||
case 'website':
|
||||
return PageType.Website
|
||||
case 'tweet':
|
||||
return PageType.Tweet
|
||||
case 'image':
|
||||
return PageType.Image
|
||||
default:
|
||||
if (content.toLowerCase().startsWith('video')) {
|
||||
return PageType.Video
|
||||
}
|
||||
return PageType.Unknown
|
||||
}
|
||||
} catch (error) {
|
||||
logger.error('Error extracting og:type from content', error)
|
||||
return PageType.Unknown
|
||||
}
|
||||
|
||||
return PageType.Unknown
|
||||
}
|
||||
|
||||
const getPurifiedContent = (html: string): Document => {
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ export class ImageHandler extends ContentHandler {
|
|||
<title>${title}</title>
|
||||
<meta property="og:image" content="${url}" />
|
||||
<meta property="og:title" content="${title}" />
|
||||
<meta property="og:type" content="image" />
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ export class PipedVideoHandler extends ContentHandler {
|
|||
<meta property="og:article:author" content="${authorName}" />
|
||||
<meta property="og:site_name" content="Piped Video" />
|
||||
<meta property="article:published_time" content="${metadata.uploadDate}" />
|
||||
<meta property="og:type" content="video" />
|
||||
</head>
|
||||
<body>
|
||||
<iframe width="${width}" height="${height}" src="${src}" title="${escapedTitle}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
|
|
|
|||
|
|
@ -376,6 +376,7 @@ export class TwitterHandler extends ContentHandler {
|
|||
<meta property="og:description" content="${description}" />
|
||||
<meta property="article:published_time" content="${tweetData.created_at}" />
|
||||
<meta property="og:site_name" content="Twitter" />
|
||||
<meta property="og:type" content="tweet" />
|
||||
</head>
|
||||
<body>
|
||||
<div>
|
||||
|
|
|
|||
|
|
@ -83,6 +83,7 @@ export class YoutubeHandler extends ContentHandler {
|
|||
<meta property="og:description" content="" />
|
||||
<meta property="og:article:author" content="${authorName}" />
|
||||
<meta property="og:site_name" content="YouTube" />
|
||||
<meta property="og:type" content="video" />
|
||||
</head>
|
||||
<body>
|
||||
<iframe width="${width}" height="${height}" src="${src}" title="${escapedTitle}" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
|
||||
|
|
|
|||
Loading…
Reference in a new issue