diff --git a/discordbot/titanembeds/database/guilds.py b/discordbot/titanembeds/database/guilds.py index 164382e..80ed764 100644 --- a/discordbot/titanembeds/database/guilds.py +++ b/discordbot/titanembeds/database/guilds.py @@ -19,7 +19,7 @@ class Guilds(Base): emojis = db.Column(db.Text().with_variant(db.Text(length=4294967295), 'mysql')) # Guild Emojis owner_id = db.Column(db.String(255)) # Snowflake of the owner icon = db.Column(db.String(255)) # The icon string, null if none - discordio = db.Column(db.String(255)) # Custom Discord.io Invite Link + invite_link = db.Column(db.String(255)) # Custom Discord Invite Link def __init__(self, guild_id, name, roles, channels, webhooks, emojis, owner_id, icon): self.guild_id = guild_id diff --git a/webapp/alembic/versions/0b7761d85555_repurposed_discordio_column_to_generic_.py b/webapp/alembic/versions/0b7761d85555_repurposed_discordio_column_to_generic_.py new file mode 100644 index 0000000..851b495 --- /dev/null +++ b/webapp/alembic/versions/0b7761d85555_repurposed_discordio_column_to_generic_.py @@ -0,0 +1,28 @@ +"""Repurposed discordio column to generic invite_link + +Revision ID: 0b7761d85555 +Revises: f146d173e028 +Create Date: 2018-01-13 18:13:51.542372 + +""" + +# revision identifiers, used by Alembic. +revision = '0b7761d85555' +down_revision = 'f146d173e028' +branch_labels = None +depends_on = None + +from alembic import op +import sqlalchemy as sa + + +def upgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('guilds', 'discordio', new_column_name='invite_link') + # ### end Alembic commands ### + + +def downgrade(): + # ### commands auto generated by Alembic - please adjust! ### + op.alter_column('guilds', 'invite_link', new_column_name='discordio') + # ### end Alembic commands ### diff --git a/webapp/titanembeds/blueprints/admin/admin.py b/webapp/titanembeds/blueprints/admin/admin.py index 8bd3e8b..e30b30b 100644 --- a/webapp/titanembeds/blueprints/admin/admin.py +++ b/webapp/titanembeds/blueprints/admin/admin.py @@ -178,7 +178,7 @@ def administrate_guild(guild_id): "mentions_limit": db_guild.mentions_limit, "unauth_captcha": db_guild.unauth_captcha, "icon": db_guild.icon, - "discordio": db_guild.discordio if db_guild.discordio != None else "", + "invite_link": db_guild.invite_link if db_guild.invite_link != None else "", "guest_icon": db_guild.guest_icon if db_guild.guest_icon != None else "", } return render_template("administrate_guild.html.j2", guild=dbguild_dict, members=users, permissions=permissions, cosmetics=cosmetics) @@ -194,10 +194,10 @@ def update_administrate_guild(guild_id): db_guild.bracket_links = request.form.get("bracket_links", db_guild.bracket_links) in ["true", True] db_guild.mentions_limit = request.form.get("mentions_limit", db_guild.mentions_limit) db_guild.unauth_captcha = request.form.get("unauth_captcha", db_guild.unauth_captcha) in ["true", True] - discordio = request.form.get("discordio", db_guild.discordio) - if discordio != None and discordio.strip() == "": - discordio = None - db_guild.discordio = discordio + invite_link = request.form.get("invite_link", db_guild.invite_link) + if invite_link != None and invite_link.strip() == "": + invite_link = None + db_guild.invite_link = invite_link guest_icon = request.form.get("guest_icon", db_guild.guest_icon) if guest_icon != None and guest_icon.strip() == "": guest_icon = None @@ -213,7 +213,7 @@ def update_administrate_guild(guild_id): chat_links=db_guild.chat_links, bracket_links=db_guild.bracket_links, mentions_limit=db_guild.mentions_limit, - discordio=db_guild.discordio, + invite_link=db_guild.invite_link, guest_icon=db_guild.guest_icon, unauth_captcha=db_guild.unauth_captcha, ) diff --git a/webapp/titanembeds/blueprints/embed/embed.py b/webapp/titanembeds/blueprints/embed/embed.py index 8d1bc93..bd352f4 100644 --- a/webapp/titanembeds/blueprints/embed/embed.py +++ b/webapp/titanembeds/blueprints/embed/embed.py @@ -6,6 +6,7 @@ from titanembeds.database import db, Guilds, UserCSS, list_disabled_guilds from config import config import random import json +from urllib.parse import urlparse embed = Blueprint("embed", __name__) @@ -52,6 +53,12 @@ def parse_css_variable(css): return CSS_VARIABLES_TEMPLATE % variables return None +def parse_url_domain(url): + parsed = urlparse(url) + if parsed.netloc != "": + return parsed.netloc + return url + @embed.route("/") def guild_embed(guild_id): if check_guild_existance(guild_id): @@ -61,7 +68,8 @@ def guild_embed(guild_id): "name": guild.name, "unauth_users": guild.unauth_users, "icon": guild.icon, - "discordio": guild.discordio, + "invite_link": guild.invite_link, + "invite_domain": parse_url_domain(guild.invite_link), } customcss = get_custom_css() return render_template("embed.html.j2", diff --git a/webapp/titanembeds/blueprints/user/user.py b/webapp/titanembeds/blueprints/user/user.py index 34ad933..f5ef15f 100644 --- a/webapp/titanembeds/blueprints/user/user.py +++ b/webapp/titanembeds/blueprints/user/user.py @@ -215,7 +215,7 @@ def administrate_guild(guild_id): "mentions_limit": db_guild.mentions_limit, "unauth_captcha": db_guild.unauth_captcha, "icon": db_guild.icon, - "discordio": db_guild.discordio if db_guild.discordio != None else "", + "invite_link": db_guild.invite_link if db_guild.invite_link != None else "", "guest_icon": db_guild.guest_icon if db_guild.guest_icon != None else "", } return render_template("administrate_guild.html.j2", guild=dbguild_dict, members=users, permissions=permissions, cosmetics=cosmetics, disabled=(guild_id in list_disabled_guilds())) @@ -240,10 +240,10 @@ def update_administrate_guild(guild_id): db_guild.mentions_limit = request.form.get("mentions_limit", db_guild.mentions_limit) db_guild.unauth_captcha = request.form.get("unauth_captcha", db_guild.unauth_captcha) in ["true", True] - discordio = request.form.get("discordio", db_guild.discordio) - if discordio != None and discordio.strip() == "": - discordio = None - db_guild.discordio = discordio + invite_link = request.form.get("invite_link", db_guild.invite_link) + if invite_link != None and invite_link.strip() == "": + invite_link = None + db_guild.invite_link = invite_link guest_icon = request.form.get("guest_icon", db_guild.guest_icon) if guest_icon != None and guest_icon.strip() == "": @@ -261,7 +261,7 @@ def update_administrate_guild(guild_id): chat_links=db_guild.chat_links, bracket_links=db_guild.bracket_links, mentions_limit=db_guild.mentions_limit, - discordio=db_guild.discordio, + invite_link=db_guild.invite_link, guest_icon=guest_icon, unauth_captcha=db_guild.unauth_captcha, ) diff --git a/webapp/titanembeds/database/guilds.py b/webapp/titanembeds/database/guilds.py index 6d6b956..13741b5 100644 --- a/webapp/titanembeds/database/guilds.py +++ b/webapp/titanembeds/database/guilds.py @@ -19,7 +19,7 @@ class Guilds(db.Model): emojis = db.Column(db.Text().with_variant(db.Text(4294967295), 'mysql'), nullable=False) # Guild Emojis owner_id = db.Column(db.String(255), nullable=False) # Snowflake of the owner icon = db.Column(db.String(255)) # The icon string, null if none - discordio = db.Column(db.String(255)) # Custom Discord.io Invite Link + invite_link = db.Column(db.String(255)) # Custom Discord Invite Link def __init__(self, guild_id, name, roles, channels, webhooks, emojis, owner_id, icon): self.guild_id = guild_id diff --git a/webapp/titanembeds/static/img/partners/discordio.png b/webapp/titanembeds/static/img/partners/discordio.png deleted file mode 100644 index 5e876f2..0000000 Binary files a/webapp/titanembeds/static/img/partners/discordio.png and /dev/null differ diff --git a/webapp/titanembeds/static/js/administrate_guild.js b/webapp/titanembeds/static/js/administrate_guild.js index 1af3c9f..1d5dba7 100644 --- a/webapp/titanembeds/static/js/administrate_guild.js +++ b/webapp/titanembeds/static/js/administrate_guild.js @@ -54,13 +54,13 @@ $("#mentions_limit").keyup(function(event){ } }); -$("#discordio").keyup(function(event){ +$("#invite_link").keyup(function(event){ if(event.keyCode == 13){ var pathname = window.location.pathname; - var value = $("#discordio").val() - var payload = {"discordio": value} + var value = $("#invite_link").val() + var payload = {"invite_link": value} $.post(pathname, payload, function(data) { - Materialize.toast('Updated Discord.io setting!', 2000) + Materialize.toast('Updated invite link setting!', 2000) }); } }); diff --git a/webapp/titanembeds/templates/about.html.j2 b/webapp/titanembeds/templates/about.html.j2 index 173f855..0bc36d3 100644 --- a/webapp/titanembeds/templates/about.html.j2 +++ b/webapp/titanembeds/templates/about.html.j2 @@ -206,25 +206,6 @@ etc.

