messages + post formatting
This commit is contained in:
parent
4c75756abc
commit
34d7d516b5
12 changed files with 359 additions and 38 deletions
|
@ -40,6 +40,15 @@
|
|||
<a href='/'>
|
||||
<img src='/icon_sanifae.svg' alt='Sanifae Logo'>
|
||||
</a>
|
||||
{#if data.read > 0}
|
||||
<a href='/messages'>
|
||||
<img src='/unread.svg' alt='Messages'>
|
||||
</a>
|
||||
{:else}
|
||||
<a href='/messages'>
|
||||
<img src='/read.svg' alt='Messages'>
|
||||
</a>
|
||||
{/if}
|
||||
{#if data.username && data.username != 'false'}
|
||||
<a href='/users/{data.username}'>
|
||||
{data.username}
|
||||
|
|
|
@ -11,15 +11,24 @@
|
|||
p {
|
||||
white-space: pre-wrap;
|
||||
}
|
||||
|
||||
.bold, .bolditalic {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.italic, .bolditalic {
|
||||
font-style: italic;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
import {formatPost} from '$lib/util.js';
|
||||
|
||||
export let content = '';
|
||||
export let excludeImg = false;
|
||||
|
||||
let contentSplit;
|
||||
$: contentSplit = formatPost(content || '');
|
||||
$: contentSplit = formatPost(content || '', excludeImg);
|
||||
|
||||
console.log(contentSplit);
|
||||
</script>
|
||||
|
@ -28,27 +37,29 @@
|
|||
{#each contentSplit as line}
|
||||
<p>
|
||||
{#each line as elem}
|
||||
{#if elem && elem.type == 'img'}
|
||||
{#if line.filter(x => x.type == 'img').length < 2}
|
||||
<img src={elem.url} class='only-img' alt='Image preview'>
|
||||
{:else}
|
||||
<img src={elem.url} alt='Image preview'>
|
||||
<span class={elem.format}>
|
||||
{#if elem && elem.type == 'img'}
|
||||
{#if line.filter(x => x.type == 'img').length < 2}
|
||||
<img src={elem.url} class='only-img' alt='Image preview'>
|
||||
{:else}
|
||||
<img src={elem.url} alt='Image preview'>
|
||||
{/if}
|
||||
{:else if elem.type == 'video'}
|
||||
{#if line.filter(x => x.type == 'video').length < 2}
|
||||
<video class='only-img' alt='Video preview' controls>
|
||||
<source src={elem.url}>
|
||||
</video>
|
||||
{:else}
|
||||
<video alt='Video preview' controls>
|
||||
<source src={elem.url}>
|
||||
</video>
|
||||
{/if}
|
||||
{:else if elem.type == 'link'}
|
||||
<a href={elem.url}>{elem.display}</a>
|
||||
{:else if elem.type == 'text'}
|
||||
{elem.content}
|
||||
{/if}
|
||||
{:else if elem.type == 'video'}
|
||||
{#if line.filter(x => x.type == 'video').length < 2}
|
||||
<video class='only-img' alt='Video preview' controls>
|
||||
<source src={elem.url}>
|
||||
</video>
|
||||
{:else}
|
||||
<video alt='Video preview' controls>
|
||||
<source src={elem.url}>
|
||||
</video>
|
||||
{/if}
|
||||
{:else if elem.type == 'link'}
|
||||
<a href={elem.url}>{elem.display + ' '}</a>
|
||||
{:else if !elem.type}
|
||||
{elem + ' '}
|
||||
{/if}
|
||||
</span>
|
||||
{/each}
|
||||
</p>
|
||||
{/each}
|
||||
|
|
|
@ -3,13 +3,15 @@
|
|||
import Button from '$lib/components/Button.svelte';
|
||||
import {setLocation} from '$lib/util.js';
|
||||
|
||||
export let data;
|
||||
export let data, noRatings;
|
||||
</script>
|
||||
|
||||
<p>
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','hot')}}>Hot</Button>
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','rating')}}>Top</Button>
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','time')}}>Recent</Button>
|
||||
{#if !noRatings}
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','hot')}}>Hot</Button>
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','rating')}}>Top</Button>
|
||||
<Button clickFunc={() => { window.location.search = setLocation(window.location,'sort','time')}}>Recent</Button>
|
||||
{/if}
|
||||
</p>
|
||||
|
||||
{#if data && data.postJson && data.postJson.data}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue