Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions public/badges/listed-on.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
57 changes: 57 additions & 0 deletions src/components/BadgeEmbed.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
<script setup lang="ts">
import { ref, computed } from 'vue'
import { Button } from 'frappe-ui'
import { appUrl, badgeHtml, badgeImageUrl, badgeMarkdown } from '../site'

const props = defineProps<{
slug: string
}>()

const copied = ref<string | null>(null)

const snippets = computed(() => [
{ id: 'markdown', label: 'Markdown', code: badgeMarkdown(props.slug) },
{ id: 'html', label: 'HTML', code: badgeHtml(props.slug) },
])

async function copy(text: string) {
await navigator.clipboard.writeText(text)
copied.value = text
setTimeout(() => { copied.value = null }, 2000)
}
</script>

<template>
<div class="rounded-lg border border-outline-gray-2 bg-surface-white overflow-hidden">
<div class="px-4 py-3 border-b border-outline-gray-1 bg-surface-gray-1">
<h2 class="text-xs font-semibold text-ink-gray-4 uppercase tracking-widest">README Badge</h2>
</div>
<div class="px-4 py-4 space-y-4">
<p class="text-sm text-ink-gray-5 leading-relaxed">
Show that your app is listed on Frappe Brewery. Add this badge to your README or project website.
</p>
<a
:href="appUrl(slug)"
target="_blank"
rel="noopener noreferrer"
class="inline-flex rounded-md focus:outline-none focus:ring-2 focus:ring-ink-gray-3"
>
<img :src="badgeImageUrl()" alt="Listed on Frappe Brewery" height="28" width="240" />
</a>
<div v-for="snippet in snippets" :key="snippet.id" class="rounded-lg border border-outline-gray-1 overflow-hidden">
<div class="flex items-center justify-between px-3 py-2 bg-surface-gray-1 border-b border-outline-gray-1">
<span class="text-xs font-semibold text-ink-gray-5 uppercase tracking-wider">{{ snippet.label }}</span>
<Button
variant="ghost"
:theme="copied === snippet.code ? 'green' : 'gray'"
:icon-left="copied === snippet.code ? 'check' : 'copy'"
@click="copy(snippet.code)"
>
{{ copied === snippet.code ? 'Copied' : 'Copy' }}
</Button>
</div>
<pre class="px-3 py-2.5 font-mono text-xs text-ink-gray-6 overflow-x-auto bg-surface-white leading-relaxed">{{ snippet.code }}</pre>
</div>
</div>
</div>
</template>
3 changes: 3 additions & 0 deletions src/pages/AppDetail.vue
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ref, watch, onMounted, computed } from 'vue'
import { useRoute, RouterLink } from 'vue-router'
import { Icon, Badge, Button, FormControl } from 'frappe-ui'
import { fetchApp } from '../api'
import BadgeEmbed from '../components/BadgeEmbed.vue'
import { formatFrappeVersion } from '../constants'
import type { App } from '../types'

Expand Down Expand Up @@ -283,6 +284,8 @@ watch(() => route.params.slug, s => s && loadApp(s as string))
</dl>
</div>

<BadgeEmbed :slug="app.slug" />

<!-- Links card -->
<div v-if="app.links?.website || app.links?.docs || app.links?.demo" class="rounded-6 border border-outline-gray-2 bg-surface-base overflow-hidden">
<div class="px-4 py-3 border-b border-outline-gray-2 bg-surface-gray-1">
Expand Down
56 changes: 56 additions & 0 deletions src/pages/Docs.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script setup lang="ts">
import { ref } from 'vue'
import { appUrl, badgeHtml, badgeImageUrl, badgeMarkdown, BADGE_PATH, SITE_URL } from '../site'
import { Icon, Button } from 'frappe-ui'

const copied = ref<string | null>(null)
Expand All @@ -15,6 +16,9 @@ const overviewCards = [
{ icon: 'lucide-refresh-cw', title: 'Auto-updated', desc: 'Index regenerated on every merge to main via GitHub Actions.' },
]

const badgeMarkdownExample = badgeMarkdown('my-app')
const badgeHtmlExample = badgeHtml('my-app')

