forked from tanner/qotnews
		
	Finish prototype web client
This commit is contained in:
		
							
								
								
									
										4
									
								
								webclient/.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										4
									
								
								webclient/.gitignore
									
									
									
									
										vendored
									
									
								
							| @@ -21,3 +21,7 @@ | ||||
| npm-debug.log* | ||||
| yarn-debug.log* | ||||
| yarn-error.log* | ||||
|  | ||||
| # Editor | ||||
| *.swp | ||||
| *.swo | ||||
|   | ||||
							
								
								
									
										68
									
								
								webclient/README.md
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										68
									
								
								webclient/README.md
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,68 @@ | ||||
| This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app). | ||||
|  | ||||
| ## Available Scripts | ||||
|  | ||||
| In the project directory, you can run: | ||||
|  | ||||
| ### `npm start` | ||||
|  | ||||
| Runs the app in the development mode.<br> | ||||
| Open [http://localhost:3000](http://localhost:3000) to view it in the browser. | ||||
|  | ||||
| The page will reload if you make edits.<br> | ||||
| You will also see any lint errors in the console. | ||||
|  | ||||
| ### `npm test` | ||||
|  | ||||
| Launches the test runner in the interactive watch mode.<br> | ||||
| See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information. | ||||
|  | ||||
| ### `npm run build` | ||||
|  | ||||
| Builds the app for production to the `build` folder.<br> | ||||
| It correctly bundles React in production mode and optimizes the build for the best performance. | ||||
|  | ||||
| The build is minified and the filenames include the hashes.<br> | ||||
| Your app is ready to be deployed! | ||||
|  | ||||
| See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information. | ||||
|  | ||||
| ### `npm run eject` | ||||
|  | ||||
| **Note: this is a one-way operation. Once you `eject`, you can’t go back!** | ||||
|  | ||||
| If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project. | ||||
|  | ||||
| Instead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own. | ||||
|  | ||||
| You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it. | ||||
|  | ||||
| ## Learn More | ||||
|  | ||||
| You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started). | ||||
|  | ||||
| To learn React, check out the [React documentation](https://reactjs.org/). | ||||
|  | ||||
| ### Code Splitting | ||||
|  | ||||
| This section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting | ||||
|  | ||||
| ### Analyzing the Bundle Size | ||||
|  | ||||
| This section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size | ||||
|  | ||||
| ### Making a Progressive Web App | ||||
|  | ||||
| This section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app | ||||
|  | ||||
| ### Advanced Configuration | ||||
|  | ||||
| This section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration | ||||
|  | ||||
| ### Deployment | ||||
|  | ||||
| This section has moved here: https://facebook.github.io/create-react-app/docs/deployment | ||||
|  | ||||
| ### `npm run build` fails to minify | ||||
|  | ||||
| This section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify | ||||
							
								
								
									
										33
									
								
								webclient/package.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										33
									
								
								webclient/package.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,33 @@ | ||||
| { | ||||
|   "name": "webclient", | ||||
|   "version": "0.1.0", | ||||
|   "private": true, | ||||
|   "dependencies": { | ||||
|     "moment": "^2.24.0", | ||||
|     "react": "^16.9.0", | ||||
|     "react-dom": "^16.9.0", | ||||
|     "react-router-dom": "^5.0.1", | ||||
|     "react-scripts": "3.1.1" | ||||
|   }, | ||||
|   "scripts": { | ||||
|     "start": "react-scripts start", | ||||
|     "build": "react-scripts build", | ||||
|     "test": "react-scripts test", | ||||
|     "eject": "react-scripts eject" | ||||
|   }, | ||||
|   "eslintConfig": { | ||||
|     "extends": "react-app" | ||||
|   }, | ||||
|   "browserslist": { | ||||
|     "production": [ | ||||
|       ">0.2%", | ||||
|       "not dead", | ||||
|       "not op_mini all" | ||||
|     ], | ||||
|     "development": [ | ||||
|       "last 1 chrome version", | ||||
|       "last 1 firefox version", | ||||
|       "last 1 safari version" | ||||
|     ] | ||||
|   } | ||||
| } | ||||
							
								
								
									
										
											BIN
										
									
								
								webclient/public/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								webclient/public/favicon.ico
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 3.8 KiB | 
							
								
								
									
										52
									
								
								webclient/public/index.html
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										52
									
								
								webclient/public/index.html
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,52 @@ | ||||
| <!DOCTYPE html> | ||||
| <html lang="en"> | ||||
|   <head> | ||||
|     <meta charset="utf-8" /> | ||||
|     <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" /> | ||||
|     <meta name="viewport" content="width=device-width, initial-scale=1" /> | ||||
|     <meta name="theme-color" content="#000000" /> | ||||
|     <meta | ||||
|       name="description" | ||||
|       content="Web site created using create-react-app" | ||||
|     /> | ||||
|     <link rel="apple-touch-icon" href="logo192.png" /> | ||||
|     <!-- | ||||
|       manifest.json provides metadata used when your web app is installed on a | ||||
|       user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||||
|     --> | ||||
|     <link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||||
|     <!-- | ||||
|       Notice the use of %PUBLIC_URL% in the tags above. | ||||
|       It will be replaced with the URL of the `public` folder during the build. | ||||
|       Only files inside the `public` folder can be referenced from the HTML. | ||||
|  | ||||
|       Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||||
|       work correctly both with client-side routing and a non-root public URL. | ||||
|       Learn how to configure a non-root public URL by running `npm run build`. | ||||
|     --> | ||||
|     <title>QNN - Qot News Network</title> | ||||
|  | ||||
| 	<style> | ||||
| 		html { | ||||
| 				overflow-y: scroll; | ||||
| 		} | ||||
| 		body { | ||||
| 			background: #202020; | ||||
| 		} | ||||
| 	</style> | ||||
|   </head> | ||||
|   <body> | ||||
|     <noscript>You need to enable JavaScript to run this app.</noscript> | ||||
|     <div id="root"></div> | ||||
|     <!-- | ||||
|       This HTML file is a template. | ||||
|       If you open it directly in the browser, you will see an empty page. | ||||
|  | ||||
|       You can add webfonts, meta tags, or analytics to this file. | ||||
|       The build step will place the bundled scripts into the <body> tag. | ||||
|  | ||||
|       To begin the development, run `npm start` or `yarn start`. | ||||
|       To create a production bundle, use `npm run build` or `yarn build`. | ||||
|     --> | ||||
|   </body> | ||||
| </html> | ||||
							
								
								
									
										
											BIN
										
									
								
								webclient/public/logo192.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								webclient/public/logo192.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 5.2 KiB | 
							
								
								
									
										
											BIN
										
									
								
								webclient/public/logo512.png
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								webclient/public/logo512.png
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| After Width: | Height: | Size: 9.4 KiB | 
							
								
								
									
										25
									
								
								webclient/public/manifest.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										25
									
								
								webclient/public/manifest.json
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,25 @@ | ||||
| { | ||||
|   "short_name": "React App", | ||||
|   "name": "Create React App Sample", | ||||
|   "icons": [ | ||||
|     { | ||||
|       "src": "favicon.ico", | ||||
|       "sizes": "64x64 32x32 24x24 16x16", | ||||
|       "type": "image/x-icon" | ||||
|     }, | ||||
|     { | ||||
|       "src": "logo192.png", | ||||
|       "type": "image/png", | ||||
|       "sizes": "192x192" | ||||
|     }, | ||||
|     { | ||||
|       "src": "logo512.png", | ||||
|       "type": "image/png", | ||||
|       "sizes": "512x512" | ||||
|     }	     | ||||
|   ], | ||||
|   "start_url": ".", | ||||
|   "display": "standalone", | ||||
|   "theme_color": "#000000", | ||||
|   "background_color": "#ffffff" | ||||
| } | ||||
							
								
								
									
										2
									
								
								webclient/public/robots.txt
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										2
									
								
								webclient/public/robots.txt
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,2 @@ | ||||
| # https://www.robotstxt.org/robotstxt.html | ||||
| User-agent: * | ||||
							
								
								
									
										49
									
								
								webclient/src/App.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										49
									
								
								webclient/src/App.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,49 @@ | ||||
| import React from 'react'; | ||||
| import { BrowserRouter as Router, Route, Link } from 'react-router-dom'; | ||||
| import './Style-light.css'; | ||||
| import './Style-dark.css'; | ||||
| import Feed from './Feed.js'; | ||||
| import Article from './Article.js'; | ||||
| import Comments from './Comments.js'; | ||||
|  | ||||
| class App extends React.Component { | ||||
| 	constructor(props) { | ||||
| 		super(props); | ||||
|  | ||||
| 		this.state = { | ||||
| 			theme: localStorage.getItem('theme') || '', | ||||
| 		}; | ||||
| 	} | ||||
|  | ||||
| 	light() { | ||||
| 		this.setState({ theme: '' }); | ||||
| 		localStorage.setItem('theme', ''); | ||||
| 	} | ||||
|  | ||||
| 	dark() { | ||||
| 		this.setState({ theme: 'dark' }); | ||||
| 		localStorage.setItem('theme', 'dark'); | ||||
| 	} | ||||
|  | ||||
| 	render() { | ||||
| 		const theme = this.state.theme; | ||||
|  | ||||
| 		return ( | ||||
| 			<div className={theme}> | ||||
| 				<Router> | ||||
| 					<div className='container menu'> | ||||
| 						<p> | ||||
| 							<Link to='/'>QNN - Home</Link> | ||||
| 							<span className='theme'>Theme: <a href='#' onClick={() => this.light()}>Light</a> - <a href='#' onClick={() => this.dark()}>Dark</a></span> | ||||
| 						</p> | ||||
| 					</div> | ||||
| 					<Route path='/' exact component={Feed} /> | ||||
| 					<Route path='/:id' exact component={Comments} /> | ||||
| 					<Route path='/:id/a' exact component={Article} /> | ||||
| 				</Router> | ||||
| 			</div> | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export default App; | ||||
							
								
								
									
										71
									
								
								webclient/src/Article.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										71
									
								
								webclient/src/Article.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,71 @@ | ||||
| import React from 'react'; | ||||
| import { Link } from 'react-router-dom'; | ||||
| import { sourceLink, infoLine } from './utils.js'; | ||||
|  | ||||
| const apiUrl = 'http://news-api.dns.t0.vc/'; | ||||
|  | ||||
| class Article extends React.Component { | ||||
| 	constructor(props) { | ||||
| 		super(props); | ||||
|  | ||||
| 		const id = this.props.match.params.id; | ||||
|  | ||||
| 		this.state = { | ||||
| 			story: JSON.parse(localStorage.getItem(id)) || false, | ||||
| 			error: false, | ||||
| 		}; | ||||
| 	} | ||||
| 	 | ||||
|     componentDidMount() { | ||||
| 		const id = this.props.match.params.id; | ||||
|  | ||||
|         fetch(apiUrl + id) | ||||
|             .then(res => res.json()) | ||||
|             .then( | ||||
|                 (result) => { | ||||
|                     this.setState({ story: result.story }); | ||||
|                     localStorage.setItem(id, JSON.stringify(result.story)); | ||||
|                 }, | ||||
|                 (error) => { | ||||
|                     this.setState({ error: true }); | ||||
|                 } | ||||
|             ); | ||||
| 	} | ||||
|  | ||||
| 	render() { | ||||
| 		const story = this.state.story; | ||||
| 		const error = this.state.error; | ||||
|  | ||||
| 		return ( | ||||
| 			<div className='article-container'> | ||||
| 				{error ? | ||||
| 					<p>Something went wrong.</p> | ||||
| 				: | ||||
| 					<div> | ||||
| 						{story ? | ||||
| 							<div className='article'> | ||||
| 								<h1>{story.title}</h1> | ||||
|  | ||||
| 								<div className='info'> | ||||
| 									Source: {sourceLink(story)} | ||||
| 								</div> | ||||
|  | ||||
| 								{infoLine(story)} | ||||
|  | ||||
| 								{story.text ? | ||||
| 									<div dangerouslySetInnerHTML={{ __html: story.text }} /> | ||||
| 								: | ||||
| 									<p>Problem getting article :(</p> | ||||
| 								} | ||||
| 							</div> | ||||
| 						: | ||||
| 							<p>loading...</p> | ||||
| 						} | ||||
| 					</div> | ||||
| 				} | ||||
| 			</div> | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export default Article; | ||||
							
								
								
									
										84
									
								
								webclient/src/Comments.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										84
									
								
								webclient/src/Comments.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,84 @@ | ||||
| import React from 'react'; | ||||
| import { Link } from 'react-router-dom'; | ||||
| import moment from 'moment'; | ||||
| import { sourceLink, infoLine } from './utils.js'; | ||||
|  | ||||
| const apiUrl = 'http://news-api.dns.t0.vc/'; | ||||
|  | ||||
| class Article extends React.Component { | ||||
| 	constructor(props) { | ||||
| 		super(props); | ||||
|  | ||||
| 		const id = this.props.match.params.id; | ||||
|  | ||||
| 		this.state = { | ||||
| 			story: JSON.parse(localStorage.getItem(id)) || false, | ||||
| 			error: false, | ||||
| 		}; | ||||
| 	} | ||||
| 	 | ||||
|     componentDidMount() { | ||||
| 		const id = this.props.match.params.id; | ||||
|  | ||||
|         fetch(apiUrl + id) | ||||
|             .then(res => res.json()) | ||||
|             .then( | ||||
|                 (result) => { | ||||
|                     this.setState({ story: result.story }); | ||||
|                     localStorage.setItem(id, JSON.stringify(result.story)); | ||||
|                 }, | ||||
|                 (error) => { | ||||
|                     this.setState({ error: true }); | ||||
|                 } | ||||
|             ); | ||||
| 	} | ||||
|  | ||||
| 	displayComment(c, level) { | ||||
| 		return ( | ||||
| 			<div className={level ? 'comment lined' : 'comment'}> | ||||
| 				<div className='info'> | ||||
| 					<p>{c.author || '[Deleted]'} | {moment.unix(c.date).fromNow()}</p> | ||||
| 				</div> | ||||
|  | ||||
| 				<div className='text' dangerouslySetInnerHTML={{ __html: c.text }} /> | ||||
|  | ||||
| 				{c.comments.map(i => this.displayComment(i, level + 1))} | ||||
| 			</div> | ||||
| 		); | ||||
| 	} | ||||
|  | ||||
| 	render() { | ||||
| 		const story = this.state.story; | ||||
| 		const error = this.state.error; | ||||
|  | ||||
| 		return ( | ||||
| 			<div className='container'> | ||||
| 				{error ? | ||||
| 					<p>Something went wrong.</p> | ||||
| 				: | ||||
| 					<div> | ||||
| 						{story ? | ||||
| 							<div className='article'> | ||||
| 								<h1>{story.title}</h1> | ||||
|  | ||||
| 								<div className='info'> | ||||
| 									<Link to={'/' + story.id + '/a'}>View article</Link> | ||||
| 								</div> | ||||
|  | ||||
| 								{infoLine(story)} | ||||
|  | ||||
| 								<div className='comments'> | ||||
| 									{story.comments.map(c => this.displayComment(c, 0))} | ||||
| 								</div> | ||||
| 							</div> | ||||
| 						: | ||||
| 							<p>loading...</p> | ||||
| 						} | ||||
| 					</div> | ||||
| 				} | ||||
| 			</div> | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export default Article; | ||||
							
								
								
									
										81
									
								
								webclient/src/Feed.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										81
									
								
								webclient/src/Feed.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,81 @@ | ||||
| import React from 'react'; | ||||
| import { Link } from 'react-router-dom'; | ||||
| import { sourceLink, infoLine } from './utils.js'; | ||||
|  | ||||
| const apiUrl = 'http://news-api.dns.t0.vc/'; | ||||
|  | ||||
|  | ||||
| class Feed extends React.Component { | ||||
| 	constructor(props) { | ||||
| 		super(props); | ||||
|  | ||||
| 		this.state = { | ||||
| 			stories: JSON.parse(localStorage.getItem('stories')) || false, | ||||
| 			error: false, | ||||
| 		}; | ||||
| 	} | ||||
| 	 | ||||
|     componentDidMount() { | ||||
|         fetch(apiUrl) | ||||
|             .then(res => res.json()) | ||||
|             .then( | ||||
|                 (result) => { | ||||
|                     this.setState({ stories: result.stories }); | ||||
|                     localStorage.setItem('stories', JSON.stringify(result.stories)); | ||||
| 					result.stories.slice(0, 25).forEach(x => { | ||||
| 						fetch(apiUrl + x.id) | ||||
| 							.then(res => res.json()) | ||||
| 							.then(result => { | ||||
| 								localStorage.setItem(x.id, JSON.stringify(result.story)); | ||||
| 								console.log('Preloaded story', x.id, x.title); | ||||
| 							}, error => {} | ||||
| 						); | ||||
| 					}); | ||||
|                 }, | ||||
|                 (error) => { | ||||
|                     this.setState({ error: true }); | ||||
|                 } | ||||
|             ); | ||||
| 	} | ||||
|  | ||||
| 	render() { | ||||
| 		const stories = this.state.stories; | ||||
| 		const error = this.state.error; | ||||
|  | ||||
| 		return ( | ||||
| 			<div className='container'> | ||||
| 				{error ? | ||||
| 					<p>Something went wrong.</p> | ||||
| 				: | ||||
| 					<div> | ||||
| 						{stories ? | ||||
| 							<div> | ||||
| 								{stories.map((x, i) => | ||||
| 									<div className='item'> | ||||
| 										<div className='num'> | ||||
| 											{i+1}. | ||||
| 										</div> | ||||
|  | ||||
| 										<div className='title'> | ||||
| 											<Link className='link' to={'/' + x.id + '/a'}>{x.title}</Link> | ||||
|  | ||||
| 											<span className='source'> | ||||
| 												​({sourceLink(x)}) | ||||
| 											</span> | ||||
| 										</div> | ||||
|  | ||||
| 										{infoLine(x)} | ||||
| 									</div> | ||||
| 								)} | ||||
| 							</div> | ||||
| 						: | ||||
| 							<p>loading...</p> | ||||
| 						} | ||||
| 					</div> | ||||
| 				} | ||||
| 			</div> | ||||
| 		); | ||||
| 	} | ||||
| } | ||||
|  | ||||
| export default Feed; | ||||
							
								
								
									
										48
									
								
								webclient/src/Style-dark.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										48
									
								
								webclient/src/Style-dark.css
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,48 @@ | ||||
| .dark { | ||||
| 	background: #202020; | ||||
| 	color: #eeeeee; | ||||
| 	position: absolute; top: 0; left: 0; right: 0; | ||||
| 	min-height: 100%; | ||||
| 	padding: 0 8px; | ||||
| } | ||||
|  | ||||
| .dark a { | ||||
| 	color: #eeeeee; | ||||
| } | ||||
|  | ||||
| .dark .item { | ||||
| 	color: #828282; | ||||
| } | ||||
|  | ||||
| .dark .item a { | ||||
| 	color: #828282; | ||||
| } | ||||
|  | ||||
| .dark .item a.link { | ||||
| 	color: #eeeeee; | ||||
| } | ||||
| .dark .item a.link:visited { | ||||
| 	color: #828282; | ||||
| } | ||||
|  | ||||
| .dark .item .info a.hot { | ||||
| 	color: #CCCCCC; | ||||
| } | ||||
|  | ||||
| .dark .article a { | ||||
| 	color: #eeeeee; | ||||
| 	border-bottom: 1px solid #aaaaaa; | ||||
| } | ||||
|  | ||||
| .dark .article .info { | ||||
| 	color: #828282; | ||||
| } | ||||
|  | ||||
| .dark .article .info a { | ||||
| 	color: #828282; | ||||
| 	border-bottom: none; | ||||
| } | ||||
|  | ||||
| .dark .comment.lined { | ||||
| 	border-left: 1px solid #444444; | ||||
| } | ||||
							
								
								
									
										127
									
								
								webclient/src/Style-light.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										127
									
								
								webclient/src/Style-light.css
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,127 @@ | ||||
| body { | ||||
| 	font: 1rem/1.3 sans-serif; | ||||
| 	background: #eeeeee; | ||||
| 	color: #000000; | ||||
| } | ||||
|  | ||||
| a { | ||||
| 	color: #000000; | ||||
| 	text-decoration: none; | ||||
| 	outline: none; | ||||
| } | ||||
|  | ||||
| .container { | ||||
| 	margin: 1rem auto; | ||||
| 	max-width: 64rem; | ||||
| } | ||||
|  | ||||
| .menu { | ||||
| 	font-size: 1.1rem; | ||||
| 	padding: 0 1rem; | ||||
| } | ||||
|  | ||||
| .theme { | ||||
| 	float: right; | ||||
| } | ||||
|  | ||||
| .item { | ||||
| 	display: table; | ||||
| 	color: #828282; | ||||
| 	margin-bottom: 0.6rem; | ||||
| } | ||||
|  | ||||
| .item a { | ||||
| 	color: #828282; | ||||
| } | ||||
| .item a:hover { | ||||
| 	text-decoration: underline; | ||||
| } | ||||
|  | ||||
| .item .num { | ||||
| 	display: table-cell; | ||||
| 	width: 2em; | ||||
| } | ||||
|  | ||||
| .item a.link { | ||||
| 	font-size: 1.1rem; | ||||
| 	color: #000000; | ||||
| } | ||||
| .item a.link:visited { | ||||
| 	color: #828282; | ||||
| } | ||||
|  | ||||
| span.source { | ||||
| 	margin-left: 0.4rem; | ||||
| } | ||||
|  | ||||
| .item .info a.hot { | ||||
| 	color: #444444; | ||||
| } | ||||
|  | ||||
| .article-container { | ||||
| 	font: 1.2rem/1.5 sans-serif; | ||||
| 	margin: 1rem auto; | ||||
| 	max-width: 44rem; | ||||
| } | ||||
|  | ||||
| .article h1 { | ||||
| 	font-size: 1.6rem; | ||||
| } | ||||
|  | ||||
| .article h2 { | ||||
| 	font-size: 1.4rem; | ||||
| } | ||||
|  | ||||
| .article h3, .article h4 { | ||||
| 	font-size: 1.3rem; | ||||
| } | ||||
|  | ||||
| .article img { | ||||
| 	width: 100%; | ||||
| 	height: auto; | ||||
| } | ||||
|  | ||||
| .article figure { | ||||
| 	width: 100%; | ||||
| 	height: auto; | ||||
| 	margin: 0; | ||||
| } | ||||
|  | ||||
| .article iframe { | ||||
| 	width: 100%; | ||||
| 	margin: 0; | ||||
| } | ||||
|  | ||||
| .article a { | ||||
| 	color: #000000; | ||||
| 	text-decoration: none; | ||||
| 	border-bottom: 1px solid #222222; | ||||
| } | ||||
|  | ||||
| .article .info { | ||||
| 	color: #828282; | ||||
| } | ||||
|  | ||||
| .article .info a { | ||||
| 	color: #828282; | ||||
| 	border-bottom: none; | ||||
| } | ||||
| .article .info a:hover { | ||||
| 	text-decoration: underline; | ||||
| } | ||||
|  | ||||
| .comments { | ||||
| 	margin-left: -1rem; | ||||
| } | ||||
|  | ||||
| .comment { | ||||
| 	padding-left: 1rem; | ||||
| } | ||||
|  | ||||
| .comment.lined { | ||||
| 	border-left: 1px solid #cccccc; | ||||
| } | ||||
|  | ||||
| .comment .text { | ||||
| 	margin-top: -0.5rem; | ||||
| } | ||||
							
								
								
									
										5
									
								
								webclient/src/index.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										5
									
								
								webclient/src/index.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,5 @@ | ||||
| import React from 'react'; | ||||
| import ReactDOM from 'react-dom'; | ||||
| import App from './App'; | ||||
|  | ||||
| ReactDOM.render(<App />, document.getElementById('root')); | ||||
							
								
								
									
										22
									
								
								webclient/src/utils.js
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										22
									
								
								webclient/src/utils.js
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,22 @@ | ||||
| import React from 'react'; | ||||
| import moment from 'moment'; | ||||
| import { Link } from 'react-router-dom'; | ||||
|  | ||||
| export const sourceLink = (story) => { | ||||
| 	const url = story.url || story.link; | ||||
| 	const urlObj = new URL(url); | ||||
| 	const host = urlObj.hostname.replace(/^www\./, ''); | ||||
| 	return (<a className='source' href={url}>{host}</a>); | ||||
| }; | ||||
|  | ||||
| export const infoLine = (story) => | ||||
| 	<div className='info'> | ||||
| 		{story.score} points | ||||
| 		by <a href={story.author_link}>{story.author}</a> | ||||
| 		​ {moment.unix(story.date).fromNow()} | ||||
| 		​ on <a href={story.link}>{story.source}</a> | ​ | ||||
| 		<Link className={story.num_comments > 99 ? 'hot' : ''} to={'/' + story.id}> | ||||
| 			{story.num_comments} comment{story.num_comments !== 1 && 's'} | ||||
| 		</Link> | ||||
| 	</div> | ||||
| ; | ||||
							
								
								
									
										10102
									
								
								webclient/yarn.lock
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										10102
									
								
								webclient/yarn.lock
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							
		Reference in New Issue
	
	Block a user