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
c8f5ff6b
Unverified
Commit
c8f5ff6b
authored
Jul 22, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐛
Fix #12821
parent
3c6e8bf1
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
11 additions
and
15 deletions
+11
-15
src/main/java/org/b3log/solo/model/Tag.java
src/main/java/org/b3log/solo/model/Tag.java
+5
-9
src/main/java/org/b3log/solo/processor/console/CategoryConsole.java
...ava/org/b3log/solo/processor/console/CategoryConsole.java
+3
-3
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
+3
-3
No files found.
src/main/java/org/b3log/solo/model/Tag.java
View file @
c8f5ff6b
...
@@ -28,7 +28,7 @@ import java.util.regex.Pattern;
...
@@ -28,7 +28,7 @@ import java.util.regex.Pattern;
* This class defines all tag model relevant keys.
* This class defines all tag 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.1.0.
3, Jun 26
, 2019
* @version 1.1.0.
4, Jul 22
, 2019
*/
*/
public
final
class
Tag
{
public
final
class
Tag
{
...
@@ -63,11 +63,6 @@ public final class Tag {
...
@@ -63,11 +63,6 @@ public final class Tag {
*/
*/
public
static
final
Pattern
TAG_TITLE_PATTERN
=
Pattern
.
compile
(
TAG_TITLE_PATTERN_STR
);
public
static
final
Pattern
TAG_TITLE_PATTERN
=
Pattern
.
compile
(
TAG_TITLE_PATTERN_STR
);
/**
* Max tag count.
*/
public
static
final
int
MAX_TAG_COUNT
=
4
;
/**
/**
* Max length of a tag.
* Max length of a tag.
*/
*/
...
@@ -81,9 +76,10 @@ public final class Tag {
...
@@ -81,9 +76,10 @@ public final class Tag {
* </ul>
* </ul>
*
*
* @param tagStr the specified tags
* @param tagStr the specified tags
* @param maxTagCount the specified max tag count
* @return formatted tags string
* @return formatted tags string
*/
*/
public
static
String
formatTags
(
final
String
tagStr
)
{
public
static
String
formatTags
(
final
String
tagStr
,
final
int
maxTagCount
)
{
final
String
tagStr1
=
tagStr
.
replaceAll
(
"\\s+"
,
""
).
replaceAll
(
","
,
","
).
replaceAll
(
"、"
,
","
).
final
String
tagStr1
=
tagStr
.
replaceAll
(
"\\s+"
,
""
).
replaceAll
(
","
,
","
).
replaceAll
(
"、"
,
","
).
replaceAll
(
";"
,
","
).
replaceAll
(
";"
,
","
);
replaceAll
(
";"
,
","
).
replaceAll
(
";"
,
","
);
String
[]
tagTitles
=
tagStr1
.
split
(
","
);
String
[]
tagTitles
=
tagStr1
.
split
(
","
);
...
@@ -119,7 +115,7 @@ public final class Tag {
...
@@ -119,7 +115,7 @@ public final class Tag {
tagsBuilder
.
append
(
title
).
append
(
","
);
tagsBuilder
.
append
(
title
).
append
(
","
);
count
++;
count
++;
if
(
count
>=
MAX_TAG_COUNT
)
{
if
(
maxTagCount
<=
count
)
{
break
;
break
;
}
}
}
}
...
...
src/main/java/org/b3log/solo/processor/console/CategoryConsole.java
View file @
c8f5ff6b
...
@@ -51,7 +51,7 @@ import java.util.Set;
...
@@ -51,7 +51,7 @@ import java.util.Set;
* Category console request processing.
* Category console request processing.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.3.
4, Mar 29
, 2019
* @version 1.1.3.
5, Jul 22
, 2019
* @since 2.0.0
* @since 2.0.0
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -254,7 +254,7 @@ public class CategoryConsole {
...
@@ -254,7 +254,7 @@ public class CategoryConsole {
try
{
try
{
final
JSONObject
requestJSON
=
context
.
requestJSON
();
final
JSONObject
requestJSON
=
context
.
requestJSON
();
String
tagsStr
=
requestJSON
.
optString
(
Category
.
CATEGORY_T_TAGS
);
String
tagsStr
=
requestJSON
.
optString
(
Category
.
CATEGORY_T_TAGS
);
tagsStr
=
Tag
.
formatTags
(
tagsStr
);
tagsStr
=
Tag
.
formatTags
(
tagsStr
,
64
);
if
(
StringUtils
.
isBlank
(
tagsStr
))
{
if
(
StringUtils
.
isBlank
(
tagsStr
))
{
throw
new
ServiceException
(
langPropsService
.
get
(
"tagsEmptyLabel"
));
throw
new
ServiceException
(
langPropsService
.
get
(
"tagsEmptyLabel"
));
}
}
...
@@ -386,7 +386,7 @@ public class CategoryConsole {
...
@@ -386,7 +386,7 @@ public class CategoryConsole {
try
{
try
{
final
JSONObject
requestJSONObject
=
context
.
requestJSON
();
final
JSONObject
requestJSONObject
=
context
.
requestJSON
();
String
tagsStr
=
requestJSONObject
.
optString
(
Category
.
CATEGORY_T_TAGS
);
String
tagsStr
=
requestJSONObject
.
optString
(
Category
.
CATEGORY_T_TAGS
);
tagsStr
=
Tag
.
formatTags
(
tagsStr
);
tagsStr
=
Tag
.
formatTags
(
tagsStr
,
64
);
if
(
StringUtils
.
isBlank
(
tagsStr
))
{
if
(
StringUtils
.
isBlank
(
tagsStr
))
{
throw
new
ServiceException
(
langPropsService
.
get
(
"tagsEmptyLabel"
));
throw
new
ServiceException
(
langPropsService
.
get
(
"tagsEmptyLabel"
));
}
}
...
...
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
c8f5ff6b
...
@@ -52,7 +52,7 @@ import static org.b3log.solo.model.Article.*;
...
@@ -52,7 +52,7 @@ import static org.b3log.solo.model.Article.*;
* Article management service.
* Article management service.
*
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.3.1.
4, Jun 6
, 2019
* @version 1.3.1.
5, Jul 22
, 2019
* @since 0.3.5
* @since 0.3.5
*/
*/
@Service
@Service
...
@@ -406,7 +406,7 @@ public class ArticleMgmtService {
...
@@ -406,7 +406,7 @@ public class ArticleMgmtService {
try
{
try
{
final
JSONObject
article
=
requestJSONObject
.
getJSONObject
(
ARTICLE
);
final
JSONObject
article
=
requestJSONObject
.
getJSONObject
(
ARTICLE
);
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
tagsString
=
Tag
.
formatTags
(
tagsString
);
tagsString
=
Tag
.
formatTags
(
tagsString
,
4
);
if
(
StringUtils
.
isBlank
(
tagsString
))
{
if
(
StringUtils
.
isBlank
(
tagsString
))
{
tagsString
=
"待分类"
;
tagsString
=
"待分类"
;
}
}
...
@@ -514,7 +514,7 @@ public class ArticleMgmtService {
...
@@ -514,7 +514,7 @@ public class ArticleMgmtService {
}
}
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
tagsString
=
Tag
.
formatTags
(
tagsString
);
tagsString
=
Tag
.
formatTags
(
tagsString
,
4
);
if
(
StringUtils
.
isBlank
(
tagsString
))
{
if
(
StringUtils
.
isBlank
(
tagsString
))
{
tagsString
=
"待分类"
;
tagsString
=
"待分类"
;
}
}
...
...
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