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
fb4f68d7
Unverified
Commit
fb4f68d7
authored
May 15, 2020
by
Liang Ding
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🎨
社区图床地址替换 #21
parent
012d0c46
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
7 deletions
+4
-7
src/main/java/org/b3log/solo/util/Images.java
src/main/java/org/b3log/solo/util/Images.java
+4
-7
No files found.
src/main/java/org/b3log/solo/util/Images.java
View file @
fb4f68d7
...
...
@@ -29,7 +29,7 @@ import java.util.concurrent.ThreadLocalRandom;
* Image utilities.
*
* @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.2.0.
0, Apr 30
, 2020
* @version 1.2.0.
1, May 15
, 2020
* @since 2.7.0
*/
public
final
class
Images
{
...
...
@@ -42,7 +42,7 @@ public final class Images {
/**
* Community file service URL.
*/
public
static
String
COMMUNITY_FILE_URL
=
"https://
img.hacpai
.com"
;
public
static
String
COMMUNITY_FILE_URL
=
"https://
b3logdata
.com"
;
/**
* Checks whether the specified URL has uploaded.
...
...
@@ -51,7 +51,7 @@ public final class Images {
* @return {@code true} if it has uploaded, returns {@code false} otherwise
*/
public
static
boolean
uploaded
(
final
String
url
)
{
return
StringUtils
.
startsWith
(
url
,
COMMUNITY_FILE_URL
);
return
StringUtils
.
startsWith
(
url
,
COMMUNITY_FILE_URL
)
||
StringUtils
.
startsWith
(
url
,
"https://img.hacpai.com"
)
;
}
/**
...
...
@@ -67,7 +67,7 @@ public final class Images {
for
(
final
Element
img
:
imgs
)
{
String
imgSrc
=
img
.
attr
(
"src"
);
if
(!
StringUtils
.
startsWith
(
imgSrc
,
COMMUNITY_FILE_URL
)
||
if
(!
uploaded
(
imgSrc
)
||
StringUtils
.
contains
(
imgSrc
,
".gif"
)
||
StringUtils
.
containsIgnoreCase
(
imgSrc
,
"imageView"
)
||
StringUtils
.
containsIgnoreCase
(
imgSrc
,
"data:"
))
{
continue
;
...
...
@@ -105,11 +105,9 @@ public final class Images {
final
long
max
=
System
.
currentTimeMillis
();
final
long
delta
=
max
-
min
;
final
long
time
=
ThreadLocalRandom
.
current
().
nextLong
(
0
,
delta
)
+
min
;
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
COMMUNITY_FILE_URL
+
"/bing/20171104.jpg"
;
}
}
...
...
@@ -122,7 +120,6 @@ public final class Images {
*/
public
static
List
<
String
>
randomImages
(
final
int
n
)
{
final
List
<
String
>
ret
=
new
ArrayList
<>();
int
i
=
0
;
while
(
i
<
n
*
5
)
{
final
String
url
=
randImage
();
...
...
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