mirror of
https://github.com/coracle-social/coracle.git
synced 2024-10-03 02:10:57 +00:00
Make dufflepud configurable
This commit is contained in:
parent
6c7ebd2b1c
commit
8fe9f2125f
1
.env.local
Normal file
1
.env.local
Normal file
@ -0,0 +1 @@
|
|||||||
|
VITE_DUFFLEPUD_URL=http://localhost:8000
|
1
.env.production
Normal file
1
.env.production
Normal file
@ -0,0 +1 @@
|
|||||||
|
VITE_DUFFLEPUD_URL=https://dufflepud.onrender.com
|
1
.gitignore
vendored
1
.gitignore
vendored
@ -10,7 +10,6 @@ lerna-debug.log*
|
|||||||
node_modules
|
node_modules
|
||||||
dist
|
dist
|
||||||
dist-ssr
|
dist-ssr
|
||||||
*.local
|
|
||||||
|
|
||||||
# Editor directories and files
|
# Editor directories and files
|
||||||
.vscode/*
|
.vscode/*
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<script>
|
<script>
|
||||||
import cx from 'classnames'
|
import cx from 'classnames'
|
||||||
import {find, uniqBy, prop, whereEq} from 'ramda'
|
import {find, last, uniqBy, prop, whereEq} from 'ramda'
|
||||||
import {onMount} from 'svelte'
|
import {onMount} from 'svelte'
|
||||||
import {fly, slide} from 'svelte/transition'
|
import {fly, slide} from 'svelte/transition'
|
||||||
import {navigate} from 'svelte-routing'
|
import {navigate} from 'svelte-routing'
|
||||||
import {LinkPreview} from 'svelte-link-preview'
|
import {LinkPreview} from 'svelte-link-preview'
|
||||||
import {ellipsize} from 'hurdak/src/core'
|
import {ellipsize, first} from 'hurdak/src/core'
|
||||||
import {hasParent, toHtml, findLink} from 'src/util/html'
|
import {hasParent, toHtml, findLink} from 'src/util/html'
|
||||||
import Anchor from 'src/partials/Anchor.svelte'
|
import Anchor from 'src/partials/Anchor.svelte'
|
||||||
import {dispatch} from "src/state/dispatch"
|
import {dispatch} from "src/state/dispatch"
|
||||||
@ -13,7 +13,6 @@
|
|||||||
import {accounts, settings, modal} from "src/state/app"
|
import {accounts, settings, modal} from "src/state/app"
|
||||||
import {user} from "src/state/user"
|
import {user} from "src/state/user"
|
||||||
import {formatTimestamp} from 'src/util/misc'
|
import {formatTimestamp} from 'src/util/misc'
|
||||||
import {getLinkPreview} from 'src/util/html'
|
|
||||||
import UserBadge from "src/partials/UserBadge.svelte"
|
import UserBadge from "src/partials/UserBadge.svelte"
|
||||||
|
|
||||||
export let note
|
export let note
|
||||||
@ -42,6 +41,28 @@
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const getLinkPreview = async url => {
|
||||||
|
const res = await fetch(`${$settings.dufflepudUrl}/link/preview`, {
|
||||||
|
method: 'POST',
|
||||||
|
body: JSON.stringify({url}),
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
|
||||||
|
const json = await res.json()
|
||||||
|
|
||||||
|
if (!json.title) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
...json,
|
||||||
|
hostname: first(last(url.split('//')).split('/')),
|
||||||
|
sitename: null,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const onClick = e => {
|
const onClick = e => {
|
||||||
if (!['I'].includes(e.target.tagName) && !hasParent('a', e.target)) {
|
if (!['I'].includes(e.target.tagName) && !hasParent('a', e.target)) {
|
||||||
modal.set({note})
|
modal.set({note})
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
<script>
|
<script>
|
||||||
import cx from "classnames"
|
|
||||||
import Switch from "svelte-switch"
|
import Switch from "svelte-switch"
|
||||||
|
|
||||||
export let wrapperClass = ""
|
|
||||||
export let value
|
export let value
|
||||||
|
|
||||||
const onChange = e => {
|
const onChange = e => {
|
||||||
@ -10,20 +8,18 @@
|
|||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class={wrapperClass}>
|
<Switch
|
||||||
<Switch
|
checked={value}
|
||||||
checked={value}
|
on:change={onChange}
|
||||||
on:change={onChange}
|
onColor="#ccc"
|
||||||
onColor="#ccc"
|
offColor="#ccc"
|
||||||
offColor="#ccc"
|
onHandleColor="#EB5E28"
|
||||||
onHandleColor="#EB5E28"
|
handleDiameter={26}
|
||||||
handleDiameter={26}
|
unCheckedIcon={false}
|
||||||
unCheckedIcon={false}
|
boxShadow="0px 1px 5px rgba(0, 0, 0, 0.6)"
|
||||||
boxShadow="0px 1px 5px rgba(0, 0, 0, 0.6)"
|
activeBoxShadow="0px 0px 1px 10px rgba(0, 0, 0, 0.2)"
|
||||||
activeBoxShadow="0px 0px 1px 10px rgba(0, 0, 0, 0.2)"
|
height={20}
|
||||||
height={20}
|
width={48}>
|
||||||
width={48}>
|
<span slot="checkedIcon" />
|
||||||
<span slot="checkedIcon" />
|
<span slot="unCheckedIcon" />
|
||||||
<span slot="unCheckedIcon" />
|
</Switch>
|
||||||
</Switch>
|
|
||||||
</div>
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
import {fly} from 'svelte/transition'
|
import {fly} from 'svelte/transition'
|
||||||
import {navigate} from "svelte-routing"
|
import {navigate} from "svelte-routing"
|
||||||
import Toggle from "src/partials/Toggle.svelte"
|
import Toggle from "src/partials/Toggle.svelte"
|
||||||
|
import Input from "src/partials/Input.svelte"
|
||||||
import Button from "src/partials/Button.svelte"
|
import Button from "src/partials/Button.svelte"
|
||||||
import {user} from "src/state/user"
|
import {user} from "src/state/user"
|
||||||
import {settings} from "src/state/app"
|
import {settings} from "src/state/app"
|
||||||
@ -44,6 +45,16 @@
|
|||||||
in any note.
|
in any note.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="flex flex-col gap-1">
|
||||||
|
<strong>Dufflepud URL</strong>
|
||||||
|
<Input bind:value={values.dufflepudUrl}>
|
||||||
|
<i slot="before" class="fa-solid fa-server" />
|
||||||
|
</Input>
|
||||||
|
<p class="text-sm text-light">
|
||||||
|
Enter a custom url for Coracle's helper application. Dufflepud is used for
|
||||||
|
hosting images and loading link previews.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
<Button type="submit" class="text-center">Done</Button>
|
<Button type="submit" class="text-center">Done</Button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,6 +11,7 @@ export const modal = writable(null)
|
|||||||
|
|
||||||
export const settings = writable({
|
export const settings = writable({
|
||||||
showLinkPreviews: true,
|
showLinkPreviews: true,
|
||||||
|
dufflepudUrl: import.meta.env.VITE_DUFFLEPUD_URL,
|
||||||
...getLocalJson("coracle/settings"),
|
...getLocalJson("coracle/settings"),
|
||||||
})
|
})
|
||||||
|
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import {last} from 'ramda'
|
|
||||||
import {first} from 'hurdak/lib/hurdak'
|
import {first} from 'hurdak/lib/hurdak'
|
||||||
|
|
||||||
export const copyToClipboard = text => {
|
export const copyToClipboard = text => {
|
||||||
@ -81,17 +80,3 @@ export const toHtml = content => {
|
|||||||
return `<a href="${url}" target="_blank noopener" class="underline">${domain}</a>`
|
return `<a href="${url}" target="_blank noopener" class="underline">${domain}</a>`
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export const getLinkPreview = async url => {
|
|
||||||
const res = await fetch('http://localhost:8000/link/preview', {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({url}),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
const json = await res.json()
|
|
||||||
|
|
||||||
return {...json, hostname: first(last(url.split('//')).split('/')), sitename: null}
|
|
||||||
}
|
|
||||||
|
@ -49,3 +49,4 @@ export const formatTimestamp = ts => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
export const sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user