diff --git a/common/utilities.js b/common/utilities.js index 048c69a..7a008d1 100644 --- a/common/utilities.js +++ b/common/utilities.js @@ -19,6 +19,7 @@ let excluded = [ //messages that should not be logged 'Combat log sent', 'News sent', + 'News sent (singular)', 'Can\'t train while attacking', 'Can\'t untrain while attacking', diff --git a/public/content/task_list.md b/public/content/task_list.md index cad09ce..50d8de6 100644 --- a/public/content/task_list.md +++ b/public/content/task_list.md @@ -13,6 +13,8 @@ Minor * Implement game ladder sorting. * Write unit tests (ensure that the game doesn't break from an update). +* Implement banning mechanism. +* Implement post scrolling for news page. Patch --- diff --git a/public/news/2019-06-05-01.md b/public/news/2019-06-05-01.md new file mode 100644 index 0000000..7cb3e1d --- /dev/null +++ b/public/news/2019-06-05-01.md @@ -0,0 +1,16 @@ +Moderation Of Usernames +--- +_5 June 2019_ + +Let's talk about something serious: user [butthole69](/profile?username=butthole69). More importantly, their cheeky (pun intended) username. + +Now, I don't mind this name in particular, although some websites might outright ban him, and other users with similarly creative names. + +However, I will take exception to any usernames that are outright hurtful, attack any group or individual, or deliberately cross a line from funny or eye-rolling to offensive. This website is my house, and you are guests here; please remember that. + +One of the items on my wishlist is a request from a fan - in game chat. This requires considerably more moderation than just usernames, so if the community can't be civil with just usernames, then I don't see any way that such a feature could be implemented in future. + +If you feel something breeches these rules, I can most easily be reached via my discord server here: [KR Game Studios](https://discord.gg/FQmz8TN). My username is Ratstail91. + +Thanks to butthole69 for bringing this topic to my attention, even if inadvertantly. + diff --git a/server/index.js b/server/index.js index 3237260..bcf1adc 100644 --- a/server/index.js +++ b/server/index.js @@ -69,12 +69,12 @@ app.use('/styles', express.static(path.resolve(__dirname + '/../public/styles')) //the app file(s) app.get('/*app.bundle.js', (req, res) => { - res.sendFile(path.resolve(`${__dirname}/../public/${req.originalUrl}`)); + res.sendFile(path.resolve(`${__dirname}/../public/${req.originalUrl.split('/').pop()}`)); }); //fallback app.get('*', (req, res) => { - res.sendFile(path.resolve(__dirname + '/../public/index.html')); + res.sendFile(path.resolve(__dirname + '/../public/index.html')); }); //startup diff --git a/server/news.js b/server/news.js index 138d55a..79f7d8e 100644 --- a/server/news.js +++ b/server/news.js @@ -11,6 +11,23 @@ const newsRequest = () => (req, res) => { let fpath = path.join(__dirname, '..', 'public', 'news'); let fileNames = fs.readdirSync(fpath); + //if it's one specific post + if (req.body.postId) { + if (!fileNames.includes(req.body.postId)) { + res.status(404).write('File Not Found'); + res.end(); + return; + } + + let json = {}; + json[req.body.postId] = fs.readFileSync(path.join(fpath, req.body.postId), 'utf8'); + res.status(200).json(json); + res.end(); + + log('News sent (singular)', req.body.postId, JSON.stringify(json)); + return; + } + //set the maximum let max = parseInt(req.body.length) || 99; if (isNaN(max) || max > fileNames.length) { @@ -26,7 +43,7 @@ const newsRequest = () => (req, res) => { } //actually send the data - res.json(json); + res.status(200).json(json); res.end(); log('News sent', max, fileNames, JSON.stringify(json)); diff --git a/src/components/app.jsx b/src/components/app.jsx index 6a7dabf..74e5c0d 100644 --- a/src/components/app.jsx +++ b/src/components/app.jsx @@ -73,6 +73,7 @@ export default class App extends React.Component { import('./pages/task_list.jsx')} /> import('./pages/patron_list.jsx')} /> + import('./pages/news.jsx')} /> import('./pages/page_not_found.jsx')} /> diff --git a/src/components/pages/news.jsx b/src/components/pages/news.jsx new file mode 100644 index 0000000..3b92056 --- /dev/null +++ b/src/components/pages/news.jsx @@ -0,0 +1,53 @@ +import React from 'react'; + +//panels +import CommonLinks from '../panels/common_links.jsx'; +import NewsPanel from '../panels/news.jsx'; + +class News extends React.Component { + constructor(props) { + super(props); + this.state = { + warning: '', //TODO: unified warning? + fetch: null + }; + } + + componentDidUpdate(prevProps, prevState, snapshot) { + this.state.fetch(); + } + + render() { + let warningStyle = { + display: this.state.warning.length > 0 ? 'flex' : 'none' + }; + + return ( +
+
+
+ +
+ +
+
+

{this.state.warning}

+
+ + this.setState({ fetch: fn }) } + postId={this.props.match.params.postId} + /> +
+
+
+ ); + } + + setWarning(s) { + this.setState({ warning: s }); + } +}; + +export default News; \ No newline at end of file diff --git a/src/components/pages/signup.jsx b/src/components/pages/signup.jsx index 53e9445..7b34d03 100644 --- a/src/components/pages/signup.jsx +++ b/src/components/pages/signup.jsx @@ -31,7 +31,10 @@ class Signup extends React.Component {
Return Home +

Remember to verify your email!

+
+

See the recent news post on
Moderation Of Usernames.

); } diff --git a/src/components/panels/news.jsx b/src/components/panels/news.jsx index e4f49e2..f3a8deb 100644 --- a/src/components/panels/news.jsx +++ b/src/components/panels/news.jsx @@ -11,7 +11,7 @@ class News extends React.Component { }; if (props.getFetch) { - props.getFetch( () => this.sendRequest('/newsrequest', {length: this.props.length || 10}) ); + props.getFetch( () => this.sendRequest('/newsrequest', {length: this.props.length || 10, postId: this.props.postId}) ); } }