show the neighbourhood
This commit is contained in:
parent
e83f25461d
commit
08d391010d
@ -9,9 +9,11 @@ tasks:
|
|||||||
export-db:
|
export-db:
|
||||||
cmds:
|
cmds:
|
||||||
- sqlite3 /home/bggsell/games.db '.mode json' '.once /home/bggsell/db/games.json' 'select * from game'
|
- sqlite3 /home/bggsell/games.db '.mode json' '.once /home/bggsell/db/games.json' 'select * from game'
|
||||||
|
- sqlite3 /home/bggsell/games.db '.mode json' '.once /home/bggsell/db/sellers.json' 'select * from bgg_user'
|
||||||
export-db:dev:
|
export-db:dev:
|
||||||
cmds:
|
cmds:
|
||||||
- sqlite3 games.db '.mode json' '.once static/dev/games.json' 'select * from game'
|
- sqlite3 games.db '.mode json' '.once static/dev/games.json' 'select * from game'
|
||||||
|
- sqlite3 games.db '.mode json' '.once static/dev/sellers.json' 'select * from bgg_user'
|
||||||
|
|
||||||
deploy:
|
deploy:
|
||||||
deps: [build]
|
deps: [build]
|
||||||
|
@ -7,7 +7,37 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
import 'beercss/dist/cdn/beer.min.css';
|
import 'beercss/dist/cdn/beer.min.css';
|
||||||
//import beercss from "./dist/cdn/beer.min.js";
|
import { setContext } from 'svelte';
|
||||||
|
import { dev, browser } from '$app/environment';
|
||||||
|
import { readable } from 'svelte/store';
|
||||||
|
|
||||||
|
const prefix = dev ? '/dev/' : '/db/';
|
||||||
|
|
||||||
|
const games = readable([], async (set) => {
|
||||||
|
if (!browser) return () => {};
|
||||||
|
|
||||||
|
fetch(prefix + 'games.json')
|
||||||
|
.then((doc) => doc.json())
|
||||||
|
.then(set);
|
||||||
|
|
||||||
|
return () => {};
|
||||||
|
});
|
||||||
|
setContext('games', games);
|
||||||
|
|
||||||
|
const sellers = readable({}, async (set) => {
|
||||||
|
if (!browser) return () => {};
|
||||||
|
|
||||||
|
const sellers_list = await fetch(prefix + 'sellers.json').then((doc) =>
|
||||||
|
doc.json(),
|
||||||
|
);
|
||||||
|
set(
|
||||||
|
Object.fromEntries(
|
||||||
|
sellers_list.map((seller) => [seller.username, seller]),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
return () => {};
|
||||||
|
});
|
||||||
|
setContext('sellers', sellers);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -1,9 +0,0 @@
|
|||||||
import { dev, browser } from '$app/environment';
|
|
||||||
|
|
||||||
export async function load({ fetch }) {
|
|
||||||
const url = dev ? '/dev/games.json' : '/games.json';
|
|
||||||
|
|
||||||
return {
|
|
||||||
games: browser ? fetch(url).then((doc) => doc.json()) : [],
|
|
||||||
};
|
|
||||||
}
|
|
@ -8,7 +8,7 @@
|
|||||||
</header>
|
</header>
|
||||||
|
|
||||||
<article>
|
<article>
|
||||||
{#await data.games}
|
{#await $games}
|
||||||
<div class="medium-height middle-align center-align">
|
<div class="medium-height middle-align center-align">
|
||||||
<div class="center-align">
|
<div class="center-align">
|
||||||
<progress class="circle"></progress>
|
<progress class="circle"></progress>
|
||||||
@ -17,17 +17,17 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{:then games}
|
{:then games}
|
||||||
<GameList {games} />
|
<GameList {games} sellers={$sellers} />
|
||||||
{/await}
|
{/await}
|
||||||
</article>
|
</article>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
// TODO hide games I'm not interested in
|
import { getContext } from 'svelte';
|
||||||
// TODO add cart
|
|
||||||
// TODO prettify via beercss
|
|
||||||
import GameList from './GameList.svelte';
|
import GameList from './GameList.svelte';
|
||||||
|
|
||||||
export let data;
|
const games = getContext('games');
|
||||||
|
const sellers = getContext('sellers');
|
||||||
|
$: console.log($sellers);
|
||||||
|
|
||||||
function pretty_date(date) {
|
function pretty_date(date) {
|
||||||
if (!date) return '';
|
if (!date) return '';
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
</strong>
|
</strong>
|
||||||
</div>
|
</div>
|
||||||
<div class="s3">
|
<div class="s3">
|
||||||
|
<div>
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href={`https://boardgamegeek.com/collection/user/${game.username}?trade=1&subtype=boardgame&ff=1`}
|
href={`https://boardgamegeek.com/collection/user/${game.username}?trade=1&subtype=boardgame&ff=1`}
|
||||||
@ -27,6 +28,10 @@
|
|||||||
href={`https://boardgamegeek.com/geekmail/compose?touser=${game.username}`}>
|
href={`https://boardgamegeek.com/geekmail/compose?touser=${game.username}`}>
|
||||||
<i>email</i></a>
|
<i>email</i></a>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="neighbourhood">
|
||||||
|
{sellers[game.username]?.neighbourhood ?? ''}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="s1 right-align">
|
<div class="s1 right-align">
|
||||||
{game.price ? '$' + game.price : ''}
|
{game.price ? '$' + game.price : ''}
|
||||||
</div>
|
</div>
|
||||||
@ -44,6 +49,7 @@
|
|||||||
|
|
||||||
<script>
|
<script>
|
||||||
export let games;
|
export let games;
|
||||||
|
export let sellers = {};
|
||||||
|
|
||||||
// add filter
|
// add filter
|
||||||
// add sort (user, game, price)
|
// add sort (user, game, price)
|
||||||
@ -78,4 +84,7 @@
|
|||||||
.updated-at::before {
|
.updated-at::before {
|
||||||
content: 'last update: ';
|
content: 'last update: ';
|
||||||
}
|
}
|
||||||
|
.neighbourhood {
|
||||||
|
font-size: smaller;
|
||||||
|
}
|
||||||
</style>
|
</style>
|
||||||
|
2
static/dev/sellers.json
Normal file
2
static/dev/sellers.json
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
[{"username":"yenzie","neighbourhood":"Bells Corners"},
|
||||||
|
{"username":"jmarkmoss","neighbourhood":null}]
|
Loading…
Reference in New Issue
Block a user