Skip to content

Commit

Permalink
Merge pull request #128 from jamebal/recycle
Browse files Browse the repository at this point in the history
Recycle
  • Loading branch information
jamebal authored Jul 8, 2024
2 parents aed2306 + 7121bd9 commit b85ebb3
Show file tree
Hide file tree
Showing 13 changed files with 74 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import cn.hutool.core.text.CharSequenceUtil;
import cn.hutool.core.util.BooleanUtil;
import cn.hutool.core.util.ReUtil;
import cn.hutool.core.util.StrUtil;
import com.jmal.clouddisk.annotation.LogOperatingFun;
import com.jmal.clouddisk.model.*;
import com.jmal.clouddisk.service.IMarkdownService;
Expand Down Expand Up @@ -293,7 +294,7 @@ public String author(HttpServletRequest request, Model map, @PathVariable String
}

private WebsiteSettingDTO getSetting(HttpServletRequest request, Model map) {
WebsiteSettingDTO websiteSettingDTO = settingService.getWebsiteSetting();
WebsiteSettingDTO websiteSettingDTO = getWebsiteSetting(request);
setOperatingButtonList(websiteSettingDTO);
List<MarkdownVO> markdownVOList = fileService.getAlonePages();
map.addAttribute("alonePages", markdownVOList);
Expand Down Expand Up @@ -360,12 +361,24 @@ private boolean pjaxMap(HttpServletRequest request, Model map, String viewName)
if (!isPjax) {
getSetting(request, map);
} else {
map.addAttribute("setting", settingService.getWebsiteSetting());
map.addAttribute("setting", getWebsiteSetting(request));
}
map.addAttribute("mark", viewName);
return isPjax;
}

private WebsiteSettingDTO getWebsiteSetting(HttpServletRequest request) {
WebsiteSettingDTO websiteSettingDTO = settingService.getWebsiteSetting();
if (StrUtil.isNotBlank(websiteSettingDTO.getSiteUrl())) {
String siteUrl = websiteSettingDTO.getSiteUrl();
if (siteUrl.endsWith("/")) {
siteUrl = siteUrl.substring(0, siteUrl.length() - 1);
websiteSettingDTO.setSiteUrl(siteUrl);
}
}
return websiteSettingDTO;
}

}


