Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
solo-1
Project overview
Project overview
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Administrator
solo-1
Commits
493a8f97
Unverified
Commit
493a8f97
authored
Sep 17, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 3.6.5-dev
parents
8fe1aebc
6b4c5201
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
45 additions
and
66 deletions
+45
-66
src/main/java/org/b3log/solo/SoloServletListener.java
src/main/java/org/b3log/solo/SoloServletListener.java
+3
-3
src/main/java/org/b3log/solo/model/Common.java
src/main/java/org/b3log/solo/model/Common.java
+3
-3
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
...n/java/org/b3log/solo/processor/console/AdminConsole.java
+2
-3
src/main/java/org/b3log/solo/service/DataModelService.java
src/main/java/org/b3log/solo/service/DataModelService.java
+2
-4
src/main/java/org/b3log/solo/util/Markdowns.java
src/main/java/org/b3log/solo/util/Markdowns.java
+33
-51
src/main/webapp/common-template/label.ftl
src/main/webapp/common-template/label.ftl
+1
-1
src/main/webapp/js/common.js
src/main/webapp/js/common.js
+1
-1
No files found.
src/main/java/org/b3log/solo/SoloServletListener.java
View file @
493a8f97
...
...
@@ -59,7 +59,7 @@ import javax.servlet.http.HttpSessionEvent;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Vanessa</a>
* @version 1.11.0.2
2, Aug 18
, 2019
* @version 1.11.0.2
3, Sep 17
, 2019
* @since 0.3.1
*/
public
final
class
SoloServletListener
extends
AbstractServletListener
{
...
...
@@ -94,10 +94,10 @@ public final class SoloServletListener extends AbstractServletListener {
final
Latkes
.
RuntimeMode
runtimeMode
=
Latkes
.
getRuntimeMode
();
final
String
jdbcUsername
=
Latkes
.
getLocalProperty
(
"jdbc.username"
);
final
String
jdbcURL
=
Latkes
.
getLocalProperty
(
"jdbc.URL"
);
final
boolean
markdownHttpAvailable
=
Markdowns
.
MARKDOWN_HTTP
_AVAILABLE
;
final
boolean
luteAvailable
=
Markdowns
.
LUTE
_AVAILABLE
;
LOGGER
.
log
(
Level
.
INFO
,
"Solo is booting [ver="
+
VERSION
+
", servletContainer="
+
Latkes
.
getServletInfo
(
servletContextEvent
.
getServletContext
())
+
", os="
+
Latkes
.
getOperatingSystemName
()
+
", isDocker="
+
Latkes
.
isDocker
()
+
",
markdownHttpAvailable="
+
markdownHttp
Available
+
", pid="
+
Latkes
.
currentPID
()
+
", os="
+
Latkes
.
getOperatingSystemName
()
+
", isDocker="
+
Latkes
.
isDocker
()
+
",
luteAvailable="
+
lute
Available
+
", pid="
+
Latkes
.
currentPID
()
+
", runtimeDatabase="
+
runtimeDatabase
+
", runtimeMode="
+
runtimeMode
+
", jdbc.username="
+
jdbcUsername
+
", jdbc.URL="
+
jdbcURL
+
"]"
);
validateSkin
();
...
...
src/main/java/org/b3log/solo/model/Common.java
View file @
493a8f97
...
...
@@ -22,7 +22,7 @@ package org.b3log.solo.model;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="https://hacpai.com/member/e">Dongxu Wang</a>
* @version 1.7.0.
5, Mar 29
, 2019
* @version 1.7.0.
6, Sep 17
, 2019
* @since 0.3.1
*/
public
final
class
Common
{
...
...
@@ -68,9 +68,9 @@ public final class Common {
public
static
final
String
UPLOAD_TOKEN
=
"uploadToken"
;
/**
* Key of
marked
engine available.
* Key of
Lute
engine available.
*/
public
static
final
String
MARKED_AVAILABLE
=
"marked
Available"
;
public
static
final
String
LUTE_AVAILABLE
=
"lute
Available"
;
/**
* Key of keyword.
...
...
src/main/java/org/b3log/solo/processor/console/AdminConsole.java
View file @
493a8f97
...
...
@@ -66,7 +66,7 @@ import java.util.*;
* Admin console render processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.7.0.1
5, Jul 13
, 2019
* @version 1.7.0.1
6, Sep 17
, 2019
* @since 0.4.1
*/
@Singleton
...
...
@@ -147,8 +147,7 @@ public class AdminConsole {
dataModel
.
put
(
Option
.
CATEGORY_C_SKIN
,
skin
.
optString
(
Option
.
ID_C_SKIN_DIR_NAME
));
Keys
.
fillRuntime
(
dataModel
);
dataModelService
.
fillMinified
(
dataModel
);
// 使用 Marked 时代码高亮问题 https://github.com/b3log/solo/issues/12614
dataModel
.
put
(
Common
.
MARKED_AVAILABLE
,
Markdowns
.
MARKDOWN_HTTP_AVAILABLE
);
dataModel
.
put
(
Common
.
LUTE_AVAILABLE
,
Markdowns
.
LUTE_AVAILABLE
);
// 内置 HTTPS+CDN 文件存储 https://github.com/b3log/solo/issues/12556
dataModel
.
put
(
Common
.
UPLOAD_TOKEN
,
""
);
dataModel
.
put
(
Common
.
UPLOAD_URL
,
""
);
...
...
src/main/java/org/b3log/solo/service/DataModelService.java
View file @
493a8f97
...
...
@@ -59,7 +59,7 @@ import static org.b3log.solo.model.Article.ARTICLE_CONTENT;
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://vanessa.b3log.org">Liyuan Li</a>
* @version 1.7.0.1
0, Apr 22
, 2019
* @version 1.7.0.1
1, Sep 17
, 2019
* @since 0.3.1
*/
@Service
...
...
@@ -597,9 +597,7 @@ public class DataModelService {
}
dataModel
.
put
(
"customVars"
,
customVars
);
// 使用 Marked 时代码高亮问题 https://github.com/b3log/solo/issues/12614
dataModel
.
put
(
Common
.
MARKED_AVAILABLE
,
Markdowns
.
MARKDOWN_HTTP_AVAILABLE
);
dataModel
.
put
(
Common
.
LUTE_AVAILABLE
,
Markdowns
.
LUTE_AVAILABLE
);
String
hljsTheme
=
preference
.
optString
(
Option
.
ID_C_HLJS_THEME
);
if
(
StringUtils
.
isBlank
(
hljsTheme
))
{
hljsTheme
=
Option
.
DefaultPreference
.
DEFAULT_HLJS_THEME
;
...
...
src/main/java/org/b3log/solo/util/Markdowns.java
View file @
493a8f97
...
...
@@ -58,7 +58,7 @@ import java.util.concurrent.*;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 2.3.1.
8, Jul 29
, 2019
* @version 2.3.1.
9, Sep 17
, 2019
* @since 0.4.5
*/
public
final
class
Markdowns
{
...
...
@@ -101,42 +101,24 @@ public final class Markdowns {
private
static
final
HtmlRenderer
RENDERER
=
HtmlRenderer
.
builder
(
OPTIONS
).
build
();
/**
*
Markdown engine serve path.
*
Lute engine serve path. https://github.com/b3log/lute
*/
private
static
final
String
MARKDOWN_ENGINE_URL
=
"http://localhost:8250
"
;
private
static
final
String
LUTE_ENGINE_URL
=
"http://localhost:8249
"
;
/**
* Whether
markdown-http
is available.
* Whether
Lute
is available.
*/
public
static
boolean
MARKDOWN_HTTP
_AVAILABLE
;
public
static
boolean
LUTE
_AVAILABLE
;
static
{
try
{
final
URL
url
=
new
URL
(
MARKDOWN_ENGINE_URL
);
final
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setDoOutput
(
true
);
try
(
final
OutputStream
outputStream
=
conn
.
getOutputStream
())
{
IOUtils
.
write
(
"昔日舞曲"
,
outputStream
,
"UTF-8"
);
}
String
html
;
try
(
final
InputStream
inputStream
=
conn
.
getInputStream
())
{
html
=
IOUtils
.
toString
(
inputStream
,
"UTF-8"
);
}
conn
.
disconnect
();
MARKDOWN_HTTP_AVAILABLE
=
StringUtils
.
contains
(
html
,
"<p>昔日舞曲</p>"
);
if
(
MARKDOWN_HTTP_AVAILABLE
)
{
LOGGER
.
log
(
Level
.
INFO
,
"[markdown-http] is available, uses it for markdown processing"
);
}
else
{
LOGGER
.
log
(
Level
.
INFO
,
"[markdown-http] is not available, uses built-in [flexmark] for markdown processing"
);
final
String
html
=
toHtmlByLute
(
"旧日的足迹"
);
LUTE_AVAILABLE
=
StringUtils
.
contains
(
html
,
"<p>旧日的足迹</p>"
);
if
(
LUTE_AVAILABLE
)
{
LOGGER
.
log
(
Level
.
INFO
,
"[Lute] is available"
);
}
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
INFO
,
"[markdown-http] is not available, uses built-in [flexmark] for markdown processing. "
+
"Please read FAQ section in user guide (https://hacpai.com/article/1492881378588) for more details."
);
// ignored
}
}
...
...
@@ -177,31 +159,23 @@ public final class Markdowns {
final
Callable
<
String
>
call
=
()
->
{
threadId
[
0
]
=
Thread
.
currentThread
().
getId
();
String
html
=
langPropsService
.
get
(
"contentRenderFailedLabel"
);
if
(
MARKDOWN_HTTP_AVAILABLE
)
{
String
html
=
null
;
if
(
LUTE_AVAILABLE
)
{
try
{
html
=
toHtmlByMarkdownHTTP
(
markdownText
);
if
(!
StringUtils
.
startsWith
(
html
,
"<p>"
))
{
html
=
"<p>"
+
html
+
"</p>"
;
}
html
=
toHtmlByLute
(
markdownText
);
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
WARN
,
"Failed to use [markdown-http] for markdown [md="
+
StringUtils
.
substring
(
markdownText
,
0
,
256
)
+
"]: "
+
e
.
getMessage
());
com
.
vladsch
.
flexmark
.
util
.
ast
.
Node
document
=
PARSER
.
parse
(
markdownText
);
html
=
RENDERER
.
render
(
document
);
if
(!
StringUtils
.
startsWith
(
html
,
"<p>"
))
{
html
=
"<p>"
+
html
+
"</p>"
;
}
}
}
else
{
com
.
vladsch
.
flexmark
.
util
.
ast
.
Node
document
=
PARSER
.
parse
(
markdownText
);
html
=
RENDERER
.
render
(
document
);
if
(!
StringUtils
.
startsWith
(
html
,
"<p>"
))
{
html
=
"<p>"
+
html
+
"</p>"
;
LOGGER
.
log
(
Level
.
WARN
,
"Failed to use [Lute] for markdown [md="
+
StringUtils
.
substring
(
markdownText
,
0
,
256
)
+
"]: "
+
e
.
getMessage
());
}
}
if
(
StringUtils
.
isBlank
(
html
))
{
html
=
toHtmlByFlexmark
(
markdownText
);
}
if
(!
StringUtils
.
startsWith
(
html
,
"<p>"
))
{
html
=
"<p>"
+
html
+
"</p>"
;
}
final
Document
doc
=
Jsoup
.
parse
(
html
);
doc
.
select
(
"a"
).
forEach
(
a
->
{
final
String
src
=
a
.
attr
(
"href"
);
...
...
@@ -291,9 +265,11 @@ public final class Markdowns {
return
langPropsService
.
get
(
"contentRenderFailedLabel"
);
}
private
static
String
toHtmlBy
MarkdownHTTP
(
final
String
markdownText
)
throws
Exception
{
final
URL
url
=
new
URL
(
MARKDOWN
_ENGINE_URL
);
private
static
String
toHtmlBy
Lute
(
final
String
markdownText
)
throws
Exception
{
final
URL
url
=
new
URL
(
LUTE
_ENGINE_URL
);
final
HttpURLConnection
conn
=
(
HttpURLConnection
)
url
.
openConnection
();
conn
.
setConnectTimeout
(
1000
);
conn
.
setReadTimeout
(
7000
);
conn
.
setDoOutput
(
true
);
try
(
final
OutputStream
outputStream
=
conn
.
getOutputStream
())
{
...
...
@@ -305,11 +281,17 @@ public final class Markdowns {
ret
=
IOUtils
.
toString
(
inputStream
,
"UTF-8"
);
}
//
conn.disconnect();
conn
.
disconnect
();
return
ret
;
}
private
static
String
toHtmlByFlexmark
(
final
String
markdownText
)
{
com
.
vladsch
.
flexmark
.
util
.
ast
.
Node
document
=
PARSER
.
parse
(
markdownText
);
return
RENDERER
.
render
(
document
);
}
/**
* Gets HTML for the specified markdown text.
*
...
...
src/main/webapp/common-template/label.ftl
View file @
493a8f97
...
...
@@ -21,7 +21,7 @@
var Label = {
servePath: "${servePath}",
staticServePath: "${staticServePath}",
markedAvailable: ${marked
Available?c},
luteAvailable: ${lute
Available?c},
hljsStyle: '${hljsTheme}',
langLabel: "${langLabel}",
version: "${version}",
...
...
src/main/webapp/js/common.js
View file @
493a8f97
...
...
@@ -150,7 +150,7 @@ var Util = {
if
(
$
(
'
.vditor-reset pre > code
'
).
length
===
0
)
{
return
}
Vditor
.
highlightRender
(
Label
.
hljsStyle
,
!
Label
.
marked
Available
,
document
)
Vditor
.
highlightRender
(
Label
.
hljsStyle
,
!
Label
.
lute
Available
,
document
)
},
/**
* 按需加载数学公式、流程图、代码复制、五线谱、多媒体、图表
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment