From 1bad148d668948dcb7c19b0f64d3eac98692ce0a Mon Sep 17 00:00:00 2001 From: cxt <853663049@qq.com> Date: Sat, 21 Sep 2019 15:30:37 +0800 Subject: [PATCH] =?UTF-8?q?es=E6=90=9C=E7=B4=A2=E6=97=B6=E5=8E=BB=E6=8E=89?= =?UTF-8?q?=E5=9B=BE=E7=89=87=E9=93=BE=E6=8E=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/views/searchs/index.json.jbuilder | 6 ++++-- app/views/shixun_lists/index.json.jbuilder | 8 +++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/app/views/searchs/index.json.jbuilder b/app/views/searchs/index.json.jbuilder index e12ebbca8..164e90b53 100644 --- a/app/views/searchs/index.json.jbuilder +++ b/app/views/searchs/index.json.jbuilder @@ -9,8 +9,10 @@ json.results do # 去除开头标点符号 reg = /^[,。?:;‘’!“”—……、]/ - highlights[:description]&.first&.sub!(reg, '') - highlights[:content]&.first&.sub!(reg, '') + # 附件的替换 + atta_reg = /!\[\]\(\/api\/attachments\/\d+\)/ + highlights[:description]&.first&.sub!(reg, '').sub!(atta_reg, '') + highlights[:content]&.first&.sub!(reg, '').sub!(atta_reg, '') json.content highlights end diff --git a/app/views/shixun_lists/index.json.jbuilder b/app/views/shixun_lists/index.json.jbuilder index d6c651743..400e6fb8e 100644 --- a/app/views/shixun_lists/index.json.jbuilder +++ b/app/views/shixun_lists/index.json.jbuilder @@ -7,11 +7,13 @@ json.shixun_list do # 去除开头标点符号 reg = /^[,。?:;‘’!“”—……、]/ - highlights[:description]&.first&.sub!(reg, '') - highlights[:content]&.first&.sub!(reg, '') + # 附件的替换 + atta_reg = /!\[\]\(\/api\/attachments\/\d+\)/ + highlights[:description]&.first&.sub!(reg, '').sub!(atta_reg, '') + highlights[:content]&.first&.sub!(reg, '').sub!(atta_reg, '') json.title highlights.delete(:name)&.join('...') || obj.searchable_title - json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300] + json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300].sub!(atta_reg, '') json.content highlights json.level level_to_s(obj.trainee)