Browse Source
for github only. added notes for enabling displaying readme for other git servers in the futuremaster
8 changed files with 172 additions and 70 deletions
@ -0,0 +1,28 @@ |
|||||||
|
import { extractGithubDetails } from '$lib/components/repo/utils' |
||||||
|
|
||||||
|
export const GET = async ({ params }: { params: { clone: string } }) => { |
||||||
|
const github_details = extractGithubDetails(decodeURIComponent(params.clone)) |
||||||
|
if (github_details) { |
||||||
|
const res = await fetch( |
||||||
|
`https://raw.githubusercontent.com/${github_details.org}/${github_details.repo_name}/HEAD/README.md` |
||||||
|
) |
||||||
|
const text = await res.text() |
||||||
|
|
||||||
|
return new Response(text) |
||||||
|
} else { |
||||||
|
// options:
|
||||||
|
// * add support for different git server implementations that serve raw
|
||||||
|
// files and cycle through the urls until we find the readme
|
||||||
|
// * add a worker that can use 'git archive' to get specific files
|
||||||
|
// * unfortunately the two options that can easily embeded within this
|
||||||
|
// sveltekit backend (wasm-git and isomorphicgit) don't support the
|
||||||
|
// 'archive' command
|
||||||
|
// https://github.com/petersalomonsen/wasm-git/
|
||||||
|
// https://github.com/isomorphic-git
|
||||||
|
// * 'git clone' is too expensive for retrieving single files. even when
|
||||||
|
// done using treeless or blobless flags. see:
|
||||||
|
// https://noise.getoto.net/2020/12/21/get-up-to-speed-with-partial-clone-and-shallow-clone/
|
||||||
|
|
||||||
|
return new Response(null) |
||||||
|
} |
||||||
|
} |
||||||
@ -1,39 +1,42 @@ |
|||||||
<script lang="ts"> |
<script lang="ts"> |
||||||
import ProposalsList from '$lib/components/proposals/ProposalsList.svelte' |
import { selected_repo_readme } from '$lib/stores/repo' |
||||||
import { proposal_summaries } from '$lib/stores/Proposals' |
import SvelteMarkdown from 'svelte-markdown' |
||||||
import RepoPageWrapper from '$lib/wrappers/RepoPageWrapper.svelte' |
import RepoPageWrapper from '$lib/wrappers/RepoPageWrapper.svelte' |
||||||
|
import { goto } from '$app/navigation' |
||||||
|
|
||||||
export let data: { repo_id: string } |
export let data: { repo_id: string } |
||||||
let identifier = data.repo_id |
let identifier = data.repo_id |
||||||
|
|
||||||
|
let selected_tab: '' | 'issues' | 'proposals' = '' |
||||||
|
$: { |
||||||
|
if ($selected_repo_readme.failed === true) |
||||||
|
goto(`/repo/${identifier}/proposals`) |
||||||
|
} |
||||||
</script> |
</script> |
||||||
|
|
||||||
<RepoPageWrapper {identifier} selected_tab="proposals"> |
<RepoPageWrapper {identifier} {selected_tab}> |
||||||
<ProposalsList |
<div class="my-3 rounded-lg border border-base-400"> |
||||||
proposals_or_issues={$proposal_summaries.summaries} |
<div class="border-b border-base-400 bg-base-300 px-6 py-3"> |
||||||
loading={$proposal_summaries.loading} |
<h4 class="">README.md</h4> |
||||||
/> |
</div> |
||||||
<div role="alert" class="alert mt-6"> |
<div class="p-6"> |
||||||
<svg |
{#if $selected_repo_readme.loading} |
||||||
xmlns="http://www.w3.org/2000/svg" |
<div class="skeleton my-3 h-5 w-20"></div> |
||||||
fill="none" |
<div class="skeleton my-2 h-4"></div> |
||||||
viewBox="0 0 24 24" |
<div class="skeleton my-2 mb-3 h-4 w-2/3"></div> |
||||||
class="h-6 w-6 shrink-0 stroke-info" |
<div class="skeleton my-3 h-5 w-20"></div> |
||||||
><path |
<div class="skeleton my-2 h-4"></div> |
||||||
stroke-linecap="round" |
<div class="skeleton my-2 mb-3 h-4 w-2/3"></div> |
||||||
stroke-linejoin="round" |
{:else if $selected_repo_readme.failed} |
||||||
stroke-width="2" |
<div>failed to load readme from git server...</div> |
||||||
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" |
{:else} |
||||||
></path></svg |
<article class="prose prose-sm"> |
||||||
> |
<SvelteMarkdown |
||||||
<div> |
options={{ gfm: true }} |
||||||
<h3 class="prose mb-2 text-sm font-bold">want to submit a proposal?</h3> |
source={$selected_repo_readme.md} |
||||||
<p class="prose text-xs"> |
/> |
||||||
<a href="/ngit">install ngit</a>, create add a feature in the local |
</article> |
||||||
repository and run |
{/if} |
||||||
<span class="rounded bg-neutral p-1 font-mono" |
|
||||||
><span class="py-3">ngit send</span></span |
|
||||||
> |
|
||||||
</p> |
|
||||||
</div> |
</div> |
||||||
</div> |
</div> |
||||||
</RepoPageWrapper> |
</RepoPageWrapper> |
||||||
|
|||||||
@ -0,0 +1,39 @@ |
|||||||
|
<script lang="ts"> |
||||||
|
import ProposalsList from '$lib/components/proposals/ProposalsList.svelte' |
||||||
|
import { proposal_summaries } from '$lib/stores/Proposals' |
||||||
|
import RepoPageWrapper from '$lib/wrappers/RepoPageWrapper.svelte' |
||||||
|
|
||||||
|
export let data: { repo_id: string } |
||||||
|
let identifier = data.repo_id |
||||||
|
</script> |
||||||
|
|
||||||
|
<RepoPageWrapper {identifier} selected_tab="proposals"> |
||||||
|
<ProposalsList |
||||||
|
proposals_or_issues={$proposal_summaries.summaries} |
||||||
|
loading={$proposal_summaries.loading} |
||||||
|
/> |
||||||
|
<div role="alert" class="alert mt-6"> |
||||||
|
<svg |
||||||
|
xmlns="http://www.w3.org/2000/svg" |
||||||
|
fill="none" |
||||||
|
viewBox="0 0 24 24" |
||||||
|
class="h-6 w-6 shrink-0 stroke-info" |
||||||
|
><path |
||||||
|
stroke-linecap="round" |
||||||
|
stroke-linejoin="round" |
||||||
|
stroke-width="2" |
||||||
|
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z" |
||||||
|
></path></svg |
||||||
|
> |
||||||
|
<div> |
||||||
|
<h3 class="prose mb-2 text-sm font-bold">want to submit a proposal?</h3> |
||||||
|
<p class="prose text-xs"> |
||||||
|
<a href="/ngit">install ngit</a>, create add a feature in the local |
||||||
|
repository and run |
||||||
|
<span class="rounded bg-neutral p-1 font-mono" |
||||||
|
><span class="py-3">ngit send</span></span |
||||||
|
> |
||||||
|
</p> |
||||||
|
</div> |
||||||
|
</div> |
||||||
|
</RepoPageWrapper> |
||||||
Loading…
Reference in new issue