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
d2171d16
Unverified
Commit
d2171d16
authored
Feb 28, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🗃
#12678
parent
ebd1e57d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
11 deletions
+37
-11
src/main/java/org/b3log/solo/model/Article.java
src/main/java/org/b3log/solo/model/Article.java
+28
-8
src/main/resources/repository.json
src/main/resources/repository.json
+9
-3
No files found.
src/main/java/org/b3log/solo/model/Article.java
View file @
d2171d16
...
@@ -28,7 +28,7 @@ import org.jsoup.safety.Whitelist;
...
@@ -28,7 +28,7 @@ import org.jsoup.safety.Whitelist;
* This class defines all article model relevant keys.
* This class defines all article model relevant keys.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
3.0.1
, Feb 28, 2019
* @version 1.
4.0.0
, Feb 28, 2019
* @since 0.3.1
* @since 0.3.1
*/
*/
public
final
class
Article
{
public
final
class
Article
{
...
@@ -53,6 +53,11 @@ public final class Article {
...
@@ -53,6 +53,11 @@ public final class Article {
*/
*/
public
static
final
String
ARTICLE_ABSTRACT
=
"articleAbstract"
;
public
static
final
String
ARTICLE_ABSTRACT
=
"articleAbstract"
;
/**
* Key of abstract text.
*/
public
static
final
String
ARTICLE_ABSTRACT_TEXT
=
"articleAbstractText"
;
/**
/**
* Key of content.
* Key of content.
*/
*/
...
@@ -220,17 +225,32 @@ public final class Article {
...
@@ -220,17 +225,32 @@ public final class Article {
}
}
/**
/**
* Gets the abstract of the specified content.
* Gets the abstract
plain text
of the specified content.
*
*
* @param content the specified content
* @param content the specified content
* @return the abstract
* @return the abstract plain text
*/
public
static
String
getAbstractText
(
final
String
content
)
{
final
String
ret
=
Jsoup
.
clean
(
Markdowns
.
toHTML
(
content
),
Whitelist
.
none
());
if
(
ret
.
length
()
>
ARTICLE_ABSTRACT_LENGTH
)
{
return
ret
.
substring
(
0
,
ARTICLE_ABSTRACT_LENGTH
)
+
"...."
;
}
return
ret
;
}
/**
* Gets the abstract plain text of the specified article.
*
* @param article the specified article
* @return the abstract plain text
*/
*/
public
static
String
getAbstract
(
final
String
content
)
{
public
static
String
getAbstract
Text
(
final
JSONObject
article
)
{
final
String
plainTextContent
=
Jsoup
.
clean
(
Markdowns
.
toHTML
(
content
),
Whitelist
.
none
()
);
String
content
=
article
.
optString
(
Article
.
ARTICLE_ABSTRACT
);
if
(
plainTextContent
.
length
()
>
ARTICLE_ABSTRACT_LENGTH
)
{
if
(
StringUtils
.
isBlank
(
content
)
)
{
return
plainTextContent
.
substring
(
0
,
ARTICLE_ABSTRACT_LENGTH
)
+
"...."
;
content
=
article
.
optString
(
Article
.
ARTICLE_CONTENT
)
;
}
}
return
plainTextContent
;
return
getAbstractText
(
content
)
;
}
}
}
}
src/main/resources/repository.json
View file @
d2171d16
...
@@ -445,15 +445,21 @@
...
@@ -445,15 +445,21 @@
},
},
{
{
"name"
:
"articleAbstract"
,
"name"
:
"articleAbstract"
,
"description"
:
"文章摘要"
,
"description"
:
"文章摘要
Markdown
"
,
"type"
:
"String"
,
"type"
:
"String"
,
"length"
:
2000
"length"
:
2048
},
{
"name"
:
"articleAbstractText"
,
"description"
:
"文章摘要纯文本"
,
"type"
:
"String"
,
"length"
:
2048
},
},
{
{
"name"
:
"articleTags"
,
"name"
:
"articleTags"
,
"description"
:
"文章标签,英文逗号分隔"
,
"description"
:
"文章标签,英文逗号分隔"
,
"type"
:
"String"
,
"type"
:
"String"
,
"length"
:
20
00
"length"
:
20
48
},
},
{
{
"name"
:
"articleAuthorId"
,
"name"
:
"articleAuthorId"
,
...
...
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