mirror of https://github.com/halo-dev/halo
Change ctx to context.
parent
18975dd7f7
commit
9e1edd26bc
|
@ -88,14 +88,14 @@ public class FreemarkerConfigAwareListener {
|
|||
|
||||
private void loadOptionsConfig() throws TemplateModelException {
|
||||
configuration.setSharedVariable("options", optionService.listOptions());
|
||||
configuration.setSharedVariable("ctx", optionService.getBlogBaseUrl());
|
||||
configuration.setSharedVariable("context", optionService.getBlogBaseUrl());
|
||||
log.debug("Loaded options");
|
||||
}
|
||||
|
||||
private void loadThemeConfig() throws TemplateModelException {
|
||||
ThemeProperty activatedTheme = themeService.getActivatedTheme();
|
||||
configuration.setSharedVariable("theme", activatedTheme);
|
||||
configuration.setSharedVariable("static", activatedTheme.getFolderName());
|
||||
configuration.setSharedVariable("static", optionService.getBlogBaseUrl() + "/" + activatedTheme.getFolderName());
|
||||
configuration.setSharedVariable("settings", themeSettingService.listAsMapBy(themeService.getActivatedThemeId()));
|
||||
log.debug("Loaded theme and settings");
|
||||
}
|
||||
|
|
|
@ -97,6 +97,15 @@ public interface PostService extends BasePostService<Post> {
|
|||
@NonNull
|
||||
List<ArchiveMonthVO> listMonthArchives();
|
||||
|
||||
/**
|
||||
* Import post from markdown document.
|
||||
*
|
||||
* @param markdown markdown document.
|
||||
* @return imported post
|
||||
*/
|
||||
@NonNull
|
||||
Post importMarkdown(@NonNull String markdown);
|
||||
|
||||
/**
|
||||
* Converts to detail vo.
|
||||
*
|
||||
|
|
|
@ -45,6 +45,15 @@ public interface SheetService extends BasePostService<Sheet> {
|
|||
@Override
|
||||
Sheet getBy(PostStatus status, String url);
|
||||
|
||||
/**
|
||||
* Import sheet from markdown document.
|
||||
*
|
||||
* @param markdown markdown document.
|
||||
* @return imported sheet
|
||||
*/
|
||||
@NonNull
|
||||
Sheet importMarkdown(@NonNull String markdown);
|
||||
|
||||
/**
|
||||
* Converts to list dto page.
|
||||
*
|
||||
|
@ -53,6 +62,4 @@ public interface SheetService extends BasePostService<Sheet> {
|
|||
*/
|
||||
@NonNull
|
||||
Page<SheetListVO> convertToListVo(@NonNull Page<Sheet> sheetPage);
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -26,6 +26,7 @@ import run.halo.app.model.vo.PostListVO;
|
|||
import run.halo.app.repository.PostRepository;
|
||||
import run.halo.app.service.*;
|
||||
import run.halo.app.utils.DateUtils;
|
||||
import run.halo.app.utils.MarkdownUtils;
|
||||
import run.halo.app.utils.ServiceUtils;
|
||||
|
||||
import javax.persistence.criteria.Predicate;
|
||||
|
@ -272,6 +273,19 @@ public class PostServiceImpl extends BasePostServiceImpl<Post> implements PostSe
|
|||
return archives;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Post importMarkdown(String markdown) {
|
||||
Assert.notNull(markdown, "Markdown document must not be null");
|
||||
|
||||
// Render markdown to html document.
|
||||
String content = MarkdownUtils.renderMarkdown(markdown);
|
||||
|
||||
// Gets frontMatter
|
||||
Map<String, List<String>> frontMatter = MarkdownUtils.getFrontMatter(markdown);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PostDetailVO convertToDetailVo(Post post) {
|
||||
return convertTo(post,
|
||||
|
|
|
@ -15,6 +15,7 @@ import run.halo.app.repository.SheetRepository;
|
|||
import run.halo.app.service.OptionService;
|
||||
import run.halo.app.service.SheetCommentService;
|
||||
import run.halo.app.service.SheetService;
|
||||
import run.halo.app.utils.MarkdownUtils;
|
||||
import run.halo.app.utils.ServiceUtils;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -94,6 +95,19 @@ public class SheetServiceImpl extends BasePostServiceImpl<Sheet> implements Shee
|
|||
return sheet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sheet importMarkdown(String markdown) {
|
||||
Assert.notNull(markdown, "Markdown document must not be null");
|
||||
|
||||
// Render markdown to html document.
|
||||
String content = MarkdownUtils.renderMarkdown(markdown);
|
||||
|
||||
// Gets frontMatter
|
||||
Map<String, List<String>> frontMatter = MarkdownUtils.getFrontMatter(markdown);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Sheet removeById(Integer id) {
|
||||
Sheet sheet = super.removeById(id);
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
<#list archive.posts?sort_by("createTime")?reverse as post>
|
||||
<div class="listing-item">
|
||||
<div class="listing-post">
|
||||
<a href="${ctx!}/archives/${post.url!}" title="${post.title!}">${post.title!}</a>
|
||||
<a href="${context!}/archives/${post.url!}" title="${post.title!}">${post.title!}</a>
|
||||
<div class="post-time">
|
||||
<span class="date">${post.createTime?string("yyyy-MM-dd")}</span>
|
||||
</div>
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
<#if posts.hasPrevious()>
|
||||
<#if posts.number == 1>
|
||||
<li class="pre pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/">上一页</a>
|
||||
<a class="btn" role="navigation" href="${context!}/">上一页</a>
|
||||
</li>
|
||||
<#else >
|
||||
<li class="pre pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/page/${posts.number}">上一页</a>
|
||||
<a class="btn" role="navigation" href="${context!}/page/${posts.number}">上一页</a>
|
||||
</li>
|
||||
</#if>
|
||||
</#if>
|
||||
<#if posts.hasNext()>
|
||||
<li class="next pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/page/${posts.number+2}">下一页</a>
|
||||
<a class="btn" role="navigation" href="${context!}/page/${posts.number+2}">下一页</a>
|
||||
</li>
|
||||
</#if>
|
||||
</ul>
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
<#if posts.hasPrevious()>
|
||||
<#if posts.number == 1>
|
||||
<li class="pre pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/">上一页</a>
|
||||
<a class="btn" role="navigation" href="${context!}/">上一页</a>
|
||||
</li>
|
||||
<#else >
|
||||
<li class="pre pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/page/${posts.number}">上一页</a>
|
||||
<a class="btn" role="navigation" href="${context!}/page/${posts.number}">上一页</a>
|
||||
</li>
|
||||
</#if>
|
||||
</#if>
|
||||
<#if posts.hasNext()>
|
||||
<li class="next pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/page/${posts.number+2}">下一页</a>
|
||||
<a class="btn" role="navigation" href="${context!}/page/${posts.number+2}">下一页</a>
|
||||
</li>
|
||||
</#if>
|
||||
</ul>
|
||||
|
|
|
@ -16,9 +16,9 @@
|
|||
<meta name="description" content="${description!}" />
|
||||
<@verification />
|
||||
<@favicon />
|
||||
<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" />
|
||||
<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" />
|
||||
<link rel="alternate" type="application/rss+xml" title="atom 1.0" href="/atom.xml">
|
||||
<style>
|
||||
<#if !settings.post_title_uppper!true>
|
||||
|
@ -48,7 +48,7 @@
|
|||
<body>
|
||||
</#macro>
|
||||
<#macro footer>
|
||||
<script type="text/javascript" src="/${static!}/source/js/jquery.min.js"></script>
|
||||
<script type="text/javascript" src="${static!}/source/js/jquery.min.js"></script>
|
||||
<script type="text/javascript">
|
||||
var url = location.href;
|
||||
var urlstatus = false;
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
</li>
|
||||
</div>
|
||||
<div class="avatar">
|
||||
<img src="${settings.icon!'/${static!}/source/images/logo.png'}" />
|
||||
<img src="${settings.icon!'${static!}/source/images/logo.png'}" />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<div class="post animated fadeInDown">
|
||||
<div class="post-title">
|
||||
<h3>
|
||||
<a href="${ctx!}/archives/${post.url}">${post.title}</a>
|
||||
<a href="${context!}/archives/${post.url}">${post.title}</a>
|
||||
</h3>
|
||||
</div>
|
||||
<div class="post-content">
|
||||
|
@ -19,11 +19,11 @@
|
|||
<i class="fa fa-sun-o"></i>
|
||||
<span class="date">${post.createTime?string("yyyy-MM-dd")}</span>
|
||||
<i class="fa fa-comment-o"></i>
|
||||
<a href="${ctx!}/archives/${post.url}#comment_widget">Comments</a>
|
||||
<a href="${context!}/archives/${post.url}#comment_widget">Comments</a>
|
||||
<#if post.tags?size gt 0>
|
||||
<i class="fa fa-tag"></i>
|
||||
<#list post.tags as tag>
|
||||
<a href="${ctx!}/tags/${tag.slugName}" class="tag"> ${tag.name}</a>
|
||||
<a href="${context!}/tags/${tag.slugName}" class="tag"> ${tag.name}</a>
|
||||
</#list>
|
||||
</#if>
|
||||
</div>
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
<div class="sidebar animated fadeInDown">
|
||||
<div class="logo-title">
|
||||
<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>" />
|
||||
<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="${ctx!}">${options.blog_title!'Anatole'}</a>
|
||||
<a href="${context!}">${options.blog_title!'Anatole'}</a>
|
||||
</h3>
|
||||
<div class="description">
|
||||
<#if settings.hitokoto!false>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
<#if settings.rss!true>
|
||||
<li>
|
||||
<a target="_blank" href="${ctx!}/atom.xml">
|
||||
<a target="_blank" href="${context!}/atom.xml">
|
||||
<i class="fa fa-rss"></i>
|
||||
</a>
|
||||
</li>
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<meta charset="utf-8" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<link rel="stylesheet" href="${static!}/source/plugins/gallery/css/main.css" />
|
||||
<noscript><link rel="stylesheet" href="/${static!}/plugins/gallery/css/noscript.css" /></noscript>
|
||||
<noscript><link rel="stylesheet" href="${static!}/plugins/gallery/css/noscript.css" /></noscript>
|
||||
</head>
|
||||
<body class="is-loading-0 is-loading-1 is-loading-2">
|
||||
<div id="main">
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<@head title="${post.title!} · ${options.blog_title!'Anatole'}" keywords="${post.title!},${options.seo_keywords!'Anatole'},${tagWords!}" description="${post.summary!'Anatole'}"></@head>
|
||||
<#include "module/sidebar.ftl">
|
||||
<div class="main">
|
||||
<link href="/${static!}/source/plugins/prism/prism.css" type="text/css" rel="stylesheet" />
|
||||
<link href="${static!}/source/plugins/prism/prism.css" type="text/css" rel="stylesheet" />
|
||||
<style>
|
||||
code, tt {
|
||||
font-size: 1.2em;
|
||||
|
@ -52,11 +52,11 @@
|
|||
<i class="fa fa-sun-o"></i>
|
||||
<span class="date">${post.createTime?string("yyyy-MM-dd")}</span>
|
||||
<i class="fa fa-comment-o"></i>
|
||||
<a href="${ctx!}/archives/${post.url}#comment_widget">Comments</a>
|
||||
<a href="${context!}/archives/${post.url}#comment_widget">Comments</a>
|
||||
<#if tags?size gt 0>
|
||||
<i class="fa fa-tag"></i>
|
||||
<#list tags as tag>
|
||||
<a href="${ctx!}/tags/${tag.slugName}" class="tag"> ${tag.name}</a>
|
||||
<a href="${context!}/tags/${tag.slugName}" class="tag"> ${tag.name}</a>
|
||||
</#list>
|
||||
</#if>
|
||||
</div>
|
||||
|
@ -73,7 +73,7 @@
|
|||
class="fa fa-weibo"></a>
|
||||
</div>
|
||||
<div class="twitter">
|
||||
<a href="http://twitter.com/home?status=${ctx!}/archives/${post.url} ,${options.blog_title!},${post.title},;"
|
||||
<a href="http://twitter.com/home?status=${context!}/archives/${post.url} ,${options.blog_title!},${post.title},;"
|
||||
class="fa fa-twitter"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -81,12 +81,12 @@
|
|||
<ul class="clearfix">
|
||||
<#if nextPost??>
|
||||
<li class="next pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/archives/${nextPost.url}" title="${nextPost.title}">下一篇</a>
|
||||
<a class="btn" role="navigation" href="${context!}/archives/${nextPost.url}" title="${nextPost.title}">下一篇</a>
|
||||
</li>
|
||||
</#if>
|
||||
<#if prePost??>
|
||||
<li class="pre pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/archives/${prePost.url}" title="${prePost.title}">上一篇</a>
|
||||
<a class="btn" role="navigation" href="${context!}/archives/${prePost.url}" title="${prePost.title}">上一篇</a>
|
||||
</li>
|
||||
</#if>
|
||||
</ul>
|
||||
|
@ -99,5 +99,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="/${static!}/source/plugins/prism/prism.js"></script>
|
||||
<script type="text/javascript" src="${static!}/source/plugins/prism/prism.js"></script>
|
||||
<@footer></@footer>
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
<@head title="${post.title!} · ${options.blog_title!'Anatole'}" keywords="${post.title!},${options.seo_keywords!'Anatole'}" description="${post.summary!'Anatole'}"></@head>
|
||||
<#include "module/sidebar.ftl">
|
||||
<div class="main">
|
||||
<link href="/${static!}/source/plugins/prism/prism.css" type="text/css" rel="stylesheet" />
|
||||
<link href="${static!}/source/plugins/prism/prism.css" type="text/css" rel="stylesheet" />
|
||||
<style>
|
||||
code, tt {
|
||||
font-size: 1.2em;
|
||||
|
@ -52,7 +52,7 @@
|
|||
<i class="fa fa-sun-o"></i>
|
||||
<span class="date">${post.createTime?string("yyyy-MM-dd")}</span>
|
||||
<i class="fa fa-comment-o"></i>
|
||||
<a href="${ctx!}/archives/${post.url!}#comment_widget">Comments</a>
|
||||
<a href="${context!}/archives/${post.url!}#comment_widget">Comments</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -67,7 +67,7 @@
|
|||
class="fa fa-weibo"></a>
|
||||
</div>
|
||||
<div class="twitter">
|
||||
<a href="http://twitter.com/home?status=${ctx!}/archives/${post.url!} ,${options.blog_title!},${post.title!},;"
|
||||
<a href="http://twitter.com/home?status=${context!}/archives/${post.url!} ,${options.blog_title!},${post.title!},;"
|
||||
class="fa fa-twitter"></a>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -79,5 +79,5 @@
|
|||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript" src="/${static!}/source/plugins/prism/prism.js"></script>
|
||||
<script type="text/javascript" src="${static!}/source/plugins/prism/prism.js"></script>
|
||||
<@footer></@footer>
|
||||
|
|
|
@ -12,17 +12,17 @@
|
|||
<#if posts.hasPrevious()>
|
||||
<#if posts.number == 1>
|
||||
<li class="pre pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/">上一页</a>
|
||||
<a class="btn" role="navigation" href="${context!}/">上一页</a>
|
||||
</li>
|
||||
<#else >
|
||||
<li class="pre pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/page/${posts.number}">上一页</a>
|
||||
<a class="btn" role="navigation" href="${context!}/page/${posts.number}">上一页</a>
|
||||
</li>
|
||||
</#if>
|
||||
</#if>
|
||||
<#if posts.hasNext()>
|
||||
<li class="next pagbuttons">
|
||||
<a class="btn" role="navigation" href="${ctx!}/page/${posts.number+2}">下一页</a>
|
||||
<a class="btn" role="navigation" href="${context!}/page/${posts.number+2}">下一页</a>
|
||||
</li>
|
||||
</#if>
|
||||
</ul>
|
||||
|
|
Loading…
Reference in New Issue