replace zxq.co/ripple/hanayo
This commit is contained in:
17
scripts/dark-logos.php
Normal file
17
scripts/dark-logos.php
Normal file
@@ -0,0 +1,17 @@
|
||||
<?php
|
||||
// For such a stupid task, I felt like writing some PHP.
|
||||
|
||||
$search_replace = [
|
||||
'fill="#050505"' => 'fill="#FFFFFF"',
|
||||
'fill="#030303"' => 'fill="#F5F5F5"',
|
||||
'd="M371.611,149.506H353.4v33.801h41' => 'fill="#FFFFFF" d="M371.611,149.506H353.4v33.801h41',
|
||||
];
|
||||
|
||||
$files = glob("static/logos/logo-*.svg");
|
||||
foreach ($files as $fname) {
|
||||
$file = file_get_contents($fname);
|
||||
foreach ($search_replace as $s => $r) {
|
||||
$file = str_replace($s, $r, $file);
|
||||
}
|
||||
file_put_contents(substr($fname, 0, -4) . "-dark.svg", $file);
|
||||
}
|
11
scripts/download-locales.sh
Normal file
11
scripts/download-locales.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
rm data/{js-,}locales/templates-*.po
|
||||
cd data/locales
|
||||
for i in it es de pl ru fr nl sv "fi" ro ko vi; do
|
||||
echo "$i"
|
||||
wget -O templates-$i.po --quiet "https://cutebirbs.ripple.moe/export/?path=/$i/Hanayo/"
|
||||
cd ../js-locales
|
||||
wget -O templates-$i.po --quiet "https://cutebirbs.ripple.moe/export/?path=/$i/HanayoJS/"
|
||||
i18next-conv -l $i -s templates-$i.po -t ../../static/locale/$i.json
|
||||
cd ../locales
|
||||
done
|
51
scripts/generate_configs.go
Normal file
51
scripts/generate_configs.go
Normal file
@@ -0,0 +1,51 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
|
||||
"github.com/thehowl/conf"
|
||||
)
|
||||
|
||||
type simplePage struct {
|
||||
Handler, Template, TitleBar, KyutGrill string
|
||||
MinPrivilegesRaw uint64
|
||||
}
|
||||
|
||||
type noTemplate struct {
|
||||
Handler, TitleBar, KyutGrill string
|
||||
MinPrivileges uint64
|
||||
}
|
||||
|
||||
var simplePages = [...]simplePage{{"/", "homepage.html", "Home Page", "homepage2.jpg", 0}, {"/login", "login.html", "Log in", "login2.jpg", 0}, {"/settings/avatar", "settings/avatar.html", "Change avatar", "settings2.jpg", 2}, {"/dev/tokens", "dev/tokens.html", "Your API tokens", "dev.jpg", 2}, {"/beatmaps/rank_request", "beatmaps/rank_request.html", "Request beatmap ranking", "request_beatmap_ranking.jpg", 2}, {"/donate", "support.html", "Support Ripple", "donate2.png", 0}, {"/doc", "doc.html", "Documentation", "documentation.jpg", 0}, {"/doc/:id", "doc_content.html", "View document", "documentation.jpg", 0}, {"/help", "help.html", "Contact support", "help.jpg", 0}, {"/leaderboard", "leaderboard.html", "Leaderboard", "leaderboard2.jpg", 0}, {"/friends", "friends.html", "Friends", "", 2}, {"/changelog", "changelog.html", "Changelog", "changelog.jpg", 0}, {"/team", "team.html", "Team", "", 0}, {"/pwreset", "pwreset.html", "Reset password", "", 0}, {"/about", "about.html", "About", "", 0}}
|
||||
|
||||
func main() {
|
||||
for _, p := range simplePages {
|
||||
fmt.Print("=> ", p.Handler+" ... ")
|
||||
noTemplateP := noTemplate{
|
||||
Handler: p.Handler,
|
||||
TitleBar: p.TitleBar,
|
||||
KyutGrill: p.KyutGrill,
|
||||
MinPrivileges: p.MinPrivilegesRaw,
|
||||
}
|
||||
d := []byte("{{/*###\n")
|
||||
confData, err := conf.ExportRaw(&noTemplateP)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
d = append(d, confData...)
|
||||
fileData, err := ioutil.ReadFile("templates/" + p.Template)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
d = append(d, []byte("*/}}\n")...)
|
||||
d = append(d, fileData...)
|
||||
err = ioutil.WriteFile("templates/"+p.Template, d, 0644)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fmt.Println("ok.")
|
||||
}
|
||||
}
|
83
scripts/generate_mappings.go
Normal file
83
scripts/generate_mappings.go
Normal file
@@ -0,0 +1,83 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"flag"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"regexp"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var toGoMap bool
|
||||
flag.BoolVar(&toGoMap, "g", false, "Set if you want to export data to mappings.go")
|
||||
flag.Parse()
|
||||
|
||||
semantic, err := getMappings("https://raw.githubusercontent.com/Semantic-Org/Semantic-UI/master/src/themes/default/elements/icon.overrides", semanticRegex)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
fontawesome, err := getMappings("https://maxcdn.bootstrapcdn.com/font-awesome/latest/css/font-awesome.css", fontAwesomeRegex)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
classMappings := make(map[string]string, len(semantic))
|
||||
for k, v := range semantic {
|
||||
if equivalent, ok := fontawesome[k]; ok {
|
||||
classMappings[equivalent] = v
|
||||
}
|
||||
}
|
||||
b, err := json.MarshalIndent(classMappings, "", "\t")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if toGoMap {
|
||||
f, err := os.Create("modules/fa-semantic-mappings/mappings.go")
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
f.Write([]byte(fileHeader))
|
||||
fmt.Fprintf(f, "var Mappings = %#v\n", classMappings)
|
||||
fmt.Println("generate: mappings.go")
|
||||
} else {
|
||||
fmt.Println(string(b))
|
||||
}
|
||||
}
|
||||
|
||||
const fileHeader = `// THIS FILE WAS AUTOMATICALLY GENERATED BY A TOOL
|
||||
// Use ` + "`go generate`" + ` to generate this.
|
||||
|
||||
package fasuimappings
|
||||
|
||||
// Mappings is a map containing the Semantic UI icon equivalent of FontAwesome
|
||||
// icons.
|
||||
`
|
||||
|
||||
var semanticRegex = regexp.MustCompile(`i\.([\.a-zA-Z0-9-]+):before { content: "(.{5})"; }`)
|
||||
var fontAwesomeRegex = regexp.MustCompile(`.([a-zA-Z0-9-]+):before {
|
||||
content: "(.{5})";
|
||||
}`)
|
||||
|
||||
func getMappings(url string, regex *regexp.Regexp) (map[string]string, error) {
|
||||
ov, err := http.Get(url)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
b, err := ioutil.ReadAll(ov.Body)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
strs := regex.FindAllStringSubmatch(string(b), -1)
|
||||
m := make(map[string]string, len(strs))
|
||||
for _, strs := range strs {
|
||||
m[strs[2]] = strings.Replace(strs[1], ".", " ", -1)
|
||||
}
|
||||
return m, nil
|
||||
}
|
24
scripts/key_plural_generator.js
Normal file
24
scripts/key_plural_generator.js
Normal file
@@ -0,0 +1,24 @@
|
||||
var parser = require("gettext-parser")
|
||||
var fs = require("fs")
|
||||
|
||||
fs.readFile("data/js-locales/templates.pot", "utf-8", (err, data) => {
|
||||
if (err)
|
||||
throw err
|
||||
var tpl = parser.po.parse(data, "utf-8")
|
||||
var plurals = {}
|
||||
Object.keys(tpl.translations[""]).forEach(key => {
|
||||
let val = tpl.translations[""][key]
|
||||
|
||||
if (typeof val === "undefined")
|
||||
return
|
||||
|
||||
if (!val.msgid_plural)
|
||||
return
|
||||
|
||||
plurals[val.msgid] = val.msgid_plural
|
||||
})
|
||||
|
||||
fs.writeFile("static/key_plural.js", "var keyPlurals = " + JSON.stringify(plurals) + ";", err => {
|
||||
if (err) throw err;
|
||||
})
|
||||
})
|
11
scripts/make-dark.sh
Normal file
11
scripts/make-dark.sh
Normal file
@@ -0,0 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
echo 'preparing...'
|
||||
sed -i 's/static\//static\/dark\//g' semantic.json
|
||||
mv semantic/src/theme.config{,.default}
|
||||
mv semantic/src/theme.config{.dark,}
|
||||
echo 'building...'
|
||||
gulp build-semantic
|
||||
echo 'rolling back...'
|
||||
sed -i 's/static\/dark\//static\//g' semantic.json
|
||||
mv semantic/src/theme.config{,.dark}
|
||||
mv semantic/src/theme.config{.default,}
|
9
scripts/package.json
Normal file
9
scripts/package.json
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"name": "hanayo-scripts",
|
||||
"version": "1.0.0",
|
||||
"author": "Morgan Bazalgette <the@howl.moe>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"gettext-parser": "^1.2.2"
|
||||
}
|
||||
}
|
51
scripts/top_passwords.go
Normal file
51
scripts/top_passwords.go
Normal file
@@ -0,0 +1,51 @@
|
||||
// +build ignore
|
||||
|
||||
package main
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
)
|
||||
|
||||
const topPasswords = `https://raw.githubusercontent.com/danielmiessler/SecLists/master/Passwords/10_million_password_list_top_10000.txt`
|
||||
const fileHeader = `// THIS FILE WAS AUTOMATICALLY GENERATED BY A TOOL
|
||||
// Use ` + "`go generate`" + ` to generate this.
|
||||
|
||||
package toppasswords
|
||||
|
||||
// TopPassword is a list of the top 10,000 passwords longer or exactly 8
|
||||
// characters. This is used in Hanayo to detect common password, and to inform
|
||||
// the user about it.
|
||||
var TopPasswords = []string{
|
||||
`
|
||||
|
||||
func main() {
|
||||
resp, err := http.Get(topPasswords)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
f, err := os.Create("modules/top-passwords/top_passwords.go")
|
||||
defer f.Close()
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
f.Write([]byte(fileHeader))
|
||||
|
||||
s := bufio.NewScanner(resp.Body)
|
||||
|
||||
for s.Scan() {
|
||||
// passwords shorter than 8 characters aren't allowed on ripple anyway.
|
||||
if len(s.Text()) < 8 {
|
||||
continue
|
||||
}
|
||||
fmt.Fprintf(f, "\t\"%s\",\n", s.Text())
|
||||
}
|
||||
|
||||
f.Write([]byte{'}', '\n'})
|
||||
|
||||
fmt.Println("generate: top_passwords.go")
|
||||
}
|
2
scripts/update-submodules.sh
Normal file
2
scripts/update-submodules.sh
Normal file
@@ -0,0 +1,2 @@
|
||||
#!/bin/bash
|
||||
git submodule update --remote --merge
|
19
scripts/yarn.lock
Normal file
19
scripts/yarn.lock
Normal file
@@ -0,0 +1,19 @@
|
||||
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
|
||||
# yarn lockfile v1
|
||||
|
||||
|
||||
encoding@0.1.12:
|
||||
version "0.1.12"
|
||||
resolved "https://registry.yarnpkg.com/encoding/-/encoding-0.1.12.tgz#538b66f3ee62cd1ab51ec323829d1f9480c74beb"
|
||||
dependencies:
|
||||
iconv-lite "~0.4.13"
|
||||
|
||||
gettext-parser@^1.2.2:
|
||||
version "1.2.2"
|
||||
resolved "https://registry.yarnpkg.com/gettext-parser/-/gettext-parser-1.2.2.tgz#1ef0da75c1e759ae3089c73efa4d19e40298748e"
|
||||
dependencies:
|
||||
encoding "0.1.12"
|
||||
|
||||
iconv-lite@~0.4.13:
|
||||
version "0.4.15"
|
||||
resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.15.tgz#fe265a218ac6a57cfe854927e9d04c19825eddeb"
|
Reference in New Issue
Block a user