Commit 6c8b4b6d authored by Liang Ding's avatar Liang Ding

🎨 #21

parent 94b3f9a2
...@@ -49,7 +49,7 @@ import java.util.stream.Collectors; ...@@ -49,7 +49,7 @@ import java.util.stream.Collectors;
* Article console request processing. * Article 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.2.0.2, May 18, 2019 * @version 1.2.0.3, Dec 28, 2019
* @since 0.4.0 * @since 0.4.0
*/ */
@Singleton @Singleton
...@@ -105,10 +105,10 @@ public class ArticleConsole { ...@@ -105,10 +105,10 @@ public class ArticleConsole {
* { * {
* "sc": true, * "sc": true,
* "data": [ * "data": [
* "https://img.hacpai.com/bing/20171226.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://img.hacpai.com/bing/20171105.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://img.hacpai.com/bing/20180105.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://img.hacpai.com/bing/20171114.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> * </pre>
......
...@@ -52,7 +52,7 @@ import java.util.List; ...@@ -52,7 +52,7 @@ import java.util.List;
* Solo initialization service. * Solo initialization service.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @author <a href="http://88250.b3log.org">Liang Ding</a>
* @version 1.5.2.35, Oct 23, 2019 * @version 1.5.2.36, Dec 28, 2019
* @since 0.4.0 * @since 0.4.0
*/ */
@Service @Service
...@@ -284,7 +284,7 @@ public class InitService { ...@@ -284,7 +284,7 @@ public class InitService {
comment.put(Comment.COMMENT_CONTENT, langPropsService.get("helloWorld.comment.content")); comment.put(Comment.COMMENT_CONTENT, langPropsService.get("helloWorld.comment.content"));
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, ""); comment.put(Comment.COMMENT_ORIGINAL_COMMENT_ID, "");
comment.put(Comment.COMMENT_ORIGINAL_COMMENT_NAME, ""); 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_CREATED, now);
comment.put(Comment.COMMENT_ON_ID, articleId); comment.put(Comment.COMMENT_ON_ID, articleId);
final String commentId = Ids.genTimeMillisId(); final String commentId = Ids.genTimeMillisId();
......
...@@ -31,7 +31,7 @@ import java.util.concurrent.ThreadLocalRandom; ...@@ -31,7 +31,7 @@ import java.util.concurrent.ThreadLocalRandom;
* Image utilities. * Image utilities.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 2.7.0
*/ */
public final class Images { public final class Images {
...@@ -41,6 +41,11 @@ public final class Images { ...@@ -41,6 +41,11 @@ public final class Images {
*/ */
private static final Logger LOGGER = Logger.getLogger(Images.class); 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. * Qiniu image processing.
* *
...@@ -49,15 +54,13 @@ public final class Images { ...@@ -49,15 +54,13 @@ public final class Images {
*/ */
public static String qiniuImgProcessing(final String html) { public static String qiniuImgProcessing(final String html) {
String ret = html; String ret = html;
final String qiniuDomain = "https://img.hacpai.com";
final String[] imgSrcs = StringUtils.substringsBetween(html, "<img src=\"", "\""); final String[] imgSrcs = StringUtils.substringsBetween(html, "<img src=\"", "\"");
if (null == imgSrcs) { if (null == imgSrcs) {
return ret; return ret;
} }
for (final String imgSrc : imgSrcs) { for (final String imgSrc : imgSrcs) {
if (!StringUtils.startsWith(imgSrc, qiniuDomain) || StringUtils.contains(imgSrc, ".gif") if (StringUtils.contains(imgSrc, ".gif") || StringUtils.containsIgnoreCase(imgSrc, "imageView")) {
|| StringUtils.containsIgnoreCase(imgSrc, "imageView")) {
continue; continue;
} }
...@@ -76,7 +79,7 @@ public final class Images { ...@@ -76,7 +79,7 @@ public final class Images {
* @return image URL * @return image URL
*/ */
public static String imageSize(final String imageURL, final int width, final int height) { 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; return imageURL;
} }
...@@ -95,11 +98,11 @@ public final class Images { ...@@ -95,11 +98,11 @@ public final class Images {
final long delta = max - min; final long delta = max - min;
final long time = ThreadLocalRandom.current().nextLong(0, delta) + 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) { } catch (final Exception e) {
LOGGER.log(Level.ERROR, "Generates random image URL failed", 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";
} }
} }
......
...@@ -26,7 +26,7 @@ import java.util.List; ...@@ -26,7 +26,7 @@ import java.util.List;
* {@link org.b3log.solo.util.Images} test case. * {@link org.b3log.solo.util.Images} test case.
* *
* @author <a href="http://88250.b3log.org">Liang Ding</a> * @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 * @since 2.7.0
*/ */
public final class ImagesTestCase { public final class ImagesTestCase {
...@@ -37,7 +37,7 @@ public final class ImagesTestCase { ...@@ -37,7 +37,7 @@ public final class ImagesTestCase {
@Test @Test
public void randImage() { public void randImage() {
final String url = Images.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());
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment