uprank
This commit is contained in:
parent
4ac870e3cc
commit
4126bdc64b
6 changed files with 73 additions and 1 deletions
|
@ -3,6 +3,8 @@
|
|||
import Nodes from './Nodes.svelte'
|
||||
import Node from './Node.svelte'
|
||||
import User from './User.svelte'
|
||||
import Journals from './Journals.svelte'
|
||||
import Settings from './Settings.svelte'
|
||||
export let url = "";
|
||||
|
||||
</script>
|
||||
|
@ -13,6 +15,8 @@
|
|||
<Route path="/nodes" component="{Nodes}"></Route>
|
||||
<Route path="/node/:id" component="{Node}"></Route>
|
||||
<Route path="/user/:id" component="{User}"></Route>
|
||||
<Route path="/journals" component="{Journals}"></Route>
|
||||
<Route path="/settings" component="{Settings}"></Route>
|
||||
</div>
|
||||
</Router>
|
||||
|
||||
|
|
41
src/Journals.svelte
Normal file
41
src/Journals.svelte
Normal file
|
@ -0,0 +1,41 @@
|
|||
<script>
|
||||
const fetchNodes = (async () => {
|
||||
const response = await fetch("http://127.0.0.1:5000/journals.json");
|
||||
return await response.json();
|
||||
})();
|
||||
const converter = new showdown.Converter();
|
||||
import { replaceWiki } from "./util.js";
|
||||
|
||||
</script>
|
||||
|
||||
<main>
|
||||
This is nodes module
|
||||
{#await fetchNodes}
|
||||
.. Waiting
|
||||
{:then nodes}
|
||||
{#each nodes as node}
|
||||
<div>
|
||||
New Node <span class="node-title">{node.uri}</span>
|
||||
{#each node.subnodes as subnode}
|
||||
<div>
|
||||
User: <span class="node-title">{subnode.user}</span>
|
||||
</div>
|
||||
<div>
|
||||
{#if typeof subnode.content === "string"}
|
||||
{@html converter.makeHtml(replaceWiki(subnode.content))}
|
||||
{/if}
|
||||
</div>
|
||||
{/each}
|
||||
</div>
|
||||
{/each}
|
||||
{/await}
|
||||
</main>
|
||||
|
||||
<style>
|
||||
div {
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
.node-title {
|
||||
font-weight: bold;
|
||||
}
|
||||
</style>
|
|
@ -1,7 +1,10 @@
|
|||
<script>
|
||||
export let id;
|
||||
import { settings } from "./store.js";
|
||||
const fetchNode = (async () => {
|
||||
const response = await fetch(`http://127.0.0.1:5000/node/${id}.json`);
|
||||
$settings = JSON.parse(localStorage["settings"])
|
||||
console.log("settings", $settings)
|
||||
const response = await fetch(`http://127.0.0.1:5000/node/${id}/uprank/${$settings.ranking}.json`);
|
||||
return await response.json();
|
||||
})();
|
||||
const converter = new showdown.Converter();
|
||||
|
|
18
src/Settings.svelte
Normal file
18
src/Settings.svelte
Normal file
|
@ -0,0 +1,18 @@
|
|||
<script>
|
||||
import { settings } from "./store.js";
|
||||
const processSettings = ()=> {
|
||||
localStorage["settings"] = JSON.stringify($settings)
|
||||
console.log("updated")
|
||||
}
|
||||
import { onMount } from 'svelte';
|
||||
onMount(async () => {
|
||||
$settings = JSON.parse(localStorage["settings"])
|
||||
})
|
||||
</script>
|
||||
<main>
|
||||
<form >
|
||||
Enter comma separated list of users to rank
|
||||
<input type="text" id="settings-ranking" placeholder="e.g. flancian, vera" bind:value={$settings.ranking} on:change={processSettings}>
|
||||
</form>
|
||||
{JSON.stringify($settings)}
|
||||
</main>
|
|
@ -1,5 +1,6 @@
|
|||
<script>
|
||||
export let id;
|
||||
import { settings } from "./store.js";
|
||||
const fetchUser = (async () => {
|
||||
const response = await fetch(`http://127.0.0.1:5000/user/${id}.json`);
|
||||
return await response.json();
|
||||
|
|
5
src/store.js
Normal file
5
src/store.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { writable } from 'svelte/store';
|
||||
|
||||
export const settings = writable({
|
||||
ranking: ""
|
||||
})
|
Loading…
Reference in a new issue