Skip to content

Commit

Permalink
Merge pull request #417 from zekroTJA/dev
Browse files Browse the repository at this point in the history
Release 1.39.0
  • Loading branch information
zekroTJA authored Mar 17, 2023
2 parents 412415c + 0d6db3f commit 0427287
Show file tree
Hide file tree
Showing 18 changed files with 625 additions and 434 deletions.
1 change: 1 addition & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ insert_final_newline = false
[*.py]
indent_style = space
indent_size = 4
end_of_line = lf

[*.bash]
[*.sh]
Expand Down
19 changes: 19 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,25 @@

This release finally brings a huge update to the web interface of shinpuru. Because the old web interface had no clear style concept while also growing with each new feature, it got more and more cluttered, unstructured, obscure and simply uglier. So I decided [almost a year ago](https://github.com/zekroTJA/shinpuru/issues/370) to rewrite the whole web interface, which has now come to the final stage. There is still a lot to do and - especially translation-wise - a lot missing, but the feature set is now 100% ported and so I decided to finally port it over.

Here you can see a very small demo of the new web interface.

https://user-images.githubusercontent.com/16734205/225418408-beecb181-5dbe-4c0b-9110-94b8e715f308.mp4
<br />

The whole web interface is now also more optimized for mobile usage!

https://user-images.githubusercontent.com/16734205/225419824-63543e4a-bca8-40bb-8312-3b14a588e7b7.mp4
<br />

And because the web app is now a [PWA](https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps) as well, you can even install it on your device when you are using a chromium browser!

https://user-images.githubusercontent.com/16734205/225420680-12dbc648-7768-490e-8707-1c92da804854.mp4
<br />

But feel free to [discover](https://shnp.de) the new web interface on your own. It is still far from perfect, so if you spot an issue or have an idea for improvement, feel free to [create an issue](https://github.com/zekroTJA/shinpuru/issues/new/choose)!

Also, there are still a lot of [german translations](https://github.com/zekroTJA/shinpuru/tree/dev/web/public/locales/de) missing. So if you want to contribute some translations, feel free to do so. In the [Contributing](https://github.com/zekroTJA/shinpuru/blob/master/CONTRIBUTING.md) document, you can find some useful information on how to work with the language files.

## Unban Request Improvements

The unban request received a small "rework". First of all, special reports are created in the mod log which display if an unban request has been accepted or rejected and who has processed the unban request.
Expand Down
14 changes: 14 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,20 @@ The shinpuru web frontend is a [**React**](https://reactjs.org/) SPA, which is d

For communication with the API, a [custom package](https://github.com/zekroTJA/shinpuru/tree/master/web/src/lib/shinpuru-ts) has been written (which will soon also be available as NPM package). With the use of the custom [useApi](https://github.com/zekroTJA/shinpuru/blob/master/web/src/hooks/useApi.ts) hook, you can access the API from anywhere in the app. There are also a lot of [more custom hooks](https://github.com/zekroTJA/shinpuru/tree/master/web/src/hooks) available, which you can use. Also, feel free to add your owns if you want.

#### Translations

Translation files for the web app can be found in [web/public/locales/](web/public/locales/). If you want to ad missing translations or add a translation for a new language, you can use the provided [`merge-langs`](scripts/merge-langs.py) script. It takes a `--base` language pack and applies it to the `--target` language pack by inserting missing language keys from the base pack or adding missing translation files from the base pack to the target pack.

Here is an example how to execute the script.
```
python3 scripts/merge-langs.py --base web/public/locales/en-US --target web/public/locales/de
```

If you want to add translations for a new language, just use a new folder as target path.
```
python3 scripts/merge-langs.py --base web/public/locales/en-US --target web/public/locales/it
```

## Preparing a Development Environment

There are two main ways to set up a development environment for shinpuru.
Expand Down
773 changes: 397 additions & 376 deletions README.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/requirements.md → docs/requirements-be.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- insert:REQUIREMENTS -->
<!-- insert:REQUIREMENTS_BE -->
- [bwmarrin/discordgo](https://github.com/bwmarrin/discordgo) `(v0.27.0)`
- [bwmarrin/snowflake](https://github.com/bwmarrin/snowflake) `(v0.3.0)`
- [esimov/stackblur-go](https://github.com/esimov/stackblur-go) `(v1.1.0)`
Expand Down Expand Up @@ -31,6 +31,7 @@
- [zekrotja/dgrs](https://github.com/zekrotja/dgrs) `(v0.5.7)`
- [zekrotja/jwt](https://github.com/zekrotja/jwt) `(v0.0.0-20220515133240-d66362c9fbc9)`
- [zekrotja/ken](https://github.com/zekrotja/ken) `(v0.18.0)`
- [zekrotja/promtail](https://github.com/zekrotja/promtail) `(v0.0.0-20230303162843-4e609d577b74)`
- [zekrotja/rogu](https://github.com/zekrotja/rogu) `(v0.3.0)`
- [zekrotja/sop](https://github.com/zekrotja/sop) `(v0.3.1)`
- [x/image](https://golang.org/x/image) `(v0.5.0)`
Expand Down
26 changes: 26 additions & 0 deletions docs/requirements-fe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!-- insert:REQUIREMENTS_FE -->
- [@hcaptcha/react-hcaptcha](https://github.com/hCaptcha/react-hcaptcha#readme) `(^1.4.4)`
- [byte-formatter](None) `(^1.0.1)`
- [color](https://github.com/Qix-/color#readme) `(^4.2.1)`
- [date-fns](https://github.com/date-fns/date-fns#readme) `(^2.28.0)`
- [debounce](https://github.com/component/debounce#readme) `(^1.2.1)`
- [emoji.json](https://github.com/amio/emoji.json#readme) `(^13.1.0)`
- [fuse.js](http://fusejs.io) `(^6.6.2)`
- [i18next](https://www.i18next.com) `(^21.6.14)`
- [i18next-browser-languagedetector](https://github.com/i18next/i18next-browser-languageDetector) `(^6.1.3)`
- [i18next-http-backend](https://github.com/i18next/i18next-http-backend) `(^1.4.0)`
- [react](https://reactjs.org/) `(^18.2.0)`
- [react-dom](https://reactjs.org/) `(^18.2.0)`
- [react-fast-marquee](https://github.com/justin-chu/react-fast-marquee#readme) `(^1.3.5)`
- [react-i18next](https://github.com/i18next/react-i18next) `(^11.15.7)`
- [react-markdown](https://github.com/remarkjs/react-markdown#readme) `(^8.0.1)`
- [react-router](https://github.com/remix-run/react-router#readme) `(^6.0.2)`
- [react-router-dom](https://github.com/remix-run/react-router#readme) `(^6.2.1)`
- [react-scripts](https://github.com/facebook/create-react-app#readme) `(5.0.0)`
- [react-spinners](https://www.davidhu.io/react-spinners/) `(^0.13.8)`
- [react-uid](https://github.com/thearnica/react-uid#readme) `(^2.3.1)`
- [react-wavify](https://github.com/woofers/react-wavify#readme) `(^1.7.0)`
- [sass](https://github.com/sass/dart-sass) `(^1.49.0)`
- [styled-components](https://styled-components.com) `(^5.3.0)`
- [web-vitals](https://github.com/GoogleChrome/web-vitals#readme) `(^2.1.2)`
- [zustand](https://github.com/pmndrs/zustand) `(^3.7.0)`
4 changes: 2 additions & 2 deletions internal/slashcommands/help.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ func (c *Help) Run(ctx ken.Context) (err error) {
cmdHelp := "[Here](https://github.com/zekroTJA/shinpuru/wiki/Commands) you can find a list of all commands " +
"and detailed meta and help information."
if webEnabled {
cmdHelp += fmt.Sprintf("\nThere is also an interactive [web view](%s/commands) where you can "+
cmdHelp += fmt.Sprintf("\nThere is also an interactive [web view](%s/info/commands) where you can "+
"discover and look up command information.", webAddr)
} else {
webAddr = ""
Expand Down Expand Up @@ -146,7 +146,7 @@ func (c *Help) cmdHelp(ctx ken.Context, webAddr, name string) (err error) {
}

if webAddr != "" {
emb.WithURL(fmt.Sprintf("%s/commands/#%s", webAddr, name))
emb.WithURL(fmt.Sprintf("%s/info/commands/#%s", webAddr, name))
}

options := info.ApplicationCommand.Options
Expand Down
5 changes: 0 additions & 5 deletions package.json

This file was deleted.

58 changes: 29 additions & 29 deletions scripts/parse-gomod.py → scripts/gen-requirements-be.py
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@


class Module:
def __init__(self, line):
split = line.split(' ')
self.url = split[0]
self.version = split[1]
self.name = '/'.join(self.url.split('/')[-2:])

def string(self):
return '[{}](https://{}) `({})`'.format(self.name, self.url, self.version)


def main():
lines = []
with open('./go.mod') as f:
lines = [l.strip() for l in f.readlines()]
start = lines.index('require (')
end = lines.index(')')
lines = [l for l in lines[start+1:end] if not l.endswith('// indirect')]
modules = [Module(l) for l in lines]

with open('./docs/requirements.md', 'w') as f:
f.write('<!-- insert:REQUIREMENTS -->\n')
f.writelines(['- {}\n'.format(m.string()) for m in modules])


if __name__ == '__main__':
main()
OUTPUT='./docs/requirements-be.md'

class Module:
def __init__(self, line):
split = line.split(' ')
self.url = split[0]
self.version = split[1]
self.name = '/'.join(self.url.split('/')[-2:])

def string(self):
return '[{}](https://{}) `({})`'.format(self.name, self.url, self.version)


def main():
lines = []
with open('./go.mod') as f:
lines = [l.strip() for l in f.readlines()]
start = lines.index('require (')
end = lines.index(')')
lines = [l for l in lines[start+1:end] if not l.endswith('// indirect')]
modules = [Module(l) for l in lines]

with open(OUTPUT, 'w') as f:
f.write('<!-- insert:REQUIREMENTS_BE -->\n')
f.writelines(['- {}\n'.format(m.string()) for m in modules])


if __name__ == '__main__':
main()
26 changes: 26 additions & 0 deletions scripts/gen-requirements-fe.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import json
import requests


OUTPUT = './docs/requirements-fe.md'


def main():
data = {}
with open('web/package.json') as f:
data = json.load(f)

modules = []
for (name, version) in data.get("dependencies").items():
print(f"Processing package {name} ...")
resp = requests.get(f'https://registry.npmjs.com/{name}/latest')
homepage = resp.json().get('homepage')
modules.append(f"[{name}]({homepage}) `({version})`")

with open(OUTPUT, 'w') as f:
f.write('<!-- insert:REQUIREMENTS_FE -->\n')
f.writelines([f'- {m}\n' for m in modules])


if __name__ == '__main__':
main()
91 changes: 91 additions & 0 deletions scripts/get-translation-state.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
#!/usr/bin/env python3

import argparse
import os
from os import path
import json
import re


WORDS_RX = r'[\w]+'


def parse_args():
p = argparse.ArgumentParser()

p.add_argument('dir', nargs=1, type=str,
help="Language pack directory.")
p.add_argument('--base', '-b', type=str, default="en-US",
help="Base language code to compare against.")

return p.parse_args()


def main() -> int:
args = parse_args()

indices = {}
for dir in os.listdir(args.dir[0]):
indices[dir] = index_trans_pack(path.join(args.dir[0], dir))

base = indices.get(args.base)
if not base:
print("Error: Given base translation pack does not exist")
return 1

stats = {}
for (key, index) in indices.items():
files = len(index)
(keys, words) = get_n_kvs(index)
stats[key] = (files, keys, words)

base_state = stats[args.base]
for (key, stats) in [(k, s) for (k, s) in stats.items() if k != args.base]:
print_state(key, base_state, stats)

return 0


def index_trans_pack(dir):
index = {}
for (root, _, files) in os.walk(dir):
for file in files:
with open(path.join(root, file)) as f:
index[file] = json.load(f)
return index


def get_n_kvs(index):
n_keys = 0
n_words = 0
for (_, v) in index.items():
if type(v) == dict:
(keys, words) = get_n_kvs(v)
n_keys += keys
n_words += words
elif type(v) == list or type(v) == tuple:
n_keys += len(v)
n_words += sum([count_words(e) for e in v])
elif len(v) != 0:
n_keys += 1
n_words += count_words(v)
return (n_keys, n_words)


def count_words(s):
return len(re.findall(WORDS_RX, s))


def print_state(key, base, target):
(b_files, b_keys, b_words) = base
(t_files, t_keys, t_words) = target
print(
f"{key}:\n"
f" files: {t_files:>5} / {b_files:>5} ({t_files/b_files:.1%})\n"
f" keys: {t_keys:>5} / {b_keys:>5} ({t_keys/b_keys:.1%})\n"
f" words: {t_words:>5} / {b_words:>5} ({t_words/b_words:.1%})\n"
)


if __name__ == "__main__":
exit(main())
9 changes: 7 additions & 2 deletions scripts/update-readme.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,10 @@ PYTHON=py
which $PYTHON > /dev/null 2>&1 || PYTHON=python3

$PYTHON scripts/gen-package-descriptions.py
$PYTHON scripts/parse-gomod.py
$PYTHON scripts/md-replace.py -i README.md docs/public-packages.md docs/requirements.md
$PYTHON scripts/gen-requirements-be.py
$PYTHON scripts/gen-requirements-fe.py

$PYTHON scripts/md-replace.py -i README.md \
docs/public-packages.md \
docs/requirements-be.md \
docs/requirements-fe.md
10 changes: 5 additions & 5 deletions web/public/locales/de/routes.login.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"discord": {
"title": "Loggen Sie ich entweder über Ihren Discord Account via OAuth2 ein",
"action": "Via Discord einloggen",
"subline": "Wir speichern weder Ihre E-Mail-Addresse noch irgend etwas anderes und wir verifizieren nur Ihre Discord ID."
"title": "Logge dich entweder mit deinem Discord-Account via OAuth2 ein ...",
"action": "Mit Discord einloggen",
"subline": "Wir speichern weder deine E-Mail-Addresse noch irgendetwas anderes und wir verifizieren nur deine Discord-ID."
},
"alternative": {
"title": "Oder schicke den folgenden Code via Direktnachricht an shinpuru",
"subline": "Alternativ können Sie auch den <1>/login</1> Command benutzen."
"title": "... oder schicke den folgenden Code via Direktnachricht an shinpuru.",
"subline": "Alternativ kannst du auch den <1>/login</1> Befehl benutzen."
}
}
6 changes: 3 additions & 3 deletions web/public/locales/en-US/routes.login.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
"discord": {
"title": "Either log in with your Discord Account via OAuth2",
"title": "Either log in with your Discord account via OAuth2 ...",
"action": "Login with Discord",
"subline": "We don't store your E-Mail mail address or anything else and just verify your ID."
"subline": "We neither store your E-Mail address nor anything else and just verify your Discord ID."
},
"alternative": {
"title": "Or DM the following Code to shinpuru on Discord",
"title": "... or send the following code via direct message to shinpuru.",
"subline": "Alternatively, you can also use the <1>/login</1> command."
}
}
2 changes: 1 addition & 1 deletion web/public/locales/en-US/routes.usersettings.apitoken.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"regenerate": "Re-generate token",
"reset": "Reset token",
"tokenwarning": "The token will be only shown after generation. After that, the token will not be shown again, so please store it somewhere safe.",
"tokeninfo": "One API token is avtive.<br />The token has been created at <b>{{created}}</b> and will expire at <b>{{expires}}</b>. The token has been used <b>{{hits}}</b> times.",
"tokeninfo": "One API token is active.<br />The token has been created at <b>{{created}}</b> and will expire at <b>{{expires}}</b>. The token has been used <b>{{hits}}</b> times.",
"notifications": {
"generated": "An API token has been generated.",
"reset": "The API token has been reset."
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/Switch/Switch.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const SwitchContainer = styled.div<{ enabled: boolean; theaming?: Partial<Theme>
> div {
height: 100%;
border-radius: 2em;
background-color: ${(p) => p.theme.white};
background-color: ${(p) => (p.enabled ? p.theme.textAlt : p.theme.text)};
margin-left: ${(p) => (p.enabled ? '2em' : '0')};
margin-right: ${(p) => (p.enabled ? '0' : '2em')};
Expand Down
2 changes: 1 addition & 1 deletion web/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export default defineConfig({
'locales/**/*.json',
],
cacheId: 'shinpuru-v1',
navigateFallbackDenylist: [/^\/api\/auth\/.*/, /^\/invite/],
navigateFallbackDenylist: [/^\/api\/(auth|public)\/.*/, /^\/invite/],
runtimeCaching: [
{
urlPattern: /\/api\/(?:v\d\/)?guilds\/\d+\/(members|\d+)/,
Expand Down
8 changes: 0 additions & 8 deletions yarn.lock

This file was deleted.

0 comments on commit 0427287

Please sign in to comment.