예제 #1
0
func make_text_readable(entry *ReadEntry, txt string, trans, insimg bool) (string, feed.FeedTextStatus) {
	var status feed.FeedTextStatus
	if txt == "" {
		status.Status = status.Status | feed.Feed_status_content_empty
		return empty_flowdocument, status
	}
	if trans {
		txt = markhtml.TransferText(txt)
	}
	redirector := func(uri string) string {
		return redirect_thumbnail(url_resolve(entry.Uri, uri))
	}
	imgurl_maker := func(uri string) string {
		u := url_resolve(entry.Uri, uri)
		return imageurl_from_video(u)
	}
	frag, _ := html_create_fragment(txt)
	frag, score, _ := cleaner.NewExtractor(backend_context.config.CleanFolder).MakeFragmentReadable(frag)
	entry.Images = append_unique(entry.Images, feedmedias_from_docsummary(score.Images, redirector)...)
	entry.Images = append_unique(entry.Images, feedmedias_from_docsummary(score.Medias, imgurl_maker)...)

	entry.Videos = append_unique(entry.Videos, feedmedias_from_docsummary(score.Medias, func(o string) string { return o })...)
	status.WordCount = score.WordCount
	status.LinkCount = score.LinkCount
	status.LinkWordCount = score.LinkWordCount
	if status.WordCount < backend_config().SummaryMinWords {
		//		if status.WordCount > 0 {
		//			entry.Title.Others = append(entry.Title.Others, score.Text)
		//		}
		status.Status = status.Status | feed.Feed_status_content_empty
	}
	if status.WordCount > 0 && feedentry_content_exists(score.Hash) {
		status.Status = status.Status | feed.Feed_status_content_duplicated
	}
	status.Status |= feed.Feed_status_content_ready
	imgs := entry.Images
	if insimg == false || len(imgs) > 1 ||
		len(entry.Videos) > 0 ||
		status.WordCount < backend_config().SummaryMinWords {
		imgs = nil
	} else if len(imgs) > 0 {
		status.Status |= feed.Feed_status_content_mediainline
	}
	return new_flowdoc_maker().make(frag, imgs), status
}
예제 #2
0
파일: main.go 프로젝트: heartszhang/famous
func main() {
	fmt.Println(markhtml.TransferText(x))
}