mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Merge pull request #2025 from omnivore-app/feature/content-type
Add TWEET, VIDEO and IMAGE pageType
This commit is contained in:
commit
4db953492b
11 changed files with 42 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,8 +1683,11 @@ export enum PageType {
|
|||
Book = 'BOOK',
|
||||
File = 'FILE',
|
||||
Highlights = 'HIGHLIGHTS',
|
||||
Image = 'IMAGE',
|
||||
Profile = 'PROFILE',
|
||||
Tweet = 'TWEET',
|
||||
Unknown = 'UNKNOWN',
|
||||
Video = 'VIDEO',
|
||||
Website = 'WEBSITE'
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1219,8 +1219,11 @@ enum PageType {
|
|||
BOOK
|
||||
FILE
|
||||
HIGHLIGHTS
|
||||
IMAGE
|
||||
PROFILE
|
||||
TWEET
|
||||
UNKNOWN
|
||||
VIDEO
|
||||
WEBSITE
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -409,7 +409,7 @@ export const getArticleResolver: ResolverFn<
|
|||
Record<string, unknown>,
|
||||
WithDataSourcesContext,
|
||||
QueryArticleArgs
|
||||
> = async (_obj, { slug, format }, { claims, pubsub }, info) => {
|
||||
> = async (_obj, { slug, format }, { claims }, info) => {
|
||||
try {
|
||||
if (!claims?.uid) {
|
||||
return { errorCodes: [ArticleErrorCode.Unauthorized] }
|
||||
|
|
@ -950,7 +950,6 @@ export const searchResolver = authorized<
|
|||
originalArticleUrl: r.url,
|
||||
publishedAt: validatedDate(r.publishedAt),
|
||||
ownedByViewer: r.userId === claims.uid,
|
||||
pageType: r.pageType || PageType.Unknown,
|
||||
siteIcon,
|
||||
} as SearchItem,
|
||||
cursor: endCursor,
|
||||
|
|
@ -1054,7 +1053,6 @@ export const updatesSinceResolver = authorized<
|
|||
p.pageType === PageType.File
|
||||
? ContentReader.Pdf
|
||||
: ContentReader.Web,
|
||||
pageType: p.pageType || PageType.Unknown,
|
||||
} as SearchItem,
|
||||
cursor: endCursor,
|
||||
itemID: p.id,
|
||||
|
|
|
|||
|
|
@ -559,6 +559,9 @@ export const functionResolvers = {
|
|||
}
|
||||
return item.url
|
||||
},
|
||||
pageType(item: SearchItem) {
|
||||
return item.pageType || PageType.Unknown
|
||||
},
|
||||
},
|
||||
...resultResolveTypeResolver('Login'),
|
||||
...resultResolveTypeResolver('LogOut'),
|
||||
|
|
|
|||
|
|
@ -309,6 +309,9 @@ const schema = gql`
|
|||
WEBSITE
|
||||
HIGHLIGHTS
|
||||
UNKNOWN
|
||||
TWEET
|
||||
VIDEO
|
||||
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