4 changes: 2 additions & 2 deletions src/main/resources/templates/archives.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div xmlns:th="http://www.thymeleaf.org">
<link rel="stylesheet" type="text/css" href="/articles/css/independent.css">
<link rel="stylesheet" type="text/css" th:href="${setting.siteUrl} + '/css/independent.css'">
<div id="body">
<div class="article-header">
<div class="article-background"></div>
Expand Down Expand Up @@ -30,7 +30,7 @@
<div class="layui-timeline-content layui-text">
<h3 class="layui-timeline-title" th:text="${articles.get(0).date()}"></h3>
<div class="brick" th:each="article : ${articles}">
<a th:href="'/s/'+${article.slug == null ? article.id:article.slug}">
<a th:href="${setting.siteUrl} + '/s/'+${article.slug == null ? article.id:article.slug}">
<span class="time" th:text="${article.dateTime()}"></span>
<span th:text="${article.name}"> </span>
</a>
Expand Down
21 changes: 10 additions & 11 deletions src/main/resources/templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,27 @@
<div class="inner">
<div class="blog-title"><span id="article-title" th:text="${markdown.name}"></span><span class="typed-cursor">_</span></div>
<div class="blog-description font-mono">
<a class="edit" itemprop="name" th:href="'/author/'+${markdown.username}" rel="author" th:text="${markdown.username}"></a>
<a class="edit" itemprop="name" th:href="${setting.siteUrl} + '/author/'+${markdown.username}" rel="author" th:text="${markdown.username}"></a>
<span th:text="'· '+${markdown.uploadTime()}"></span>
<span th:if="${visits != null}">
· 阅读: <span th:text="${visits}"></span>
</span>
<span class="link" th:if="${markdown.categories != null && markdown.categories.size() > 0}">
·
<a th:each="categoryDO,categoryStat : ${markdown.categories}">
<span th:text="${categoryStat.index > 0?' · ':''}"></span><a th:href="'/categories/'+${categoryDO.name}" th:text="${categoryDO.name}"></a>
<span th:text="${categoryStat.index > 0?' · ':''}"></span><a th:href="${setting.siteUrl} + '/categories/'+${categoryDO.name}" th:text="${categoryDO.name}"></a>
</a>
</span>
<span class="edit" th:if="${markdown.editable != null && markdown.editable}">
·
<a th:href="'/setting/website/manager-articles?operation=editor&id='+${markdown.id}" target="_blank">编辑</a>
<a th:href="'setting/website/manager-articles?operation=editor&id='+${markdown.id}" target="_blank">编辑</a>
</span>
<div class="meta-item-tag" th:if="${markdown.tags != null && markdown.tags.size() > 0}">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-tag"></use>
</svg>
<span th:each="tag,tagStat : ${markdown.tags}">
<span th:text="${tagStat.index > 0?' · ':''}"></span><a th:href="'/tags/'+${tag.slug}" th:text="${tag.name}"></a>
<span th:text="${tagStat.index > 0?' · ':''}"></span><a th:href="${setting.siteUrl} + '/tags/'+${tag.slug}" th:text="${tag.name}"></a>
</span>
</div>
</div>
Expand Down Expand Up @@ -81,6 +81,7 @@
</div>
<script th:inline="javascript">
$(document).ready(function(){
const articleSiteUrl = [[${setting.siteUrl}]]
document.title = [[${titleName}]]
// 是否为独立页面
const isAlonePage = [[${markdown.alonePage}]]
Expand Down Expand Up @@ -116,7 +117,7 @@
theme: {
current: 'light'
},
cdn: `${window.location.origin}/articles/[email protected]`,
cdn: `${articleSiteUrl}/[email protected]`,
transform(htmlStr) {
renderContents($(htmlStr))
return htmlStr;
Expand Down Expand Up @@ -504,9 +505,9 @@
}
function setContentTheme(){
const isDark = getThemeCSSName() === 'dark'
Vditor.setContentTheme(isDark ? 'dark': 'light', `${origin}/articles/[email protected]/dist/css/content-theme`)
Vditor.setCodeTheme(isDark ? 'native': 'github', `${origin}/articles/[email protected]`)
// Vditor.highlightRender({cnd: `${origin}/articles/[email protected]`})
Vditor.setContentTheme(isDark ? 'dark': 'light', `${articleSiteUrl}/[email protected]/dist/css/content-theme`)
Vditor.setCodeTheme(isDark ? 'native': 'github', `${articleSiteUrl}/[email protected]`)
// Vditor.highlightRender({cnd: `${articleSiteUrl}/[email protected]`})
}

// common.js
Expand Down Expand Up @@ -539,7 +540,7 @@
link.type = 'text/css';
link.id = "theme-css-dark"; // 加上id方便后面好查找到进行删除
link.rel = 'stylesheet';
link.href = '/articles/css/dark/index-2.0.2.css';
link.href = articleSiteUrl + '/css/dark/index-2.0.2.css';
document.getElementsByTagName("head")[0].appendChild(link);
labelIcon.removeClass('fa-moon')
labelIcon.addClass('fa-sun')
Expand Down Expand Up @@ -621,9 +622,7 @@
function updateLink() {
// 选择所有的a标签
document.querySelectorAll('a').forEach(function(link) {
console.log('link', link)
link.addEventListener('click', function(e) {
console.log('123')
// 获取链接的href属性
let href = link.getAttribute('href');
// 判断是否为外部链接
Expand Down
4 changes: 2 additions & 2 deletions src/main/resources/templates/categories.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<div xmlns:th="http://www.thymeleaf.org">
<link rel="stylesheet" type="text/css" href="/articles/css/independent.css">
<link rel="stylesheet" type="text/css" th:href="${setting.siteUrl} + '/css/independent.css'">
<div id="body">
<div class="article-header">
<div class="article-background"></div>
Expand Down Expand Up @@ -31,7 +31,7 @@
if (typeof echarts !== 'undefined') {
initEcharts()
} else {
loadScript('/articles/js/echarts.min.js',function(){
loadScript(siteUrl + '/js/echarts.min.js',function(){
initEcharts()
})
}
Expand Down
6 changes: 3 additions & 3 deletions src/main/resources/templates/component/article-tail.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</svg>
</div>
<div class="flex-text" th:each="categoryDO,categoryStat : ${markdown.categories}">
<a th:href="'/categories/'+${categoryDO.slug}" th:text="${categoryDO.name}"></a>
<a th:href="${setting.siteUrl} + '/categories/'+${categoryDO.slug}" th:text="${categoryDO.name}"></a>
</div>
</div>
<div class="meta-item tag" th:if="${markdown.tags != null && markdown.tags.size() > 0}">
Expand All @@ -18,8 +18,8 @@
</svg>
</div>
<div class="flex-text" th:each="tag,tagStat : ${markdown.tags}">
<a th:href="'/tags/'+${tag.slug}" th:text="${tag.name}"></a>
<a th:href="${setting.siteUrl} + '/tags/'+${tag.slug}" th:text="${tag.name}"></a>
</div>
</div>
</div>
</div>
</div>
14 changes: 7 additions & 7 deletions src/main/resources/templates/component/article-top.html
Original file line number Diff line number Diff line change
@@ -1,34 +1,34 @@
<div class="navbar animated fadeIn fast delay-1s" xmlns:th="http://www.thymeleaf.org">
<div class="container-fluid">
<a class="navbar-brand text-brand" href="/" th:text="${setting.siteLogo}"></a>
<a class="navbar-brand text-brand" th:href="${setting.siteUrl}" th:text="${setting.siteLogo}"></a>
<div class="collapse navbar-collapse">
<ul class="navbar-nav mr-auto">
<li class="nav-item" th:if="${setting.isShowAlonePage('archives')}">
<a class="nav-link" href="/archives" title="归档">
<a class="nav-link" th:href="${setting.siteUrl} + '/archives'" title="归档">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-guidang"></use>
</svg>
<span class="nav-link-label">归档</span>
</a>
</li>
<li class="nav-item" th:if="${setting.isShowAlonePage('categories')}">
<a class="nav-link" href="/categories" title="分类">
<a class="nav-link" th:href="${setting.siteUrl} + '/categories'" title="分类">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-fenlei"></use>
</svg>
<span class="nav-link-label">分类</span>
</a>
</li>
<li class="nav-item" th:if="${setting.isShowAlonePage('tags')}">
<a class="nav-link" href="/tags" title="标签">
<a class="nav-link" th:href="${setting.siteUrl} + '/tags'" title="标签">
<svg class="icon" aria-hidden="true">
<use xlink:href="#icon-tag"></use>
</svg>
<span class="nav-link-label">标签</span>
</a>
</li>
<li class="nav-item" th:each="page: ${showAlonePages}">
<a class="nav-link" th:href="'/o/'+${page.slug}" th:title="${page.name}">
<a class="nav-link" th:href="${setting.siteUrl} + '/o/'+${page.slug}" th:title="${page.name}">
<span class="nav-link-label" th:text="${page.name}"></span>
</a>
</li>
Expand All @@ -41,7 +41,7 @@
</a>
<ul class="dropdown-menu">
<li class="dropdown-item alone-page" th:each="page,pageStat : ${alonePages}" th:if="${pageStat.index > (showAlonePages.size() - 1)}">
<a th:href="'/o/'+${page.slug}" th:text="${page.name}"></a>
<a th:href="${setting.siteUrl} + '/o/'+${page.slug}" th:text="${page.name}"></a>
</li>
</ul>
</li>
Expand Down Expand Up @@ -94,4 +94,4 @@
searchLi.style.width = '11rem'
}
}
</script>
</script>
14 changes: 7 additions & 7 deletions src/main/resources/templates/component/articles-list.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<section class="meta">
<div class="meta" id="header-meta">
<h2 class="title">
<a th:href="'/s/'+${article.slug == null ? article.id:article.slug}" th:text="${article.name}"></a>
<a th:href="${setting.siteUrl} + '/s/'+${article.slug == null ? article.id:article.slug}" th:text="${article.name}"></a>
</h2>
<div class="new-meta-box">
<div class="new-meta-item author">
<a th:href="'/author/'+${article.username}" rel="nofollow">
<img th:src="'/s/view/thumbnail?id='+${article.avatar}">
<a th:href="${setting.siteUrl} + '/author/'+${article.username}" rel="nofollow">
<img th:src="'/api/public/s/view/thumbnail?id='+${article.avatar}">
<p th:text="${article.username}"></p>
</a>
</div>
Expand All @@ -32,7 +32,7 @@ <h2 class="title">
<div class="flex-text">
<span class="flex-text" th:each="categoryDO,categoryStat : ${article.categories}">
<span th:text="${categoryStat.index > 0?' , ':''}"></span>
<a th:href="'/categories/'+${categoryDO.slug}" th:text="${categoryDO.name}"></a>
<a th:href="${setting.siteUrl} + '/categories/'+${categoryDO.slug}" th:text="${categoryDO.name}"></a>
</span>
</div>
</div>
Expand All @@ -45,7 +45,7 @@ <h2 class="title">
<div class="flex-text">
<span class="flex-text" th:each="tag,tagStat : ${article.tags}">
<span th:text="${tagStat.index > 0?' , ':''}"></span>
<a th:href="'/tags/'+${tag.slug}" th:text="${tag.name}"></a>
<a th:href="${setting.siteUrl} + '/tags/'+${tag.slug}" th:text="${tag.name}"></a>
</span>
</div>
</div>
Expand All @@ -54,7 +54,7 @@ <h2 class="title">
</div>
</section>
<section class="article typo">
<a th:href="'/s/'+${article.slug == null ? article.id:article.slug}">
<a th:href="${setting.siteUrl} + '/s/'+${article.slug == null ? article.id:article.slug}">
<div class="article-entry" itemprop="articleBody">
<p>
<img class="blog-background articles-list" style="display: none"
Expand All @@ -81,7 +81,7 @@ <h2 class="title">

<i class="rainbow-page">
<i th:if="${articlesData.getCurrentPage() >= 5}">
<a data-pjax href="/articles" class="layui-laypage-first" title="首页">1</a>
<a data-pjax th:href="${setting.siteUrl}" class="layui-laypage-first" title="首页">1</a>
<span class="layui-laypage-spr"></span>
</i>
<i th:each="page : ${articlesData.rainbow()}">
Expand Down
5 changes: 3 additions & 2 deletions src/main/resources/templates/component/common-js.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
</script>
<script th:inline="javascript">
document.title = [[${titleName}]]
const commonSiteUrl = [[${setting.siteUrl}]]
$(function(){
// common.js
/***
Expand Down Expand Up @@ -54,7 +55,7 @@
link.type = 'text/css';
link.id = "theme-css-dark"; // 加上id方便后面好查找到进行删除
link.rel = 'stylesheet';
link.href = '/articles/css/dark/index-2.0.2.css';
link.href = commonSiteUrl + '/css/dark/index-2.0.2.css';
document.getElementsByTagName("head")[0].appendChild(link);
labelIcon.removeClass('fa-moon')
labelIcon.addClass('fa-sun')
Expand Down Expand Up @@ -136,4 +137,4 @@
}
});
</script>
</div>
</div>
2 changes: 1 addition & 1 deletion src/main/resources/templates/component/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<p><span th:text="${setting.copyright}"></span></p>
<p style="margin-top: 5px;">
<a href="http://beian.miit.gov.cn" target="_blank" th:text="${setting.recordPermissionNum}"></a>
<a target="_blank" style="margin-left: 5px;" th:href="'http://www.beian.gov.cn/portal/registerSystemInfo?recordcode='+${setting.networkRecordNumber}"><img th:if="${setting.isShowBeian()}" style="width: 15px;" src="/articles/img/beian.png" /><span th:text="${setting.networkRecordNumberStr}"></span></a>
<a target="_blank" style="margin-left: 5px;" th:href="'http://www.beian.gov.cn/portal/registerSystemInfo?recordcode='+${setting.networkRecordNumber}"><img th:if="${setting.isShowBeian()}" style="width: 15px;" th:src="${setting.siteUrl} + '/img/beian.png'" /><span th:text="${setting.networkRecordNumberStr}"></span></a>
</p>
</div>
</footer>
10 changes: 5 additions & 5 deletions src/main/resources/templates/component/head.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<link rel="shortcut icon" th:href="${setting.siteIco != null ? setting.siteIco : '/articles/favicon.ico'}" type="image/x-icon" />
<link rel="shortcut icon" th:href="${setting.siteIco != null ? setting.siteIco : setting.siteUrl + '/favicon.ico'}" type="image/x-icon" />
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge, chrome=1">
<meta name="renderer" content="webkit">
Expand All @@ -16,7 +16,7 @@
<meta name="author" th:content="${markdown != null ? markdown.username : ''}">
<meta name="promote_title" th:content="${titleName}"/>
<meta name="promote_image" th:content="${markdown != null && markdown.cover !=null ? markdown.cover : setting.backgroundSite}"/>
<link rel="stylesheet" type="text/css" href="/articles/font-awesome/free-6.4.2/css/all.min.css">
<link rel="stylesheet" type="text/css" href="/articles/css/light/index-2.0.2.css">
<link id="theme-css-dark" th:if="${darkTheme}" rel="stylesheet" type="text/css" href="/articles/css/dark/index-2.0.2.css">
<script src="/articles/js/font_2024484_qwtkvngfp5b.js" type="text/javascript"></script>
<link rel="stylesheet" type="text/css" th:href="${setting.siteUrl} + '/font-awesome/free-6.4.2/css/all.min.css'">
<link rel="stylesheet" type="text/css" th:href="${setting.siteUrl} + '/css/light/index-2.0.2.css'">
<link id="theme-css-dark" th:if="${darkTheme}" rel="stylesheet" type="text/css" th:href="${setting.siteUrl} + '/css/dark/index-2.0.2.css'">
<script th:src="${setting.siteUrl} + '/js/font_2024484_qwtkvngfp5b.js'" type="text/javascript"></script>
Loading

0 comments on commit b85ebb3

Please sign in to comment.