feat: load footer ctx in all templates
ci/woodpecker/push/woodpecker Pipeline was successful Details
ci/woodpecker/pr/woodpecker Pipeline failed Details

pull/14/head
Aravinth Manivannan 2022-06-30 14:37:49 +05:30
parent faca7286b7
commit 8be1e02a21
Signed by: realaravinth
GPG Key ID: AD9F0F08E855ED88
8 changed files with 59 additions and 22 deletions

View File

@ -2,20 +2,6 @@
<div class="footer__container">
<div class="footer__column">
<span class="license__conatiner">
<a class="license__link" rel="noreferrer" href="/docs" target="_blank"
>Docs</a
>
<span class="footer__column-divider--mobile-visible">|</span>
<a
class="license__link"
rel="noreferrer"
href="https://www.eff.org/issues/do-not-track/amp/"
target="_blank"
>No AMP</a
>
</span>
</div>
<div class="footer__column">
<a
href="/"
class="footer__link"
@ -23,6 +9,21 @@
rel="noopener"
title="RSS"
>Home</a>
<span class="footer__column-divider--mobile-visible">|</span>
<a class="license__link" rel="noreferrer" href="https://hostea.org/about" target="_blank"
>&nbsp; About</a
>
</span>
</div>
<div class="footer__column">
<a
class="license__link"
rel="noreferrer"
href="https://www.eff.org/issues/do-not-track/amp/"
target="_blank"
>No AMP</a
>
<div class="footer__column-divider">|</div>
<a href="mailto:{{ footer.admin_email }}" class="footer__link"
>Contact Instance Maintainer</a
@ -30,12 +31,12 @@
<div class="footer__column-divider">|</div>
<a
class="footer__link"
href="{{ footer.source_code }}"
href="{{ footer.source_code.link }}"
target="_blank"
rel="noopener"
title="Source Code"
>
v{{ footer.version }}-{{ footer.git_hash }}
{{ footer.source_code.text }}
</a>
</div>
</div>

View File

@ -23,6 +23,7 @@ from django.http import HttpResponse
from django.views.decorators.csrf import csrf_protect
from django.urls import reverse
from dash.utils import footer_ctx
from .models import AccountConfirmChallenge
from .utils import send_verification_email, ConfirmAccess
@ -35,6 +36,7 @@ def login_view(request):
def default_login_ctx():
return {
"title": "Login",
"footer": footer_ctx(),
}
if request.method == "GET":
@ -102,6 +104,7 @@ def register_view(request):
"title": "Register",
"username": username,
"email": username,
"footer": footer_ctx(),
}
if request.method == "GET":
@ -213,6 +216,7 @@ def sudo(request):
def default_login_ctx():
return {
"title": "Confirm Access",
"footer": footer_ctx(),
}
if request.method == "GET":

View File

@ -24,6 +24,7 @@ from payments import get_payment_model, RedirectNeeded, PaymentStatus
from dash.models import Instance
from django.db.models import Q
from infrastructure.utils import create_vm_if_not_exists
from dash.utils import footer_ctx
def default_ctx(title: str, username: str):
@ -33,6 +34,7 @@ def default_ctx(title: str, username: str):
return {
"title": title,
"username": username,
"footer": footer_ctx(),
}

View File

@ -14,7 +14,9 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from enum import Enum, unique
from git import Repo
from django.contrib.auth.models import User
from django.conf import settings
from .models import Instance, InstanceConfiguration
@ -55,3 +57,23 @@ def create_instance(vm_name: str, configuration_name: str, user: User) -> Instan
instance = Instance(name=vm_name, configuration_id=configuration, owned_by=user)
instance.save()
return instance
source_code = None
def footer_ctx():
global source_code
if source_code is None:
source_code = {"text": "Source Code", "link": settings.HOSTEA["SOURCE_CODE"]}
try:
r = Repo(".")
commit = r.head.commit.hexsha
source_code["text"] = f"v-{commit.hexsha[0:8]}"
except:
pass
return {
"source_code": source_code,
"admin_email": settings.HOSTEA["INSTANCE_MAINTAINER_CONTACT"],
}

View File

@ -25,7 +25,12 @@ from accounts.decorators import confirm_access
from infrastructure.utils import Infra
from .models import Instance, InstanceConfiguration
from .utils import create_instance as create_instance_util, VmErrors, VmException
from .utils import (
create_instance as create_instance_util,
VmErrors,
VmException,
footer_ctx,
)
def default_ctx(title: str, username: str):
@ -36,6 +41,7 @@ def default_ctx(title: str, username: str):
"title": title,
"username": username,
"open_instances": "open",
"footer": footer_ctx(),
}

View File

@ -62,7 +62,7 @@ your new Gitea instance. Great powers come with great responsibilities,
so use the admin credentials wisely. When in doubt, consult the Gitea
docs or contact support!\n
-username : root
- username : root
- password: {gitea_password}
""",
from_email="No reply Hostea<no-reply@exampl.org>", # TODO read from settings.py

View File

@ -34,11 +34,9 @@ h2 {
body {
width: 100%;
min-height: 100vh;
/*
display: flex;
flex-direction: column;
justify-content: space-between;
*/
}
a:hover {
@ -244,6 +242,8 @@ footer {
display: block;
font-size: 0.7rem;
margin-bottom: 5px;
margin-left: 260px;
width: 100%;
}
.footer__container {
@ -391,6 +391,8 @@ footer {
font-size: 0.7rem;
padding: 0;
margin: 0;
margin-left: 260px;
width: calc(100vw - 260px);
}
.footer__container {
@ -607,8 +609,6 @@ fieldset {
background-color: #e11d21;
}
/*
.form__label {
margin: 5px 0;

View File

@ -15,6 +15,7 @@
from django.shortcuts import render, redirect
from django.contrib.auth.decorators import login_required
from dash.utils import footer_ctx
from .utils import IssueTracker
@ -28,6 +29,7 @@ def default_ctx(title: str, username: str):
"username": username,
"open_support": "open",
"support": {"list": it.get_issue_tracker(), "new": it.open_issue()},
"footer": footer_ctx(),
}