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
6c8b4b6d
Unverified
Commit
6c8b4b6d
authored
Dec 28, 2019
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
#21
parent
94b3f9a2
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
19 additions
and
16 deletions
+19
-16
src/main/java/org/b3log/solo/processor/console/ArticleConsole.java
...java/org/b3log/solo/processor/console/ArticleConsole.java
+5
-5
src/main/java/org/b3log/solo/service/InitService.java
src/main/java/org/b3log/solo/service/InitService.java
+2
-2
src/main/java/org/b3log/solo/util/Images.java
src/main/java/org/b3log/solo/util/Images.java
+10
-7
src/test/java/org/b3log/solo/util/ImagesTestCase.java
src/test/java/org/b3log/solo/util/ImagesTestCase.java
+2
-2
No files found.
src/main/java/org/b3log/solo/processor/console/ArticleConsole.java
View file @
6c8b4b6d
...
...
@@ -49,7 +49,7 @@ import java.util.stream.Collectors;
* Article console request processing.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.
2, May 1
8, 2019
* @version 1.2.0.
3, Dec 2
8, 2019
* @since 0.4.0
*/
@Singleton
...
...
@@ -105,10 +105,10 @@ public class ArticleConsole {
* {
* "sc": true,
* "data": [
* "https://
img.hacpai
.com/bing/20171226.jpg?imageView2/1/w/960/h/540/interlace/1/q/100",
* "https://
img.hacpai
.com/bing/20171105.jpg?imageView2/1/w/960/h/540/interlace/1/q/100",
* "https://
img.hacpai
.com/bing/20180105.jpg?imageView2/1/w/960/h/540/interlace/1/q/100",
* "https://
img.hacpai
.com/bing/20171114.jpg?imageView2/1/w/960/h/540/interlace/1/q/100"
* "https://
b3logfile
.com/bing/20171226.jpg?imageView2/1/w/960/h/540/interlace/1/q/100",
* "https://
b3logfile
.com/bing/20171105.jpg?imageView2/1/w/960/h/540/interlace/1/q/100",
* "https://
b3logfile
.com/bing/20180105.jpg?imageView2/1/w/960/h/540/interlace/1/q/100",
* "https://
b3logfile
.com/bing/20171114.jpg?imageView2/1/w/960/h/540/interlace/1/q/100"
* ]
* }
* </pre>
...
...
src/main/java/org/b3log/solo/service/InitService.java
View file @
6c8b4b6d
...
...
@@ -52,7 +52,7 @@ import java.util.List;
* Solo initialization service.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.3
5, Oct 23
, 2019
* @version 1.5.2.3
6, Dec 28
, 2019
* @since 0.4.0
*/
@Service
...
...
@@ -284,7 +284,7 @@ public class InitService {
comment
.
put
(
Comment
.
COMMENT_CONTENT
,
langPropsService
.
get
(
"helloWorld.comment.content"
));
comment
.
put
(
Comment
.
COMMENT_ORIGINAL_COMMENT_ID
,
""
);
comment
.
put
(
Comment
.
COMMENT_ORIGINAL_COMMENT_NAME
,
""
);
comment
.
put
(
Comment
.
COMMENT_THUMBNAIL_URL
,
"https://img.hacpai.com
/avatar/1353745196354_1535379434567.png?imageView2/1/w/64/h/64/q/100"
);
comment
.
put
(
Comment
.
COMMENT_THUMBNAIL_URL
,
Images
.
COMMUNITY_FILE_URL
+
"
/avatar/1353745196354_1535379434567.png?imageView2/1/w/64/h/64/q/100"
);
comment
.
put
(
Comment
.
COMMENT_CREATED
,
now
);
comment
.
put
(
Comment
.
COMMENT_ON_ID
,
articleId
);
final
String
commentId
=
Ids
.
genTimeMillisId
();
...
...
src/main/java/org/b3log/solo/util/Images.java
View file @
6c8b4b6d
...
...
@@ -31,7 +31,7 @@ import java.util.concurrent.ThreadLocalRandom;
* Image utilities.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.1.0.
1, Apr 13
, 2019
* @version 1.1.0.
2, Dec 28
, 2019
* @since 2.7.0
*/
public
final
class
Images
{
...
...
@@ -41,6 +41,11 @@ public final class Images {
*/
private
static
final
Logger
LOGGER
=
Logger
.
getLogger
(
Images
.
class
);
/**
* Community file service URL.
*/
public
static
String
COMMUNITY_FILE_URL
=
"https://img.hacpai.com"
;
/**
* Qiniu image processing.
*
...
...
@@ -49,15 +54,13 @@ public final class Images {
*/
public
static
String
qiniuImgProcessing
(
final
String
html
)
{
String
ret
=
html
;
final
String
qiniuDomain
=
"https://img.hacpai.com"
;
final
String
[]
imgSrcs
=
StringUtils
.
substringsBetween
(
html
,
"<img src=\""
,
"\""
);
if
(
null
==
imgSrcs
)
{
return
ret
;
}
for
(
final
String
imgSrc
:
imgSrcs
)
{
if
(!
StringUtils
.
startsWith
(
imgSrc
,
qiniuDomain
)
||
StringUtils
.
contains
(
imgSrc
,
".gif"
)
||
StringUtils
.
containsIgnoreCase
(
imgSrc
,
"imageView"
))
{
if
(
StringUtils
.
contains
(
imgSrc
,
".gif"
)
||
StringUtils
.
containsIgnoreCase
(
imgSrc
,
"imageView"
))
{
continue
;
}
...
...
@@ -76,7 +79,7 @@ public final class Images {
* @return image URL
*/
public
static
String
imageSize
(
final
String
imageURL
,
final
int
width
,
final
int
height
)
{
if
(
StringUtils
.
containsIgnoreCase
(
imageURL
,
"imageView"
)
||
!
StringUtils
.
containsIgnoreCase
(
imageURL
,
"img.hacpai.com"
)
)
{
if
(
StringUtils
.
containsIgnoreCase
(
imageURL
,
"imageView"
))
{
return
imageURL
;
}
...
...
@@ -95,11 +98,11 @@ public final class Images {
final
long
delta
=
max
-
min
;
final
long
time
=
ThreadLocalRandom
.
current
().
nextLong
(
0
,
delta
)
+
min
;
return
"https://img.hacpai.com
/bing/"
+
DateFormatUtils
.
format
(
time
,
"yyyyMMdd"
)
+
".jpg"
;
return
COMMUNITY_FILE_URL
+
"
/bing/"
+
DateFormatUtils
.
format
(
time
,
"yyyyMMdd"
)
+
".jpg"
;
}
catch
(
final
Exception
e
)
{
LOGGER
.
log
(
Level
.
ERROR
,
"Generates random image URL failed"
,
e
);
return
"https://img.hacpai.com
/bing/20171104.jpg"
;
return
COMMUNITY_FILE_URL
+
"
/bing/20171104.jpg"
;
}
}
...
...
src/test/java/org/b3log/solo/util/ImagesTestCase.java
View file @
6c8b4b6d
...
...
@@ -26,7 +26,7 @@ import java.util.List;
* {@link org.b3log.solo.util.Images} test case.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.0.0.
0, Feb 14, 2018
* @version 1.0.0.
1, Dec 28, 2019
* @since 2.7.0
*/
public
final
class
ImagesTestCase
{
...
...
@@ -37,7 +37,7 @@ public final class ImagesTestCase {
@Test
public
void
randImage
()
{
final
String
url
=
Images
.
randImage
();
Assert
.
assertEquals
(
url
.
length
(),
"https://img.hacpai.com
/bing/20171104.jpg"
.
length
());
Assert
.
assertEquals
(
url
.
length
(),
Images
.
COMMUNITY_FILE_URL
+
"
/bing/20171104.jpg"
.
length
());
}
/**
...
...
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