<commit_before>package impl

import (
	"log"
	"os"
	"strings"

	"github.com/Anteoy/go-gypsy/yaml"
	. "github.com/Anteoy/liongo/constant"
	. "github.com/Anteoy/liongo/utils"
	"github.com/Anteoy/liongo/utils/logrus"
	"strconv"
	"fmt"
)

type ProcessBlogListPage struct{}

//渲染生成/blog.html
func (processBlogList *ProcessBlogListPage) Dispose(dir string) {
	if !strings.HasSuffix(dir, "/") {
		dir += "/"
	}

	yCfg := YamlData["config.yml"]
	var cfg *yaml.File
	if value, ok := yCfg.(*yaml.File); ok {
		cfg = value
	}
	//var cfg = yCfg.(*yaml.File)
	t := ParseTemplate(dir, BLOG_LIST_TPL, cfg)

	targetFile := PUBLISH_DIR + "/blog.html"
	fout, err := os.Create(targetFile)
	if err != nil {
		logrus.Error("create file " + targetFile + " error!")
		os.Exit(1)
	}
	defer fout.Close()
	m := map[string]interface{}{"ar": Articlesl[:], "nav": NavBarsl, "cats": Classifiesm}
	exErr := t.Execute(fout, m)
	if exErr != nil {
		log.Fatal(exErr)
	}

	//处理分页
	totalPage := len(Articlesl)/10
	fmt.Println("============1",len(Articlesl))
	//TODO
	if len(Articlesl)%10 != 0 {
		totalPage++
	}
	//每页显示个数
	pageSize := 10
	//当前需要渲染的articlesl
	for i := 0;i < totalPage;i++ {
		targetFile := PUBLISH_DIR + "/blog_"+ strconv.Itoa(i) + ".html"
		var pre string
		var next string
		if os.Getenv("liongo_env") == "online"{
			pre = "http://anteoy.site" + "/blog_"+ strconv.Itoa(i-1) + ".html"
			next = 	"http://anteoy.site" + "/blog_"+ strconv.Itoa(i+1) + ".html"
		}else {
			pre = "http://127.0.0.1:8080" + "/blog_"+ strconv.Itoa(i-1) + ".html"
			next = 	"http://127.0.0.1:8080" + "/blog_"+ strconv.Itoa(i+1) + ".html"
		}
		fout, err := os.Create(targetFile)
		if err != nil {
			logrus.Error("create file " + targetFile + " error!")
			os.Exit(1)
		}
		defer fout.Close()
		start := i * pageSize<commit_msg>update count + 1<commit_after>package impl

import (
	"log"
	"os"
	"strings"

	"github.com/Anteoy/go-gypsy/yaml"
	. "github.com/Anteoy/liongo/constant"
	. "github.com/Anteoy/liongo/utils"
	"github.com/Anteoy/liongo/utils/logrus"
	"strconv"
	"fmt"
)

type ProcessBlogListPage struct{}

//渲染生成/blog.html
func (processBlogList *ProcessBlogListPage) Dispose(dir string) {
	if !strings.HasSuffix(dir, "/") {
		dir += "/"
	}

	yCfg := YamlData["config.yml"]
	var cfg *yaml.File
	if value, ok := yCfg.(*yaml.File); ok {
		cfg = value
	}
	//var cfg = yCfg.(*yaml.File)
	t := ParseTemplate(dir, BLOG_LIST_TPL, cfg)

	targetFile := PUBLISH_DIR + "/blog.html"
	fout, err := os.Create(targetFile)
	if err != nil {
		logrus.Error("create file " + targetFile + " error!")
		os.Exit(1)
	}
	defer fout.Close()
	m := map[string]interface{}{"ar": Articlesl[:], "nav": NavBarsl, "cats": Classifiesm}
	exErr := t.Execute(fout, m)
	if exErr != nil {
		log.Fatal(exErr)
	}

	//处理分页
	totalPage := len(Articlesl)/10
	fmt.Println("============1",len(Articlesl))
	//TODO
	if len(Articlesl)%10 != 0 {
		totalPage++
	}
	//每页显示个数
	pageSize := 10
	//当前需要渲染的articlesl
	for i := 0;i < totalPage;i++ {
		targetFile := PUBLISH_DIR + "/blog_"+ strconv.Itoa(i+1) + ".html"
		var pre string
		var next string
		//update count + 1
		if os.Getenv("liongo_env") == "online"{
			pre = "http://anteoy.site" + "/blog_"+ strconv.Itoa(i-1+1) + ".html"
			next = 	"http://anteoy.site" + "/blog_"+ strconv.Itoa(i+1+1) + ".html"
		}else {
			pre = "http://127.0.0.1:8080" + "/blog_"+ strconv.Itoa(i-1+1) + ".html"
			next = 	"http://127.0.0.1:8080" + "/blog_"+ strconv.Itoa(i+1+1) + ".html"
		}
		fout, err := os.Create(targetFile)
		if err != nil {
			logrus.Error("create file " + targetFile + " error!")
			os.Exit(1)
		}
		defer fout.Close()
		start := i * pageSize
{'fraction_non_alphanumeric': 0.20593126385809313, 'fraction_numerical': 0.021341463414634148, 'mean_word_length': 3.4888059701492535, 'pattern_counts': {'":': 6, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4656334', 'n_tokens_mistral': 1692, 'n_tokens_neox': 1574, 'n_words': 286}