build out comment page and opengraph rendering

This commit is contained in:
2024-11-28 01:51:52 -07:00
parent e660906090
commit 92c981a7e3
13 changed files with 708 additions and 295 deletions

View File

@ -0,0 +1,55 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>AnyRemark</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>
<header>
<nav>
<a href="#">Home</a>
<a href="#">About</a>
</nav>
</header>
<main>
<article>
<h1>Stingrays with Friends - FPV Formation</h1>
<p>My favorite thing to do in this hobby is fly FPV with friends and chase planes. Morning FPV flights with Ben and Eric. If you are interested in this plane (The...</p>
<div class="video-container">
<img src="https://via.placeholder.com/800x450" alt="Video Thumbnail">
<div class="play-button"></div>
</div>
</article>
<section class="comments">
<h2>Comments</h2>
<div class="comment">
<img src="https://via.placeholder.com/50" alt="User Avatar" class="avatar">
<div class="comment-content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.</p>
</div>
</div>
<div class="comment">
<img src="https://via.placeholder.com/50" alt="User Avatar" class="avatar">
<div class="comment-content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.</p>
</div>
</div>
<div class="comment">
<img src="https://via.placeholder.com/50" alt="User Avatar" class="avatar">
<div class="comment-content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.</p>
</div>
</div>
<form class="comment-form">
<textarea placeholder="Add a comment..."></textarea>
<button type="submit">Submit</button>
</form>
</section>
</main>
<footer>
<p>Video icons created by Freepik - Flaticon</p>
</footer>
</body>
</html>

142
AnyRemark-design/styles.css Normal file
View File

@ -0,0 +1,142 @@
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f9f9f9;
color: #333;
}
header {
background-color: #fff;
border-bottom: 1px solid #ddd;
padding: 10px 20px;
}
nav a {
margin-right: 20px;
color: #007bff;
text-decoration: none;
}
nav a:hover {
text-decoration: underline;
}
main {
max-width: 800px;
margin: 20px auto;
padding: 20px;
background-color: #fff;
border-radius: 8px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}
article h1 {
color: #28a745;
font-size: 24px;
}
.video-container {
position: relative;
padding-top: 56.25%; /* 16:9 Aspect Ratio */
margin-top: 20px;
margin-bottom: 20px;
}
.video-container img {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 8px;
}
.play-button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 60px;
height: 60px;
background: rgba(0, 0, 0, 0.5);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.play-button::before {
content: '';
display: block;
width: 0;
height: 0;
border-left: 20px solid white;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
}
.comments {
margin-top: 40px;
}
.comments h2 {
font-size: 20px;
margin-bottom: 20px;
}
.comment {
display: flex;
align-items: flex-start;
margin-bottom: 20px;
}
.comment .avatar {
width: 50px;
height: 50px;
border-radius: 50%;
margin-right: 10px;
}
.comment-content {
background-color: #f1f1f1;
padding: 10px 15px;
border-radius: 8px;
flex-grow: 1;
}
.comment-form {
display: flex;
flex-direction: column;
}
.comment-form textarea {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 8px;
resize: none;
}
.comment-form button {
align-self: flex-end;
padding: 10px 20px;
background-color: #28a745;
color: #fff;
border: none;
border-radius: 8px;
cursor: pointer;
}
.comment-form button:hover {
background-color: #218838;
}
footer {
text-align: center;
padding: 20px;
background-color: #fff;
border-top: 1px solid #ddd;
}

View File

@ -1,15 +1,10 @@
<script setup lang="ts">
import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from './components/HelloWorld.vue'
</script>
<template>
<header>
<img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" />
<div class="wrapper">
<HelloWorld msg="You did it!" />
<nav>
<RouterLink to="/">Home</RouterLink>
<RouterLink to="/about">About</RouterLink>
@ -21,65 +16,9 @@ import HelloWorld from './components/HelloWorld.vue'
</template>
<style scoped>
header {
line-height: 1.5;
max-height: 100vh;
}
.logo {
display: block;
margin: 0 auto 2rem;
}
nav {
width: 100%;
font-size: 12px;
text-align: center;
margin-top: 2rem;
}
nav a.router-link-exact-active {
color: var(--color-text);
}
nav a.router-link-exact-active:hover {
background-color: transparent;
}
nav a {
display: inline-block;
padding: 0 1rem;
border-left: 1px solid var(--color-border);
}
nav a:first-of-type {
border: 0;
}
@media (min-width: 1024px) {
header {
display: flex;
place-items: center;
padding-right: calc(var(--section-gap) / 2);
}
.logo {
margin: 0 2rem 0 0;
}
header .wrapper {
display: flex;
place-items: flex-start;
flex-wrap: wrap;
}
nav {
text-align: left;
margin-left: -1rem;
font-size: 1rem;
padding: 1rem 0;
margin-top: 1rem;
}
}
</style>

