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
81d4b081
Commit
81d4b081
authored
Jun 25, 2017
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
摘要生成重构
parent
99ceb1f4
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
39 deletions
+38
-39
src/main/java/org/b3log/solo/api/metaweblog/MetaWeblogAPI.java
...ain/java/org/b3log/solo/api/metaweblog/MetaWeblogAPI.java
+2
-14
src/main/java/org/b3log/solo/api/symphony/ArticleReceiver.java
...ain/java/org/b3log/solo/api/symphony/ArticleReceiver.java
+8
-21
src/main/java/org/b3log/solo/model/Article.java
src/main/java/org/b3log/solo/model/Article.java
+28
-4
No files found.
src/main/java/org/b3log/solo/api/metaweblog/MetaWeblogAPI.java
View file @
81d4b081
...
...
@@ -67,7 +67,7 @@ import java.util.List;
* </p>
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.1
3, Jun 8
, 2017
* @version 1.0.0.1
4, Jun 25
, 2017
* @since 0.4.0
*/
@RequestProcessor
...
...
@@ -153,11 +153,6 @@ public class MetaWeblogAPI {
*/
private
static
final
int
INDEX_PUBLISH
=
4
;
/**
* Article abstract length.
*/
private
static
final
int
ARTICLE_ABSTRACT_LENGTH
=
500
;
/**
* Preference query service.
*/
...
...
@@ -375,14 +370,7 @@ public class MetaWeblogAPI {
final
String
content
=
member
.
getJSONObject
(
"value"
).
getString
(
"string"
);
ret
.
put
(
Article
.
ARTICLE_CONTENT
,
content
);
final
String
plainTextContent
=
Jsoup
.
parse
(
content
).
text
();
if
(
plainTextContent
.
length
()
>
ARTICLE_ABSTRACT_LENGTH
)
{
ret
.
put
(
Article
.
ARTICLE_ABSTRACT
,
plainTextContent
.
substring
(
0
,
ARTICLE_ABSTRACT_LENGTH
));
}
else
{
ret
.
put
(
Article
.
ARTICLE_ABSTRACT
,
plainTextContent
);
}
ret
.
put
(
Article
.
ARTICLE_ABSTRACT
,
Article
.
getAbstract
(
Jsoup
.
parse
(
content
).
text
()));
}
else
if
(
"categories"
.
equals
(
name
))
{
final
StringBuilder
tagBuilder
=
new
StringBuilder
();
...
...
src/main/java/org/b3log/solo/api/symphony/ArticleReceiver.java
View file @
81d4b081
...
...
@@ -34,11 +34,8 @@ import org.b3log.solo.service.ArticleMgmtService;
import
org.b3log.solo.service.ArticleQueryService
;
import
org.b3log.solo.service.PreferenceQueryService
;
import
org.b3log.solo.service.UserQueryService
;
import
org.b3log.solo.util.Markdowns
;
import
org.b3log.solo.util.QueryResults
;
import
org.json.JSONObject
;
import
org.jsoup.Jsoup
;
import
org.jsoup.safety.Whitelist
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -47,7 +44,7 @@ import javax.servlet.http.HttpServletResponse;
* Article receiver (from B3log Symphony).
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.3.
7, Jan 1
5, 2017
* @version 1.0.3.
8, Jan 2
5, 2017
* @since 0.5.5
*/
@RequestProcessor
...
...
@@ -56,26 +53,26 @@ public class ArticleReceiver {
/**
* Logger.
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ArticleReceiver
.
class
.
getName
());
/**
* Article abstract length.
*/
private
static
final
int
ARTICLE_ABSTRACT_LENGTH
=
500
;
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
ArticleReceiver
.
class
);
/**
* Preference query service.
*/
@Inject
private
PreferenceQueryService
preferenceQueryService
;
/**
* Article management service.
*/
@Inject
private
ArticleMgmtService
articleMgmtService
;
/**
* Article query service.
*/
@Inject
private
ArticleQueryService
articleQueryService
;
/**
* User query service.
*/
...
...
@@ -134,12 +131,7 @@ public class ArticleReceiver {
article
.
put
(
Article
.
ARTICLE_AUTHOR_EMAIL
,
admin
.
getString
(
User
.
USER_EMAIL
));
final
String
articleContent
=
article
.
optString
(
Article
.
ARTICLE_CONTENT
);
final
String
plainTextContent
=
Jsoup
.
clean
(
Markdowns
.
toHTML
(
articleContent
),
Whitelist
.
none
());
if
(
plainTextContent
.
length
()
>
ARTICLE_ABSTRACT_LENGTH
)
{
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
plainTextContent
.
substring
(
0
,
ARTICLE_ABSTRACT_LENGTH
)
+
"...."
);
}
else
{
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
plainTextContent
);
}
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
Article
.
getAbstract
(
articleContent
));
article
.
put
(
Article
.
ARTICLE_IS_PUBLISHED
,
true
);
article
.
put
(
Common
.
POST_TO_COMMUNITY
,
false
);
// Do not send to rhythm
article
.
put
(
Article
.
ARTICLE_COMMENTABLE
,
true
);
...
...
@@ -227,12 +219,7 @@ public class ArticleReceiver {
}
final
String
articleContent
=
article
.
optString
(
Article
.
ARTICLE_CONTENT
);
final
String
plainTextContent
=
Jsoup
.
clean
(
Markdowns
.
toHTML
(
articleContent
),
Whitelist
.
none
());
if
(
plainTextContent
.
length
()
>
ARTICLE_ABSTRACT_LENGTH
)
{
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
plainTextContent
.
substring
(
0
,
ARTICLE_ABSTRACT_LENGTH
)
+
"...."
);
}
else
{
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
plainTextContent
);
}
article
.
put
(
Article
.
ARTICLE_ABSTRACT
,
Article
.
getAbstract
(
articleContent
));
article
.
put
(
Article
.
ARTICLE_IS_PUBLISHED
,
true
);
article
.
put
(
Common
.
POST_TO_COMMUNITY
,
false
);
// Do not send to rhythm
article
.
put
(
Article
.
ARTICLE_COMMENTABLE
,
true
);
...
...
src/main/java/org/b3log/solo/model/Article.java
View file @
81d4b081
...
...
@@ -15,12 +15,15 @@
*/
package
org
.
b3log
.
solo
.
model
;
import
org.b3log.solo.util.Markdowns
;
import
org.jsoup.Jsoup
;
import
org.jsoup.safety.Whitelist
;
/**
* This class defines all article model relevant keys.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.
0.1.6, Jan 8, 2013
* @version 1.
1.1.6, Jun 25, 2017
* @since 0.3.1
*/
public
final
class
Article
{
...
...
@@ -137,13 +140,34 @@ public final class Article {
/**
* Key of article editor type.
*
* @see Preference#EDITOR_TYPE
*/
public
static
final
String
ARTICLE_EDITOR_TYPE
=
"articleEditorType"
;
//// constants
/**
* Article abstract length.
*/
private
static
final
int
ARTICLE_ABSTRACT_LENGTH
=
500
;
/**
* Private default constructor.
*/
private
Article
()
{}
private
Article
()
{
}
/**
* Gets the abstract of the specified content.
*
* @param content the specified content
* @return the abstract
*/
public
static
String
getAbstract
(
final
String
content
)
{
final
String
plainTextContent
=
Jsoup
.
clean
(
Markdowns
.
toHTML
(
content
),
Whitelist
.
none
());
if
(
plainTextContent
.
length
()
>
ARTICLE_ABSTRACT_LENGTH
)
{
return
plainTextContent
.
substring
(
0
,
ARTICLE_ABSTRACT_LENGTH
)
+
"...."
;
}
return
plainTextContent
;
}
}
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