Skip to content

Commit

Permalink
添加自定义环境标题功能-custom_title_suffix (#2631)
Browse files Browse the repository at this point in the history
* 添加favicon图片

* 修改favicon

* 修改favicon.ico

* 添加自定义环境标题

* update

* update 自定义环境标题

* update custom_environment_title

* update custom_environment_title

* 添加favicon图片

* 修改favicon

* 修改favicon.ico

* 添加自定义环境标题

* update

* update 自定义环境标题

* update custom_environment_title

* update custom_environment_title

* 修改字段名称,添加环境变量

* Update __init__.py

* Update settings.py

* update CUSTOM_TITLE_SUFFIX

* 从env读写。env("CUSTOM_TITLE_SUFFIX", default="")

* docker的环境变量加上此配置

---------

Co-authored-by: 王飞 <fei.wang@xgo.one>
  • Loading branch information
feiazifeiazi and 王飞 authored May 10, 2024
1 parent 4d0b75f commit b143525
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 6 deletions.
3 changes: 3 additions & 0 deletions archery/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,9 @@
},
}

# 在网站标题及登录页面追加此内容, 可用于多archery实例的区分。Archery后台也有相同配置,如都做了配置,以后台配置为准
CUSTOM_TITLE_SUFFIX = env("CUSTOM_TITLE_SUFFIX", default="")

MEDIA_ROOT = os.path.join(BASE_DIR, "media")
if not os.path.exists(MEDIA_ROOT):
os.mkdir(MEDIA_ROOT)
Expand Down
4 changes: 2 additions & 2 deletions common/templates/base.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Archery-SQL审核查询平台</title>
<title>{% block title %}Archery-SQL审核查询平台{{ custom_title_suffix }}{% endblock %}</title>
<link rel="shortcut icon" href="{% static 'img/favicon.ico' %}"/>

<!-- 引入 Bootstrap -->
Expand Down Expand Up @@ -35,7 +35,7 @@
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="/index/"><strong>Archery</strong></a>
<a class="navbar-brand" href="/index/"><strong>Archery{{ custom_title_suffix }}</strong></a>
</div>

<!-- /.navbar-header -->
Expand Down
11 changes: 11 additions & 0 deletions common/templates/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,17 @@ <h4 style="color: darkgrey"><b>其他配置</b></h4>

</div>
</div>
<div class="form-group">
<label for="custom_title_suffix"
class="col-sm-4 control-label">CUSTOM_TITLE_SUFFIX</label>
<div class="col-sm-5">
<input type="text" class="form-control"
id="custom_title_suffix"
key="custom_title_suffix"
value="{{ config.custom_title_suffix }}"
placeholder="在网站标题及登录页面追加此内容, 可用于多archery实例的区分">
</div>
</div>
</div>
<hr />
<div class="form-group">
Expand Down
4 changes: 2 additions & 2 deletions common/templates/login.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>Login To Archery</title>
<title>Login To Archery{{ custom_title_suffix }}</title>
{% load static %}
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!-- 引入 Bootstrap -->
Expand All @@ -18,7 +18,7 @@
<body style="background-color:#edeff1;">
<div class="row lsb-login">
<div class="col-sm-4 login-form-wrapper">
<h3 class="text-center">Login To Archery</h3>
<h3 class="text-center">Login To Archery{{ custom_title_suffix }}</h3>
<form class="login-form fade-in-effect" id="login" method="post" role="form">
{% csrf_token %}
{% if dingding_enabled %}
Expand Down
6 changes: 5 additions & 1 deletion common/utils/global_info.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# -*- coding: UTF-8 -*-
from sql.utils.workflow_audit import Audit
from archery import display_version
from archery import display_version, settings
from common.config import SysConfig
from sql.models import TwoFactorAuthConfig

Expand All @@ -25,12 +25,16 @@ def global_info(request):
# 添加公告
announcement_content_enabled = sys_config.get("announcement_content_enabled", False)
announcement_content = sys_config.get("announcement_content", "")
custom_title_suffix = sys_config.get("custom_title_suffix", "")
if not custom_title_suffix:
custom_title_suffix = settings.CUSTOM_TITLE_SUFFIX

return {
"todo": todo,
"archery_version": display_version,
"watermark_enabled": watermark_enabled,
"announcement_content_enabled": announcement_content_enabled,
"custom_title_suffix": custom_title_suffix,
"announcement_content": announcement_content,
"twofa_type": twofa_type,
}
2 changes: 1 addition & 1 deletion sql/templates/legacy_login_form.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@
</div>
<br/>
<div class="form-group">
<button class="btn btn-primary btn-block" id="btnLogin" type="button"><i class="fa-lock"></i>登录</button>
<button class="btn btn-primary btn-block" id="btnLogin" type="button"><i class="fa-lock"></i>登录{{ custom_title_suffix }}</button>
</div>
3 changes: 3 additions & 0 deletions src/docker-compose/.env
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ Q_CLUISTER_WORKERS=4
Q_CLUISTER_TIMEOUT=60
Q_CLUISTER_SYNC=false

# 在网站标题及登录页面追加此内容, 可用于多archery实例的区分。Archery后台也有相同配置,如都做了配置,以后台配置为准
CUSTOM_TITLE_SUFFIX = ""

0 comments on commit b143525

Please sign in to comment.