Partners

These are awesome communities that offers amazing tools to enhance your Discord experience and are willing to promote us! So do we!! #TitanThoughtOfTheDay

-
-
-
-
-
- -
-
-
Discord.io
-

Personalized Discord Invites

-

Are you tired of having random Discord.gg invite links? Wouldn't it be better if you could customize the letters in your link? Well look no further, we have the perfect solution for you! Discord.io is an unofficial project, which focuses around giving companies and communities on Discord, the option to create their very own personal invitation links.

- Website - Discord Server -
-
-
-
-
-
diff --git a/webapp/titanembeds/templates/administrate_guild.html.j2 b/webapp/titanembeds/templates/administrate_guild.html.j2 index 81feb26..bf972bf 100644 --- a/webapp/titanembeds/templates/administrate_guild.html.j2 +++ b/webapp/titanembeds/templates/administrate_guild.html.j2 @@ -134,10 +134,10 @@
-

Custom Discord.io Link

-

Because we are a partner with Discord.io, we enable you to enter your custom discord.io link and replace the discord.gg link on the embed!

+

Custom Invite Link

+

Have a permanent invite that you really want to use? Something like discord.io on your mind? Enter your custom invite link here to replace the default one on the embed!

(Leave blank if none - enter to submit)

- +
diff --git a/webapp/titanembeds/templates/embed.html.j2 b/webapp/titanembeds/templates/embed.html.j2 index 5d72ff8..45b83f2 100644 --- a/webapp/titanembeds/templates/embed.html.j2 +++ b/webapp/titanembeds/templates/embed.html.j2 @@ -99,8 +99,8 @@ {% endif %} - {% if guild["discordio"] %} - discord.io/{{ guild["discordio"]|e }} + {% if guild["invite_link"] %} + {{ guild["invite_domain"]|e }} {% else %} discord.gg {% endif %}