View File

@ -23,13 +23,13 @@ a,
@media (min-width: 1024px) {
body {
display: flex;
/*display: flex;*/
place-items: center;
}
#app {
display: grid;
grid-template-columns: 1fr 1fr;
/*display: grid;*/
/*grid-template-columns: 1fr 1fr;*/
padding: 0 2rem;
}
}

View File

@ -0,0 +1,35 @@
<script setup lang="ts">
</script>
<template>
<div class="comment">
<img src="https://cdn.vuetifyjs.com/images/lists/1.jpg" alt="User Avatar" class="avatar"/>
<div class="comment-content">
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer nec odio. Praesent libero. Sed cursus ante dapibus diam. Sed nisi.</p>
</div>
</div>
</template>
<style scoped>
.comment {
display: flex;
align-items: flex-start;
margin-bottom: 20px;
}
.comment .avatar {
width: 50px;
height: 50px;
border-radius: 50%;
margin-right: 10px;
}
.comment-content {
background-color: #f1f1f1;
padding: 10px 15px;
border-radius: 8px;
flex-grow: 1;
}
</style>

View File

@ -1,41 +0,0 @@
<script setup lang="ts">
defineProps<{
msg: string
}>()
</script>
<template>
<div class="greetings">
<h1 class="green">{{ msg }}</h1>
<h3>
Youve successfully created a project with
<a href="https://vite.dev/" target="_blank" rel="noopener">Vite</a> +
<a href="https://vuejs.org/" target="_blank" rel="noopener">Vue 3</a>. What's next?
</h3>
</div>
</template>
<style scoped>
h1 {
font-weight: 500;
font-size: 2.6rem;
position: relative;
top: -10px;
}
h3 {
font-size: 1.2rem;
}
.greetings h1,
.greetings h3 {
text-align: center;
}
@media (min-width: 1024px) {
.greetings h1,
.greetings h3 {
text-align: left;
}
}
</style>

View File

