From be813201ec6a634fee3f466523600e1e80805cb6 Mon Sep 17 00:00:00 2001 From: Clinton D'Annolfo Date: Sat, 28 Mar 2020 12:09:32 -0400 Subject: [PATCH] Cleaned up pages --- pages/active.tsx | 13 +- pages/ask.tsx | 13 +- pages/best.tsx | 14 +- pages/bestcomments.tsx | 14 +- pages/bookmarklet.tsx | 78 ++-- pages/changepw.tsx | 16 +- pages/favorites.tsx | 14 +- pages/forgot.tsx | 11 +- pages/formatdoc.tsx | 10 +- pages/front.tsx | 15 +- pages/hidden.tsx | 14 +- pages/index.tsx | 14 +- pages/item.tsx | 34 +- pages/jobs.tsx | 16 +- pages/leaders.tsx | 16 +- pages/lists.tsx | 148 +++--- pages/login.tsx | 10 +- pages/newcomments.tsx | 33 +- pages/newest.tsx | 31 +- pages/newpoll.tsx | 14 +- pages/newsfaq.tsx | 378 +++++++-------- pages/newsguidelines.tsx | 239 +++++----- pages/newswelcome.tsx | 164 +++---- pages/noobcomments.tsx | 14 +- pages/noobstories.tsx | 14 +- pages/reply.tsx | 190 ++++---- pages/security.tsx | 433 +++++++++--------- pages/show.tsx | 13 +- pages/showhn.tsx | 141 +++--- pages/shownew.tsx | 20 +- pages/submit.tsx | 20 +- pages/submitted.tsx | 14 +- pages/threads.tsx | 14 +- pages/upvoted.tsx | 20 +- pages/user.tsx | 112 ++--- server/graphql-resolvers.spec.ts | 56 +++ server/graphql-schema.spec.ts | 58 --- .../__snapshots__/comment.spec.tsx.snap | 6 +- src/components/comment.tsx | 4 +- src/components/header-nav.tsx | 4 - src/components/header.tsx | 4 - 41 files changed, 1229 insertions(+), 1217 deletions(-) create mode 100644 server/graphql-resolvers.spec.ts delete mode 100644 server/graphql-schema.spec.ts diff --git a/pages/active.tsx b/pages/active.tsx index 1cec6dd..13bc528 100644 --- a/pages/active.tsx +++ b/pages/active.tsx @@ -5,19 +5,20 @@ import { sampleData } from '../src/data/sample-data'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const ActivePage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function ActivePage(props): JSX.Element { + const { router } = props; + const pageNumber = (router.query && +router.query.p) || 0; return ( - + ); -}); +} -export default ActivePage; +export default withDataAndRouter(ActivePage); diff --git a/pages/ask.tsx b/pages/ask.tsx index 2676c47..cd3d50b 100644 --- a/pages/ask.tsx +++ b/pages/ask.tsx @@ -25,8 +25,9 @@ export interface IAskPageProps { }; } -export const AskPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function AskPage(props): JSX.Element { + const { router } = props; + const pageNumber = (router.query && +router.query.p) || 0; const first = POSTS_PER_PAGE; const skip = POSTS_PER_PAGE * pageNumber; @@ -34,10 +35,10 @@ export const AskPage = withDataAndRouter((props) => { const { data } = useQuery(query, { variables: { first, skip, type: FeedType.ASK } }); return ( - - + + ); -}); +} -export default AskPage; +export default withDataAndRouter(AskPage); diff --git a/pages/best.tsx b/pages/best.tsx index 772f3f7..6f0cb34 100644 --- a/pages/best.tsx +++ b/pages/best.tsx @@ -25,8 +25,10 @@ export interface IBestNewsFeedProps { }; } -export const BestPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function BestPage(props): JSX.Element { + const { router } = props; + + const pageNumber = (router.query && +router.query.p) || 0; const first = POSTS_PER_PAGE; const skip = POSTS_PER_PAGE * pageNumber; @@ -34,10 +36,10 @@ export const BestPage = withDataAndRouter((props) => { const { data } = useQuery(query, { variables: { first, skip, type: FeedType.BEST } }); return ( - - + + ); -}); +} -export default BestPage; +export default withDataAndRouter(BestPage); diff --git a/pages/bestcomments.tsx b/pages/bestcomments.tsx index 24a987e..c45f804 100644 --- a/pages/bestcomments.tsx +++ b/pages/bestcomments.tsx @@ -5,19 +5,21 @@ import { sampleData } from '../src/data/sample-data'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const BestCommentsPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function BestCommentsPage(props): JSX.Element { + const { router } = props; + + const pageNumber = (router.query && +router.query.p) || 0; return ( - + ); -}); +} -export default BestCommentsPage; +export default withDataAndRouter(BestCommentsPage); diff --git a/pages/bookmarklet.tsx b/pages/bookmarklet.tsx index e27429b..c5e72ec 100644 --- a/pages/bookmarklet.tsx +++ b/pages/bookmarklet.tsx @@ -3,47 +3,49 @@ import * as React from 'react'; import { NoticeLayout } from '../src/layouts/notice-layout'; -export const BookmarkletPage = (props) => ( - - Bookmarklet -
-
-
-

