|
|
@ -59,7 +59,10 @@
|
|
|
|
headers: { Authorization },
|
|
|
|
headers: { Authorization },
|
|
|
|
body: JSON.stringify({
|
|
|
|
body: JSON.stringify({
|
|
|
|
name,
|
|
|
|
name,
|
|
|
|
components
|
|
|
|
files: components.map(component => ({
|
|
|
|
|
|
|
|
name: `${component.name}.${component.type}`,
|
|
|
|
|
|
|
|
source: component.source
|
|
|
|
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
@ -107,16 +110,16 @@
|
|
|
|
const files = {};
|
|
|
|
const files = {};
|
|
|
|
const { components } = repl.toJSON();
|
|
|
|
const { components } = repl.toJSON();
|
|
|
|
|
|
|
|
|
|
|
|
components.forEach(module => {
|
|
|
|
|
|
|
|
const text = module.source.trim();
|
|
|
|
|
|
|
|
if (!text.length) return; // skip empty file
|
|
|
|
|
|
|
|
files[`${module.name}.${module.type}`] = text;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const r = await fetch(`repl/${gist.uid}.json`, {
|
|
|
|
const r = await fetch(`repl/${gist.uid}.json`, {
|
|
|
|
method: 'PATCH',
|
|
|
|
method: 'PATCH',
|
|
|
|
headers: { Authorization },
|
|
|
|
headers: { Authorization },
|
|
|
|
body: JSON.stringify({ name, files })
|
|
|
|
body: JSON.stringify({
|
|
|
|
|
|
|
|
name,
|
|
|
|
|
|
|
|
files: components.map(component => ({
|
|
|
|
|
|
|
|
name: `${component.name}.${component.type}`,
|
|
|
|
|
|
|
|
source: component.source
|
|
|
|
|
|
|
|
}))
|
|
|
|
|
|
|
|
})
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
if (r.status < 200 || r.status >= 300) {
|
|
|
|
if (r.status < 200 || r.status >= 300) {
|
|
|
@ -197,29 +200,21 @@ export default app;` });
|
|
|
|
<Icon name="download" />
|
|
|
|
<Icon name="download" />
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
|
|
{#if $user}
|
|
|
|
<button class="icon" disabled="{saving || !$user}" on:click={() => fork(false)} title="fork">
|
|
|
|
<button class="icon" disabled="{saving || !$user}" on:click={fork} title="fork">
|
|
|
|
{#if justForked}
|
|
|
|
{#if justForked}
|
|
|
|
<Icon name="check" />
|
|
|
|
<Icon name="check" />
|
|
|
|
{:else}
|
|
|
|
{:else}
|
|
|
|
<Icon name="git-branch" />
|
|
|
|
<Icon name="git-branch" />
|
|
|
|
{/if}
|
|
|
|
{/if}
|
|
|
|
</button>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<button class="icon" disabled="{saving || !$user}" on:click={save} title="save">
|
|
|
|
|
|
|
|
{#if justSaved}
|
|
|
|
|
|
|
|
<Icon name="check" />
|
|
|
|
|
|
|
|
{:else}
|
|
|
|
|
|
|
|
<Icon name="save" />
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
{#if gist}
|
|
|
|
<button class="icon" disabled="{saving || !$user}" on:click={save} title="save">
|
|
|
|
<a class="icon no-underline" href={gist.html_url} title="link to gist">
|
|
|
|
{#if justSaved}
|
|
|
|
<Icon name="link" />
|
|
|
|
<Icon name="check" />
|
|
|
|
</a>
|
|
|
|
{:else}
|
|
|
|
{/if}
|
|
|
|
<Icon name="save" />
|
|
|
|
|
|
|
|
{/if}
|
|
|
|
|
|
|
|
</button>
|
|
|
|
|
|
|
|
|
|
|
|
{#if $user}
|
|
|
|
{#if $user}
|
|
|
|
<UserMenu />
|
|
|
|
<UserMenu />
|
|
|
|