Skip to content

Commit

Permalink
Merge pull request #136 from zediious/0.4.4
Browse files Browse the repository at this point in the history
Changes for 0.4.4
  • Loading branch information
zediious authored Nov 23, 2023
2 parents e1f6d81 + 533f133 commit d980603
Show file tree
Hide file tree
Showing 28 changed files with 176 additions and 72 deletions.
5 changes: 5 additions & 0 deletions config/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,11 @@
'level': 'DEBUG',
'propagate': False,
},
'raptormc.addParams': {
'handlers': ['console', 'log_file'],
'level': 'DEBUG',
'propagate': False,
},
'raptormc.routes': {
'handlers': ['console', 'log_file'],
'level': 'DEBUG',
Expand Down
9 changes: 9 additions & 0 deletions raptorWeb/gameservers/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ def get(self, request: HttpRequest, *args: tuple, **kwargs: dict) -> HttpRespons

else:
return HttpResponseRedirect('/')

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
if self.request.GET:
try:
context['opened_server_pk'] = int(self.request.GET.get('server'))
except ValueError:
context['opened_server_pk'] = self.request.GET.get('server')
return context


class Server_Buttons(Server_List_Base):
Expand Down
19 changes: 18 additions & 1 deletion raptorWeb/panel/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,17 @@ class PanelSettingsInformation(forms.ModelForm):
required=False)

enable_server_query: forms.BooleanField = forms.BooleanField(
help_text=("If this is un-checked, the address/port of created Servers will NOT be "
help_text=("If this is un-checked, the address/port of created Servers will NOT be "
"queried for state and player data. Each server's information will still be "
"displayed on the website as normal, however the Player Counts section "
"of the Header Box will no longer appear."),
required=False)

collapse_network_rules_when_accessing_server_rules: forms.BooleanField = forms.BooleanField(
help_text=("If this is un-checked, the Network Rules section on the Rules page will NOT be "
"collapsed when accessing Rules from a Server Modal"),
required=False)

discord_guild: forms.CharField = forms.CharField(
help_text=("Set this to the ID for the Discord Guild that the Bot will be reading global and "
"server announcements from."),
Expand Down Expand Up @@ -117,17 +122,29 @@ class PanelSettingsFiles(forms.ModelForm):
"homepage. Optimal size for this image is w800xh200."),
required=False)

remove_branding_image: forms.BooleanField = forms.BooleanField(
help_text=("If this is checked, the current Branding Image will be cleared "),
required=False)

background_image: forms.ImageField = forms.ImageField(
help_text=("The image displayed layered behind server buttons. This image will "
"cover the defined Secondary Color if used. Optimal size for this image "
" is 1920x1080 or within the same aspect ratio."),
required=False)

remove_background_image: forms.BooleanField = forms.BooleanField(
help_text=("If this is checked, the current Background Image will be cleared "),
required=False)

avatar_image: forms.ImageField = forms.ImageField(
help_text=("The image displayed in OpenGraph embeds, such as when a link is "
"pasted to a Discord Channel or a Twitter post. This should be a 1x1 image. "
"This will also be used as your Favicon, after being converted to a .ico file."),
required=False)

remove_avatar_image: forms.BooleanField = forms.BooleanField(
help_text=("If this is checked, the current Avatar Image will be cleared "),
required=False)

class Meta():
model: SiteInformation = SiteInformation
Expand Down
12 changes: 12 additions & 0 deletions raptorWeb/panel/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,18 @@ def post(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:

changed: list = []
changed_string: str = ""
if settings_files_form.cleaned_data['remove_branding_image'] == True:
site_info.branding_image.delete(save=True)
changed.append('Branding Image Deleted')

if settings_files_form.cleaned_data['remove_background_image'] == True:
site_info.background_image.delete(save=True)
changed.append('Background Image Deleted')

if settings_files_form.cleaned_data['remove_avatar_image'] == True:
site_info.avatar_image.delete(save=True)
changed.append('Avatar Image Deleted')

if settings_files_form.cleaned_data['branding_image'] != None:
site_info.branding_image = settings_files_form.cleaned_data['branding_image']
changed.append('Branding Image')
Expand Down
7 changes: 4 additions & 3 deletions raptorWeb/raptorbot/discordbot/util/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@ async def craft_embed(server: Server) -> list[discord.Embed]:
inline=False)
info_embed.add_field(
name="\u200b",
value=(f"**Rules:** {WEB_PROTO}://{DOMAIN_NAME}/rules/#{server.pk}\n"
f"**Banned Items:** {WEB_PROTO}://{DOMAIN_NAME}/banneditems/#{server.pk}\n"
f"**Vote Links:** {WEB_PROTO}://{DOMAIN_NAME}/voting/#{server.pk}"))
value=( f"**Announcements:** {WEB_PROTO}://{DOMAIN_NAME}/announcements?server={server.pk}\n"
f"**Rules:** {WEB_PROTO}://{DOMAIN_NAME}/rules?server={server.pk}\n"
f"**Banned Items:** {WEB_PROTO}://{DOMAIN_NAME}/banneditems?server={server.pk}\n"
f"**Vote Links:** {WEB_PROTO}://{DOMAIN_NAME}/voting?server={server.pk}"))
info_embed.add_field(
name="\u200b",
value=(f"The server is running;```v{server.modpack_version}```\n"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 4.2.7 on 2023-11-23 16:50

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('raptormc', '0055_defaultpages_onboarding'),
]

operations = [
migrations.AddField(
model_name='siteinformation',
name='collapse_network_rules_when_accessing_server_rules',
field=models.BooleanField(default=True, help_text='If this is un-checked, the Network Rules section on the Rules page will NOT be collapsed when accessing Rules from a Server Modal', verbose_name='Enable server querying and player counts section'),
),
]
7 changes: 7 additions & 0 deletions raptorWeb/raptormc/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,13 @@ class SiteInformation(models.Model):
default=True
)

