Bladeren bron

Merge branch 'master' of http://8.136.199.33:3000/hongze/hongze_cygx into cygx_12.1

xingzai 1 jaar geleden
bovenliggende
commit
404c11c231
2 gewijzigde bestanden met toevoegingen van 23 en 5 verwijderingen
  1. 6 5
      controllers/yanxuan_special.go
  2. 17 0
      services/article.go

+ 6 - 5
controllers/yanxuan_special.go

@@ -69,11 +69,12 @@ func (this *YanxuanSpecialController) List() {
 		}
 		v.Content = utils.ArticleRemoveImgUrl(v.Content)
 
-		v.Content, err = utils.ExtractText(v.Content)
-		if err != nil {
-			return
-		}
-		v.Content, _ = services.GetReportContentTextSubNew(v.Content)
+		//v.Content, err = utils.ExtractText(v.Content)
+		//if err != nil {
+		//	return
+		//}
+		//v.Content, _ = services.GetReportContentTextSubNew(v.Content)
+		v.Content = services.AnnotationHtml(v.Content)
 		if v.DocUrl != "" {
 			var docs []models.Doc
 			err := json.Unmarshal([]byte(v.DocUrl), &docs)

+ 17 - 0
services/article.go

@@ -1924,6 +1924,12 @@ func ArticleAnnotation(item *models.HomeArticle) (annotation string) {
 	return
 }
 
+//func init() {
+//	strss := AnnotationHtml("")
+//
+//	fmt.Println(strss)
+//}
+
 // 处理核心观点的展示规则
 func AnnotationHtml(bodyText string) (annotation string) {
 	if bodyText == "" {
@@ -1966,6 +1972,17 @@ func AnnotationHtml(bodyText string) (annotation string) {
 			mapSort = append(mapSort, textLen)
 		}
 	})
+
+	section := doc.Find("section")
+	section.Each(func(tk int, section *goquery.Selection) {
+		sectionText := section.Text()
+		sectionText = strings.Replace(sectionText, " ", "", -1)
+		if sectionText != "" {
+			textLen := strings.Index(docText, sectionText)
+			mapDoc[(strings.Index(docText, sectionText))] = sectionText
+			mapSort = append(mapSort, textLen)
+		}
+	})
 	if len(mapSort) == 0 {
 		return
 	} else {