@ -0,0 +1,368 @@
<script setup lang="ts">
import { onMounted, ref } from 'vue'
type OpenGraph = {
type: string;
url: string;
title: string;
description: string;
determiner: string;
site_name: string;
locale: string;
locales_alternate: string | null;
images: {
url: string;
secure_url: string;
type: string;
width: number;
height: number;
}[];
audios: {
url: string;
secure_url: string;
type: string;
}[] | null;
videos: {
url: string;
secure_url: string;
type: string;
width: number;
height: number;
}[] | null;
article: {
published_time: string | null;
modified_time: string | null;
expiration_time: string | null;
section: string;
tags: string[] | null;
authors: string[] | null;
} | null;
};
const url = defineProps({
url: {
type: String,
required: true,
}
});
const og = ref<OpenGraph>({
type: "",
url: "",
title: "",
description: "",
determiner: "",
site_name: "",
locale: "",
locales_alternate: "",
images: [],
audios: [],
videos: [],
article: {
published_time: null,
modified_time: null,
expiration_time: null,
section: "",
tags: null,
authors: null
},
});
onMounted(() => {
// fetch(`https://anyremark.com/api/opengraph?url=${url}`)
// .then(response => response.json())
// .then(data => {
// og.value = data;
// });
// og.value = {
// type: "video.other",
// url: "https://www.youtube.com/watch?v=iedMwhLrFQQ",
// title: "Stingrays with Friends - FPV Formation",
// description: "My favorite thing to do in this hobby is fly FPV with friends and chase planes.Morning FPV flights with Ben and Eric.If you are interested in this plane (The...",
// determiner: "",
// site_name: "YouTube",
// locale: "",
// locales_alternate: "",
// images: [
// {
// url: "https://i.ytimg.com/vi/iedMwhLrFQQ/maxresdefault.jpg",
// secure_url: "",
// type: "",
// width: 1280,
// height: 720
// }
// ],
// audios: [],
// videos: [
// {
// url: "https://www.youtube.com/embed/iedMwhLrFQQ",
// secure_url: "https://www.youtube.com/embed/iedMwhLrFQQ",
// type: "text/html",
// width: 1280,
// height: 720
// }
// ],
// article: {
// published_time: null,
// modified_time: null,
// expiration_time: null,
// section: "",
// tags: null,
// authors: null
// },
// };
console.log(url);
// og.value = {
// "type": "video.other",
// "url": "https://vimeo.com/867950660",
// "title": "Hands Of Sicily.",
// "description": "The hands of a human can tell a million stories. This film is an intimate portrait of Sicily. It simply shows the hands of the people from the island in action.\u0026hellip;",
// "determiner": "",
// "site_name": "Vimeo",
// "locale": "",
// "locales_alternate": null,
// "images": [
// {
// "url": "https://i.vimeocdn.com/video/1728918730-bfdfd12d26406a06d263d62fef2da83aea8a684a0eeff059bb2ae6c41eda4aec-d?f=webp",
// "secure_url": "https://i.vimeocdn.com/video/1728918730-bfdfd12d26406a06d263d62fef2da83aea8a684a0eeff059bb2ae6c41eda4aec-d?f=webp",
// "type": "image/webp",
// "width": 1280,
// "height": 953
// }
// ],
// "audios": null,
// "videos": [
// {
// "url": "https://player.vimeo.com/video/867950660?autoplay=1\u0026amp;h=f094db59eb",
// "secure_url": "https://player.vimeo.com/video/867950660?autoplay=1\u0026amp;h=f094db59eb",
// "type": "text/html",
// "width": 1280,
// "height": 953
// }
// ],
// "article": {
// "published_time": null,
// "modified_time": null,
// "expiration_time": null,
// "section": "",
// "tags": null,
// "authors": null
// }
// };
og.value = {
"type": "article",
"url": "https://github.blog/changelog/2024-11-27-access-a-repositorys-secret-scanning-scan-history-with-the-rest-api/",
"title": "Access a repositorys secret scanning scan history with the REST API · GitHub Changelog",
"description": "Access a repository's secret scanning scan history with the REST API",
"determiner": "",
"site_name": "The GitHub Blog",
"locale": "en_US",
"locales_alternate": null,
"images": [
{
"url": "https://github.blog/wp-content/uploads/2024/08/d34e9c19123898a8a886147f37a1d167130d1c15be6d399a9c4b30ee6f2a7395-1200x630-1.png?fit=1200%2C630",
"secure_url": "",
"type": "image/png",
"width": 1200,
"height": 630
}
],
"audios": null,
"videos": null,
"article": {
"published_time": null,
"modified_time": null,
"expiration_time": null,
"section": "",
"tags": null,
"authors": null
}
};
});
const videoVisible = ref(false);
function showVideo() {
videoVisible.value = true;
}
</script>
<template>
<!-- Show the topic webpage's open graph content-->
<!-- server side will use https://github.com/dyatlov/go-opengraph -->
<!-- example opengraph output here
{
"type": "video.other",
"url": "https://www.youtube.com/watch?v=iedMwhLrFQQ",
"title": "Stingrays with Friends - FPV Formation",
"description": "My favorite thing to do in this hobby is fly FPV with friends and chase planes.Morning FPV flights with Ben and Eric.If you are interested in this plane (The...",
"determiner": "",
"site_name": "YouTube",
"locale": "",
"locales_alternate": null,
"images": [
{
"url": "https://i.ytimg.com/vi/iedMwhLrFQQ/maxresdefault.jpg",
"secure_url": "",
"type": "",
"width": 1280,
"height": 720
}
],
"audios": null,
"videos": [
{
"url": "https://www.youtube.com/embed/iedMwhLrFQQ",
"secure_url": "https://www.youtube.com/embed/iedMwhLrFQQ",
"type": "text/html",
"width": 1280,
"height": 720
}
]
}
-->
<article>
<h1><a :href="og.url">{{og.title}}</a></h1>
<p>{{og.description}}</p>
<div class="article-thumb-container" v-if="og.type === 'article'">
<img :src="!!og.images.length ? og.images[0].url : ''" alt="Article Thumbnail" />
</div>
<div class="video-other" v-if="og.type === 'video.other'">
<div class="video-container" v-if="!!og.videos?.length && (og.url.startsWith('https://www.youtube.com') || og.url.startsWith('https://vimeo.com'))">
<iframe :src="og.videos[0].url" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>
</div>
<div class="non-yt-container" v-if="!!og.videos?.length && (!og.url.startsWith('https://www.youtube.com') && !og.url.startsWith('https://vimeo.com'))">
<div class="thumbnail-container" @click="showVideo" v-if="!videoVisible">
<img :src="!!og.images.length ? og.images[0].url : ''" alt="Video Thumbnail" />
<div class="play-button"></div>
</div>
<div class="thumbnail-container" v-else>
<video controls>
<source :src="og.videos[0].url" type="video/mp4">
Your browser does not support the video tag.
</video>
</div>
</div>
</div>
</article>
</template>
<style scoped>
article {
display: flex;
flex-direction: column;
align-items: flex-start;
}
.article-thumb-container {
width: 100%;
margin-top: 20px;
margin-bottom: 20px;
}
.article-thumb-container img {
width: 100%;
height: auto;
max-width: 100%;
max-height: 100%;
border-radius: 8px;
}
.video-other {
width: 100%;
}
.video-container {
position: relative;
width: 100%;
padding-bottom: 56.25%;
margin-top: 20px;
margin-bottom: 20px;
}
.video-container img, .video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 8px;
}
.non-yt-container, .non-yt-container>div {
width: 100%;
/* padding-bottom: 56.25%;
margin-top: 20px;
margin-bottom: 20px; */
}
.thumbnail-container {
position: relative;
display: inline-block;
cursor: pointer;
}
.thumbnail-container img, .thumbnail-container video {
display: block;
width: 100%;
height: auto;
max-width: 100%;
max-height: 100%;
}
.thumbnail-container img:after {
content: '';
display: block;
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background: linear-gradient(0deg, rgba(0, 0, 0, 0.5) 0%, rgba(0, 0, 0, 0) 100%);
}
/*.play-button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 256px;
height: 256px;
background: url('/play-button.png') no-repeat center center;
background-size: contain;
}*/
.play-button {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
width: 60px;
height: 60px;
background: rgba(0, 0, 0, 0.5);
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
cursor: pointer;
}
.play-button::before {
content: '';
display: block;
width: 0;
height: 0;
border-left: 20px solid white;
border-top: 12px solid transparent;
border-bottom: 12px solid transparent;
}
</style>