collapse_network_rules_when_accessing_server_rules = models.BooleanField(
verbose_name="Enable server querying and player counts section",
help_text=("If this is un-checked, the Network Rules section on the Rules page will NOT be "
"collapsed when accessing Rules from a Server Modal"),
default=True
)

server_pagination_count = models.IntegerField(
verbose_name="Server button pagination count",
help_text=("How many server buttons will appear per page. If the amount of Servers exceeds "
Expand Down
15 changes: 15 additions & 0 deletions raptorWeb/raptormc/templatetags/addParams.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
from logging import getLogger

from django import template

LOGGER = getLogger('raptormc.addParams')
register = template.Library()

@register.simple_tag(takes_context=True)
def get_param(context, value):
"""
Return the value of a GET parameter. This needs to be
called when wanting the value of a parameter when
iterating over them from a template.
"""
return context['request'].GET.get(value)
10 changes: 10 additions & 0 deletions raptorWeb/raptormc/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:

def get_context_data(self, **kwargs: dict[str, Any]) -> dict[str, Any]:
context: dict[str, Any] = super().get_context_data(**kwargs)
if self.request.GET:
context['opened_server_pk'] = self.request.GET.get('server')
return get_or_create_informative_text(
context = context,
informative_text_names = ["Announcements Information"])
Expand All @@ -88,7 +90,11 @@ def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:
return super().get(request, *args, **kwargs)

def get_context_data(self, **kwargs: dict[str, Any]) -> dict[str, Any]:
site_info = SiteInformation.objects.get_or_create(pk=1)[0]
context: dict[str, Any] = super().get_context_data(**kwargs)
context["collapse_network"] = site_info.collapse_network_rules_when_accessing_server_rules
if self.request.GET:
context['opened_server_pk'] = self.request.GET.get('server')
return get_or_create_informative_text(
context = context,
informative_text_names = ["Rules Information", "Network Rules"])
Expand All @@ -111,6 +117,8 @@ def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:

def get_context_data(self, **kwargs: dict[str, Any]) -> dict[str, Any]:
context: dict[str, Any] = super().get_context_data(**kwargs)
if self.request.GET:
context['opened_server_pk'] = self.request.GET.get('server')
return get_or_create_informative_text(
context = context,
informative_text_names = ["Banneditems Information"])
Expand All @@ -133,6 +141,8 @@ def get(self, request: HttpRequest, *args: Any, **kwargs: Any) -> HttpResponse:

def get_context_data(self, **kwargs: dict[str, Any]) -> dict[str, Any]:
context: dict[str, Any] = super().get_context_data(**kwargs)
if self.request.GET:
context['opened_server_pk'] = self.request.GET.get('server')
return get_or_create_informative_text(
context = context,
informative_text_names = ["Voting Information"])
Expand Down
4 changes: 2 additions & 2 deletions raptorWeb/static/css/raptormc.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion raptorWeb/static/css/raptormc.css.map

Large diffs are not rendered by default.

15 changes: 10 additions & 5 deletions raptorWeb/static/css/raptormc.scss
Original file line number Diff line number Diff line change
Expand Up @@ -128,11 +128,6 @@ body {
width: 100%;
}

#navImage {
width: 100%;
height: 100%;
}

.serverBoxCollapseImage {
width: 25px;
height: 25px
Expand Down Expand Up @@ -213,6 +208,11 @@ body {

@media (min-width: 768px) {

#navImage {
width: 75%;
height: 100%;
}

.pageHeader {
font-size: xx-large;
}
Expand Down Expand Up @@ -253,6 +253,11 @@ body {

@media (max-width: 767px) {

#navImage {
width: 100%;
height: 100%;
}

.pageHeader {
font-size: medium;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,3 @@
console.log("raptormc.js loaded")

function closeOffCanvas() {

let closeCanvas = document.querySelector('[data-bs-dismiss="offcanvas"]');
closeCanvas.click();

}

function closeModal() {

$('.modal').modal('hide');
console.log("did run closeModal")

}

document.getElementById("body").onscroll = function myFunction() {
var scrolltotop = document.scrollingElement.scrollTop;
var target = document.getElementById("backgroundWrapper");
Expand All @@ -22,4 +6,3 @@ document.getElementById("body").onscroll = function myFunction() {
var yvalue = scrolltotop * factor;
target.style.backgroundPosition = xvalue + " " + yvalue + "px";
}

14 changes: 14 additions & 0 deletions raptorWeb/static/javascript/src/modalClose.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
function closeOffCanvas() {

let closeCanvas = document.querySelector('[data-bs-dismiss="offcanvas"]');
closeCanvas.click();

}

function closeModal() {

$('.modal').modal('hide');
console.log("did run closeModal")

}

2 changes: 1 addition & 1 deletion raptorWeb/templates/gameservers/server_list.html
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@
{% endif %}
{% if server_query_enabled %}
{% if server.in_maintenance %}
<img class="indicatorImage p-2 fade-in"
<img class="w-25 indicatorImage p-2 fade-in"
src="{% static 'image/maintenance_indicator.svg' %}"
alt="Maintenance">
{% else %}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ <h2 class="accordion-header" id="{{ server.pk }}Announcements">
</button>
</div>
</h2>
<div id="collapse{{ server.pk }}" class="accordion-collapse collapse" aria-labelledby="collapse{{ server.pk }}">
<div id="collapse{{ server.pk }}" class="accordion-collapse collapse{% if server.pk == opened_server_pk %} show{% endif %}" aria-labelledby="collapse{{ server.pk }}">
<div class="accordion-body pageContent p-3">
<div id="announcements_{{server.pk}}"
hx-get="{% url 'raptorbot:server_announcements_list' server_pk=server.pk %}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2 class="accordion-header" id="{{ server.pk }}BannedItems">
</button>
</h2>
<div id="collapse{{ server.pk }}"
class="accordion-collapse collapse"
class="accordion-collapse collapse{% if server.pk == opened_server_pk %} show{% endif %}"
aria-labelledby="collapse{{ server.pk }}"
>
<div class="accordion-body pageContent p-4">
Expand Down
16 changes: 8 additions & 8 deletions raptorWeb/templates/gameservers/server_list_modals.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ <h3 class="col-12 modal-title" id="inner_{{ server.pk }}InfoModal">

{% if default_pages.announcements %}
<a role="button" class="btn btn-outline-secondary"
href="/announcements"
hx-get="{% url 'raptormc:announcements' %}"
href="/announcements?server={{server.pk}}"
hx-get="{% url 'raptormc:announcements' %}?server={{server.pk}}"
hx-target='#home'
hx-push-url="/announcements"
hx-indicator="#mainLoadingspinner,.loaded-content"
Expand All @@ -59,8 +59,8 @@ <h3 class="col-12 modal-title" id="inner_{{ server.pk }}InfoModal">

{% if default_pages.rules %}
<a role="button" class="btn btn-outline-secondary"
href="/rules"
hx-get="{% url 'raptormc:rules' %}"
href="/rules?server={{server.pk}}"
hx-get="{% url 'raptormc:rules' %}?server={{server.pk}}"
hx-target='#home'
hx-push-url="/rules"
hx-indicator="#mainLoadingspinner,.loaded-content"
Expand All @@ -72,8 +72,8 @@ <h3 class="col-12 modal-title" id="inner_{{ server.pk }}InfoModal">

{% if default_pages.banned_items %}
<a role="button" class="btn btn-outline-secondary"
href="/banneditems"
hx-get="{% url 'raptormc:banneditems' %}"
href="/banneditems?server={{server.pk}}"
hx-get="{% url 'raptormc:banneditems' %}?server={{server.pk}}"
hx-target='#home'
hx-push-url="/banneditems"
hx-indicator="#mainLoadingspinner,.loaded-content"
Expand All @@ -85,8 +85,8 @@ <h3 class="col-12 modal-title" id="inner_{{ server.pk }}InfoModal">

{% if default_pages.voting %}
<a role="button" class="btn btn-outline-secondary"
href='/voting'
hx-get="{% url 'raptormc:voting' %}"
href='/voting?server={{server.pk}}'
hx-get="{% url 'raptormc:voting' %}?server={{server.pk}}"
hx-target='#home'
hx-push-url="/voting"
hx-indicator="#mainLoadingspinner,.loaded-content"
Expand Down
2 changes: 1 addition & 1 deletion raptorWeb/templates/gameservers/server_list_rules.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2 class="accordion-header" id="{{ server.pk }}Rules">
</button>
</h2>
<div id="collapse{{ server.pk }}"
class="accordion-collapse collapse"
class="accordion-collapse collapse{% if server.pk == opened_server_pk %} show{% endif %}"
aria-labelledby="collapse{{ server.pk }}"
>
<div class="accordion-body pageContent p-4">
Expand Down
2 changes: 1 addition & 1 deletion raptorWeb/templates/gameservers/server_list_voting.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ <h2 class="accordion-header" id="{{ server.pk }}Voting">
</button>
</h2>
<div id="collapse{{ server.pk }}"
class="accordion-collapse collapse"
class="accordion-collapse collapse{% if server.pk == opened_server_pk %} show{% endif %}"
aria-labelledby="collapse{{ server.pk }}"
>
<div class="accordion-body pageContent p-4">
Expand Down
Loading

0 comments on commit d980603

Please sign in to comment.