diff --git a/webapp/src/components/Article.svelte b/webapp/src/components/Article.svelte new file mode 100644 index 0000000..12da966 --- /dev/null +++ b/webapp/src/components/Article.svelte @@ -0,0 +1,52 @@ + + + + + + + {story.title} + {#if story.url} + source: {host} + {/if} + + + + + {@html story.text} + + diff --git a/webapp/src/components/Comment.svelte b/webapp/src/components/Comment.svelte index 6384246..be623f7 100644 --- a/webapp/src/components/Comment.svelte +++ b/webapp/src/components/Comment.svelte @@ -1,12 +1,9 @@ - - - - News - - - - - - - + + + + + News + + + Search + + + + + + + Qot. + + diff --git a/webapp/src/components/Pagination.svelte b/webapp/src/components/Pagination.svelte new file mode 100644 index 0000000..20bef24 --- /dev/null +++ b/webapp/src/components/Pagination.svelte @@ -0,0 +1,55 @@ + + + + + + {#if skip > 0} + Previous + {/if} + {#if count >= limit} + Next + {/if} + diff --git a/webapp/src/components/StoryInfo.svelte b/webapp/src/components/StoryInfo.svelte index 955c1ca..3881646 100644 --- a/webapp/src/components/StoryInfo.svelte +++ b/webapp/src/components/StoryInfo.svelte @@ -1,26 +1,18 @@ - - {dateString} - {#if story.author && story.author_link} - by - {story.author} - {:else if story.author}by {story.author}{/if} - on - {story.source} - {#if story.score}• {story.score} points{/if} - {#if story.num_comments} - • - {story.num_comments} - comments - {/if} - + +{#if story.author && story.author_link} + by + {story.author} +{:else if story.author}by {story.author}{/if} +on +{story.source} +{#if story.score}• {story.score} points{/if} +{#if story.num_comments} + • + {story.num_comments} + comments +{/if} diff --git a/webapp/src/components/StoryList.svelte b/webapp/src/components/StoryList.svelte new file mode 100644 index 0000000..09b1fad --- /dev/null +++ b/webapp/src/components/StoryList.svelte @@ -0,0 +1,55 @@ + + + + +{#each stories as story} + + + + {story.title} + {host(story.url || story.link)} + + + + + +{/each} + + diff --git a/webapp/src/components/Time.svelte b/webapp/src/components/Time.svelte new file mode 100644 index 0000000..795b774 --- /dev/null +++ b/webapp/src/components/Time.svelte @@ -0,0 +1,11 @@ + + +{dateString} diff --git a/webapp/src/routes/[id].json.js b/webapp/src/routes/[id].json.js index daa8d5f..39e7c73 100644 --- a/webapp/src/routes/[id].json.js +++ b/webapp/src/routes/[id].json.js @@ -1,6 +1,5 @@ import fetch from 'isomorphic-fetch'; -// const API_URL = process.env.API_URL || 'http://news.1j.nz'; const API_URL = process.env.API_URL || 'http://localhost:33842'; export async function get(req, res) { diff --git a/webapp/src/routes/[id].svelte b/webapp/src/routes/[id].svelte index b6df878..30c71a7 100644 --- a/webapp/src/routes/[id].svelte +++ b/webapp/src/routes/[id].svelte @@ -14,7 +14,7 @@ @@ -54,41 +42,37 @@ - - - {story.title} - - + + - - {@html story.text} - - + {#if hasComments} + -{#if hasComments} - + + + Comments - - - Comments - - {#if others.length} - - Other discussions: - {#each others as r} - {#if r.num_comments} - {r.source} - {/if} + {#if others.length} + + Other discussions: + {#each others as r} + {#if r.num_comments} + + {r.source} + ({r.num_comments}) + + {/if} + {/each} + + {/if} + + {#if story.comments.length} + + {#each story.comments as comment} + {/each} - + {/if} - - {#if story.comments.length} - - {#each story.comments as comment} - - {/each} - - {/if} - -{/if} + + {/if} + diff --git a/webapp/src/routes/_layout.svelte b/webapp/src/routes/_layout.svelte index 72eb7ed..5d870f7 100644 --- a/webapp/src/routes/_layout.svelte +++ b/webapp/src/routes/_layout.svelte @@ -6,9 +6,9 @@ - QotNews - - {#each stories as story} - - - - {story.title} - ({new URL(story.url || story.link).hostname.replace(/^www\./, '')}) - - - - - - {/each} - - - - {#if Number(skip) > 0} - Previous - {/if} - {#if stories.length == Number(limit)} - Next - {/if} - + + + diff --git a/webapp/src/routes/search.json.js b/webapp/src/routes/search.json.js index b2c83ec..a200d07 100644 --- a/webapp/src/routes/search.json.js +++ b/webapp/src/routes/search.json.js @@ -1,6 +1,6 @@ import fetch from 'isomorphic-fetch'; -const API_URL = process.env.API_URL || 'http://news.1j.nz'; +const API_URL = process.env.API_URL || 'http://localhost:33842'; export async function get(req, res) { const { skip, limit } = { diff --git a/webapp/src/routes/search.svelte b/webapp/src/routes/search.svelte index cbe6294..6bf00a6 100644 --- a/webapp/src/routes/search.svelte +++ b/webapp/src/routes/search.svelte @@ -20,84 +20,23 @@ - - QotNews - - {#each stories as story} - - - - {story.title} - ({new URL(story.url || story.link).hostname.replace(/^www\./, '')}) - - - - - - {/each} - - - - {#if Number(skip) > 0} - Previous - {/if} - {#if stories.length == Number(limit)} - Next - {/if} - + + + diff --git a/webapp/static/global.css b/webapp/static/global.css index 3566e73..0e2b9a9 100644 --- a/webapp/static/global.css +++ b/webapp/static/global.css @@ -1,36 +1,38 @@ body { - margin: 0; - font-family: Roboto, -apple-system, BlinkMacSystemFont, Segoe UI, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; - font-size: 14px; - line-height: 1.5; - color: #333; + margin: 0; + font-family: Roboto, -apple-system, BlinkMacSystemFont, Segoe UI, Oxygen, + Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif; + font-size: 16px; + line-height: 1.5; + color: #333; + + margin-bottom: 50vh; } -h1, h2, h3, h4, h5, h6 { - margin: 0 0 0.5em 0; - font-weight: 400; - line-height: 1.2; +h1, +h2, +h3, +h4, +h5, +h6 { + margin: 0 0 0.5em 0; + font-weight: 400; + line-height: 1.2; } h1 { - font-size: 2em; + font-size: 2em; } a { - color: inherit; + color: inherit; } code { - font-family: menlo, inconsolata, monospace; - font-size: calc(1em - 2px); - color: #555; - background-color: #f0f0f0; - padding: 0.2em 0.4em; - border-radius: 2px; + font-family: menlo, inconsolata, monospace; + font-size: calc(1em - 2px); + color: #555; + background-color: #f0f0f0; + padding: 0.2em 0.4em; + border-radius: 2px; } - -@media (min-width: 400px) { - body { - font-size: 16px; - } -} \ No newline at end of file diff --git a/webclient/src/App.js b/webclient/src/App.js index 4c74151..617bfe9 100644 --- a/webclient/src/App.js +++ b/webclient/src/App.js @@ -13,6 +13,12 @@ import Article from './pages/Article.js'; import Comments from './pages/Comments.js'; import Results from './pages/Results.js'; +const pagingKey = (props) => { + const query = new URLSearchParams(props.location.search); + const skip = query.get('skip') || 0; + const limit = query.get('limit') || 20; + return `skip=${skip}&limit=${limit}`; +} class App extends React.Component { constructor(props) { @@ -66,7 +72,7 @@ class App extends React.Component { - } /> + } /> } /> diff --git a/webclient/src/pages/Feed.js b/webclient/src/pages/Feed.js index fc899e5..2c0d0e5 100644 --- a/webclient/src/pages/Feed.js +++ b/webclient/src/pages/Feed.js @@ -76,11 +76,4 @@ class Feed extends React.Component { } } -Feed.key = function (props) { - const query = new URLSearchParams(props.location.search); - const skip = query.get('skip') || 0; - const limit = query.get('limit') || 20; - return `skip=${skip}&limit=${limit}`; -} - export default Feed;