From 572b05c7d2c2afba5f756aa8b157decb17bf97e4 Mon Sep 17 00:00:00 2001 From: fengyang Date: Mon, 21 Nov 2022 12:47:42 +0800 Subject: [PATCH 1/9] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E6=89=98=E7=AE=A1?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E7=9A=84=E9=85=8D=E7=BD=AE=EF=BC=9B=E5=AE=89?= =?UTF-8?q?=E5=85=A8=E8=B5=B7=E8=A7=81=EF=BC=8C=20=E5=A6=82=E6=9E=9C?= =?UTF-8?q?=E5=9C=A8=20ConfigKeyEnum=20=E6=9E=9A=E4=B8=BE=E4=B8=AD?= =?UTF-8?q?=E4=B8=8D=E5=AD=98=E5=9C=A8=EF=BC=8C=E5=88=99=E4=B8=8D=E5=85=81?= =?UTF-8?q?=E8=AE=B8=E4=BF=9D=E5=AD=98=EF=BC=8C=E5=BF=BD=E7=95=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/resources/templates/config.ftl | 8 ++++++ .../blog/business/enums/ConfigKeyEnum.java | 28 ++++++++++++++++++- .../service/impl/SysConfigServiceImpl.java | 5 ++++ .../resources/templates/layout/footer.ftl | 19 +++++++++++-- 4 files changed, 57 insertions(+), 3 deletions(-) diff --git a/blog-admin/src/main/resources/templates/config.ftl b/blog-admin/src/main/resources/templates/config.ftl index e26ad90..ca80049 100644 --- a/blog-admin/src/main/resources/templates/config.ftl +++ b/blog-admin/src/main/resources/templates/config.ftl @@ -104,6 +104,14 @@ +
+ +
+ +
+
diff --git a/blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java b/blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java index c494044..4484ed4 100644 --- a/blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java +++ b/blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java @@ -1,5 +1,8 @@ package com.zyd.blog.business.enums; +import java.util.HashMap; +import java.util.Map; + /** * @author yadong.zhang (yadong.zhang0415(a)gmail.com) * @version 1.0 @@ -258,6 +261,13 @@ public enum ConfigKeyEnum { * 微信公众号AppSecret */ WX_GZH_APP_SECRET("wxGzhAppSecret"), + + + /** + * 托管信息 + */ + HOSTING_INFORMATION("hostingInformation"), + ; private final String key; @@ -268,4 +278,20 @@ public enum ConfigKeyEnum { public String getKey() { return key; - }} + } + + private static final Map CONF_ENUM_MAPS = new HashMap<>(ConfigKeyEnum.values().length); + static { + for (ConfigKeyEnum e: ConfigKeyEnum.values()) { + CONF_ENUM_MAPS.put(e.getKey(), e); + } + } + + /** + * key 是否在定义中。 true 为是 + */ + public static final boolean contains(String key) { + return CONF_ENUM_MAPS.containsKey(key); + } + +} diff --git a/blog-core/src/main/java/com/zyd/blog/business/service/impl/SysConfigServiceImpl.java b/blog-core/src/main/java/com/zyd/blog/business/service/impl/SysConfigServiceImpl.java index b4ae56e..fa38cf2 100644 --- a/blog-core/src/main/java/com/zyd/blog/business/service/impl/SysConfigServiceImpl.java +++ b/blog-core/src/main/java/com/zyd/blog/business/service/impl/SysConfigServiceImpl.java @@ -95,6 +95,11 @@ public class SysConfigServiceImpl implements SysConfigService { @Override @RedisCache(flush = true, enable = false) public void saveConfig(String key, String value) { + // 安全起见, 如果在 ConfigKeyEnum 枚举中不存在,则不允许保存,忽略 + if(!ConfigKeyEnum.contains(key)){ + return; + } + if (!StringUtils.isEmpty(key)) { SysConfig config = null; if (null == (config = this.getByKey(key))) { diff --git a/blog-web/src/main/resources/templates/layout/footer.ftl b/blog-web/src/main/resources/templates/layout/footer.ftl index dc85083..cc8e327 100644 --- a/blog-web/src/main/resources/templates/layout/footer.ftl +++ b/blog-web/src/main/resources/templates/layout/footer.ftl @@ -120,7 +120,19 @@
  • 免责声明
  • -

    托管于阿里云 & 七牛云<#if config.recordNumber!> · ${config.recordNumber}

    +

    + <#if config.hostingInformation!> + 托管于 ${config.hostingInformation} + + + <#if config.recordNumber!> + <#if config.hostingInformation!> + · + + + ${config.recordNumber} + +

    @@ -131,7 +143,10 @@
    -

    <#if config.copyright!>${config.copyright} | Powered by OneBlog ${appInfo.version!}

    +

    + <#if config.copyright!>${config.copyright} | + Powered by OneBlog ${appInfo.version!} +

    <#if url?? && (url == "index")>
    + + <#-- 系统配置模块 --> + <#include "/config/sys-tab.ftl"/> +
    diff --git a/blog-admin/src/main/resources/templates/config/sys-tab.ftl b/blog-admin/src/main/resources/templates/config/sys-tab.ftl new file mode 100644 index 0000000..c7c88c2 --- /dev/null +++ b/blog-admin/src/main/resources/templates/config/sys-tab.ftl @@ -0,0 +1,43 @@ +<#-- 系统配置模块 --> + +
    + + +
    + +
    +
      +
    • +
    • +
    +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    + +
    + +
    +
    + +
    diff --git a/blog-admin/src/main/resources/templates/include/macros.ftl b/blog-admin/src/main/resources/templates/include/macros.ftl index adbf546..8df4836 100644 --- a/blog-admin/src/main/resources/templates/include/macros.ftl +++ b/blog-admin/src/main/resources/templates/include/macros.ftl @@ -69,7 +69,13 @@ <#if footerHtml>
    + <#-- 后台站点统计脚本代码 --> + <#if config.adminSiteStat!> + ${config.adminSiteStat} + + Gentelella - Bootstrap Admin Template by Colorlib +
    diff --git a/blog-admin/src/main/resources/templates/login.ftl b/blog-admin/src/main/resources/templates/login.ftl index eb06d12..9a03f1a 100644 --- a/blog-admin/src/main/resources/templates/login.ftl +++ b/blog-admin/src/main/resources/templates/login.ftl @@ -60,6 +60,9 @@
    Gentelella - Bootstrap Admin Template by Colorlib + + <#-- 后台站点统计 --> + <#if config.adminSiteStat!>${config.adminSiteStat}
    diff --git a/blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java b/blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java index 14f1f36..74923d3 100644 --- a/blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java +++ b/blog-core/src/main/java/com/zyd/blog/business/enums/ConfigKeyEnum.java @@ -280,6 +280,20 @@ public enum ConfigKeyEnum { */ WEB_CSS_CDN("webCssCdn"), + //##################################### 系统配置 ##################################### + /** + * 是否展示网站信息 + */ + SHOW_WEB_SITE_ENABLED("showWebSiteEnabled"), + /** + * 前台站点统计脚本代码 + */ + web_Site_Stat("webSiteStat"), + /** + * 后台站点统计脚本代码 + */ + ADMIN_SITE_STAT("adminSiteStat"), + /** * 托管信息 */ diff --git a/blog-web/src/main/resources/templates/layout/footer.ftl b/blog-web/src/main/resources/templates/layout/footer.ftl index cc8e327..7921fdf 100644 --- a/blog-web/src/main/resources/templates/layout/footer.ftl +++ b/blog-web/src/main/resources/templates/layout/footer.ftl @@ -122,14 +122,19 @@

    <#if config.hostingInformation!> - 托管于 ${config.hostingInformation} + 托管于 ${config.hostingInformation} | - <#if config.recordNumber!> - <#if config.hostingInformation!> - · - + <#-- 前台站点统计脚本代码 --> + <#if config.webSiteStat!> + + + ${config.webSiteStat} · + + + <#if config.recordNumber!> ${config.recordNumber}

    diff --git a/blog-web/src/main/resources/templates/layout/sidebar.ftl b/blog-web/src/main/resources/templates/layout/sidebar.ftl index 117c4a5..3818571 100644 --- a/blog-web/src/main/resources/templates/layout/sidebar.ftl +++ b/blog-web/src/main/resources/templates/layout/sidebar.ftl @@ -165,21 +165,26 @@
    - + + <#-- 是否展示网站信息 --> + <#if config.showWebSiteEnabled! && config.showWebSiteEnabled == 1> + + + <#-- 广告位 -->
    -- Gitee From 8ba3699e0319140c8244a7882c8027c26cf81630 Mon Sep 17 00:00:00 2001 From: fengyang Date: Wed, 23 Nov 2022 20:02:04 +0800 Subject: [PATCH 5/9] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E4=B8=AD=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E2=80=9C=E7=B3=BB=E7=BB=9F=E9=85=8D=E7=BD=AE=E2=80=9D?= =?UTF-8?q?=EF=BC=8C=E5=8C=85=E5=90=AB=E5=89=8D=E5=8F=B0=E7=AB=99=E7=82=B9?= =?UTF-8?q?=E7=BB=9F=E8=AE=A1=E8=84=9A=E6=9C=AC=E4=BB=A3=E7=A0=81=EF=BC=8C?= =?UTF-8?q?=20=E5=90=8E=E5=8F=B0=E7=AB=99=E7=82=B9=E7=BB=9F=E8=AE=A1?= =?UTF-8?q?=EF=BC=8C=E6=98=AF=E5=90=A6=E5=B1=95=E7=A4=BA=E7=BD=91=E7=AB=99?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog-admin/src/main/resources/application-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog-admin/src/main/resources/application-dev.yml b/blog-admin/src/main/resources/application-dev.yml index 7a2bb36..23401ed 100644 --- a/blog-admin/src/main/resources/application-dev.yml +++ b/blog-admin/src/main/resources/application-dev.yml @@ -5,7 +5,7 @@ server: # SPRING PROFILES spring: profiles: - include: center, fengyang + include: center # logging settings logging: -- Gitee From a2bec8fc97c87e8d7ebc0190a4ec0a3439cf9ceb Mon Sep 17 00:00:00 2001 From: fengyang Date: Thu, 24 Nov 2022 20:13:44 +0800 Subject: [PATCH 6/9] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E6=A1=86=E5=BA=95?= =?UTF-8?q?=E9=83=A8=E5=A2=9E=E5=8A=A0=E5=B9=BF=E5=91=8A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog-admin/src/main/resources/application-dev.yml | 2 +- .../java/com/zyd/blog/business/enums/AdPositionEnum.java | 5 +++++ blog-web/src/main/resources/templates/article.ftl | 3 +++ blog-web/src/main/resources/templates/guestbook.ftl | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/blog-admin/src/main/resources/application-dev.yml b/blog-admin/src/main/resources/application-dev.yml index 23401ed..7a2bb36 100644 --- a/blog-admin/src/main/resources/application-dev.yml +++ b/blog-admin/src/main/resources/application-dev.yml @@ -5,7 +5,7 @@ server: # SPRING PROFILES spring: profiles: - include: center + include: center, fengyang # logging settings logging: diff --git a/blog-core/src/main/java/com/zyd/blog/business/enums/AdPositionEnum.java b/blog-core/src/main/java/com/zyd/blog/business/enums/AdPositionEnum.java index e160ec7..3999168 100644 --- a/blog-core/src/main/java/com/zyd/blog/business/enums/AdPositionEnum.java +++ b/blog-core/src/main/java/com/zyd/blog/business/enums/AdPositionEnum.java @@ -37,6 +37,11 @@ public enum AdPositionEnum { * 适用于文章详情页、留言板、等存在评论框的页面 */ COMMENT_BOX_TOP("评论框顶部"), + + /** + * 适用于文章详情页、留言板、等存在评论框的页面 + */ + COMMENT_BOX_BOTTOM("评论框底部"), ; private String desc; diff --git a/blog-web/src/main/resources/templates/article.ftl b/blog-web/src/main/resources/templates/article.ftl index e29d078..2aec70e 100644 --- a/blog-web/src/main/resources/templates/article.ftl +++ b/blog-web/src/main/resources/templates/article.ftl @@ -238,6 +238,9 @@ + + <#-- 广告位: 评论框底部 --> + <#include "layout/sidebar.ftl"/> diff --git a/blog-web/src/main/resources/templates/guestbook.ftl b/blog-web/src/main/resources/templates/guestbook.ftl index 274de3a..89bfffd 100644 --- a/blog-web/src/main/resources/templates/guestbook.ftl +++ b/blog-web/src/main/resources/templates/guestbook.ftl @@ -57,6 +57,9 @@ 评论功能已被站长关闭 + + <#-- 广告位: 评论框底部 --> + -- Gitee From 5711bcfa2ae17ab1297d5a51638f6b2d6a6448ed Mon Sep 17 00:00:00 2001 From: fengyang Date: Thu, 24 Nov 2022 20:14:38 +0800 Subject: [PATCH 7/9] =?UTF-8?q?=E8=AF=84=E8=AE=BA=E6=A1=86=E5=BA=95?= =?UTF-8?q?=E9=83=A8=E5=A2=9E=E5=8A=A0=E5=B9=BF=E5=91=8A=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog-admin/src/main/resources/application-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog-admin/src/main/resources/application-dev.yml b/blog-admin/src/main/resources/application-dev.yml index 7a2bb36..23401ed 100644 --- a/blog-admin/src/main/resources/application-dev.yml +++ b/blog-admin/src/main/resources/application-dev.yml @@ -5,7 +5,7 @@ server: # SPRING PROFILES spring: profiles: - include: center, fengyang + include: center # logging settings logging: -- Gitee From fe156b98c699aa8a4b0b33b134649f67ad2d0cdf Mon Sep 17 00:00:00 2001 From: fengyang Date: Mon, 19 Dec 2022 17:03:13 +0800 Subject: [PATCH 8/9] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=81=A2=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- blog-admin/src/main/resources/application-dev.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/blog-admin/src/main/resources/application-dev.yml b/blog-admin/src/main/resources/application-dev.yml index 23401ed..ff93f55 100644 --- a/blog-admin/src/main/resources/application-dev.yml +++ b/blog-admin/src/main/resources/application-dev.yml @@ -5,7 +5,7 @@ server: # SPRING PROFILES spring: profiles: - include: center + include: [center] # logging settings logging: -- Gitee From 989e666d8727dd4289b0c776b089dc29a532b6e4 Mon Sep 17 00:00:00 2001 From: fengyang Date: Mon, 19 Dec 2022 17:06:06 +0800 Subject: [PATCH 9/9] ignore delete --- blog-admin/.gitignore | 1 - 1 file changed, 1 deletion(-) diff --git a/blog-admin/.gitignore b/blog-admin/.gitignore index 4bb6831..d5dba20 100644 --- a/blog-admin/.gitignore +++ b/blog-admin/.gitignore @@ -23,4 +23,3 @@ /dist/ /nbdist/ /.nb-gradle/ -/src/main/resources/application-prod.yml -- Gitee