const usageExamples = [
{
title: 'Fetch all apps (JavaScript)',
Expand Down Expand Up @@ -169,6 +173,58 @@ const endpoints = [
</div>
</section>

<!-- README Badge -->
<section class="mb-12" aria-labelledby="badge-heading">
<h2 id="badge-heading" class="text-lg font-semibold text-ink-gray-8 mb-3">README Badge</h2>
<div class="rounded-lg border border-outline-gray-1 p-6 bg-surface-white space-y-4">
<p class="text-sm text-ink-gray-5 leading-relaxed">
Listed apps can display a badge in their README or website. The badge links to the app's detail page on Frappe Brewery.
</p>
<a
:href="appUrl('erpnext')"
target="_blank"
rel="noopener noreferrer"
class="inline-flex rounded-md focus:outline-none focus:ring-2 focus:ring-ink-gray-3"
>
<img :src="badgeImageUrl()" alt="Listed on Frappe Brewery" height="28" width="240" />
</a>
<div class="space-y-3">
<div class="rounded-lg border border-outline-gray-1 overflow-hidden">
<div class="flex items-center justify-between px-4 py-3 bg-surface-gray-1 border-b border-outline-gray-1">
<h3 class="text-sm font-semibold text-ink-gray-7">Markdown</h3>
<Button
variant="ghost"
:theme="copied === badgeMarkdownExample ? 'green' : 'gray'"
:icon-left="copied === badgeMarkdownExample ? 'check' : 'copy'"
@click="copy(badgeMarkdownExample)"
>
{{ copied === badgeMarkdownExample ? 'Copied' : 'Copy' }}
</Button>
</div>
<pre class="p-4 font-mono text-xs text-ink-gray-6 overflow-x-auto bg-surface-white leading-relaxed">{{ badgeMarkdownExample }}</pre>
</div>
<div class="rounded-lg border border-outline-gray-1 overflow-hidden">
<div class="flex items-center justify-between px-4 py-3 bg-surface-gray-1 border-b border-outline-gray-1">
<h3 class="text-sm font-semibold text-ink-gray-7">HTML</h3>
<Button
variant="ghost"
:theme="copied === badgeHtmlExample ? 'green' : 'gray'"
:icon-left="copied === badgeHtmlExample ? 'check' : 'copy'"
@click="copy(badgeHtmlExample)"
>
{{ copied === badgeHtmlExample ? 'Copied' : 'Copy' }}
</Button>
</div>
<pre class="p-4 font-mono text-xs text-ink-gray-6 overflow-x-auto bg-surface-white leading-relaxed">{{ badgeHtmlExample }}</pre>
</div>
</div>
<p class="text-xs text-ink-gray-4 leading-relaxed">
Replace <code class="font-mono bg-surface-gray-2 px-1 py-0.5 rounded border border-outline-gray-1">my-app</code> with your app slug.
Badge image URL: <code class="font-mono bg-surface-gray-2 px-1 py-0.5 rounded border border-outline-gray-1">{{ SITE_URL }}{{ BADGE_PATH }}</code>
</p>
</div>
</section>

<!-- Self-hosting -->
<section aria-labelledby="selfhost-heading">
<h2 id="selfhost-heading" class="text-lg-semibold text-ink-gray-8 mb-3">Self-hosting</h2>
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Submit.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const steps = [
},
{
title: 'Open a Pull Request',
desc: 'Push your branch and open a PR. GitHub Actions CI validates automatically.',
desc: 'Push your branch and open a PR. GitHub Actions CI validates automatically. Once merged, you can add a README badge from your app\'s detail page.',
code: null,
icon: 'lucide-git-pull-request',
},
Expand Down
19 changes: 19 additions & 0 deletions src/site.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const SITE_URL = 'https://frappe-brewery.lubus.in'

export const BADGE_PATH = '/badges/listed-on.svg'

export function appUrl(slug: string): string {
return `${SITE_URL}/apps/${slug}`
}

export function badgeImageUrl(): string {
return `${SITE_URL}${BADGE_PATH}`
}

export function badgeMarkdown(slug: string): string {
return `[![Listed on Frappe Brewery](${badgeImageUrl()})](${appUrl(slug)})`
}

export function badgeHtml(slug: string): string {
return `<a href="${appUrl(slug)}"><img src="${badgeImageUrl()}" alt="Listed on Frappe Brewery" height="28"></a>`
}