diff --git a/_server.py b/_server.py
index 10b5494..997bc09 100644
--- a/_server.py
+++ b/_server.py
@@ -1,3 +1,6 @@
+# MAKE SURE YOU INSTALL ALL NEEDED LIBRARIES!
+# pip install flask dotindex ensure-file
+
CONTENT_DIRECTORY = "./public/"
SAVING_DIRECTORY = "./save/"
@@ -12,6 +15,7 @@ import os
import re
from DotIndex import DotIndex
+from ensure_file import ensure_file
from typing import Union, Callable
from flask import request, redirect
from werkzeug.middleware.proxy_fix import ProxyFix
@@ -19,6 +23,36 @@ from werkzeug.middleware.proxy_fix import ProxyFix
app = flask.Flask(__name__)
app.url_map.strict_slashes = False
+FLAGS = {
+ "agender": "Agender",
+ "ally": "Ally",
+ "aroace": "Aroace",
+ "aro": "Aromantic",
+ "ace": "Asexual",
+ "bicurious": "Bicurious",
+ "bigender": "Bigender",
+ "bi": "Bisexual",
+ "cisgender": "Cisgender",
+ "demiboy": "Demiboy",
+ "demigirl": "Demigirl",
+ "demiromantic": "Demiromantic",
+ "demisexual": "Demisexual",
+ "gay": "Gay (Rainbow)",
+ "gayman": "Gay Man",
+ "genderfluid": "Genderfluid",
+ "intersex": "Intersex",
+ "lesbian": "Lesbian",
+ "nonbinary": "Nonbinary",
+ "omnigender": "Omnigender",
+ "pan": "Pansexual",
+ "polyamory": "Polyamorous",
+ "straight": "Straight",
+ "transfem": "Transfeminine",
+ "trans": "Transgender",
+ "transmasc": "Transmasculine"
+}
+
+
SOCIALS_REGEX = {
"discord" : re.compile(r"^(?!.*\.\.)(?=.{2,32}$)[a-z0-9_.]+$"),
"twitter" : re.compile(r"^(?!.*twitter)(?!.*admin)[a-z0-9_]{1,15}$", re.IGNORECASE),
@@ -126,24 +160,6 @@ def sha(string: Union[str, bytes]) -> str:
return hashlib.sha256(string).hexdigest()
return ""
-def ensure_file(path: str, *, default_value: str="", folder: bool=False) -> None:
- if os.path.exists(path):
- if folder and not os.path.isdir(path):
- os.remove(path)
- os.makedirs(path)
- elif not folder and os.path.isdir(path):
- shutil.rmtree(path, ignore_errors=True)
- f = open(path, "w")
- f.write(default_value)
- f.close()
- else:
- if folder:
- os.makedirs(path)
- else:
- f = open(path, "w")
- f.write(default_value)
- f.close()
-
def escape_html(string: str) -> str:
return string.replace("&", "&").replace("<", "<").replace("\"", """)
@@ -226,11 +242,10 @@ def get_template(json, username):
inner = add_to_output(inner, json, "compliments", "Compliments");
inner = add_to_output(inner, json, "relationship", "Relationship
Descriptions");
- try:
- social = json.social # type: ignore
+ if "social" in json and len(json.social):
inner += '
Social Links
'
- for i in social:
+ for i in json.social:
if SOCIAL_INFO[i[1]]["link"]:
inner += f"
"
else:
@@ -238,10 +253,15 @@ def get_template(json, username):
inner += "
"
- except AttributeError as e:
- print(e)
+ if "flags" in json and len(json.flags):
+ inner += 'Pride Flags
'
- inner += "
"
+ for i in json.flags:
+ inner += f'
'
+
+ inner += "
"
+
+ inner += f'Key:
{icons["4"]} - Great
{icons["3"]} - Good
{icons["2"]} - Okay
{icons["1"]} - Bad
'
return title, inner, styles, embed
@@ -535,6 +555,13 @@ def api_save():
social.append(i)
user_data["social"] = sort_list(social, True)
+ if "flags" in x:
+ flags = {}
+ for i in x["flags"]:
+ if i in FLAGS:
+ flags[i] = None
+ user_data["flags"] = sorted([i for i in flags])
+
f = open(f"{SAVING_DIRECTORY}{username}.json", "w")
f.write(json.dumps(user_data))
f.close()
@@ -590,8 +617,9 @@ app.route("/editor")(create_file_serve("editor.html"))
app.route("/u/")(get_user_page)
app.route("/home")(home)
-app.route("/js/")(create_folder_serve("js"))
app.route("/css/")(create_folder_serve("css"))
+app.route("/img/flags/")(create_folder_serve("img/flags"))
+app.route("/js/")(create_folder_serve("js"))
app.route("/api/account/login", methods=["POST"])(api_account_login)
app.route("/api/account/signup", methods=["POST"])(api_account_signup)
diff --git a/public/browse.html b/public/browse.html
index ae5e2af..b0b702d 100644
--- a/public/browse.html
+++ b/public/browse.html
@@ -22,7 +22,7 @@
function load(fromStart) {
if (fromStart) { next = 0; }
- fetch(`/api/browse?sort=alphabetical&page=${next}`, {
+ fetch(`/api/browse?sort=random&page=${next}`, {
"method": "GET"
}).then((request) => (request.json()))
.then((json) => {
diff --git a/public/css/page.css b/public/css/page.css
index ebd3c9b..e1d1250 100644
--- a/public/css/page.css
+++ b/public/css/page.css
@@ -1,5 +1,5 @@
body {
- padding-bottom: calc(20px + 8em);
+ padding-bottom: calc(30px + 8em);
}
svg {
@@ -26,6 +26,19 @@ footer a, footer a:visited, footer a:link {
white-space: break-word;
}
+.added .img-list {
+ display: flex;
+ flex-direction: row;
+ flex-wrap: wrap;
+ justify-content: center;
+ column-gap: 0.5em;
+ max-width: 10em;
+}
+
+.added img {
+ max-width: 4em;
+}
+
.added h2 {
text-align: center;
}
diff --git a/public/img/flags/ace.png b/public/img/flags/ace.png
new file mode 100644
index 0000000..2812c60
Binary files /dev/null and b/public/img/flags/ace.png differ
diff --git a/public/img/flags/agender.png b/public/img/flags/agender.png
new file mode 100644
index 0000000..6eaa024
Binary files /dev/null and b/public/img/flags/agender.png differ
diff --git a/public/img/flags/ally.png b/public/img/flags/ally.png
new file mode 100644
index 0000000..39028d5
Binary files /dev/null and b/public/img/flags/ally.png differ
diff --git a/public/img/flags/aro.png b/public/img/flags/aro.png
new file mode 100644
index 0000000..8f7b364
Binary files /dev/null and b/public/img/flags/aro.png differ
diff --git a/public/img/flags/aroace.png b/public/img/flags/aroace.png
new file mode 100644
index 0000000..9301f22
Binary files /dev/null and b/public/img/flags/aroace.png differ
diff --git a/public/img/flags/bi.png b/public/img/flags/bi.png
new file mode 100644
index 0000000..a12ee18
Binary files /dev/null and b/public/img/flags/bi.png differ
diff --git a/public/img/flags/bicurious.png b/public/img/flags/bicurious.png
new file mode 100644
index 0000000..c3b24c0
Binary files /dev/null and b/public/img/flags/bicurious.png differ
diff --git a/public/img/flags/bigender.png b/public/img/flags/bigender.png
new file mode 100644
index 0000000..8f8c4b9
Binary files /dev/null and b/public/img/flags/bigender.png differ
diff --git a/public/img/flags/cisgender.png b/public/img/flags/cisgender.png
new file mode 100644
index 0000000..d6aec9a
Binary files /dev/null and b/public/img/flags/cisgender.png differ
diff --git a/public/img/flags/demiboy.png b/public/img/flags/demiboy.png
new file mode 100644
index 0000000..5268470
Binary files /dev/null and b/public/img/flags/demiboy.png differ
diff --git a/public/img/flags/demigirl.png b/public/img/flags/demigirl.png
new file mode 100644
index 0000000..76c3d23
Binary files /dev/null and b/public/img/flags/demigirl.png differ
diff --git a/public/img/flags/demiromantic.png b/public/img/flags/demiromantic.png
new file mode 100644
index 0000000..59d2fad
Binary files /dev/null and b/public/img/flags/demiromantic.png differ
diff --git a/public/img/flags/demisexual.png b/public/img/flags/demisexual.png
new file mode 100644
index 0000000..c9c7d79
Binary files /dev/null and b/public/img/flags/demisexual.png differ
diff --git a/public/img/flags/gay.png b/public/img/flags/gay.png
new file mode 100644
index 0000000..8cd746a
Binary files /dev/null and b/public/img/flags/gay.png differ
diff --git a/public/img/flags/gayman.png b/public/img/flags/gayman.png
new file mode 100644
index 0000000..2b4e590
Binary files /dev/null and b/public/img/flags/gayman.png differ
diff --git a/public/img/flags/genderfluid.png b/public/img/flags/genderfluid.png
new file mode 100644
index 0000000..8b1bc58
Binary files /dev/null and b/public/img/flags/genderfluid.png differ
diff --git a/public/img/flags/intersex.png b/public/img/flags/intersex.png
new file mode 100644
index 0000000..8de8f63
Binary files /dev/null and b/public/img/flags/intersex.png differ
diff --git a/public/img/flags/lesbian.png b/public/img/flags/lesbian.png
new file mode 100644
index 0000000..acad97e
Binary files /dev/null and b/public/img/flags/lesbian.png differ
diff --git a/public/img/flags/nonbinary.png b/public/img/flags/nonbinary.png
new file mode 100644
index 0000000..bddb62b
Binary files /dev/null and b/public/img/flags/nonbinary.png differ
diff --git a/public/img/flags/omnigender.png b/public/img/flags/omnigender.png
new file mode 100644
index 0000000..524f837
Binary files /dev/null and b/public/img/flags/omnigender.png differ
diff --git a/public/img/flags/pan.png b/public/img/flags/pan.png
new file mode 100644
index 0000000..ec7f69e
Binary files /dev/null and b/public/img/flags/pan.png differ
diff --git a/public/img/flags/polyamory.png b/public/img/flags/polyamory.png
new file mode 100644
index 0000000..ab868d7
Binary files /dev/null and b/public/img/flags/polyamory.png differ
diff --git a/public/img/flags/straight.png b/public/img/flags/straight.png
new file mode 100644
index 0000000..4f99463
Binary files /dev/null and b/public/img/flags/straight.png differ
diff --git a/public/img/flags/trans.png b/public/img/flags/trans.png
new file mode 100644
index 0000000..4cc3f2c
Binary files /dev/null and b/public/img/flags/trans.png differ
diff --git a/public/img/flags/transfem.png b/public/img/flags/transfem.png
new file mode 100644
index 0000000..1a312fa
Binary files /dev/null and b/public/img/flags/transfem.png differ
diff --git a/public/img/flags/transmasc.png b/public/img/flags/transmasc.png
new file mode 100644
index 0000000..0475e47
Binary files /dev/null and b/public/img/flags/transmasc.png differ
diff --git a/public/js/base.js b/public/js/base.js
index c37cbb8..e674ea4 100644
--- a/public/js/base.js
+++ b/public/js/base.js
@@ -158,6 +158,35 @@ const socialRegex = {
}
}
+const flags = {
+ agender: "Agender",
+ ally: "Ally",
+ aroace: "Aroace",
+ aro: "Aromantic",
+ ace: "Asexual",
+ bicurious: "Bicurious",
+ bigender: "Bigender",
+ bi: "Bisexual",
+ cisgender: "Cisgender",
+ demiboy: "Demiboy",
+ demigirl: "Demigirl",
+ demiromantic: "Demiromantic",
+ demisexual: "Demisexual",
+ gay: "Gay (Rainbow)",
+ gayman: "Gay Man",
+ genderfluid: "Genderfluid",
+ intersex: "Intersex",
+ lesbian: "Lesbian",
+ nonbinary: "Nonbinary",
+ omnigender: "Omnigender",
+ pan: "Pansexual",
+ polyamory: "Polyamorous",
+ straight: "Straight",
+ transfem: "Transfeminine",
+ trans: "Transgender",
+ transmasc: "Transmasculine"
+}
+
const icons = {
1: '',
2: '',
diff --git a/public/js/editor.js b/public/js/editor.js
index d2f7e0f..6729947 100644
--- a/public/js/editor.js
+++ b/public/js/editor.js
@@ -58,11 +58,11 @@ function updateColors() {
document.body.setAttribute("style", `--primary: ${colors.text}; --secondary-low-opacity: ${colors.text}22; --background: ${colors.background}; --background-low-opacity: ${colors.background}33; --accent: ${colors.accent}; --accent-low-opacity: ${colors.accent}66; --text: ${colors.text}; --text-low-opacity: ${colors.text}88;`);
}
-function get_list(key) {
+function get_list(key, hasInput=true) {
let output = [];
[...document.querySelectorAll(`#${key} div[id^="${key}-"]`)].forEach((val, index) => {
if (!val.classList.contains("bad")) {
- output.push([val.querySelector("input").value, val.querySelector("select").value]);
+ output.push(hasInput ? [val.querySelector("input").value, val.querySelector("select").value] : val.querySelector("select").value);
}
});
return output;
@@ -94,6 +94,12 @@ for (const key of Object.keys(socialRegex)) {
}
socialInput += ``;
+let flagInput = "`
+
fetch("/api/account/self", {
"method": "GET"
}).then((response) => (response.json()))
@@ -129,7 +135,15 @@ fetch("/api/account/self", {
i++;
}
- inner += ``;
+ inner += `
+ Pride Flags
`;
+
+ i = 0;
+ for (const flag of (json.flags || [])) {
+ inner += `
${flagInput.split("
`;
+ i++;
+ }
+ inner += `
`
x.id = "container";
x.innerHTML = inner;
@@ -157,6 +171,7 @@ fetch("/api/account/self", {
compliments: get_list("compliments"),
relationship: get_list("relationship"),
social: get_list("social"),
+ flags: get_list("flags", false),
public: dom("public").checked
})
}).then((response) => (response.text()))
diff --git a/public/user.html b/public/user.html
index cdf4d66..b32d4af 100644
--- a/public/user.html
+++ b/public/user.html
@@ -12,23 +12,5 @@
{{TEMPLATE}}
-
-
- Key:
- - Great
- - Good
- - Okay
- - Bad
-
-
-
-
-
Social Links
' - for i in social: + for i in json.social: if SOCIAL_INFO[i[1]]["link"]: inner += f"