소스 검색

新闻中心图片全路径调整

huangct 8 년 전
부모
커밋
2fca8e4b63

+ 2 - 0
jpress-model/src/main/java/io/jpress/model/query/ContentQuery.java

@@ -710,6 +710,7 @@ public class ContentQuery extends JBaseQuery {
                         public Object load() {
                             StringBuilder sqlBuilder = new StringBuilder(" select c.* from content c ,mapping m, taxonomy t where c.module='news' and c.status='normal' and m.content_id=c.id and m.taxonomy_id=t.id and t.type = 'category' ");
                             List<Taxonomy> taxonomys =  currentContent.getTaxonomys();
+							//TODO taxonomys 判空
                             for (int i = 0; i < taxonomys.size(); i++) {
                                 String slug = taxonomys.get(i).getSlug();
                                 if ("tradeNews".equals(slug) || "companyDynamic".equals(slug)) {
@@ -797,6 +798,7 @@ public class ContentQuery extends JBaseQuery {
                         public Object load() {
                             StringBuilder sqlBuilder = new StringBuilder(" select c.* from content c ,mapping m, taxonomy t where c.module='news' and c.status='normal' and m.content_id=c.id and m.taxonomy_id=t.id and t.type = 'category' ");
                             List<Taxonomy> taxonomys =  currentContent.getTaxonomys();
+							//TODO taxonomys 判空
                             for (int i = 0; i < taxonomys.size(); i++) {
                                 String slug = taxonomys.get(i).getSlug();
                                 if ("tradeNews".equals(slug) || "companyDynamic".equals(slug)) {

+ 8 - 2
jpress-web-admin/src/main/java/io/jpress/admin/controller/_ContentController.java

@@ -576,8 +576,14 @@ public class _ContentController extends JBaseCRUDController<Content> {
 
 	private Content getContent() {
 		Content content = getModel(Content.class);
-
-		content.setText(JsoupUtils.getBodyHtml(content.getText()));
+		String text = JsoupUtils.getBodyHtml(content.getText());
+		if ("news".equals(content.getModule())) {// /jpress/attachment/
+			//String requestUrlMessage = this.getRequest().getScheme() +"://" + this.getRequest().getServerName() + ":" + this.getRequest().getServerPort();
+			String regexStr = "src=\"/attachment/";
+			String replacement = "src=\"https://www.usoftchina.com/attachment/";
+			text = text.replaceAll(regexStr, replacement);
+		}
+		content.setText(text);
 
 		if (content.getCommentStatus() == null) {
 			content.setCommentStatus(Content.COMMENT_STATUS_CLOSE);