parent
2749754eb0
commit
7e17d02726
16 changed files with 756 additions and 503 deletions
@ -0,0 +1,41 @@ |
|||||||
|
package cc.bnblogs.utils; |
||||||
|
|
||||||
|
import javax.servlet.http.Cookie; |
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author zfp@bnblogs.cc |
||||||
|
* @createTime: 2022/10/21 |
||||||
|
* @desciption: cookie工具类 |
||||||
|
*/ |
||||||
|
public class CookieUtil { |
||||||
|
public static String getCookie(HttpServletRequest request, String cookieName) { |
||||||
|
|
||||||
|
Cookie[] cookies = request.getCookies(); |
||||||
|
if (cookies != null) { |
||||||
|
for (Cookie cookie : cookies) { |
||||||
|
if (cookie.getName().equals(cookieName)) { |
||||||
|
return cookie.getValue(); |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
public static void setCookie(HttpServletResponse response, String cookieName, String value, int cookieMaxAge) { |
||||||
|
Cookie cookie = new Cookie(cookieName, value); |
||||||
|
cookie.setPath("/"); |
||||||
|
cookie.setMaxAge(cookieMaxAge); |
||||||
|
response.addCookie(cookie); |
||||||
|
} |
||||||
|
|
||||||
|
public static void setCookie(HttpServletResponse response, String cookieName, String value) { |
||||||
|
// 有效期为7天
|
||||||
|
setCookie(response, cookieName, value, 7 * 24 * 60 * 60); |
||||||
|
} |
||||||
|
|
||||||
|
public static void deleteCookie(HttpServletResponse response, String cookieName) { |
||||||
|
setCookie(response, cookieName, null, 0); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,45 @@ |
|||||||
|
package cc.bnblogs.utils; |
||||||
|
|
||||||
|
import org.commonmark.Extension; |
||||||
|
import org.commonmark.ext.gfm.tables.TablesExtension; |
||||||
|
import org.commonmark.node.Heading; |
||||||
|
import org.commonmark.node.Link; |
||||||
|
import org.commonmark.node.Node; |
||||||
|
import org.commonmark.parser.Parser; |
||||||
|
import org.commonmark.renderer.html.HtmlRenderer; |
||||||
|
|
||||||
|
import java.util.Collections; |
||||||
|
import java.util.List; |
||||||
|
import java.util.UUID; |
||||||
|
|
||||||
|
/** |
||||||
|
* @author zfp@bnblogs.cc |
||||||
|
* @createTime: 2022/10/21 |
||||||
|
*/ |
||||||
|
public interface MarkdownUtil { |
||||||
|
Parser PARSER = Parser.builder().build(); |
||||||
|
// 引入表格支持插件
|
||||||
|
List<Extension> EXTENSIONS = Collections.singletonList(TablesExtension.create()); |
||||||
|
HtmlRenderer RENDERER = HtmlRenderer.builder() |
||||||
|
.extensions(EXTENSIONS) |
||||||
|
.attributeProviderFactory(attributeProviderContext -> (node, tagName, attributes) -> { |
||||||
|
if (node instanceof Link) { |
||||||
|
attributes.put("target", "_blank");// 链接都在新标签页中打开
|
||||||
|
} |
||||||
|
if (node instanceof Heading) { |
||||||
|
attributes.put("id", UUID.randomUUID().toString().replace("-", "")); |
||||||
|
attributes.put("class", "title-toc"); // 生成目录
|
||||||
|
} |
||||||
|
}).build(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 解析markdown为html |
||||||
|
* |
||||||
|
* @param markdownStr markdown源文件 |
||||||
|
* @return 对应的html格式 |
||||||
|
*/ |
||||||
|
static String parse(String markdownStr) { |
||||||
|
Node document = PARSER.parse(markdownStr); |
||||||
|
return RENDERER.render(document); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,309 @@ |
|||||||
|
.fw-tool-bar { |
||||||
|
padding: 10px; |
||||||
|
position: relative; |
||||||
|
background-color: #21252B; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-tool-bar.fullScreen { |
||||||
|
position: fixed; |
||||||
|
top: 0; |
||||||
|
left: 0; |
||||||
|
width: 100vw; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-tool-bar .fw-tool-item { |
||||||
|
display: inline-block; |
||||||
|
width: 32px; |
||||||
|
height: 32px; |
||||||
|
border-radius: 3px; |
||||||
|
line-height: 32px; |
||||||
|
text-align: center; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-tool-bar .fw-tool-item:hover { |
||||||
|
background-color: #43454B; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-tool-bar svg { |
||||||
|
height: 18px; |
||||||
|
width: 18px; |
||||||
|
display: inline-block; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-tool-bar .fw-menu-headline { |
||||||
|
position: relative; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-tool-bar .fw-menu-headlist { |
||||||
|
z-index: 9999; |
||||||
|
position: absolute; |
||||||
|
list-style: none; |
||||||
|
background-color: #353B45; |
||||||
|
color: #fff; |
||||||
|
padding: 5px 0; |
||||||
|
top: 20px; |
||||||
|
left: -12px; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-tool-bar .fw-menu-headlist li { |
||||||
|
padding: 5px 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-tool-bar .fw-menu-headlist li:hover { |
||||||
|
background-color: #43454B; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-tool-bar #lw-article-content { |
||||||
|
position: absolute; |
||||||
|
background-color: #ffffff; |
||||||
|
width: 50%; |
||||||
|
right: 0; |
||||||
|
bottom: 0; |
||||||
|
overflow-y: scroll; |
||||||
|
transform: translateY(100%); |
||||||
|
z-index: 9999; |
||||||
|
display: none; |
||||||
|
} |
||||||
|
|
||||||
|
.CodeMirror.CodeMirror-fullscreen { |
||||||
|
top: 52px; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-layer-content { |
||||||
|
padding: 0 20px; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-layer-content .fw-form-item { |
||||||
|
margin: 10px 0; |
||||||
|
color: #777; |
||||||
|
font-size: 12px; |
||||||
|
} |
||||||
|
|
||||||
|
.fw-layer-content .fw-form-item select, |
||||||
|
.fw-layer-content .fw-form-item input { |
||||||
|
outline: none; |
||||||
|
border: 1px solid #EAEEF3; |
||||||
|
padding: 5px; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#lw-article-content { |
||||||
|
font-size: 14px !important; |
||||||
|
font-family: "Helvetica Neue", Helvetica, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "微软雅黑, Arial", sans-serif; |
||||||
|
white-space: normal; |
||||||
|
overflow-wrap: break-word; |
||||||
|
color: rgb(96, 98, 102); |
||||||
|
-webkit-font-smoothing: antialiased; |
||||||
|
padding: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h1, |
||||||
|
#lw-article-content h2, |
||||||
|
#lw-article-content h3, |
||||||
|
#lw-article-content h4, |
||||||
|
#lw-article-content h5, |
||||||
|
#lw-article-content h6 { |
||||||
|
color: #303133; |
||||||
|
font-size: 18px; |
||||||
|
font-weight: 100; |
||||||
|
height: 30px; |
||||||
|
line-height: 30px; |
||||||
|
margin: 0 0 15px; |
||||||
|
position: relative; |
||||||
|
padding-left: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h1::before, |
||||||
|
#lw-article-content h2::before, |
||||||
|
#lw-article-content h3::before, |
||||||
|
#lw-article-content h4::before, |
||||||
|
#lw-article-content h5::before, |
||||||
|
#lw-article-content h6::before { |
||||||
|
position: absolute; |
||||||
|
background-color: #c2005f; |
||||||
|
font-size: 22px; |
||||||
|
top: 0; |
||||||
|
left: 0; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h1::before { |
||||||
|
content: "¶"; |
||||||
|
font-weight: normal; |
||||||
|
color: #c2005f; |
||||||
|
left: -5px; |
||||||
|
background-color: transparent; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h2::before { |
||||||
|
content: ' '; |
||||||
|
height: 30px; |
||||||
|
width: 4px; |
||||||
|
/*left: 5px;*/ |
||||||
|
border-radius: 2px; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h3::before { |
||||||
|
content: ''; |
||||||
|
width: 4px; |
||||||
|
height: 30px; |
||||||
|
/*left: 5px;*/ |
||||||
|
border-radius: 0 4px 4px 0; |
||||||
|
font-size: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#lw-article-content h4, |
||||||
|
#lw-article-content h5, |
||||||
|
#lw-article-content h6 { |
||||||
|
padding-left: 0; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h4::before, |
||||||
|
#lw-article-content h5::before, |
||||||
|
#lw-article-content h6::before { |
||||||
|
color: #c2005f; |
||||||
|
/*margin-left: 5px;*/ |
||||||
|
font-size: 18px; |
||||||
|
font-weight: normal; |
||||||
|
background-color: transparent; |
||||||
|
position: relative; |
||||||
|
margin-right: 5px; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h4::after, |
||||||
|
#lw-article-content h5::after, |
||||||
|
#lw-article-content h6::after { |
||||||
|
color: #c2005f; |
||||||
|
font-weight: normal; |
||||||
|
background-color: transparent; |
||||||
|
position: relative; |
||||||
|
margin-left: 5px; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h4::before { |
||||||
|
content: 'ß'; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h4::after { |
||||||
|
content: 'ß'; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#lw-article-content h5::before { |
||||||
|
content: "ç"; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h5::after { |
||||||
|
content: "ç"; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#lw-article-content h6::before { |
||||||
|
content: "∫"; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content h6::after { |
||||||
|
content: "∫"; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content li { |
||||||
|
line-height: 30px; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content p { |
||||||
|
margin: 0 0 15px; |
||||||
|
line-height: 30px; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#lw-article-content p > code { |
||||||
|
color: #c2005f; |
||||||
|
display: inline-block; |
||||||
|
padding: 0 5px; |
||||||
|
border-radius: 3px; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content hr { |
||||||
|
border: none; |
||||||
|
height: 1px; |
||||||
|
background-color: #e4e7ed; |
||||||
|
margin: 0 0 15px; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content blockquote > p { |
||||||
|
margin: 0; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
#lw-article-content blockquote { |
||||||
|
color: #c2005f; |
||||||
|
background-color: #ecf8ff; |
||||||
|
border-left: 5px solid #c2005f; |
||||||
|
padding: 7px 15px; |
||||||
|
margin: 0 0 15px; |
||||||
|
font-size: 14px; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content a { |
||||||
|
color: #c2005f; |
||||||
|
/*text-decoration: none;*/ |
||||||
|
} |
||||||
|
|
||||||
|
/*#lw-article-content a[href^='http']::after {*/ |
||||||
|
/* content: "\f1d9";*/ |
||||||
|
/* font: normal normal normal 14px/1 FontAwesome;*/ |
||||||
|
/* padding-left: 5px;*/ |
||||||
|
/*}*/ |
||||||
|
|
||||||
|
#lw-article-content img { |
||||||
|
max-width: 100%; |
||||||
|
border-radius: 4px; |
||||||
|
transition: transform .35s, box-shadow .35s; |
||||||
|
border: 1px solid #cccccc; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content table { |
||||||
|
max-width: 100%; |
||||||
|
table-layout: fixed; |
||||||
|
color: #909399; |
||||||
|
margin-bottom: 15px; |
||||||
|
font-size: 13px; |
||||||
|
border-top: 1px solid #ebeef5; |
||||||
|
border-left: 1px solid #ebeef5; |
||||||
|
border-collapse: collapse; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content table thead th { |
||||||
|
font-weight: 500; |
||||||
|
background: #ebeef5; |
||||||
|
padding: 8px; |
||||||
|
min-width: 100px; |
||||||
|
text-align: center; |
||||||
|
border-bottom: 1px solid #ebeef5; |
||||||
|
border-right: 1px solid #ebeef5; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content table tbody td { |
||||||
|
padding: 8px; |
||||||
|
text-align: center; |
||||||
|
border-bottom: 1px solid #ebeef5; |
||||||
|
border-right: 1px solid #ebeef5; |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content { |
||||||
|
box-sizing: border-box; |
||||||
|
} |
||||||
|
|
||||||
|
#lw-article-content ol, |
||||||
|
#lw-article-content ul { |
||||||
|
padding-left: 20px; |
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
/* end */ |
||||||
|
|
||||||
|
|
||||||
|
#lw-article-content img:hover { |
||||||
|
cursor: pointer; |
||||||
|
} |
@ -0,0 +1,6 @@ |
|||||||
|
/* PrismJS 1.29.0 |
||||||
|
https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+css+clike+javascript+bash+c+csharp+cpp+cil+cilkc+cilkcpp+cmake+csv+django+docker+git+go+go-module+gradle+http+java+javadoc+javadoclike+javastacktrace+json+json5+latex+makefile+markdown+markup-templating+mongodb+nginx+php+plsql+powerquery+powershell+python+jsx+tsx+scheme+sql+typescript+xml-doc+yaml&plugins=line-highlight+line-numbers+file-highlight+toolbar+copy-to-clipboard+download-button */ |
||||||
|
code[class*=language-],pre[class*=language-]{color:#ccc;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green} |
||||||
|
pre[data-line]{position:relative;padding:1em 0 1em 3em}.line-highlight{position:absolute;left:0;right:0;padding:inherit 0;margin-top:1em;background:hsla(24,20%,50%,.08);background:linear-gradient(to right,hsla(24,20%,50%,.1) 70%,hsla(24,20%,50%,0));pointer-events:none;line-height:inherit;white-space:pre}@media print{.line-highlight{-webkit-print-color-adjust:exact;color-adjust:exact}}.line-highlight:before,.line-highlight[data-end]:after{content:attr(data-start);position:absolute;top:.4em;left:.6em;min-width:1em;padding:0 .5em;background-color:hsla(24,20%,50%,.4);color:#f4f1ef;font:bold 65%/1.5 sans-serif;text-align:center;vertical-align:.3em;border-radius:999px;text-shadow:none;box-shadow:0 1px #fff}.line-highlight[data-end]:after{content:attr(data-end);top:auto;bottom:.4em}.line-numbers .line-highlight:after,.line-numbers .line-highlight:before{content:none}pre[id].linkable-line-numbers span.line-numbers-rows{pointer-events:all}pre[id].linkable-line-numbers span.line-numbers-rows>span:before{cursor:pointer}pre[id].linkable-line-numbers span.line-numbers-rows>span:hover:before{background-color:rgba(128,128,128,.2)} |
||||||
|
pre[class*=language-].line-numbers{position:relative;padding-left:3.8em;counter-reset:linenumber}pre[class*=language-].line-numbers>code{position:relative;white-space:inherit}.line-numbers .line-numbers-rows{position:absolute;pointer-events:none;top:0;font-size:100%;left:-3.8em;width:3em;letter-spacing:-1px;border-right:1px solid #999;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.line-numbers-rows>span{display:block;counter-increment:linenumber}.line-numbers-rows>span:before{content:counter(linenumber);color:#999;display:block;padding-right:.8em;text-align:right} |
||||||
|
div.code-toolbar{position:relative}div.code-toolbar>.toolbar{position:absolute;z-index:10;top:.3em;right:.2em;transition:opacity .3s ease-in-out;opacity:0}div.code-toolbar:hover>.toolbar{opacity:1}div.code-toolbar:focus-within>.toolbar{opacity:1}div.code-toolbar>.toolbar>.toolbar-item{display:inline-block}div.code-toolbar>.toolbar>.toolbar-item>a{cursor:pointer}div.code-toolbar>.toolbar>.toolbar-item>button{background:0 0;border:0;color:inherit;font:inherit;line-height:normal;overflow:visible;padding:0;-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none}div.code-toolbar>.toolbar>.toolbar-item>a,div.code-toolbar>.toolbar>.toolbar-item>button,div.code-toolbar>.toolbar>.toolbar-item>span{color:#bbb;font-size:.8em;padding:0 .5em;background:#f5f2f0;background:rgba(224,224,224,.2);box-shadow:0 2px 0 0 rgba(0,0,0,.2);border-radius:.5em}div.code-toolbar>.toolbar>.toolbar-item>a:focus,div.code-toolbar>.toolbar>.toolbar-item>a:hover,div.code-toolbar>.toolbar>.toolbar-item>button:focus,div.code-toolbar>.toolbar>.toolbar-item>button:hover,div.code-toolbar>.toolbar>.toolbar-item>span:focus,div.code-toolbar>.toolbar>.toolbar-item>span:hover{color:inherit;text-decoration:none} |
File diff suppressed because one or more lines are too long
Loading…
Reference in new issue