View File

@ -1,90 +0,0 @@
<script setup lang="ts">
import WelcomeItem from './WelcomeItem.vue'
import DocumentationIcon from './icons/IconDocumentation.vue'
import ToolingIcon from './icons/IconTooling.vue'
import EcosystemIcon from './icons/IconEcosystem.vue'
import CommunityIcon from './icons/IconCommunity.vue'
import SupportIcon from './icons/IconSupport.vue'
</script>
<template>
<WelcomeItem>
<template #icon>
<DocumentationIcon />
</template>
<template #heading>Documentation</template>
Vues
<a href="https://vuejs.org/" target="_blank" rel="noopener">official documentation</a>
provides you with all information you need to get started.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<ToolingIcon />
</template>
<template #heading>Tooling</template>
This project is served and bundled with
<a href="https://vite.dev/guide/features.html" target="_blank" rel="noopener">Vite</a>. The
recommended IDE setup is
<a href="https://code.visualstudio.com/" target="_blank" rel="noopener">VSCode</a>
+
<a href="https://github.com/johnsoncodehk/volar" target="_blank" rel="noopener">Volar</a>. If
you need to test your components and web pages, check out
<a href="https://www.cypress.io/" target="_blank" rel="noopener">Cypress</a>
and
<a href="https://on.cypress.io/component" target="_blank" rel="noopener"
>Cypress Component Testing</a
>.
<br />
More instructions are available in <code>README.md</code>.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<EcosystemIcon />
</template>
<template #heading>Ecosystem</template>
Get official tools and libraries for your project:
<a href="https://pinia.vuejs.org/" target="_blank" rel="noopener">Pinia</a>,
<a href="https://router.vuejs.org/" target="_blank" rel="noopener">Vue Router</a>,
<a href="https://test-utils.vuejs.org/" target="_blank" rel="noopener">Vue Test Utils</a>, and
<a href="https://github.com/vuejs/devtools" target="_blank" rel="noopener">Vue Dev Tools</a>. If
you need more resources, we suggest paying
<a href="https://github.com/vuejs/awesome-vue" target="_blank" rel="noopener">Awesome Vue</a>
a visit.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<CommunityIcon />
</template>
<template #heading>Community</template>
Got stuck? Ask your question on
<a href="https://chat.vuejs.org" target="_blank" rel="noopener">Vue Land</a>, our official
Discord server, or
<a href="https://stackoverflow.com/questions/tagged/vue.js" target="_blank" rel="noopener"
>StackOverflow</a
>. You should also subscribe to
<a href="https://news.vuejs.org" target="_blank" rel="noopener">our mailing list</a>
and follow the official
<a href="https://twitter.com/vuejs" target="_blank" rel="noopener">@vuejs</a>
twitter account for latest news in the Vue world.
</WelcomeItem>
<WelcomeItem>
<template #icon>
<SupportIcon />
</template>
<template #heading>Support Vue</template>
As an independent project, Vue relies on community backing for its sustainability. You can help
us by
<a href="https://vuejs.org/sponsor/" target="_blank" rel="noopener">becoming a sponsor</a>.
</WelcomeItem>
</template>

