This commit is contained in:
Dawid Wysokiński 2020-06-30 13:12:39 +02:00
parent 54c0197574
commit 69242c6b4c
23 changed files with 388 additions and 98 deletions

View File

@ -1,8 +1,10 @@
const siteUrl = "https://dcbot.tribalwarshelp.com";
module.exports = {
siteMetadata: {
title: `TWHelp Discord Bot`,
description: `Live notifications about lost/conquered village by a tribe in the game TribalWars.`,
siteUrl: "https://dcbot.tribalwarshelp.com",
siteUrl,
twhelpUrl: "https://tribalwarshelp.com",
botInviteUrl:
"https://discord.com/oauth2/authorize?client_id=707859810900508703&scope=bot&permissions=8",
@ -35,8 +37,8 @@ module.exports = {
{
resolve: "gatsby-plugin-robots-txt",
options: {
host: "https://dcbot.tribalwarshelp.com",
sitemap: "https://dcbot.tribalwarshelp.com/sitemap.xml",
host: siteUrl,
sitemap: siteUrl + "/sitemap.xml",
env: {
development: {
policy: [{ userAgent: "*", disallow: ["/"] }],
@ -47,5 +49,14 @@ module.exports = {
},
},
},
{
resolve: "gatsby-plugin-i18n",
options: {
langKeyDefault: "en",
langKeyForNull: "en",
useLangKeyLayout: false,
prefixDefault: false,
},
},
],
};

View File

@ -12,6 +12,7 @@
"babel-plugin-transform-imports": "^2.0.0",
"gatsby": "^2.23.10",
"gatsby-image": "^2.4.8",
"gatsby-plugin-i18n": "^1.0.1",
"gatsby-plugin-manifest": "^2.4.13",
"gatsby-plugin-offline": "^3.2.12",
"gatsby-plugin-react-helmet": "^3.3.5",
@ -22,6 +23,7 @@
"gatsby-theme-material-ui": "^1.0.10",
"gatsby-transformer-sharp": "^2.5.6",
"prop-types": "^15.7.2",
"ptz-i18n": "^1.0.0",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-helmet": "^6.1.0"

View File

@ -15,15 +15,25 @@ const useStyles = makeStyles(() => ({
},
}));
function Footer({ title }) {
const locales = {
en: {
backgroundCredits: "I customized the wicked cool background at",
},
pl: {
backgroundCredits: "Tło pochodzi z",
},
};
function Footer({ title, lang }) {
const classes = useStyles();
const translations = locales[lang] || locales["en"];
return (
<AppBar component="footer" position="static" className={classes.appBar}>
<Container>
<Toolbar disableGutters>
<Typography align="center" className={classes.copyright}>
I customized the wicked cool background at{" "}
{translations.backgroundCredits}{" "}
<Link color="secondary" href="https://svgbackgrounds.com">
svgbackgrounds.com
</Link>

View File

@ -1,4 +1,6 @@
import React, { useState } from "react";
import routes from "@config/routes";
import { makeStyles } from "@material-ui/core/styles";
import {
AppBar,
@ -23,7 +25,7 @@ const useStyles = makeStyles(() => ({
},
}));
function Header({ title, twhelpUrl }) {
function Header({ title, twhelpUrl, lang }) {
const [anchorEl, setAnchorEl] = useState(null);
const classes = useStyles();
const open = Boolean(anchorEl);
@ -42,7 +44,7 @@ function Header({ title, twhelpUrl }) {
<Container>
<Toolbar disableGutters>
<Typography variant="h4" className={classes.title}>
<Link to="/" underline="none" color="inherit">
<Link to={routes[lang].HOME} underline="none" color="inherit">
{title}
</Link>
</Typography>

View File

@ -21,7 +21,7 @@ const useStyles = makeStyles(theme => ({
},
}));
const Layout = ({ children, className }) => {
const Layout = ({ children, className, lang }) => {
const classes = useStyles();
const { site } = useStaticQuery(
graphql`
@ -41,13 +41,14 @@ const Layout = ({ children, className }) => {
<Header
title={site.siteMetadata.title}
twhelpUrl={site.siteMetadata.twhelpUrl}
lang={lang}
/>
<main
className={className ? classes.main + " " + className : classes.main}
>
<div className={classes.mainChild}>{children}</div>
</main>
<Footer title={site.siteMetadata.title} />
<Footer title={site.siteMetadata.title} lang={lang} />
<CssBaseline />
</ThemeProvider>
);
@ -55,6 +56,8 @@ const Layout = ({ children, className }) => {
Layout.propTypes = {
children: PropTypes.node.isRequired,
className: PropTypes.string,
lang: PropTypes.string.isRequired,
};
export default Layout;

View File

@ -1 +1,13 @@
export const COMMANDS_PAGE = "/commands/";
const pl = {
HOME: "/pl/",
COMMANDS_PAGE: "/pl/commands/",
};
const en = {
HOME: "/",
COMMANDS_PAGE: "/commands/",
};
export default {
pl,
en,
};

View File

@ -0,0 +1,24 @@
import React from "react";
import { Card, CardHeader, CardContent, Typography } from "@material-ui/core";
function Command({ command, commandSyntax, description, example }) {
return (
<Card>
<CardHeader title={command} subheader={commandSyntax} />
<CardContent>
<Typography>
{description}
{example && (
<>
<br />
<strong>Example</strong>: {example}
</>
)}
</Typography>
</CardContent>
</Card>
);
}
export default Command;

View File

@ -0,0 +1,52 @@
import React from "react";
import translations from "./translations";
import commands from "./commands";
import { Container, Typography, Grid, Box } from "@material-ui/core";
import Layout from "@components/Layout/Layout";
import SEO from "@components/SEO";
import Command from "./Command";
const CommandsPage = ({ location, pageContext }) => {
const t = translations[pageContext.langKey];
const c = commands[pageContext.langKey];
return (
<Layout lang={pageContext.langKey}>
<SEO
title={t.title}
location={location.pathname}
description={t.description}
lang={pageContext.langKey}
/>
<Container>
<Box mb={3} component="section">
<Typography variant="h2" component="h1" align="center" gutterBottom>
{t.commandsForAllSection.title}
</Typography>
<Grid container spacing={2}>
{c.commandsForAll.map(cmd => (
<Grid key={cmd.command} item xs={12} sm={6}>
<Command {...cmd} />
</Grid>
))}
</Grid>
</Box>
<section>
<Typography variant="h2" component="h1" align="center" gutterBottom>
{t.adminCommandsSection.title}
</Typography>
<Grid container spacing={2}>
{c.adminCommands.map(cmd => (
<Grid key={cmd.command} item xs={12} sm={6}>
<Command {...cmd} />
</Grid>
))}
</Grid>
</section>
</Container>
</Layout>
);
};
export default CommandsPage;

View File

@ -1,36 +1,3 @@
import React from "react";
import {
Container,
Card,
CardHeader,
CardContent,
Typography,
Grid,
Box,
} from "@material-ui/core";
import Layout from "@components/Layout/Layout";
import SEO from "@components/SEO";
const Command = ({ command, commandSyntax, description, example }) => {
return (
<Card>
<CardHeader title={command} subheader={commandSyntax} />
<CardContent>
<Typography>
{description}
{example && (
<>
<br />
<strong>Example</strong>: {example}
</>
)}
</Typography>
</CardContent>
</Card>
);
};
const commandsForAll = [
{
command: "tw!help",
@ -116,7 +83,7 @@ const adminCommands = [
command: "tw!unobserve",
commandSyntax:
"tw!unobserve [group ID from tw!groups] [id from tw!observations]",
description: "This command adds a tribe to the observation group.",
description: "This command removes a tribe to the observation group.",
example: "tw!unobserve 1 pl143 975 170",
},
{
@ -147,45 +114,7 @@ const adminCommands = [
},
];
const pageDescription =
"List of commands offered by TWHelp Discord Bot with examples";
const CommandsPage = ({ location }) => {
return (
<Layout>
<SEO
title="Commands"
location={location.pathname}
description={pageDescription}
/>
<Container>
<Box mb={3} component="section">
<Typography variant="h2" component="h1" align="center" gutterBottom>
Commands for all guild members
</Typography>
<Grid container spacing="2">
{commandsForAll.map(cmd => (
<Grid item xs={12} sm={6}>
<Command key={cmd.command} {...cmd} />
</Grid>
))}
</Grid>
</Box>
<section>
<Typography variant="h2" component="h1" align="center" gutterBottom>
Admin commands
</Typography>
<Grid container spacing="2">
{adminCommands.map(cmd => (
<Grid item xs={12} sm={6}>
<Command key={cmd.command} {...cmd} />
</Grid>
))}
</Grid>
</section>
</Container>
</Layout>
);
export default {
commandsForAll,
adminCommands,
};
export default CommandsPage;

View File

@ -0,0 +1,7 @@
import en from "./commands.en";
import pl from "./commands.pl";
export default {
en,
pl,
};

View File

@ -0,0 +1,120 @@
const commandsForAll = [
{
command: "tw!help",
commandSyntax: "tw!help",
description: "Pokazuje wszystkie dostępne komendy.",
example: "tw!help",
},
{
command: "tw!tribe topatt",
commandSyntax:
"tw!tribe topatt [serwer] [strona] [id_plemienia1] [id_plemienia2] ... [id_plemienia n]",
description:
"Generuje listę graczy z wybranych plemion i sortuje po pokonanych w ataku.",
example: "tw!tribe topatt pl143 1 975 170",
},
{
command: "tw!tribe topdef",
commandSyntax:
"tw!tribe topdef [serwer] [strona] [id_plemienia1] [id_plemienia2] ... [id_plemienia n]",
description:
"Generuje listę graczy z wybranych plemion i sortuje po pokonanych w obronie.",
example: "tw!tribe topdef pl143 1 975 170",
},
{
command: "tw!tribe topsupp",
commandSyntax:
"tw!tribe topsupp [serwer] [strona] [id_plemienia1] [id_plemienia2] ... [id_plemienia n]",
description:
"Generuje listę graczy z wybranych plemion i sortuje po pokonanych jako wspierający.",
example: "tw!tribe topsupp pl143 1 975 170",
},
{
command: "tw!tribe toptotal",
commandSyntax:
"tw!tribe toptotal [serwer] [strona] [id_plemienia1] [id_plemienia2] ... [id_plemienia n]",
description:
"Generuje listę graczy z wybranych plemion i sortuje po pokonanych ogólnie.",
example: "tw!tribe toptotal pl143 1 975 170",
},
{
command: "tw!tribe toppoints",
commandSyntax:
"tw!tribe toppoints [serwer] [strona] [id_plemienia1] [id_plemienia2] ... [id_plemienia n]",
description:
"Generuje listę graczy z wybranych plemion i sortuje po punktach.",
example: "tw!tribe toppoints pl143 1 975 170",
},
];
const adminCommands = [
{
command: "tw!addgroup",
commandSyntax: "tw!addgroup",
description: "Dodaje nową grupę.",
example: "tw!addgroup",
},
{
command: "tw!groups",
commandSyntax: "tw!addgroup",
description:
"Pokazuje listę grup dodanych przez administrację tego serwera Discord.",
example: "tw!addgroup",
},
{
command: "tw!deletegroup",
commandSyntax: "tw!deletegroup [ID grupy z tw!groups]",
description: "Usuwa grupę.",
example: "tw!deletegroup 1",
},
{
command: "tw!observe",
commandSyntax: "tw!observe [ID grupy z tw!groups] [serwer] [id plemienia]",
description: "Dodaje plemię do grupy.",
example: "tw!observe 1 pl143 975 170",
},
{
command: "tw!observations",
commandSyntax: "tw!observations [ID grupy z tw!groups]",
description: "Pokazuje plemiona należące do wybranej grupy.",
example: "tw!observations 1",
},
{
command: "tw!unobserve",
commandSyntax:
"tw!unobserve [ID grupy z tw!groups] [id from tw!observations]",
description: "Usuwa plemię z grupy.",
example: "tw!unobserve 1 pl143 975 170",
},
{
command: "tw!conqueredvillages",
commandSyntax: "tw!conqueredvillages [ID grupy z tw!groups]",
description:
"Zmienia kanał na którym będą się pojawiać informację o podbitych wioskach w danej grupie. WAŻNE! Wywołaj tę komendę na kanale na którym chcesz dostawać te powiadomienia.",
example: "tw!conqueredvillages 1",
},
{
command: "tw!lostvillages",
commandSyntax: "tw!lostvillages [ID grupy z tw!groups]",
description:
"Zmienia kanał na którym będą się pojawiać informację o straconych wioskach w danej grupie. WAŻNE! Wywołaj tę komendę na kanale na którym chcesz dostawać te powiadomienia.",
example: "tw!lostvillages 2",
},
{
command: "tw!unobserveconqueredvillages",
commandSyntax: "tw!unobserveconqueredvillages [ID grupy z tw!groups]",
description: "Wyłącza powiadomienia o podbitych wioskach w danej grupie.",
example: "tw!unobserveconqueredvillages 1",
},
{
command: "tw!unobservelostvillages",
commandSyntax: "tw!unobservelostvillages [ID grupy z tw!groups]",
description: "Wyłącza powiadomienia o straconych wioskach w danej grupie.",
example: "tw!unobservelostvillages 1",
},
];
export default {
commandsForAll,
adminCommands,
};

View File

@ -0,0 +1,10 @@
export default {
title: "Commands",
description: "List of commands offered by TWHelp Discord Bot with examples",
commandsForAllSection: {
title: "Commands for all guild members",
},
adminCommandsSection: {
title: "Admin commands",
},
};

View File

@ -0,0 +1,7 @@
import en from "./translations.en";
import pl from "./translations.pl";
export default {
en,
pl,
};

View File

@ -0,0 +1,11 @@
export default {
title: "Komendy",
description:
"Lista komend oferowanych przez TWHelp Discord Bot z przykładami",
commandsForAllSection: {
title: "Komendy dla wszystkich",
},
adminCommandsSection: {
title: "Komendy przeznaczone tylko dla administratorów",
},
};

View File

@ -1,6 +1,7 @@
import React from "react";
import { graphql, useStaticQuery } from "gatsby";
import { COMMANDS_PAGE } from "@config/routes";
import routes from "@config/routes";
import translations from "./translations";
import { makeStyles } from "@material-ui/core/styles";
import Image from "gatsby-image";
@ -32,7 +33,7 @@ const useStyles = makeStyles(theme => ({
},
}));
const IndexPage = ({ location }) => {
const IndexPage = ({ location, pageContext }) => {
const classes = useStyles();
const data = useStaticQuery(graphql`
query {
@ -51,20 +52,23 @@ const IndexPage = ({ location }) => {
}
}
`);
const t = translations[pageContext.langKey];
return (
<Layout className={classes.layout}>
<SEO title="Home" location="/" />
<Layout className={classes.layout} lang={pageContext.langKey}>
<SEO
title={t.title}
description={t.description}
location={location.pathname}
lang={pageContext.langKey}
/>
<Container className={classes.container}>
<Grid container spacing={3} alignItems="center">
<Grid item xs={12} md={7}>
<Typography variant="h2" component="h1" gutterBottom>
Observe your tribe ennoblements!
</Typography>
<Typography gutterBottom>
This bot notifies you about conquered/lost village by a tribe near
real-time.
{t.header.title}
</Typography>
<Typography gutterBottom>{t.header.description}</Typography>
<Divider variant="fullWidth" className={classes.divider} />
<ButtonGroup variant="contained" color="secondary">
<Button>
@ -72,14 +76,18 @@ const IndexPage = ({ location }) => {
href={data.site.siteMetadata.botInviteUrl}
color="inherit"
underline="none"
title={`Invite bot to your server`}
title={t.header.inviteBot}
>
Invite bot to your server
{t.header.inviteBot}
</Link>
</Button>
<Button>
<Link to={COMMANDS_PAGE} color="inherit" underline="none">
Commands
<Link
to={routes[pageContext.langKey].COMMANDS_PAGE}
color="inherit"
underline="none"
>
{t.header.commands}
</Link>
</Button>
</ButtonGroup>

View File

@ -0,0 +1,12 @@
export default {
title: "Home",
description:
"Live notifications about lost/conquered village by a tribe in the game TribalWars.",
header: {
title: "Observe your tribe ennoblements!",
description:
"This bot notifies you about conquered/lost village by a tribe near real-time.",
inviteBot: "Invite bot to your server",
commands: "Commands",
},
};

View File

@ -0,0 +1,7 @@
import en from "./translations.en";
import pl from "./translations.pl";
export default {
en,
pl,
};

View File

@ -0,0 +1,12 @@
export default {
title: "Strona główna",
description:
"Powiadomienia o podbiciu/straceniu wioski przez plemię w grze TribalWars na Twoim serwerze Discord.",
header: {
title: "Obserwuj podboje swojego plemienia!",
description:
"Ten powiadamia Ciebie o podbitej/straconej wiosce w czasie rzeczywistym.",
inviteBot: "Zaproś bota na swój serwer",
commands: "Komendy",
},
};

3
src/pages/commands.en.js Normal file
View File

@ -0,0 +1,3 @@
import CommandsPage from "@features/CommandsPage/CommandsPage";
export default CommandsPage;

3
src/pages/commands.pl.js Normal file
View File

@ -0,0 +1,3 @@
import CommandsPage from "@features/CommandsPage/CommandsPage";
export default CommandsPage;

3
src/pages/index.en.js Normal file
View File

@ -0,0 +1,3 @@
import IndexPage from "@features/IndexPage/IndexPage";
export default IndexPage;

3
src/pages/index.pl.js Normal file
View File

@ -0,0 +1,3 @@
import IndexPage from "@features/IndexPage/IndexPage";
export default IndexPage;

View File

@ -6178,6 +6178,11 @@ flush-write-stream@^1.0.0:
inherits "^2.0.3"
readable-stream "^2.3.6"
folktale@^2.0.1:
version "2.3.2"
resolved "https://registry.yarnpkg.com/folktale/-/folktale-2.3.2.tgz#38231b039e5ef36989920cbf805bf6b227bf4fd4"
integrity sha512-+8GbtQBwEqutP0v3uajDDoN64K2ehmHd0cjlghhxh0WpcfPzAIjPA03e1VvHlxL02FVGR0A6lwXsNQKn3H1RNQ==
follow-redirects@1.5.10, follow-redirects@^1.0.0:
version "1.5.10"
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.5.10.tgz#7b7a9f9aea2fdff36786a94ff643ed07f4ff5e2a"
@ -6434,6 +6439,15 @@ gatsby-plugin-compile-es6-packages@^2.1.0:
"@babel/runtime" "^7.0.0"
regex-escape "^3.4.8"
gatsby-plugin-i18n@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/gatsby-plugin-i18n/-/gatsby-plugin-i18n-1.0.1.tgz#573fb98b85654c29e0cda50740037061fa38e694"
integrity sha512-6Cucb15sLQp9cTVgmRC34MeWVJu0a09G7LRrCNV87PgMlbS5iVUX00TwDnIUB0b+f6RUq3z5+V6/sIBIvsz8/Q==
dependencies:
folktale "^2.0.1"
graphql "^0.11.7"
ptz-i18n "^1.0.0"
gatsby-plugin-manifest@^2.4.13:
version "2.4.13"
resolved "https://registry.yarnpkg.com/gatsby-plugin-manifest/-/gatsby-plugin-manifest-2.4.13.tgz#49e4ed03f46f0d9bbcdd4a9dc4be8d2fb68ecb30"
@ -7269,6 +7283,13 @@ graphql-type-json@^0.3.1:
resolved "https://registry.yarnpkg.com/graphql-type-json/-/graphql-type-json-0.3.2.tgz#f53a851dbfe07bd1c8157d24150064baab41e115"
integrity sha512-J+vjof74oMlCWXSvt0DOf2APEdZOCdubEvGDUAlqH//VBYcOYsGgRW7Xzorr44LvkjiuvecWc8fChxuZZbChtg==
graphql@^0.11.7:
version "0.11.7"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-0.11.7.tgz#e5abaa9cb7b7cccb84e9f0836bf4370d268750c6"
integrity sha512-x7uDjyz8Jx+QPbpCFCMQ8lltnQa4p4vSYHx6ADe8rVYRTdsyhCJbvSty5DAsLVmU6cGakl+r8HQYolKHxk/tiw==
dependencies:
iterall "1.1.3"
graphql@^14.6.0:
version "14.6.0"
resolved "https://registry.yarnpkg.com/graphql/-/graphql-14.6.0.tgz#57822297111e874ea12f5cd4419616930cd83e49"
@ -8626,6 +8647,11 @@ isurl@^1.0.0-alpha5:
has-to-string-tag-x "^1.2.0"
is-object "^1.0.1"
iterall@1.1.3:
version "1.1.3"
resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.1.3.tgz#1cbbff96204056dde6656e2ed2e2226d0e6d72c9"
integrity sha512-Cu/kb+4HiNSejAPhSaN1VukdNTTi/r4/e+yykqjlG/IW+1gZH5b4+Bq3whDX4tvbYugta3r8KTMUiqT3fIGxuQ==
iterall@^1.2.1, iterall@^1.2.2:
version "1.3.0"
resolved "https://registry.yarnpkg.com/iterall/-/iterall-1.3.0.tgz#afcb08492e2915cbd8a0884eb93a8c94d0d72fea"
@ -11410,6 +11436,14 @@ psl@^1.1.28:
resolved "https://registry.yarnpkg.com/psl/-/psl-1.8.0.tgz#9326f8bcfb013adcc005fdff056acce020e51c24"
integrity sha512-RIdOzyoavK+hA18OGGWDqUTsCLhtA7IcZ/6NCs4fFJaHBDab+pDDmDIByWFRQJq2Cd7r1OoQxBGKOaztq+hjIQ==
ptz-i18n@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/ptz-i18n/-/ptz-i18n-1.0.0.tgz#803df4d0f5ce9a7732f5d1d805ea624c6a1f5e8c"
integrity sha512-3buuv2T+Qo2tyo3A1pSx2arxheW0vd+tPGizmWdvr9RWJKfQlrNw8GtnYXdjChUKN0s2UO/JJkWswOTRYBi/OQ==
dependencies:
folktale "^2.0.1"
ramda "^0.24.1"
public-encrypt@^4.0.0:
version "4.0.3"
resolved "https://registry.yarnpkg.com/public-encrypt/-/public-encrypt-4.0.3.tgz#4fcc9d77a07e48ba7527e7cbe0de33d0701331e0"
@ -11523,6 +11557,11 @@ quick-lru@^4.0.1:
resolved "https://registry.yarnpkg.com/quick-lru/-/quick-lru-4.0.1.tgz#5b8878f113a58217848c6482026c73e1ba57727f"
integrity sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==
ramda@^0.24.1:
version "0.24.1"
resolved "https://registry.yarnpkg.com/ramda/-/ramda-0.24.1.tgz#c3b7755197f35b8dc3502228262c4c91ddb6b857"
integrity sha1-w7d1UZfzW43DUCIoJixMkd22uFc=
randombytes@^2.0.0, randombytes@^2.0.1, randombytes@^2.0.5, randombytes@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"