dev_ec
cxt 5 years ago
parent fbb033a0a2
commit 8cc30ccd52

@ -11,12 +11,12 @@ json.shixun_list do
atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/ atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/
highlights[:description]&.first&.sub!(reg, '') highlights[:description]&.first&.sub!(reg, '')
highlights[:description]&.map{|des| des.gsub!(atta_reg, '')} highlights[:description]&.map{|des| des.gsub(atta_reg, '')}
highlights[:content]&.first&.sub!(reg, '') highlights[:content]&.first&.sub!(reg, '')
highlights[:content]&.map{|des| des.gsub!(atta_reg, '')} highlights[:content]&.map{|des| des.gsub(atta_reg, '')}
json.title highlights.delete(:name)&.join('...') || obj.searchable_title json.title highlights.delete(:name)&.join('...') || obj.searchable_title
json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.sub!(atta_reg, '') json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.gsub(atta_reg, '')
json.content highlights json.content highlights
json.level level_to_s(obj.trainee) json.level level_to_s(obj.trainee)

@ -7,15 +7,15 @@ json.subject_list do
# 去除开头标点符号 # 去除开头标点符号
reg = /^[,。?:;‘’!“”—……、]/ reg = /^[,。?:;‘’!“”—……、]/
# 附件的替换 # 附件的替换
atta_reg = /!\[.*]\(\/api\/attachments\/\d+\)/ atta_reg = /!\[.*\]\(\/api\/attachments\/\d+\)/
highlights[:description]&.first&.sub!(reg, '') highlights[:description]&.first&.sub!(reg, '')
highlights[:description]&.map{|des| des.gsub!(atta_reg, '')} highlights[:description]&.map{|des| des.gsub(atta_reg, '')}
highlights[:content]&.first&.sub!(reg, '') highlights[:content]&.first&.sub!(reg, '')
highlights[:content]&.map{|des| des.gsub!(atta_reg, '')} highlights[:content]&.map{|des| des.gsub(atta_reg, '')}
json.title highlights.delete(:name)&.join('...') || obj.searchable_title json.title highlights.delete(:name)&.join('...') || obj.searchable_title
json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.sub!(atta_reg, '') json.description highlights[:description]&.join('...') || Util.extract_content(obj.description)[0..300]&.gsub(atta_reg, '')
json.content highlights json.content highlights
end end

Loading…
Cancel
Save