View File

@ -1,87 +0,0 @@
<template>
<div class="item">
<i>
<slot name="icon"></slot>
</i>
<div class="details">
<h3>
<slot name="heading"></slot>
</h3>
<slot></slot>
</div>
</div>
</template>
<style scoped>
.item {
margin-top: 2rem;
display: flex;
position: relative;
}
.details {
flex: 1;
margin-left: 1rem;
}
i {
display: flex;
place-items: center;
place-content: center;
width: 32px;
height: 32px;
color: var(--color-text);
}
h3 {
font-size: 1.2rem;
font-weight: 500;
margin-bottom: 0.4rem;
color: var(--color-heading);
}
@media (min-width: 1024px) {
.item {
margin-top: 0;
padding: 0.4rem 0 1rem calc(var(--section-gap) / 2);
}
i {
top: calc(50% - 25px);
left: -26px;
position: absolute;
border: 1px solid var(--color-border);
background: var(--color-background);
border-radius: 8px;
width: 50px;
height: 50px;
}
.item:before {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
bottom: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:after {
content: ' ';
border-left: 1px solid var(--color-border);
position: absolute;
left: 0;
top: calc(50% + 25px);
height: calc(50% - 25px);
}
.item:first-of-type:before {
display: none;
}
.item:last-of-type:after {
display: none;
}
}
</style>

View File

@ -1,11 +1,11 @@
import { describe, it, expect } from 'vitest'
import { mount } from '@vue/test-utils'
import HelloWorld from '../HelloWorld.vue'
describe('HelloWorld', () => {
it('renders properly', () => {
const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } })
expect(wrapper.text()).toContain('Hello Vitest')
})
})
// import { describe, it, expect } from 'vitest'
//
// import { mount } from '@vue/test-utils'
// import HelloWorld from '../HelloWorld.vue'
//
// describe('HelloWorld', () => {
// it('renders properly', () => {
// const wrapper = mount(HelloWorld, { props: { msg: 'Hello Vitest' } })
// expect(wrapper.text()).toContain('Hello Vitest')
// })
// })

View File

@ -17,6 +17,11 @@ const router = createRouter({
// which is lazy-loaded when the route is visited.
component: () => import('../views/AboutView.vue'),
},
{
path: '/remark',
name: 'remark',
component: () => import('../views/RemarkView.vue'),
}
],
})

View File

@ -1,9 +1,9 @@
<script setup lang="ts">
import TheWelcome from '../components/TheWelcome.vue'
// import TheWelcome from '../components/TheWelcome.vue'
</script>
<template>
<main>
<TheWelcome />
<!-- <TheWelcome />-->
</main>
</template>

87
src/views/RemarkView.vue Normal file
View File

@ -0,0 +1,87 @@
<script setup lang="ts">
import CommentComponent from '@/components/CommentComponent.vue'
import OpenGraphComponent from '@/components/OpenGraphComponent.vue'
import { ref } from 'vue'
// const url = ref('https://www.youtube.com/watch?v=iedMwhLrFQQ');
const url = ref('https://vimeo.com/867950660');
</script>
<template>
<div class="app-container">
<div class="remarks">
<h1>AnyRemark</h1>
<OpenGraphComponent :url="url" />
<section class="comments">
<h2>Comments</h2>
<form class="comment-form">
<textarea placeholder="Add a comment..."></textarea>
<button type="submit">Submit</button>
</form>
<div v-for="i in 5" :key="i">
<CommentComponent />
</div>
</section>
</div>
</div>
</template>
<style scoped>
.app-container {
display: flex;
justify-content: center;
padding-bottom: 20px;
}
.remarks {
max-width: 600px;
}
/*.comments {
margin-top: 20px;
}*/
.comments h2 {
font-size: 20px;
margin-bottom: 20px;
}
.comment-form {
display: flex;
flex-direction: column;
padding-bottom: 20px;
}
.comment-form textarea {
width: 100%;
padding: 10px;
margin-bottom: 10px;
border: 1px solid #ddd;
border-radius: 8px;
resize: none;
}
.comment-form button {
align-self: flex-end;
padding: 10px 20px;
background-color: #28a745;
color: #fff;
border: none;
border-radius: 8px;
cursor: pointer;
}
.comment-form button:hover {
background-color: #218838;
}
</style>