- Thanks to Phil Kast for writing this bookmarklet for submitting links to{' '} - - Hacker News - - . When you click on the bookmarklet, it will submit the page you're on. To install, drag - this link to your browser toolbar: -
-
-

- +export function BookmarkletPage(props): JSX.Element { + return ( + + Bookmarklet

- - - - - -
-
-

- +

+

+ Thanks to Phil Kast for writing this bookmarklet for submitting links to{' '} + + Hacker News + + . When you click on the bookmarklet, it will submit the page you're on. To install, + drag this link to your browser toolbar:

- -

-
-
-); +

+ +
+
+ + + + + +
+
+

+ +
+
+
+

+
+
+ ); +} export default BookmarkletPage; diff --git a/pages/changepw.tsx b/pages/changepw.tsx index 3d98340..4e39ab8 100644 --- a/pages/changepw.tsx +++ b/pages/changepw.tsx @@ -3,10 +3,14 @@ import * as React from 'react'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const ChangePasswordPage = withDataAndRouter((props) => ( - -

Change PW

-
-)); +export function ChangePasswordPage(props): JSX.Element { + const { router } = props; -export default ChangePasswordPage; + return ( + +

Change PW

+
+ ); +} + +export default withDataAndRouter(ChangePasswordPage); diff --git a/pages/favorites.tsx b/pages/favorites.tsx index 5082b16..8a5c4ee 100644 --- a/pages/favorites.tsx +++ b/pages/favorites.tsx @@ -25,8 +25,10 @@ export interface INewestNewsFeedOwnProps { }; } -export const FavoritesPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function FavoritesPage(props): JSX.Element { + const { router } = props; + + const pageNumber = (router.query && +router.query.p) || 0; const first = POSTS_PER_PAGE; const skip = POSTS_PER_PAGE * pageNumber; @@ -34,10 +36,10 @@ export const FavoritesPage = withDataAndRouter((props) => { const { data } = useQuery(query, { variables: { first, skip, type: FeedType.NEW } }); return ( - - + + ); -}); +} -export default FavoritesPage; +export default withDataAndRouter(FavoritesPage); diff --git a/pages/forgot.tsx b/pages/forgot.tsx index 6e18302..7bcaac7 100644 --- a/pages/forgot.tsx +++ b/pages/forgot.tsx @@ -1,5 +1,4 @@ -import gql from 'graphql-tag'; -import { withRouter, NextRouter } from 'next/router'; +import { NextRouter } from 'next/router'; import React, { useState } from 'react'; import { withDataAndRouter } from '../src/helpers/with-data'; @@ -9,7 +8,7 @@ export interface IForgotPageProps { router: NextRouter; // { how: UserLoginErrorCode } } -function ForgotPageView(props: IForgotPageProps): JSX.Element { +function ForgotPage(props: IForgotPageProps): JSX.Element { const [username, setUsername] = useState(''); return ( @@ -30,8 +29,4 @@ function ForgotPageView(props: IForgotPageProps): JSX.Element { ); } -export const ForgotPage = withDataAndRouter( - withRouter((props) => ) -); - -export default ForgotPage; +export default withDataAndRouter(ForgotPage); diff --git a/pages/formatdoc.tsx b/pages/formatdoc.tsx index 54a4501..d8426d8 100644 --- a/pages/formatdoc.tsx +++ b/pages/formatdoc.tsx @@ -3,12 +3,14 @@ import * as React from 'react'; import { MainLayout } from '../src/layouts/main-layout'; import { withDataAndRouter } from '../src/helpers/with-data'; -export const FormatDocPage = withDataAndRouter((props) => { +export function FormatDocPage(props): JSX.Element { + const { router } = props; + return ( @@ -45,6 +47,6 @@ export const FormatDocPage = withDataAndRouter((props) => { ); -}); +} -export default FormatDocPage; +export default withDataAndRouter(FormatDocPage); diff --git a/pages/front.tsx b/pages/front.tsx index 5257b92..e324d25 100644 --- a/pages/front.tsx +++ b/pages/front.tsx @@ -3,10 +3,13 @@ import * as React from 'react'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const FrontPage = withDataAndRouter((props) => ( - - total - -)); +export function FrontPage(props): JSX.Element { + const { router } = props; + return ( + + total + + ); +} -export default FrontPage; +export default withDataAndRouter(FrontPage); diff --git a/pages/hidden.tsx b/pages/hidden.tsx index 71acd2f..e6235d6 100644 --- a/pages/hidden.tsx +++ b/pages/hidden.tsx @@ -5,19 +5,21 @@ import { sampleData } from '../src/data/sample-data'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const HiddenPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function HiddenPage(props): JSX.Element { + const { router } = props; + + const pageNumber = (router.query && +router.query.p) || 0; return ( - + ); -}); +} -export default HiddenPage; +export default withDataAndRouter(HiddenPage); diff --git a/pages/index.tsx b/pages/index.tsx index 85f3adf..5a088ec 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -25,8 +25,10 @@ export interface ITopNewsFeedProps { }; } -export const IndexPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function IndexPage(props): JSX.Element { + const { router } = props; + + const pageNumber = (router.query && +router.query.p) || 0; const first = POSTS_PER_PAGE; const skip = POSTS_PER_PAGE * pageNumber; @@ -34,10 +36,10 @@ export const IndexPage = withDataAndRouter((props) => { const { data } = useQuery(query, { variables: { first, skip, type: FeedType.TOP } }); return ( - - + + ); -}); +} -export default IndexPage; +export default withDataAndRouter(IndexPage); diff --git a/pages/item.tsx b/pages/item.tsx index cd042bb..a0d392d 100644 --- a/pages/item.tsx +++ b/pages/item.tsx @@ -34,24 +34,18 @@ export interface INewsItemWithCommentsWithGraphQLOwnProps { id: number; } -export const ItemPage = withDataAndRouter( - (props): JSX.Element => { - const { router } = props; - - const { data } = useQuery(newsItemWithCommentsQuery, { - variables: { id: (router.query && +router.query.id) || 0 }, - }); - - return ( - - - - ); - } -); +export function ItemPage(props): JSX.Element { + const { router } = props; + + const { data } = useQuery(newsItemWithCommentsQuery, { + variables: { id: (router.query && +router.query.id) || 0 }, + }); + + return ( + + + + ); +} -export default ItemPage; +export default withDataAndRouter(ItemPage); diff --git a/pages/jobs.tsx b/pages/jobs.tsx index bef460a..874d96c 100644 --- a/pages/jobs.tsx +++ b/pages/jobs.tsx @@ -1,6 +1,6 @@ +import { useQuery } from '@apollo/react-hooks'; import gql from 'graphql-tag'; import * as React from 'react'; -import { useQuery } from '@apollo/react-hooks'; import { NewsFeed, newsFeedNewsItemFragment } from '../src/components/news-feed'; import { withDataAndRouter } from '../src/helpers/with-data'; @@ -29,8 +29,10 @@ export interface IJobsPageOwnProps { }; } -export const JobsPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function JobsPage(props): JSX.Element { + const { router } = props; + + const pageNumber = (router.query && +router.query.p) || 0; const first = POSTS_PER_PAGE; const skip = POSTS_PER_PAGE * pageNumber; @@ -38,9 +40,9 @@ export const JobsPage = withDataAndRouter((props) => { const { data } = useQuery(query, { variables: { first, skip, type: FeedType.JOB } }); return ( - + { /> ); -}); +} -export default JobsPage; +export default withDataAndRouter(JobsPage); diff --git a/pages/leaders.tsx b/pages/leaders.tsx index 650d9dd..1117653 100644 --- a/pages/leaders.tsx +++ b/pages/leaders.tsx @@ -3,10 +3,14 @@ import * as React from 'react'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const LeadersPage = withDataAndRouter((props) => ( - - total - -)); +export function LeadersPage(props): JSX.Element { + const { router } = props; -export default LeadersPage; + return ( + + total + + ); +} + +export default withDataAndRouter(LeadersPage); diff --git a/pages/lists.tsx b/pages/lists.tsx index 7eb1549..02ab597 100644 --- a/pages/lists.tsx +++ b/pages/lists.tsx @@ -4,76 +4,80 @@ import * as React from 'react'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const ListsPage = withDataAndRouter((props) => ( - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - leaders - - Users with most karma.
- - front - - - Front page submissions for a given day (e.g.{' '} - 2016-06-20), ordered by time spent there. -
- - best - - Highest-voted recent links.
- - active - - Most active current discussions.
- - bestcomments - - Highest-voted recent comments.
- - noobstories - - Submissions from new accounts.
- - noobcomments - - Comments from new accounts.
- - -
-)); +export function ListsPage(props): JSX.Element { + const { router } = props; -export default ListsPage; + return ( + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+ + leaders + + Users with most karma.
+ + front + + + Front page submissions for a given day (e.g.{' '} + 2016-06-20), ordered by time spent there. +
+ + best + + Highest-voted recent links.
+ + active + + Most active current discussions.
+ + bestcomments + + Highest-voted recent comments.
+ + noobstories + + Submissions from new accounts.
+ + noobcomments + + Comments from new accounts.
+ + +
+ ); +} + +export default withDataAndRouter(ListsPage); diff --git a/pages/login.tsx b/pages/login.tsx index c04de49..d09bb5f 100644 --- a/pages/login.tsx +++ b/pages/login.tsx @@ -1,6 +1,6 @@ import { useQuery } from '@apollo/react-hooks'; import Link from 'next/link'; -import Router, { withRouter, NextRouter } from 'next/router'; +import Router, { NextRouter } from 'next/router'; import React, { useState } from 'react'; import { IMeQuery, ME_QUERY } from '../src/data/queries/me-query'; @@ -16,7 +16,7 @@ export interface ILoginPageProps { router?: NextRouter; } -function LoginPageView(props: ILoginPageProps): JSX.Element { +function LoginPage(props: ILoginPageProps): JSX.Element { const { data } = useQuery(ME_QUERY); const { router } = props; @@ -154,8 +154,4 @@ function LoginPageView(props: ILoginPageProps): JSX.Element { ); } -export const LoginPage = withDataAndRouter( - withRouter((props) => ) -); - -export default LoginPage; +export default withDataAndRouter(LoginPage); diff --git a/pages/newcomments.tsx b/pages/newcomments.tsx index cdccb8f..2401339 100644 --- a/pages/newcomments.tsx +++ b/pages/newcomments.tsx @@ -1,4 +1,3 @@ -import { withRouter } from 'next/router'; import * as React from 'react'; import { NewsFeedView } from '../src/components/news-feed'; @@ -6,21 +5,21 @@ import { sampleData } from '../src/data/sample-data'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const NewCommentsPage = withRouter( - withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function NewCommentsPage(props): JSX.Element { + const { router } = props; - return ( - - - - ); - }) -); + const pageNumber = (router.query && +router.query.p) || 0; -export default NewCommentsPage; + return ( + + + + ); +} + +export default withDataAndRouter(NewCommentsPage); diff --git a/pages/newest.tsx b/pages/newest.tsx index a2ba7e9..efcecad 100644 --- a/pages/newest.tsx +++ b/pages/newest.tsx @@ -1,7 +1,6 @@ +import { useQuery } from '@apollo/react-hooks'; import gql from 'graphql-tag'; -import { withRouter } from 'next/router'; import * as React from 'react'; -import { useQuery } from '@apollo/react-hooks'; import { NewsFeed, newsFeedNewsItemFragment } from '../src/components/news-feed'; import { withDataAndRouter } from '../src/helpers/with-data'; @@ -26,21 +25,21 @@ export interface INewestNewsFeedProps { }; } -export const NewestPage = withDataAndRouter( - withRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function NewestPage(props): JSX.Element { + const { router } = props; - const first = POSTS_PER_PAGE; - const skip = POSTS_PER_PAGE * pageNumber; + const pageNumber = (router.query && +router.query.p) || 0; - const { data } = useQuery(query, { variables: { first, skip, type: FeedType.NEW } }); + const first = POSTS_PER_PAGE; + const skip = POSTS_PER_PAGE * pageNumber; - return ( - - - - ); - }) -); + const { data } = useQuery(query, { variables: { first, skip, type: FeedType.NEW } }); + + return ( + + + + ); +} -export default NewestPage; +export default withDataAndRouter(NewestPage); diff --git a/pages/newpoll.tsx b/pages/newpoll.tsx index 79b9930..0cd2dc2 100644 --- a/pages/newpoll.tsx +++ b/pages/newpoll.tsx @@ -5,19 +5,21 @@ import { sampleData } from '../src/data/sample-data'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const NewPollPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function NewPollPage(props): JSX.Element { + const { router } = props; + + const pageNumber = (router.query && +router.query.p) || 0; return ( - + ); -}); +} -export default NewPollPage; +export default withDataAndRouter(NewPollPage); diff --git a/pages/newsfaq.tsx b/pages/newsfaq.tsx index b2ef130..73b34dc 100644 --- a/pages/newsfaq.tsx +++ b/pages/newsfaq.tsx @@ -3,196 +3,198 @@ import * as React from 'react'; import { NoticeLayout } from '../src/layouts/notice-layout'; -export const NewsFAQPage: React.FC = () => ( - - Hacker News FAQ -
-
- Are there rules about submissions and comments? -

- - https://news.ycombinator.com/newsguidelines - -

-

- How are stories ranked? -

-

- The basic algorithm divides points by a power of the time since a story was submitted. - Comments in comment threads are ranked the same way. -

-

- Other factors affecting rank include user flags, anti-abuse software, software which - downweights overheated discussions, and moderator intervention. -

-

- How is a user's karma calculated? -

-

- Roughly, the number of upvotes on their stories and comments minus the number of downvotes. - The numbers don't match up exactly, because some votes aren't counted to prevent - abuse. -

-

- Why don't I see down arrows? -

-

- There are no down arrows on stories. They appear on comments after users reach a certain karma - threshold, but never on direct replies. -

-

- What kind of formatting can you use in comments? -

-

- - http://news.ycombinator.com/formatdoc - -

-

- How do I submit a question? -

-

Use the submit link in the top bar, and leave the url field blank.

-

- How do I make a link in a question? -

-

- You can't. This is to prevent people from submitting a link with their comments in a - privileged position at the top of the page. If you want to submit a link with comments, just - submit it, then add a regular comment. -

-

- How do I flag a comment? -

-

- Click on its timestamp to go to its page, then click the 'flag' link at the top. - There's a small karma threshold before flag links appear. -

-

- Are reposts ok? -

-

- If a story has had significant attention in the last year or so, we kill reposts as - duplicates. If not, a small number of reposts is ok. -

-

- Please don't delete and repost the same story, though. Accounts that do that eventually - lose submission privileges. -

-

- Are paywalls ok? -

-

It's ok to post stories from sites with paywalls that have workarounds.

-

- In comments, it's ok to ask how to read an article and to help other users do so. But - please don't post complaints about paywalls. Those are off topic. -

-

-

- Can I ask people to upvote my submission? -

-

- No. Users should vote for a story because it's intellectually interesting, not because - someone is promoting it. -

-

- When the software detects a voting ring, it penalizes the post. Accounts that vote like this - eventually get their votes ignored. -

-

- Can I post a job ad? -

-

Please do not post job ads as story submissions to HN.

-

- A regular "Who Is Hiring?" thread appears on the first weekday of each month. Most - job ads are welcome there. (But only an account called{' '} - - whoishiring - {' '} - is allowed to submit the thread itself. This prevents a race to post it first.) -

-

- The other kind of job ad is reserved for YC-funded startups. These appear on the front page, - but are not stories: they have no vote arrows, points, or comments. They begin part-way down, - then fall steadily, and only one should be on the front page at a time. -

-

- Why can't I post a comment to a thread? -

-

- Threads are closed to new comments after two weeks, or if the submission has been killed by - software, moderators, or user flags. -

-

- In my profile, what does showdead do? -

-

- If you turn it on, you'll see all the stories and comments that have been killed by - HN's software, moderators, and user flags. -

-

- In my profile, what is delay? -

-

- It gives you time to edit your comments before they appear to others. Set it to the number of - minutes you'd like. The maximum is 10. -

-

- In my profile, what is noprocrast? -

-

- It's a way to help you prevent yourself from spending too much time on HN. If you turn it - on you'll only be allowed to visit the site for maxvisit minutes at a time, with gaps of - minaway minutes in between. The defaults are 20 and 180, which would let you view the site for - 20 minutes at a time, and then not allow you back in for 3 hours. You can override noprocrast - if you want, in which case your visit clock starts over at zero. -

-

- How do I submit a poll? -

-

- - http://news.ycombinator.com/newpoll - -

-

- How do I reset my password? -

-

- If you have an email address in your profile, you can request a password reset{' '} - - here - - . If you haven't, you can create a new account or email hn@ycombinator.com for help. -

-

- My IP address seems to be banned. How can I unban it? -

-

- If you request many pages too quickly, your IP address might get banned. The{' '} - - self-serve unbanning procedure - {' '} - works most of the time. -

-

+export function NewsFaqPage(): JSX.Element { + return ( + + Hacker News FAQ

-
- - - - - -
-
-

-

- + Are there rules about submissions and comments? +

+ + https://news.ycombinator.com/newsguidelines + +

+

+ How are stories ranked? +

+

+ The basic algorithm divides points by a power of the time since a story was submitted. + Comments in comment threads are ranked the same way. +

+

+ Other factors affecting rank include user flags, anti-abuse software, software which + downweights overheated discussions, and moderator intervention. +

+

+ How is a user's karma calculated? +

+

+ Roughly, the number of upvotes on their stories and comments minus the number of downvotes. + The numbers don't match up exactly, because some votes aren't counted to prevent + abuse. +

+

+ Why don't I see down arrows? +

+

+ There are no down arrows on stories. They appear on comments after users reach a certain + karma threshold, but never on direct replies. +

+

+ What kind of formatting can you use in comments? +

+

+ + http://news.ycombinator.com/formatdoc + +

+

+ How do I submit a question? +

+

Use the submit link in the top bar, and leave the url field blank.

+

+ How do I make a link in a question? +

+

+ You can't. This is to prevent people from submitting a link with their comments in a + privileged position at the top of the page. If you want to submit a link with comments, just + submit it, then add a regular comment. +

+

+ How do I flag a comment? +

+

+ Click on its timestamp to go to its page, then click the 'flag' link at the top. + There's a small karma threshold before flag links appear. +

+

+ Are reposts ok? +

+

+ If a story has had significant attention in the last year or so, we kill reposts as + duplicates. If not, a small number of reposts is ok. +

+

+ Please don't delete and repost the same story, though. Accounts that do that eventually + lose submission privileges. +

+

+ Are paywalls ok? +

+

It's ok to post stories from sites with paywalls that have workarounds.

+

+ In comments, it's ok to ask how to read an article and to help other users do so. But + please don't post complaints about paywalls. Those are off topic. +

+

+

+ Can I ask people to upvote my submission? +

+

+ No. Users should vote for a story because it's intellectually interesting, not because + someone is promoting it. +

+

+ When the software detects a voting ring, it penalizes the post. Accounts that vote like this + eventually get their votes ignored. +

+

+ Can I post a job ad? +

+

Please do not post job ads as story submissions to HN.

+

+ A regular "Who Is Hiring?" thread appears on the first weekday of each month. Most + job ads are welcome there. (But only an account called{' '} + + whoishiring + {' '} + is allowed to submit the thread itself. This prevents a race to post it first.) +

+

+ The other kind of job ad is reserved for YC-funded startups. These appear on the front page, + but are not stories: they have no vote arrows, points, or comments. They begin part-way + down, then fall steadily, and only one should be on the front page at a time. +

+

+ Why can't I post a comment to a thread? +

+

+ Threads are closed to new comments after two weeks, or if the submission has been killed by + software, moderators, or user flags. +

+

+ In my profile, what does showdead do? +

+

+ If you turn it on, you'll see all the stories and comments that have been killed by + HN's software, moderators, and user flags. +

+

+ In my profile, what is delay? +

+

+ It gives you time to edit your comments before they appear to others. Set it to the number + of minutes you'd like. The maximum is 10. +

+

+ In my profile, what is noprocrast? +

+

+ It's a way to help you prevent yourself from spending too much time on HN. If you turn + it on you'll only be allowed to visit the site for maxvisit minutes at a time, with gaps + of minaway minutes in between. The defaults are 20 and 180, which would let you view the + site for 20 minutes at a time, and then not allow you back in for 3 hours. You can override + noprocrast if you want, in which case your visit clock starts over at zero. +

+

+ How do I submit a poll? +

+

+ + http://news.ycombinator.com/newpoll + +

+

+ How do I reset my password? +

+

+ If you have an email address in your profile, you can request a password reset{' '} + + here + + . If you haven't, you can create a new account or email hn@ycombinator.com for help. +

+

+ My IP address seems to be banned. How can I unban it? +

+

+ If you request many pages too quickly, your IP address might get banned. The{' '} + + self-serve unbanning procedure + {' '} + works most of the time. +

+

+


- -

-
-); + + + + + +
+
+

+

+ +
+
+
+

+ + ); +} -export default NewsFAQPage; +export default NewsFaqPage; diff --git a/pages/newsguidelines.tsx b/pages/newsguidelines.tsx index 326f75e..3ddea87 100644 --- a/pages/newsguidelines.tsx +++ b/pages/newsguidelines.tsx @@ -3,127 +3,130 @@ import * as React from 'react'; import { NoticeLayout } from '../src/layouts/notice-layout'; -export const NewsGuidelinesPage: React.FC = () => ( - - Hacker News Guidelines -
-
- What to Submit -

- On-Topic: Anything that good hackers would find interesting. That includes more than hacking - and startups. If you had to reduce it to a sentence, the answer might be: anything that - gratifies one's intellectual curiosity. -

-

- Off-Topic: Most stories about politics, or crime, or sports, unless they're evidence of - some interesting new phenomenon. Ideological or political battle or talking points. Videos of - pratfalls or disasters, or cute animal pictures. If they'd cover it on TV news, it's - probably off-topic. -

-

- In Submissions -

-

- Please don't do things to make titles stand out, like using uppercase or exclamation - points, or adding a parenthetical remark saying how great an article is. It's implicit in - submitting something that you think it's important. -

-

- If you submit a link to a video or pdf, please warn us by appending [video] or [pdf] to the - title. -

-

- Please submit the original source. If a post reports on something found on another site, - submit the latter. -

-

- If the original title includes the name of the site, please take it out, because the site name - will be displayed after the link. -

-

- If the original title begins with a number or number + gratuitous adjective, we'd - appreciate it if you'd crop it. E.g. translate "10 Ways To Do X" to "How To - Do X," and "14 Amazing Ys" to "Ys." Exception: when the number is - meaningful, e.g. "The 5 Platonic Solids." -

-

Otherwise please use the original title, unless it is misleading or linkbait.

-

- Please don't post on HN to ask or tell us something. Instead, please send it to - hn@ycombinator.com. Similarly, please don't use HN posts to ask YC-funded companies - questions that you could ask by emailing them. -

-

- Please don't submit so many links at once that the new page is dominated by your - submissions. -

-

- In Comments -

-

- Be civil. Don't say things you wouldn't say face-to-face. Don't be snarky. - Comments should get more civil and substantive, not less, as a topic gets more divisive. -

-

- When disagreeing, please reply to the argument instead of calling names. "That is - idiotic; 1 + 1 is 2, not 3" can be shortened to "1 + 1 is 2, not 3." -

-

- Please respond to the strongest plausible interpretation of what someone says, not a weaker - one that's easier to criticize. -

-

- Eschew flamebait. Don't introduce flamewar topics unless you have something genuinely new - to say. Avoid unrelated controversies and generic tangents. -

-

- Please don't insinuate that someone hasn't read an article. "Did you even read - the article? It mentions that" can be shortened to "The article mentions that." -

-

- Please don't use uppercase for emphasis. If you want to emphasize a word or phrase, put - *asterisks* around it and it will get italicized. -

-

- Please don't accuse others of astroturfing or shillage. Email us instead and we'll - look into it. -

-

- Please don't complain that a submission is inappropriate. If a story is spam or off-topic, - flag it. Don't feed egregious comments by replying;{' '} - - flag - {' '} - them instead. When you flag something, please don't also comment that you did. -

-

- Please don't comment about the voting on comments. It never does any good, and it makes - boring reading. -

-

- Throwaway accounts are ok for sensitive information, but please don't create them - routinely. On HN, users need an identity that others can relate to. -

-

- We ban accounts that use Hacker News primarily for political or ideological battle, regardless - of which politics they favor. +export function NewsGuidelinesPage(): JSX.Element { + return ( + + Hacker News Guidelines

-
- - - - - -
-
-

-

- + What to Submit +

+ On-Topic: Anything that good hackers would find interesting. That includes more than hacking + and startups. If you had to reduce it to a sentence, the answer might be: anything that + gratifies one's intellectual curiosity. +

+

+ Off-Topic: Most stories about politics, or crime, or sports, unless they're evidence of + some interesting new phenomenon. Ideological or political battle or talking points. Videos + of pratfalls or disasters, or cute animal pictures. If they'd cover it on TV news, + it's probably off-topic. +

+

+ In Submissions +

+

+ Please don't do things to make titles stand out, like using uppercase or exclamation + points, or adding a parenthetical remark saying how great an article is. It's implicit + in submitting something that you think it's important. +

+

+ If you submit a link to a video or pdf, please warn us by appending [video] or [pdf] to the + title. +

+

+ Please submit the original source. If a post reports on something found on another site, + submit the latter. +

+

+ If the original title includes the name of the site, please take it out, because the site + name will be displayed after the link. +

+

+ If the original title begins with a number or number + gratuitous adjective, we'd + appreciate it if you'd crop it. E.g. translate "10 Ways To Do X" to "How + To Do X," and "14 Amazing Ys" to "Ys." Exception: when the number + is meaningful, e.g. "The 5 Platonic Solids." +

+

Otherwise please use the original title, unless it is misleading or linkbait.

+

+ Please don't post on HN to ask or tell us something. Instead, please send it to + hn@ycombinator.com. Similarly, please don't use HN posts to ask YC-funded companies + questions that you could ask by emailing them. +

+

+ Please don't submit so many links at once that the new page is dominated by your + submissions. +

+

+ In Comments +

+

+ Be civil. Don't say things you wouldn't say face-to-face. Don't be snarky. + Comments should get more civil and substantive, not less, as a topic gets more divisive. +

+

+ When disagreeing, please reply to the argument instead of calling names. "That is + idiotic; 1 + 1 is 2, not 3" can be shortened to "1 + 1 is 2, not 3." +

+

+ Please respond to the strongest plausible interpretation of what someone says, not a weaker + one that's easier to criticize. +

+

+ Eschew flamebait. Don't introduce flamewar topics unless you have something genuinely + new to say. Avoid unrelated controversies and generic tangents. +

+

+ Please don't insinuate that someone hasn't read an article. "Did you even read + the article? It mentions that" can be shortened to "The article mentions + that." +

+

+ Please don't use uppercase for emphasis. If you want to emphasize a word or phrase, put + *asterisks* around it and it will get italicized. +

+

+ Please don't accuse others of astroturfing or shillage. Email us instead and we'll + look into it. +

+

+ Please don't complain that a submission is inappropriate. If a story is spam or + off-topic, flag it. Don't feed egregious comments by replying;{' '} + + flag + {' '} + them instead. When you flag something, please don't also comment that you did. +

+

+ Please don't comment about the voting on comments. It never does any good, and it makes + boring reading. +

+

+ Throwaway accounts are ok for sensitive information, but please don't create them + routinely. On HN, users need an identity that others can relate to. +

+

+ We ban accounts that use Hacker News primarily for political or ideological battle, + regardless of which politics they favor. +


- -

-
-); + + + + + +
+
+

+

+ +
+
+
+

+ + ); +} export default NewsGuidelinesPage; diff --git a/pages/newswelcome.tsx b/pages/newswelcome.tsx index 6febba0..d92dd59 100644 --- a/pages/newswelcome.tsx +++ b/pages/newswelcome.tsx @@ -3,90 +3,92 @@ import * as React from 'react'; import { NoticeLayout } from '../src/layouts/notice-layout'; -export const NewsWelcomePage: React.FC = () => ( - - Welcome to Hacker News -
-
-

- - Hacker News - {' '} - is a bit different from other community sites, and we'd appreciate it if you'd take a - minute to read the following as well as the{' '} - - official guidelines - - . -

-

- HN is an experiment. As a rule, a community site that becomes popular will decline in quality. - Our hypothesis is that this is not inevitable—that by making a conscious effort to resist - decline, we can keep it from happening. -

-

- Essentially there are two rules here: don't post or upvote crap links, and don't be - rude or dumb in comment threads. -

-

- A crap link is one that's only superficially interesting. Stories on HN don't have to - be about hacking, because good hackers aren't only interested in hacking, but they do have - to be deeply interesting. -

-

- What does "deeply interesting" mean? It means stuff that teaches you about the - world. A story about a robbery, for example, would probably not be deeply interesting. But if - this robbery was a sign of some bigger, underlying trend, perhaps it could be. -

-

- The worst thing to post or upvote is something that's intensely but shallowly interesting: - gossip about famous people, funny or cute pictures or videos, partisan political articles, - etc. If you let{' '} - - that sort of thing onto a news site, it will push aside the deeply interesting stuff, which - tends to be quieter. - -

-

- The most important principle on HN, though, is to make thoughtful comments. Thoughtful in both - senses: civil and substantial. -

-

- The test for substance is a lot like it is for links. Does your comment teach us anything? - There are two ways to do that: by pointing out some consideration that hadn't previously - been mentioned, and by giving more information about the topic, perhaps from personal - experience. Whereas comments like "LOL!" or worse still, "That's - retarded!" teach us nothing. -

-

- Empty comments can be ok if they're positive. There's nothing wrong with submitting a - comment saying just "Thanks." What we especially discourage are comments that are - empty and negative—comments that are mere name-calling. -

-

- Which brings us to the most important principle on HN: civility. Since long before the web, - the anonymity of online conversation has lured people into being much ruder than they'd be - in person. So the principle here is: don't say anything you wouldn't say face to face. - This doesn't mean you can't disagree. But disagree without calling names. If - you're right, your argument will be more convincing without them. +export function NewsWelcomePage(): JSX.Element { + return ( + + Welcome to Hacker News

-
- - - - - -
-
-

-

- +

+ + Hacker News + {' '} + is a bit different from other community sites, and we'd appreciate it if you'd take + a minute to read the following as well as the{' '} + + official guidelines + + . +

+

+ HN is an experiment. As a rule, a community site that becomes popular will decline in + quality. Our hypothesis is that this is not inevitable—that by making a conscious effort to + resist decline, we can keep it from happening. +

+

+ Essentially there are two rules here: don't post or upvote crap links, and don't be + rude or dumb in comment threads. +

+

+ A crap link is one that's only superficially interesting. Stories on HN don't have + to be about hacking, because good hackers aren't only interested in hacking, but they do + have to be deeply interesting. +

+

+ What does "deeply interesting" mean? It means stuff that teaches you about the + world. A story about a robbery, for example, would probably not be deeply interesting. But + if this robbery was a sign of some bigger, underlying trend, perhaps it could be. +

+

+ The worst thing to post or upvote is something that's intensely but shallowly + interesting: gossip about famous people, funny or cute pictures or videos, partisan + political articles, etc. If you let{' '} + + that sort of thing onto a news site, it will push aside the deeply interesting stuff, + which tends to be quieter. + +

+

+ The most important principle on HN, though, is to make thoughtful comments. Thoughtful in + both senses: civil and substantial. +

+

+ The test for substance is a lot like it is for links. Does your comment teach us anything? + There are two ways to do that: by pointing out some consideration that hadn't previously + been mentioned, and by giving more information about the topic, perhaps from personal + experience. Whereas comments like "LOL!" or worse still, "That's + retarded!" teach us nothing. +

+

+ Empty comments can be ok if they're positive. There's nothing wrong with submitting + a comment saying just "Thanks." What we especially discourage are comments that + are empty and negative—comments that are mere name-calling. +

+

+ Which brings us to the most important principle on HN: civility. Since long before the web, + the anonymity of online conversation has lured people into being much ruder than they'd + be in person. So the principle here is: don't say anything you wouldn't say face to + face. This doesn't mean you can't disagree. But disagree without calling names. If + you're right, your argument will be more convincing without them. +


- -

-
-); + + + + + +
+
+

+

+ +
+
+
+

+ + ); +} export default NewsWelcomePage; diff --git a/pages/noobcomments.tsx b/pages/noobcomments.tsx index 973159e..04dd6b6 100644 --- a/pages/noobcomments.tsx +++ b/pages/noobcomments.tsx @@ -5,19 +5,21 @@ import { sampleData } from '../src/data/sample-data'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const NoobCommentsPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function NoobCommentsPage(props): JSX.Element { + const { router } = props; + + const pageNumber = (router.query && +router.query.p) || 0; return ( - + ); -}); +} -export default NoobCommentsPage; +export default withDataAndRouter(NoobCommentsPage); diff --git a/pages/noobstories.tsx b/pages/noobstories.tsx index 4b669cc..8988092 100644 --- a/pages/noobstories.tsx +++ b/pages/noobstories.tsx @@ -5,19 +5,21 @@ import { sampleData } from '../src/data/sample-data'; import { withDataAndRouter } from '../src/helpers/with-data'; import { MainLayout } from '../src/layouts/main-layout'; -export const NoobStoriesPage = withDataAndRouter((props) => { - const pageNumber = (props.router.query && +props.router.query.p) || 0; +export function NoobStoriesPage(props): JSX.Element { + const { router } = props; + + const pageNumber = (router.query && +router.query.p) || 0; return ( - + ); -}); +} -export default NoobStoriesPage; +export default withDataAndRouter(NoobStoriesPage); diff --git a/pages/reply.tsx b/pages/reply.tsx index c74b63a..bfc1165 100644 --- a/pages/reply.tsx +++ b/pages/reply.tsx @@ -17,10 +17,16 @@ const query = gql` `; export interface IReplyPageProps { - data; + router; } -function ReplyPageView(props: IReplyPageProps): JSX.Element { +function ReplyPage(props: IReplyPageProps): JSX.Element { + const { router } = props; + + const { data } = useQuery(query, { + variables: { id: (router.query && +router.query.id) || 0 }, + }); + const vote = (): void => { console.log('onclick'); }; @@ -30,105 +36,95 @@ function ReplyPageView(props: IReplyPageProps): JSX.Element { }; return ( - - - - - - - +
- -
- -
- -
-
-
+ + + + + - - - -
+ + + -
-
- - - Because the vehicle is electric, there is no need to “heat up” the brakes when - descending. This is because the enormous electric engine acts as a generator - and recharges the battery pack. That same energy is then used to help the - vehicle travel back up the hill. Phys reports, “If all goes as planned, the - electric dumper truck will even harvest more electricity while traveling - downhill than it needs for the ascent. Instead of consuming fossil fuels, it - would then feed surplus electricity into the grid.” - -

- Clever. It can do this because it travels uphill empty and comes downhill - full. - -

-
- -
-
- -
- - - -