Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URLをOGPカード表示したい #18

Open
uhooi opened this issue Apr 4, 2022 · 5 comments
Open

URLをOGPカード表示したい #18

uhooi opened this issue Apr 4, 2022 · 5 comments
Labels
enhancement New feature or request

Comments

@uhooi
Copy link
Member

uhooi commented Apr 4, 2022

概要

URL を OGP カード表示したい。

@uhooi
Copy link
Member Author

uhooi commented Apr 4, 2022

OG データをダウンロードして、自前でレンダリングする必要があるかも。
その場合は OpenGraphDataDownloader が使えそう。
ref: https://github.com/marty-suzuki/URLEmbeddedView#opengraphdatadownloader

@uhooi
Copy link
Member Author

uhooi commented Apr 4, 2022

CSS が得意じゃないから、自前でレンダリングは少し厳しい、、
OG カード表示の CSS がオープンソースであればいいんだけど、、

@treastrain
Copy link
Member

macOS インスタンスを使うとすれば、LinkPresentation を使うだけで情報の取得は可能ですね。

import LinkPresentation


try await run(originalURL: URL(string: "https://github.com/treastrain/tretjapannfcreader")!)

@MainActor
func run(originalURL: URL) async throws {
    let metadataProvider = LPMetadataProvider()
    let metadata = try await metadataProvider.startFetchingMetadata(for: originalURL)
    
    // https://github.com/treastrain/TRETJapanNFCReader
    let url = metadata.url
    
    // https://github.com/treastrain/tretjapannfcreader
    let originalURL = metadata.originalURL
    
    // "treastrain/TRETJapanNFCReader: NFC (FeliCa) Reader for iOS 13 later Core NFC / Japanese e-Money prepaid or identification cards"
    let title = metadata.title
    
    let icon = try await metadata.iconProvider?.loadItem(forTypeIdentifier: "public.image") as! Data
    let image = try await metadata.imageProvider?.loadItem(forTypeIdentifier: "public.image") as! Data
}

@uhooi
Copy link
Member Author

uhooi commented May 2, 2022

そんなフレームワークあるのwww
そしたら OSS を使わずに済むかも…。
あ、でも Linux ではつかえないのか、、GitHub Actions だと macOS で Swift 5.6 がまだ使えないのがやっかい、、、

@treastrain
Copy link
Member

あ、でも Linux ではつかえないのか、、GitHub Actions だと macOS で Swift 5.6 がまだ使えないのがやっかい、、、

あっ それなのですが、すでに ios_osushi 下のリポジトリでは使えるようにしていただいております… https://github.com/ios-osushi/release-subscriptions/actions/runs/2258428022

@uhooi uhooi added the enhancement New feature or request label May 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants