web: use version family subdomain for in-app doc links
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
4c133b957c
commit
e4e7a112e3
|
@ -2,10 +2,14 @@
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
window.authentik = {};
|
window.authentik = {
|
||||||
window.authentik.locale = "{{ LANGUAGE_CODE }}";
|
locale: "{{ LANGUAGE_CODE }}",
|
||||||
window.authentik.config = JSON.parse('{{ config_json|escapejs }}');
|
config: JSON.parse('{{ config_json|escapejs }}'),
|
||||||
window.authentik.tenant = JSON.parse('{{ tenant_json|escapejs }}');
|
tenant: JSON.parse('{{ tenant_json|escapejs }}'),
|
||||||
|
versionFamily: "{{ version_family }}",
|
||||||
|
versionSubdomain: "{{ version_subdomain }}",
|
||||||
|
build: "{{ build }}",
|
||||||
|
};
|
||||||
window.addEventListener("DOMContentLoaded", () => {
|
window.addEventListener("DOMContentLoaded", () => {
|
||||||
{% for message in messages %}
|
{% for message in messages %}
|
||||||
window.dispatchEvent(
|
window.dispatchEvent(
|
||||||
|
|
|
@ -5,6 +5,8 @@ from typing import Any
|
||||||
from django.shortcuts import get_object_or_404
|
from django.shortcuts import get_object_or_404
|
||||||
from django.views.generic.base import TemplateView
|
from django.views.generic.base import TemplateView
|
||||||
from rest_framework.request import Request
|
from rest_framework.request import Request
|
||||||
|
from authentik import get_build_hash
|
||||||
|
from authentik.admin.tasks import LOCAL_VERSION
|
||||||
|
|
||||||
from authentik.api.v3.config import ConfigView
|
from authentik.api.v3.config import ConfigView
|
||||||
from authentik.flows.models import Flow
|
from authentik.flows.models import Flow
|
||||||
|
@ -17,6 +19,9 @@ class InterfaceView(TemplateView):
|
||||||
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
|
def get_context_data(self, **kwargs: Any) -> dict[str, Any]:
|
||||||
kwargs["config_json"] = dumps(ConfigView(request=Request(self.request)).get_config().data)
|
kwargs["config_json"] = dumps(ConfigView(request=Request(self.request)).get_config().data)
|
||||||
kwargs["tenant_json"] = dumps(CurrentTenantSerializer(self.request.tenant).data)
|
kwargs["tenant_json"] = dumps(CurrentTenantSerializer(self.request.tenant).data)
|
||||||
|
kwargs["version_family"] = f"{LOCAL_VERSION.major}.{LOCAL_VERSION.minor}"
|
||||||
|
kwargs["version_subdomain"] = f"version-{LOCAL_VERSION.major}-{LOCAL_VERSION.minor}"
|
||||||
|
kwargs["build"] = get_build_hash()
|
||||||
return super().get_context_data(**kwargs)
|
return super().get_context_data(**kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { docLink } from "@goauthentik/common/global";
|
||||||
import { ModalButton } from "@goauthentik/elements/buttons/ModalButton";
|
import { ModalButton } from "@goauthentik/elements/buttons/ModalButton";
|
||||||
import "@goauthentik/elements/buttons/TokenCopyButton";
|
import "@goauthentik/elements/buttons/TokenCopyButton";
|
||||||
|
|
||||||
|
@ -22,7 +23,7 @@ export class OutpostDeploymentModal extends ModalButton {
|
||||||
<p>
|
<p>
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://goauthentik.io/docs/outposts?utm_source=authentik#deploy"
|
href="${docLink("/docs/outposts?utm_source=authentik#deploy")}"
|
||||||
>${t`View deployment documentation`}</a
|
>${t`View deployment documentation`}</a
|
||||||
>
|
>
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||||
|
import { docLink } from "@goauthentik/common/global";
|
||||||
import "@goauthentik/elements/CodeMirror";
|
import "@goauthentik/elements/CodeMirror";
|
||||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||||
|
@ -164,9 +165,7 @@ export class OutpostForm extends ModelForm<Outpost, string> {
|
||||||
</p>
|
</p>
|
||||||
<p class="pf-c-form__helper-text">
|
<p class="pf-c-form__helper-text">
|
||||||
See
|
See
|
||||||
<a
|
<a target="_blank" href="${docLink("/docs/outposts?utm_source=authentik")}"
|
||||||
target="_blank"
|
|
||||||
href="https://goauthentik.io/docs/outposts?utm_source=authentik"
|
|
||||||
>documentation</a
|
>documentation</a
|
||||||
>.
|
>.
|
||||||
</p>
|
</p>
|
||||||
|
@ -209,7 +208,7 @@ export class OutpostForm extends ModelForm<Outpost, string> {
|
||||||
See
|
See
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://goauthentik.io/docs/outposts?utm_source=authentik#configuration"
|
href="${docLink("/docs/outposts?utm_source=authentik#configuration")}"
|
||||||
>documentation</a
|
>documentation</a
|
||||||
>.
|
>.
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||||
|
import { docLink } from "@goauthentik/common/global";
|
||||||
import { first } from "@goauthentik/common/utils";
|
import { first } from "@goauthentik/common/utils";
|
||||||
import "@goauthentik/elements/CodeMirror";
|
import "@goauthentik/elements/CodeMirror";
|
||||||
import "@goauthentik/elements/forms/FormGroup";
|
import "@goauthentik/elements/forms/FormGroup";
|
||||||
|
@ -85,7 +86,7 @@ export class ExpressionPolicyForm extends ModelForm<ExpressionPolicy, string> {
|
||||||
${t`Expression using Python.`}
|
${t`Expression using Python.`}
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://goauthentik.io/docs/policies/expression?utm_source=authentik"
|
href="${docLink("/docs/policies/expression?utm_source=authentik")}"
|
||||||
>
|
>
|
||||||
${t`See documentation for a list of all variables.`}
|
${t`See documentation for a list of all variables.`}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||||
|
import { docLink } from "@goauthentik/common/global";
|
||||||
import "@goauthentik/elements/CodeMirror";
|
import "@goauthentik/elements/CodeMirror";
|
||||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||||
|
@ -72,7 +73,7 @@ export class PropertyMappingLDAPForm extends ModelForm<LDAPPropertyMapping, stri
|
||||||
${t`Expression using Python.`}
|
${t`Expression using Python.`}
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://goauthentik.io/docs/property-mappings/expression?utm_source=authentik"
|
href="${docLink("/docs/property-mappings/expression?utm_source=authentik")}"
|
||||||
>
|
>
|
||||||
${t`See documentation for a list of all variables.`}
|
${t`See documentation for a list of all variables.`}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||||
|
import { docLink } from "@goauthentik/common/global";
|
||||||
import "@goauthentik/elements/CodeMirror";
|
import "@goauthentik/elements/CodeMirror";
|
||||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||||
|
@ -57,7 +58,7 @@ export class PropertyMappingNotification extends ModelForm<NotificationWebhookMa
|
||||||
${t`Expression using Python.`}
|
${t`Expression using Python.`}
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://goauthentik.io/docs/property-mappings/expression?utm_source=authentik"
|
href="${docLink("/docs/property-mappings/expression?utm_source=authentik")}"
|
||||||
>
|
>
|
||||||
${t`See documentation for a list of all variables.`}
|
${t`See documentation for a list of all variables.`}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||||
|
import { docLink } from "@goauthentik/common/global";
|
||||||
import "@goauthentik/elements/CodeMirror";
|
import "@goauthentik/elements/CodeMirror";
|
||||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||||
|
@ -82,7 +83,7 @@ export class PropertyMappingLDAPForm extends ModelForm<SAMLPropertyMapping, stri
|
||||||
${t`Expression using Python.`}
|
${t`Expression using Python.`}
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://goauthentik.io/docs/property-mappings/expression?utm_source=authentik"
|
href="${docLink("/docs/property-mappings/expression?utm_source=authentik")}"
|
||||||
>
|
>
|
||||||
${t`See documentation for a list of all variables.`}
|
${t`See documentation for a list of all variables.`}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
import { DEFAULT_CONFIG } from "@goauthentik/common/api/config";
|
||||||
|
import { docLink } from "@goauthentik/common/global";
|
||||||
import "@goauthentik/elements/CodeMirror";
|
import "@goauthentik/elements/CodeMirror";
|
||||||
import "@goauthentik/elements/forms/HorizontalFormElement";
|
import "@goauthentik/elements/forms/HorizontalFormElement";
|
||||||
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
import { ModelForm } from "@goauthentik/elements/forms/ModelForm";
|
||||||
|
@ -78,7 +79,7 @@ export class PropertyMappingScopeForm extends ModelForm<ScopeMapping, string> {
|
||||||
${t`Expression using Python.`}
|
${t`Expression using Python.`}
|
||||||
<a
|
<a
|
||||||
target="_blank"
|
target="_blank"
|
||||||
href="https://goauthentik.io/docs/property-mappings/expression?utm_source=authentik"
|
href="${docLink("/docs/property-mappings/expression?utm_source=authentik")}"
|
||||||
>
|
>
|
||||||
${t`See documentation for a list of all variables.`}
|
${t`See documentation for a list of all variables.`}
|
||||||
</a>
|
</a>
|
||||||
|
|
|
@ -7,6 +7,9 @@ export interface GlobalAuthentik {
|
||||||
};
|
};
|
||||||
config: Config;
|
config: Config;
|
||||||
tenant: CurrentTenant;
|
tenant: CurrentTenant;
|
||||||
|
versionFamily: string;
|
||||||
|
versionSubdomain: string;
|
||||||
|
build: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface AuthentikWindow {
|
export interface AuthentikWindow {
|
||||||
|
@ -16,3 +19,12 @@ export interface AuthentikWindow {
|
||||||
export function globalAK(): GlobalAuthentik | undefined {
|
export function globalAK(): GlobalAuthentik | undefined {
|
||||||
return (window as unknown as AuthentikWindow).authentik;
|
return (window as unknown as AuthentikWindow).authentik;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function docLink(path: string): string {
|
||||||
|
const ak = globalAK();
|
||||||
|
// Default case or beta build which should always point to latest
|
||||||
|
if (!ak || ak.build !== "") {
|
||||||
|
return `https://goauthentik.io${path}`;
|
||||||
|
}
|
||||||
|
return `https://${ak.versionSubdomain}.goauthentik.io${path}`;
|
||||||
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { docLink } from "@goauthentik/common/global";
|
||||||
import "@goauthentik/elements/Alert";
|
import "@goauthentik/elements/Alert";
|
||||||
import { AKElement } from "@goauthentik/elements/Base";
|
import { AKElement } from "@goauthentik/elements/Base";
|
||||||
|
|
||||||
|
@ -56,7 +57,7 @@ export class Markdown extends AKElement {
|
||||||
if (md.filename === "index.md") {
|
if (md.filename === "index.md") {
|
||||||
relPath = relPath.replace("index.md", "");
|
relPath = relPath.replace("index.md", "");
|
||||||
}
|
}
|
||||||
const baseURL = "https://goauthentik.io";
|
const baseURL = docLink("");
|
||||||
const fullURL = `${baseURL}${relPath}.$1`;
|
const fullURL = `${baseURL}${relPath}.$1`;
|
||||||
return input.replace(relativeLink, `href="${fullURL}" target="_blank"`);
|
return input.replace(relativeLink, `href="${fullURL}" target="_blank"`);
|
||||||
}
|
}
|
||||||
|
|
Reference in New Issue