mirror of https://github.com/halo-dev/halo
pref: remove cdn_domain option.
parent
04512db9ba
commit
b9e64cbb82
|
@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.*;
|
|||
import run.halo.app.cache.StringCacheStore;
|
||||
import run.halo.app.cache.lock.CacheLock;
|
||||
import run.halo.app.exception.ForbiddenException;
|
||||
import run.halo.app.exception.NotFoundException;
|
||||
import run.halo.app.model.entity.Category;
|
||||
import run.halo.app.model.entity.Post;
|
||||
import run.halo.app.model.entity.PostMeta;
|
||||
|
|
|
@ -12,7 +12,6 @@ import run.halo.app.event.options.OptionUpdatedEvent;
|
|||
import run.halo.app.event.theme.ThemeActivatedEvent;
|
||||
import run.halo.app.event.user.UserUpdatedEvent;
|
||||
import run.halo.app.handler.theme.config.support.ThemeProperty;
|
||||
import run.halo.app.model.properties.OtherProperties;
|
||||
import run.halo.app.model.support.HaloConst;
|
||||
import run.halo.app.service.OptionService;
|
||||
import run.halo.app.service.ThemeService;
|
||||
|
@ -99,8 +98,7 @@ public class FreemarkerConfigAwareListener {
|
|||
private void loadThemeConfig() throws TemplateModelException {
|
||||
ThemeProperty activatedTheme = themeService.getActivatedTheme();
|
||||
configuration.setSharedVariable("theme", activatedTheme);
|
||||
String baseUrl = optionService.getByPropertyOrDefault(OtherProperties.CDN_DOMAIN, String.class, optionService.getBlogBaseUrl());
|
||||
configuration.setSharedVariable("static", baseUrl + "/" + activatedTheme.getFolderName());
|
||||
configuration.setSharedVariable("static", optionService.getBlogBaseUrl() + "/" + activatedTheme.getFolderName());
|
||||
configuration.setSharedVariable("settings", themeSettingService.listAsMapBy(themeService.getActivatedThemeId()));
|
||||
log.debug("Loaded theme and settings");
|
||||
}
|
||||
|
|
|
@ -5,14 +5,23 @@ package run.halo.app.model.properties;
|
|||
*
|
||||
* @author johnniang
|
||||
* @author ryanwang
|
||||
* @date 4/1/19
|
||||
* @date 2019-04-01
|
||||
*/
|
||||
public enum OtherProperties implements PropertyEnum {
|
||||
|
||||
CDN_DOMAIN("blog_cdn_domain", String.class, ""),
|
||||
|
||||
/**
|
||||
* Global custom head.
|
||||
*/
|
||||
CUSTOM_HEAD("blog_custom_head", String.class, ""),
|
||||
|
||||
/**
|
||||
* Content page(post,sheet) custom head.
|
||||
*/
|
||||
CUSTOM_CONTENT_HEAD("blog_custom_content_head", String.class, ""),
|
||||
|
||||
/**
|
||||
* Statistics platform code,such as Google Analytics.
|
||||
*/
|
||||
STATISTICS_CODE("blog_statistics_code", String.class, "");
|
||||
|
||||
private final String value;
|
||||
|
|
|
@ -5,8 +5,6 @@ import cn.hutool.core.text.StrBuilder;
|
|||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.data.domain.Page;
|
||||
import org.springframework.data.domain.Pageable;
|
||||
|
@ -28,7 +26,6 @@ import run.halo.app.model.entity.*;
|
|||
import run.halo.app.model.enums.LogType;
|
||||
import run.halo.app.model.enums.PostStatus;
|
||||
import run.halo.app.model.params.PostQuery;
|
||||
import run.halo.app.model.properties.OtherProperties;
|
||||
import run.halo.app.model.vo.ArchiveMonthVO;
|
||||
import run.halo.app.model.vo.ArchiveYearVO;
|
||||
import run.halo.app.model.vo.PostDetailVO;
|
||||
|
@ -454,9 +451,6 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
// Get post meta list map
|
||||
Map<Integer, List<PostMeta>> postMetaListMap = postMetaService.listPostMetaAsMap(postIds);
|
||||
|
||||
// Get cdn domain
|
||||
String cdnDomain = optionService.getByPropertyOrDefault(OtherProperties.CDN_DOMAIN, String.class, StringUtils.EMPTY);
|
||||
|
||||
String blogUrl = optionService.getBlogBaseUrl();
|
||||
|
||||
return postPage.map(post -> {
|
||||
|
@ -495,10 +489,6 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
// Set comment count
|
||||
postListVO.setCommentCount(commentCountMap.getOrDefault(post.getId(), 0L));
|
||||
|
||||
if (StringUtils.isNotEmpty(cdnDomain) && StringUtils.isNotEmpty(postListVO.getThumbnail())) {
|
||||
postListVO.setThumbnail(postListVO.getThumbnail().replace(blogUrl, cdnDomain));
|
||||
}
|
||||
|
||||
return postListVO;
|
||||
});
|
||||
}
|
||||
|
@ -559,21 +549,6 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
postDetailVO.setPostMetaIds(postMetaIds);
|
||||
postDetailVO.setPostMetas(postMetaService.convertTo(postMetaList));
|
||||
|
||||
// Get cdn domain
|
||||
String cdnDomain = optionService.getByPropertyOrDefault(OtherProperties.CDN_DOMAIN, String.class, StringUtils.EMPTY);
|
||||
String blogUrl = optionService.getBlogBaseUrl();
|
||||
|
||||
if (StringUtils.isNotEmpty(cdnDomain) && StringUtils.isNotEmpty(postDetailVO.getThumbnail())) {
|
||||
postDetailVO.setThumbnail(postDetailVO.getThumbnail().replace(blogUrl, cdnDomain));
|
||||
}
|
||||
|
||||
Document document = Jsoup.parse(postDetailVO.getFormatContent());
|
||||
document.select("img").forEach(img -> {
|
||||
String src = img.attr("src");
|
||||
img.attr("src", src.replace(blogUrl, cdnDomain));
|
||||
});
|
||||
|
||||
postDetailVO.setFormatContent(document.html());
|
||||
return postDetailVO;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
<#ftl strip_whitespace=true>
|
||||
|
||||
<#-- 统计代码 -->
|
||||
<#-- statistics_code -->
|
||||
<#macro statistics>
|
||||
${options.blog_statistics_code!}
|
||||
</#macro>
|
||||
|
||||
<#-- 页脚信息 -->
|
||||
<#-- footer info -->
|
||||
<#macro footer_info>
|
||||
${options.blog_footer_info!}
|
||||
</#macro>
|
||||
|
@ -14,19 +14,20 @@
|
|||
${options.blog_custom_head!}
|
||||
</#macro>
|
||||
|
||||
<#-- Favicon -->
|
||||
<#macro custom_content_head>
|
||||
<#if is_post?? || is_sheet??>
|
||||
${options.blog_custom_content_head!}
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#-- favicon -->
|
||||
<#macro favicon>
|
||||
<#if options.blog_favicon?? && options.blog_favicon!=''>
|
||||
<link rel="shortcut icon" type="images/x-icon" href="${options.blog_favicon!}">
|
||||
</#if>
|
||||
</#macro>
|
||||
|
||||
<#-- 站点验证代码,已废弃 -->
|
||||
<#macro verification>
|
||||
|
||||
</#macro>
|
||||
|
||||
<#-- 时间格式化 几...前 -->
|
||||
<#-- time ago -->
|
||||
<#macro timeline datetime=.now>
|
||||
<#assign ct = (.now?long-datetime?long)/1000>
|
||||
<#if ct gte 31104000>${(ct/31104000)?int} 年前
|
||||
|
@ -46,9 +47,9 @@
|
|||
<meta name="robots" content="none">
|
||||
</#if>
|
||||
<meta name="generator" content="Halo ${version!}"/>
|
||||
<@custom_head />
|
||||
<@verification />
|
||||
<@favicon />
|
||||
<@custom_head />
|
||||
<@custom_content_head />
|
||||
</#macro>
|
||||
|
||||
<#-- global footer -->
|
||||
|
@ -57,11 +58,11 @@
|
|||
<@statistics />
|
||||
</#macro>
|
||||
|
||||
<#-- post comment module -->
|
||||
<#macro comment post,type>
|
||||
<#-- comment module -->
|
||||
<#macro comment target,type>
|
||||
<#if !post.disallowComment!false>
|
||||
<script src="//cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.min.js"></script>
|
||||
<script src="${options.comment_internal_plugin_js!'//cdn.jsdelivr.net/gh/halo-dev/halo-comment@latest/dist/halo-comment.min.js'}"></script>
|
||||
<halo-comment id="${post.id}" type="${type}"/>
|
||||
<halo-comment id="${target.id}" type="${type}"/>
|
||||
</#if>
|
||||
</#macro>
|
|
@ -1,5 +1,5 @@
|
|||
<#include "module/macro.ftl">
|
||||
<@head title="归档 · ${options.blog_title!'Anatole'}" keywords="文章归档,${options.seo_keywords!'Anatole'}" description="${options.seo_description!'Anatole'}"></@head>
|
||||
<@head title="归档 · ${options.blog_title!}" keywords="${options.seo_keywords!}" description="${options.seo_description!}" />
|
||||
<#include "module/sidebar.ftl">
|
||||
<div class="main">
|
||||
<#include "module/page-top.ftl">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<#include "module/macro.ftl">
|
||||
<@head title="分类:${category.name} · ${options.blog_title!'Anatole'}" keywords="${options.seo_keywords!'Anatole'}" description="${options.seo_description!'Anatole'}"></@head>
|
||||
<@head title="分类:${category.name} · ${options.blog_title!}" keywords="${options.seo_keywords!}" description="${options.seo_description!}" />
|
||||
<#include "module/sidebar.ftl">
|
||||
<div class="main">
|
||||
<#include "module/page-top.ftl">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<#include "module/macro.ftl">
|
||||
<@head title="${options.blog_title!'Anatole'}" keywords="${options.seo_keywords!'Anatole'}" description="${options.seo_description!'Anatole'}"></@head>
|
||||
<@head title="${options.blog_title!}" keywords="${options.seo_keywords!}" description="${options.seo_description!}" />
|
||||
<#include "module/sidebar.ftl">
|
||||
<div class="main">
|
||||
<#include "module/page-top.ftl">
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<#include "module/macro.ftl">
|
||||
<@head title="友情链接 · ${options.blog_title!'Anatole'}" keywords="${options.seo_keywords!'Anatole'}" description="${options.seo_description!'Anatole'}"></@head>
|
||||
<@head title="友情链接 · ${options.blog_title!}" keywords="${options.seo_keywords!}" description="${options.seo_description!}" />
|
||||
<#include "module/sidebar.ftl">
|
||||
<div class="main">
|
||||
<#include "module/page-top.ftl">
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<#import "/common/macro/common_macro.ftl" as common>
|
||||
<#macro head title,keywords,description>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
@ -14,10 +13,43 @@
|
|||
<meta name="author" content="${user.nickname!}" />
|
||||
<meta name="keywords" content="${keywords!}"/>
|
||||
<meta name="description" content="${description!}" />
|
||||
<@common.globalHeader />
|
||||
<@global.head />
|
||||
<link href="${static!}/source/css/font-awesome.min.css" type="text/css" rel="stylesheet"/>
|
||||
<link rel="stylesheet" href="${static!}/source/css/blog_basic.min.css?version=88107691fe">
|
||||
<link href="${static!}/source/css/style.min.css" type="text/css" rel="stylesheet" />
|
||||
|
||||
<#if is_post?? || is_sheet??>
|
||||
<link href="${static!}/source/plugins/prism/css/prism-${settings.code_pretty!'Default'}.css" type="text/css" rel="stylesheet" />
|
||||
<script type="text/javascript" src="${static!}/source/plugins/prism/js/prism.js"></script>
|
||||
<style>
|
||||
table {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
margin-top: 0;
|
||||
margin-bottom: 16px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
|
||||
}
|
||||
table th {
|
||||
font-weight: 600;
|
||||
}
|
||||
table th,
|
||||
table td {
|
||||
padding: 6px 13px;
|
||||
border: 1px solid #dfe2e5;
|
||||
}
|
||||
table tr {
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #c6cbd1;
|
||||
}
|
||||
table tr:nth-child(2n) {
|
||||
background-color: #f6f8fa;
|
||||
}
|
||||
</style>
|
||||
</#if>
|
||||
|
||||
<link rel="alternate" type="application/rss+xml" title="atom 1.0" href="/atom.xml">
|
||||
<style>
|
||||
<#if !settings.post_title_uppper!true>
|
||||
|
@ -76,7 +108,7 @@
|
|||
xhr.send();
|
||||
</#if>
|
||||
</script>
|
||||
<@common.statistics />
|
||||
<@global.statistics />
|
||||
</body>
|
||||
</html>
|
||||
</#macro>
|
||||
|
|
|
@ -3,13 +3,13 @@
|
|||
<div class="title">
|
||||
<img src="${options.blog_logo!'${static!}/source/images/logo@2x.png'}" style="width:127px;<#if settings.avatar_circle!false>border-radius:50%</#if>" />
|
||||
<h3 title="">
|
||||
<a href="${context!}">${options.blog_title!'Anatole'}</a>
|
||||
<a href="${context!}">${options.blog_title!}</a>
|
||||
</h3>
|
||||
<div class="description">
|
||||
<#if settings.hitokoto!false>
|
||||
<p id="yiyan">获取中...</p>
|
||||
<#else >
|
||||
<p>${user.description!'A other Halo theme'}</p>
|
||||
<p>${user.description!}</p>
|
||||
</#if>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -24,7 +24,7 @@
|
|||
<a href="https://github.com/halo-dev/halo" target="_blank">Proudly published with Halo!</a>
|
||||
</div>
|
||||
<div class="footer_text">
|
||||
<@common.footer_info />
|
||||
<@global.footer_info />
|
||||
</div>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
<#include "/common/macro/common_macro.ftl">
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
|
@ -44,6 +43,6 @@
|
|||
<script src="${static!}/source/plugins/gallery/js/jquery.min.js"></script>
|
||||
<script src="${static!}/source/plugins/gallery/js/skel.min.js"></script>
|
||||
<script src="${static!}/source/plugins/gallery/js/main.js"></script>
|
||||
<@statistics></@statistics>
|
||||
<@global.statistics />
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1,35 +1,7 @@
|
|||
<#include "module/macro.ftl">
|
||||
<@head title="${post.title!} · ${options.blog_title!'Anatole'}" keywords="${post.title!},${options.seo_keywords!'Anatole'},${tagWords!}" description="${post.summary!'Anatole'}"></@head>
|
||||
<@head title="${post.title!} · ${options.blog_title!}" keywords="${post.title!},${options.seo_keywords!},${tagWords!}" description="${post.summary!}" />
|
||||
<#include "module/sidebar.ftl">
|
||||
<div class="main">
|
||||
<link href="${static!}/source/plugins/prism/css/prism-${settings.code_pretty!'Default'}.css" type="text/css" rel="stylesheet" />
|
||||
<style>
|
||||
table {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
margin-top: 0;
|
||||
margin-bottom: 16px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
|
||||
}
|
||||
table th {
|
||||
font-weight: 600;
|
||||
}
|
||||
table th,
|
||||
table td {
|
||||
padding: 6px 13px;
|
||||
border: 1px solid #dfe2e5;
|
||||
}
|
||||
table tr {
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #c6cbd1;
|
||||
}
|
||||
table tr:nth-child(2n) {
|
||||
background-color: #f6f8fa;
|
||||
}
|
||||
</style>
|
||||
<#include "module/page-top.ftl">
|
||||
<div class="autopagerize_page_element">
|
||||
<div class="content">
|
||||
|
@ -96,5 +68,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="${static!}/source/plugins/prism/js/prism.js"></script>
|
||||
<@footer></@footer>
|
||||
|
|
|
@ -1,35 +1,7 @@
|
|||
<#include "module/macro.ftl">
|
||||
<@head title="${post.title!} · ${options.blog_title!'Anatole'}" keywords="${post.title!},${options.seo_keywords!'Anatole'}" description="${post.summary!'Anatole'}"></@head>
|
||||
<@head title="${sheet.title!} · ${options.blog_title!}" keywords="${sheet.title!},${options.seo_keywords!}" description="${sheet.summary!}" />
|
||||
<#include "module/sidebar.ftl">
|
||||
<div class="main">
|
||||
<link href="${static!}/source/plugins/prism/css/prism-${settings.code_pretty!'Default'}.css" type="text/css" rel="stylesheet" />
|
||||
<style>
|
||||
table {
|
||||
border-spacing: 0;
|
||||
border-collapse: collapse;
|
||||
margin-top: 0;
|
||||
margin-bottom: 16px;
|
||||
display: block;
|
||||
width: 100%;
|
||||
overflow: auto;
|
||||
|
||||
}
|
||||
table th {
|
||||
font-weight: 600;
|
||||
}
|
||||
table th,
|
||||
table td {
|
||||
padding: 6px 13px;
|
||||
border: 1px solid #dfe2e5;
|
||||
}
|
||||
table tr {
|
||||
background-color: #fff;
|
||||
border-top: 1px solid #c6cbd1;
|
||||
}
|
||||
table tr:nth-child(2n) {
|
||||
background-color: #f6f8fa;
|
||||
}
|
||||
</style>
|
||||
<#include "module/page-top.ftl">
|
||||
<div class="autopagerize_page_element">
|
||||
<div class="content">
|
||||
|
@ -37,19 +9,19 @@
|
|||
<div class="post animated fadeInDown">
|
||||
<div class="post-title">
|
||||
<h3>
|
||||
<a>${post.title!}</a>
|
||||
<a>${sheet.title!}</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="post-content">
|
||||
${post.formatContent!}
|
||||
${sheet.formatContent!}
|
||||
</div>
|
||||
<div class="post-footer">
|
||||
<div class="meta">
|
||||
<div class="info">
|
||||
<i class="fa fa-sun-o"></i>
|
||||
<span class="date">${post.createTime?string("yyyy-MM-dd")}</span>
|
||||
<span class="date">${sheet.createTime?string("yyyy-MM-dd")}</span>
|
||||
<i class="fa fa-comment-o"></i>
|
||||
<a href="${context!}/archives/${post.url!}#comment_widget">Comments</a>
|
||||
<a href="${context!}/archives/${sheet.url!}#comment_widget">Comments</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -64,7 +36,7 @@
|
|||
class="fa fa-weibo"></a>
|
||||
</div>
|
||||
<div class="twitter">
|
||||
<a href="http://twitter.com/home?status=${context!}/archives/${post.url!} ,${options.blog_title!},${post.title!},;"
|
||||
<a href="http://twitter.com/home?status=${context!}/archives/${sheet.url!} ,${options.blog_title!},${sheet.title!},;"
|
||||
class="fa fa-twitter"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -76,5 +48,4 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="${static!}/source/plugins/prism/js/prism.js"></script>
|
||||
<@footer></@footer>
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
<#include "module/macro.ftl">
|
||||
<@head title="标签:${tag.name} · ${options.blog_title!'Anatole'}" keywords="${options.seo_keywords!'Anatole'}" description="${options.seo_description!'Anatole'}"></@head>
|
||||
<@head title="标签:${tag.name} · ${options.blog_title!}" keywords="${options.seo_keywords!}" description="${options.seo_description!}" />
|
||||
<#include "module/sidebar.ftl">
|
||||
<div class="main">
|
||||
<#include "module/page-top.ftl">
|
||||
|
|
Loading…
Reference in New Issue