This repository has been archived by the owner on Sep 27, 2024. It is now read-only.
forked from elk-zone/elk
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into fix/discover-nav-update
- Loading branch information
Showing
28 changed files
with
805 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,3 +17,5 @@ public/emojis | |
*~ | ||
*swp | ||
*swo | ||
|
||
.venv/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
<script setup lang="ts"> | ||
import type { Recommendation } from '../composables/recommendations' | ||
const { | ||
item, | ||
} = defineProps<{ | ||
item: Recommendation | ||
}>() | ||
const target = ref<HTMLDivElement>() | ||
const { isActive } = useIntersectionObserver(target, checkIntersection, { threshold: 0.5 }) | ||
function checkIntersection([{ isIntersecting }]: [{ isIntersecting: boolean }]): void { | ||
if (isIntersecting && isActive.value) { | ||
// fire analytics event here: item.id || item.title || item.url | ||
isActive.value = false | ||
} | ||
} | ||
const clipboard = useClipboard() | ||
async function copyLink(url: string, event: Event): void { | ||
event.preventDefault() | ||
if (url) | ||
await clipboard.copy(url) | ||
} | ||
</script> | ||
|
||
<template> | ||
<NuxtLink ref="target" :to="item.url" target="_blank" external p-y-16px p-x-8px flex border="b base"> | ||
<div class="content" w-full pr> | ||
<h4 text-sm text-secondary> | ||
{{ item.publisher }} | ||
</h4> | ||
<h3 text-lg line-height-tight font-500 m-y-4px> | ||
{{ item.title }} | ||
</h3> | ||
<p> | ||
{{ item.excerpt }} | ||
</p> | ||
</div> | ||
<div class="media" relative overflow-hidden max-w-120px min-w-120px> | ||
<img :src="item.image.sizes?.[0]?.url" rounded-lg overflow-hidden w-full ha> | ||
<div m-y-4px flex flex-justify-end> | ||
<button p-12px text-xl @click="copyLink(item.url, $event)"> | ||
<div i-ri:share-line /> | ||
</button> | ||
</div> | ||
</div> | ||
</NuxtLink> | ||
</template> | ||
|
||
<style scoped> | ||
a:hover h3 { | ||
text-decoration: underline; | ||
} | ||
p { | ||
line-height: 1.6em; | ||
max-height: 4.8em; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
overflow-wrap: anywhere; | ||
display: -webkit-box; | ||
-webkit-line-clamp: 3; | ||
-webkit-box-orient: vertical; | ||
} | ||
</style> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<script setup lang="ts"> | ||
const user = currentUser.value | ||
interface InviteCode { | ||
token: string | ||
assigned?: string | ||
assigned_at?: string | ||
created_at: string | ||
} | ||
interface Invite { | ||
tokens: InviteCode[] | ||
} | ||
const invite: Invite = await $fetch(`/api/${publicServer.value}/invites`, { headers: { authorization: `Bearer ${user?.token}` } }) | ||
const { text, copy, copied } = useClipboard() | ||
const { t } = useI18n() | ||
const noInvites = invite.tokens.length === 0 | ||
const heading = noInvites ? t('invites.no_codes.title') : t('invites.title') | ||
const description = noInvites ? t('invites.no_codes.subtitle') : t('invites.subtitle') | ||
</script> | ||
|
||
<template> | ||
<div p-x-5 sm:p-0> | ||
<div m-b-5> | ||
<h1 text-2xl p-y-2> | ||
{{ heading }} | ||
</h1> | ||
<p> | ||
{{ description }} | ||
</p> | ||
</div> | ||
<main> | ||
<div v-for="code in invite.tokens" :key="code.token" b-t-1px> | ||
<div flex justify-between items-center b-b-1px p-4 m-b--1px> | ||
<span>{{ code.token }}</span> | ||
<div> | ||
<button flex justify-between items-center @click="copy(code.token)"> | ||
<span v-if="copied && text === code.token" m-r-2 bg-primary text-base-light p-x-3 b-rd-10>{{ $t("invites.copied") }}</span> | ||
<div i-ri:file-copy-line /> | ||
</button> | ||
</div> | ||
</div> | ||
</div> | ||
</main> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { addPlugin, createResolver, defineNuxtModule } from '@nuxt/kit' | ||
|
||
export default defineNuxtModule({ | ||
meta: { | ||
name: 'glean', | ||
}, | ||
setup() { | ||
const { resolve } = createResolver(import.meta.url) | ||
|
||
addPlugin(resolve('./runtime/glean-plugin.client')) | ||
}, | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import Glean from '@mozilla/glean/web' | ||
import * as log from 'tauri-plugin-log-api' | ||
|
||
import { linkClick, pageUrl, pageView, referrerUrl } from '../../../telemetry/generated/web' | ||
import { userAgent } from '../../../telemetry/generated/identifiers' | ||
import { engagement } from '../../../telemetry/generated/ui' | ||
import { engagementDetails } from '../../../telemetry/engagementDetails' | ||
|
||
export default defineNuxtPlugin((nuxtApp) => { | ||
nuxtApp.hook('app:mounted', () => { | ||
log.info('Glean: App mounted, start initing glean') | ||
|
||
const GLEAN_APP_ID = 'mozilla-social-web' | ||
const devMode = useAppConfig().env === ('dev' || 'canary' || 'preview') | ||
const uploadEnabled = devMode // this will eventually be a setting that the user can toggle | ||
|
||
Glean.initialize(GLEAN_APP_ID, uploadEnabled, {}) | ||
userAgent.set(navigator.userAgent) | ||
|
||
// Debugging | ||
if (devMode) { | ||
Glean.setLogPings(true) // logs to the console | ||
Glean.setDebugViewTag('moso-elk-dev') // logs to https://debug-ping-preview.firebaseapp.com | ||
} | ||
|
||
const eventListener = (event: MouseEvent) => { | ||
if (event.type === 'click') { | ||
handleButtonClick(event) | ||
handleLinkClick(event) | ||
} | ||
} | ||
|
||
function handleButtonClick(ev: MouseEvent) { | ||
const eventTarget = ev?.target as Element | ||
const closestButton = eventTarget.closest('button') | ||
|
||
if (closestButton?.hasAttribute('href')) | ||
linkClick.record({ target_url: closestButton.getAttribute('href') || '' }) | ||
|
||
const data = eventTarget?.getAttribute('data-glean') || '' | ||
const value = eventTarget?.getAttribute('data-glean-value') || '' | ||
if (eventTarget.hasAttribute('data-glean')) | ||
engagement.record({ ui_identifier: data, engagement_value: value, ...engagementDetails[data] }) | ||
} | ||
|
||
function handleLinkClick(ev: MouseEvent) { | ||
const eventTarget = ev?.target as Element | ||
const closestLink = eventTarget.closest('a') | ||
if (closestLink) | ||
linkClick.record({ target_url: closestLink.getAttribute('href') || '' }) | ||
} | ||
|
||
window.addEventListener('click', eventListener) | ||
}) | ||
|
||
nuxtApp.hook('page:finish', () => { | ||
pageUrl.set(window.location.href) | ||
|
||
if (document.referrer !== '') | ||
referrerUrl.set(window.location.href) | ||
else | ||
referrerUrl.set('') | ||
|
||
pageView.record() | ||
}) | ||
}) |
Oops, something went wrong.