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
ef1b3d98
Unverified
Commit
ef1b3d98
authored
Aug 27, 2018
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
Fix #12489
parent
e757b4de
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
125 additions
and
14 deletions
+125
-14
src/main/java/org/b3log/solo/model/Tag.java
src/main/java/org/b3log/solo/model/Tag.java
+100
-3
src/main/java/org/b3log/solo/processor/console/CategoryConsole.java
...ava/org/b3log/solo/processor/console/CategoryConsole.java
+9
-3
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
+12
-4
src/main/resources/lang_en_US.properties
src/main/resources/lang_en_US.properties
+2
-2
src/main/resources/lang_zh_CN.properties
src/main/resources/lang_zh_CN.properties
+2
-2
No files found.
src/main/java/org/b3log/solo/model/Tag.java
View file @
ef1b3d98
...
@@ -18,11 +18,18 @@
...
@@ -18,11 +18,18 @@
package
org
.
b3log
.
solo
.
model
;
package
org
.
b3log
.
solo
.
model
;
import
org.apache.commons.lang.StringUtils
;
import
org.b3log.latke.util.Strings
;
import
java.util.LinkedHashSet
;
import
java.util.Set
;
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.
0.0.7, Dec 3, 2010
* @version 1.
1.0.0, Aug 27, 2018
*/
*/
public
final
class
Tag
{
public
final
class
Tag
{
...
@@ -52,7 +59,97 @@ public final class Tag {
...
@@ -52,7 +59,97 @@ public final class Tag {
public
static
final
String
TAG_PUBLISHED_REFERENCE_COUNT
=
"tagPublishedRefCount"
;
public
static
final
String
TAG_PUBLISHED_REFERENCE_COUNT
=
"tagPublishedRefCount"
;
/**
/**
* Private default constructor.
* Tag title pattern string.
*/
public
static
final
String
TAG_TITLE_PATTERN_STR
=
"[\\u4e00-\\u9fa5,\\w,&,\\+,\\-,\\.]+"
;
/**
* Tag title pattern.
*/
public
static
final
Pattern
TAG_TITLE_PATTERN
=
Pattern
.
compile
(
TAG_TITLE_PATTERN_STR
);
/**
* Max tag count.
*/
public
static
final
int
MAX_TAG_COUNT
=
4
;
/**
* Formats the specified tags.
* <ul>
* <li>Trims every tag</li>
* <li>Deduplication</li>
* </ul>
*
* @param tagStr the specified tags
* @return formatted tags string
*/
public
static
String
formatTags
(
final
String
tagStr
)
{
final
String
tagStr1
=
tagStr
.
replaceAll
(
"\\s+"
,
""
).
replaceAll
(
","
,
","
).
replaceAll
(
"、"
,
","
).
replaceAll
(
";"
,
","
).
replaceAll
(
";"
,
","
);
String
[]
tagTitles
=
tagStr1
.
split
(
","
);
tagTitles
=
Strings
.
trimAll
(
tagTitles
);
// deduplication
final
Set
<
String
>
titles
=
new
LinkedHashSet
<>();
for
(
final
String
tagTitle
:
tagTitles
)
{
if
(!
exists
(
titles
,
tagTitle
))
{
titles
.
add
(
tagTitle
);
}
}
tagTitles
=
titles
.
toArray
(
new
String
[
0
]);
int
count
=
0
;
final
StringBuilder
tagsBuilder
=
new
StringBuilder
();
for
(
final
String
tagTitle
:
tagTitles
)
{
String
title
=
tagTitle
.
trim
();
if
(
StringUtils
.
isBlank
(
title
))
{
continue
;
}
if
(
StringUtils
.
length
(
title
)
>
12
)
{
continue
;
}
if
(!
TAG_TITLE_PATTERN
.
matcher
(
title
).
matches
())
{
continue
;
}
tagsBuilder
.
append
(
title
).
append
(
","
);
count
++;
if
(
count
>=
MAX_TAG_COUNT
)
{
break
;
}
}
if
(
tagsBuilder
.
length
()
>
0
)
{
tagsBuilder
.
deleteCharAt
(
tagsBuilder
.
length
()
-
1
);
}
return
tagsBuilder
.
toString
();
}
/**
* Checks the specified title exists in the specified title set.
*
* @param titles the specified title set
* @param title the specified title to check
* @return {@code true} if exists, returns {@code false} otherwise
*/
private
static
boolean
exists
(
final
Set
<
String
>
titles
,
final
String
title
)
{
for
(
final
String
setTitle
:
titles
)
{
if
(
setTitle
.
equalsIgnoreCase
(
title
))
{
return
true
;
}
}
return
false
;
}
/**
* Private constructor.
*/
*/
private
Tag
()
{}
private
Tag
()
{
}
}
}
src/main/java/org/b3log/solo/processor/console/CategoryConsole.java
View file @
ef1b3d98
...
@@ -52,7 +52,7 @@ import java.util.Set;
...
@@ -52,7 +52,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.1.
2, Mar 3
, 2018
* @version 1.1.1.
3, Aug 27
, 2018
* @since 2.0.0
* @since 2.0.0
*/
*/
@RequestProcessor
@RequestProcessor
...
@@ -293,7 +293,10 @@ public class CategoryConsole {
...
@@ -293,7 +293,10 @@ public class CategoryConsole {
try
{
try
{
String
tagsStr
=
requestJSONObject
.
optString
(
Category
.
CATEGORY_T_TAGS
);
String
tagsStr
=
requestJSONObject
.
optString
(
Category
.
CATEGORY_T_TAGS
);
tagsStr
=
tagsStr
.
replaceAll
(
","
,
","
).
replaceAll
(
"、"
,
","
);
tagsStr
=
Tag
.
formatTags
(
tagsStr
);
if
(
StringUtils
.
isBlank
(
tagsStr
))
{
throw
new
ServiceException
(
langPropsService
.
get
(
"tagsEmptyLabel"
));
}
final
String
[]
tagTitles
=
tagsStr
.
split
(
","
);
final
String
[]
tagTitles
=
tagsStr
.
split
(
","
);
String
addArticleWithTagFirstLabel
=
langPropsService
.
get
(
"addArticleWithTagFirstLabel"
);
String
addArticleWithTagFirstLabel
=
langPropsService
.
get
(
"addArticleWithTagFirstLabel"
);
...
@@ -423,7 +426,10 @@ public class CategoryConsole {
...
@@ -423,7 +426,10 @@ public class CategoryConsole {
try
{
try
{
String
tagsStr
=
requestJSONObject
.
optString
(
Category
.
CATEGORY_T_TAGS
);
String
tagsStr
=
requestJSONObject
.
optString
(
Category
.
CATEGORY_T_TAGS
);
tagsStr
=
tagsStr
.
replaceAll
(
","
,
","
).
replaceAll
(
"、"
,
","
);
tagsStr
=
Tag
.
formatTags
(
tagsStr
);
if
(
StringUtils
.
isBlank
(
tagsStr
))
{
throw
new
ServiceException
(
langPropsService
.
get
(
"tagsEmptyLabel"
));
}
final
String
[]
tagTitles
=
tagsStr
.
split
(
","
);
final
String
[]
tagTitles
=
tagsStr
.
split
(
","
);
String
addArticleWithTagFirstLabel
=
langPropsService
.
get
(
"addArticleWithTagFirstLabel"
);
String
addArticleWithTagFirstLabel
=
langPropsService
.
get
(
"addArticleWithTagFirstLabel"
);
...
...
src/main/java/org/b3log/solo/service/ArticleMgmtService.java
View file @
ef1b3d98
...
@@ -17,6 +17,7 @@
...
@@ -17,6 +17,7 @@
*/
*/
package
org
.
b3log
.
solo
.
service
;
package
org
.
b3log
.
solo
.
service
;
import
org.apache.commons.lang.StringUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.apache.commons.lang.time.DateFormatUtils
;
import
org.apache.commons.lang.time.DateUtils
;
import
org.apache.commons.lang.time.DateUtils
;
import
org.b3log.latke.Keys
;
import
org.b3log.latke.Keys
;
...
@@ -54,7 +55,7 @@ import static org.b3log.solo.model.Article.*;
...
@@ -54,7 +55,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.2.2.1
0, Oct 3, 2017
* @version 1.2.2.1
1, Aug 27, 2018
* @since 0.3.5
* @since 0.3.5
*/
*/
@Service
@Service
...
@@ -287,8 +288,12 @@ public class ArticleMgmtService {
...
@@ -287,8 +288,12 @@ public class ArticleMgmtService {
try
{
try
{
final
JSONObject
article
=
requestJSONObject
.
getJSONObject
(
ARTICLE
);
final
JSONObject
article
=
requestJSONObject
.
getJSONObject
(
ARTICLE
);
final
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
article
.
put
(
Article
.
ARTICLE_TAGS_REF
,
tagsString
.
replaceAll
(
","
,
","
).
replaceAll
(
"、"
,
","
));
tagsString
=
Tag
.
formatTags
(
tagsString
);
if
(
StringUtils
.
isBlank
(
tagsString
))
{
throw
new
ServiceException
(
langPropsService
.
get
(
"tagsEmptyLabel"
));
}
article
.
put
(
Article
.
ARTICLE_TAGS_REF
,
tagsString
);
final
String
articleId
=
article
.
getString
(
Keys
.
OBJECT_ID
);
final
String
articleId
=
article
.
getString
(
Keys
.
OBJECT_ID
);
// Set permalink
// Set permalink
...
@@ -471,7 +476,10 @@ public class ArticleMgmtService {
...
@@ -471,7 +476,10 @@ public class ArticleMgmtService {
try
{
try
{
// Step 1: Add tags
// Step 1: Add tags
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
String
tagsString
=
article
.
optString
(
Article
.
ARTICLE_TAGS_REF
);
tagsString
=
tagsString
.
replaceAll
(
","
,
","
).
replaceAll
(
"、"
,
","
);
tagsString
=
Tag
.
formatTags
(
tagsString
);
if
(
StringUtils
.
isBlank
(
tagsString
))
{
throw
new
ServiceException
(
langPropsService
.
get
(
"tagsEmptyLabel"
));
}
article
.
put
(
Article
.
ARTICLE_TAGS_REF
,
tagsString
);
article
.
put
(
Article
.
ARTICLE_TAGS_REF
,
tagsString
);
final
String
[]
tagTitles
=
tagsString
.
split
(
","
);
final
String
[]
tagTitles
=
tagsString
.
split
(
","
);
final
JSONArray
tags
=
tag
(
tagTitles
,
article
);
final
JSONArray
tags
=
tag
(
tagTitles
,
article
);
...
...
src/main/resources/lang_en_US.properties
View file @
ef1b3d98
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#
#
# Description: Solo language configurations(en_US).
# Description: Solo language configurations(en_US).
# Version: 2.21.0.
1, Apr 5
, 2018
# Version: 2.21.0.
2, Aug 27
, 2018
# Author: Liang Ding
# Author: Liang Ding
# Author: Liyuan Li
# Author: Liyuan Li
# Author: Dongxu Wang
# Author: Dongxu Wang
...
@@ -394,7 +394,7 @@ titleEmptyLabel=Title is empty
...
@@ -394,7 +394,7 @@ titleEmptyLabel=Title is empty
contentEmptyLabel
=
Content is empty
contentEmptyLabel
=
Content is empty
orderEmptyLabel
=
Order is empty
orderEmptyLabel
=
Order is empty
abstractEmptyLabel
=
Abstract is empty
abstractEmptyLabel
=
Abstract is empty
tagsEmptyLabel
=
Tags is empty
tagsEmptyLabel
=
Tags is empty
(do not include specific symbol)
addressEmptyLabel
=
Address is empty
addressEmptyLabel
=
Address is empty
noAuthorizationURLLabel
=
Can not retrieve authorization URL from Google, please
\
noAuthorizationURLLabel
=
Can not retrieve authorization URL from Google, please
\
make sure the <em>Consumer Secret</em> you typed in and then try again.
make sure the <em>Consumer Secret</em> you typed in and then try again.
...
...
src/main/resources/lang_zh_CN.properties
View file @
ef1b3d98
...
@@ -18,7 +18,7 @@
...
@@ -18,7 +18,7 @@
#
#
# Description: Solo default language configurations(zh_CN).
# Description: Solo default language configurations(zh_CN).
# Version: 2.21.0.
1, Apr 5
, 2018
# Version: 2.21.0.
2, Aug 27
, 2018
# Author: Liang Ding
# Author: Liang Ding
# Author: Liyuan Li
# Author: Liyuan Li
# Author: Dongxu Wang
# Author: Dongxu Wang
...
@@ -392,7 +392,7 @@ titleEmptyLabel=\u6807\u9898\u4E0D\u80FD\u4E3A\u7A7A\uFF01
...
@@ -392,7 +392,7 @@ titleEmptyLabel=\u6807\u9898\u4E0D\u80FD\u4E3A\u7A7A\uFF01
contentEmptyLabel
=
\u5185\u
5BB9
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF01
contentEmptyLabel
=
\u5185\u
5BB9
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF01
orderEmptyLabel
=
\u
5E8F
\u
53F7
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF01
orderEmptyLabel
=
\u
5E8F
\u
53F7
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF01
abstractEmptyLabel
=
\u6458\u8981\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF01
abstractEmptyLabel
=
\u6458\u8981\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF01
tagsEmptyLabel
=
\u6807\u
7B7E
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF01
tagsEmptyLabel
=
\u6807\u
7B7E
\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF0
8
\u
8BF7
\u
52FF
\u5305\u
542B
\u
7B26
\u
53F7
\u
FF09
\u
FF0
1
addressEmptyLabel
=
\u5730\u5740\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF01
addressEmptyLabel
=
\u5730\u5740\u
4E0D
\u
80FD
\u
4E3A
\u
7A7A
\u
FF01
noAuthorizationURLLabel
=
\u
4ECE Google
\u
83B7
\u
53D6
\u6388\u6743\u5730\u5740\u5931\u
8D25
\u
FF0C
\u
8BF7
\u
786E
\u
8BA4
\u
60A8
\u
8F93
\u5165\u7684
\
noAuthorizationURLLabel
=
\u
4ECE Google
\u
83B7
\u
53D6
\u6388\u6743\u5730\u5740\u5931\u
8D25
\u
FF0C
\u
8BF7
\u
786E
\u
8BA4
\u
60A8
\u
8F93
\u5165\u7684
\
<em>Consumer Secret</em>
\u
662F
\u
6B63
\u
786E
\u7684\u
FF0C
\u7136\u
540E
\u
8FDB
\u
884C
\u
91CD
\u
8BD5
\u3002
<em>Consumer Secret</em>
\u
662F
\u
6B63
\u
786E
\u7684\u
FF0C
\u7136\u
540E
\u
8FDB
\u
884C
\u
91CD
\u
8BD5
\u3002
...
...
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