Implemented news page, wrote moderation post

This commit is contained in:
2019-06-05 08:02:43 +10:00
parent b5286e1c22
commit 6bbcd03179
9 changed files with 97 additions and 4 deletions
+1
View File
@@ -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',
+2
View File
@@ -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
---
+16
View File
@@ -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.
+2 -2
View File
@@ -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
+18 -1
View File
@@ -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));
+1
View File
@@ -73,6 +73,7 @@ export default class App extends React.Component {
<LazyRoute path='/tasklist' component={() => import('./pages/task_list.jsx')} />
<LazyRoute path='/patronlist' component={() => import('./pages/patron_list.jsx')} />
<LazyRoute path='/news/:postId' component={() => import('./pages/news.jsx')} />
<LazyRoute path='*' component={() => import('./pages/page_not_found.jsx')} />
</Switch>
+53
View File
@@ -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 (
<div className='page'>
<div className='sidePanelPage'>
<div className='sidePanel'>
<CommonLinks />
</div>
<div className='mainPanel'>
<div className='warning' style={warningStyle}>
<p>{this.state.warning}</p>
</div>
<NewsPanel
setWarning={this.setWarning.bind(this)}
getFetch={ (fn) => this.setState({ fetch: fn }) }
postId={this.props.match.params.postId}
/>
</div>
</div>
</div>
);
}
setWarning(s) {
this.setState({ warning: s });
}
};
export default News;
+3
View File
@@ -31,7 +31,10 @@ class Signup extends React.Component {
<div className='page constrained'>
<Panel />
<Link to='/' className='centered'>Return Home</Link>
<div className='break' />
<p className='centered'>Remember to verify your email!</p>
<div className='break' />
<p className='centered'>See the recent news post on<br /><Link to='/news/2019-06-05-01.md'>Moderation Of Usernames</Link>.</p>
</div>
);
}
+1 -1
View File
@@ -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}) );
}
}