<commit_before>//
// model_mem.go
//
// models held in memory
//
package srnd

import (
	"encoding/json"
	"fmt"
	"io"
	"path/filepath"
	"strings"
	"time"
)

type boardModel struct {
	allowFiles bool
	frontend   string
	prefix     string
	board      string
	page       int
	pages      int
	threads    []ThreadModel
}

func (self *boardModel) MarshalJSON() (b []byte, err error) {
	return json.Marshal(self.threads)
}

func (self *boardModel) SetAllowFiles(allow bool) {
	self.allowFiles = allow
}

func (self *boardModel) AllowFiles() bool {
	return self.allowFiles
}

func (self *boardModel) PutThread(th ThreadModel) {
	idx := -1
	for i, t := range self.threads {
		if th.OP().MessageID() == t.OP().MessageID() {
			idx = i
			break
		}
	}
	if idx != -1 {
		self.threads[idx] = th
	}
}

func (self *boardModel) Navbar() string {
	param := make(map[string]interface{})
	param["name"] = fmt.Sprintf("page %d for %s", self.page, self.board)
	param["frontend"] = self.frontend
	var links []LinkModel
	for i := 0; i < self.pages; i++ {
		links = append(links, linkModel{
			link: fmt.Sprintf("%s%s-%d.html", self.prefix, self.board, i),
			text: fmt.Sprintf("[ %d ]", i),
		})
	}
	param["prefix"] = self.prefix
	param["links"] = links
	return template.renderTemplate("navbar.mustache", param)
}

func (self *boardModel) PageList() []LinkModel {
	var links []LinkModel
	for i := 0; i < self.pages; i++ {
		links = append(links, linkModel{
			link: fmt.Sprintf("%s%s-%d.html", self.prefix, self.board, i),
			text: fmt.Sprintf("%d", i),
		})
	}
	return links
}

func (self *boardModel) UpdateThread(messageID string, db Database) {<commit_msg>Add Board titles<commit_after>//
// model_mem.go
//
// models held in memory
//
package srnd

import (
	"encoding/json"
	"fmt"
	"io"
	"path/filepath"
	"strings"
	"time"
)

type boardModel struct {
	allowFiles bool
	frontend   string
	prefix     string
	board      string
	page       int
	pages      int
	threads    []ThreadModel
}

func (self *boardModel) MarshalJSON() (b []byte, err error) {
	return json.Marshal(self.threads)
}

func (self *boardModel) SetAllowFiles(allow bool) {
	self.allowFiles = allow
}

func (self *boardModel) AllowFiles() bool {
	return self.allowFiles
}

func (self *boardModel) PutThread(th ThreadModel) {
	idx := -1
	for i, t := range self.threads {
		if th.OP().MessageID() == t.OP().MessageID() {
			idx = i
			break
		}
	}
	if idx != -1 {
		self.threads[idx] = th
	}
}

func (self *boardModel) Navbar() string {
	param := make(map[string]interface{})
	param["name"] = fmt.Sprintf("page %d for %s", self.page, self.board)
	param["frontend"] = self.frontend
	var links []LinkModel
	for i := 0; i < self.pages; i++ {
		links = append(links, linkModel{
			link: fmt.Sprintf("%s%s-%d.html", self.prefix, self.board, i),
			text: fmt.Sprintf("[ %d ]", i),
		})
	}
	param["prefix"] = self.prefix
	param["links"] = links
	return template.renderTemplate("navbar.mustache", param)
}

func (self *boardModel) Board() string {
	return self.board
}

func (self *boardModel) PageList() []LinkModel {
	var links []LinkModel
	for i := 0; i < self.pages; i++ {
		links = append(links, linkModel{
			link: fmt.Sprintf("%s%s-%d.html", self.prefix, self.board, i),
			text: fmt.Sprintf("%d", i),
		})
	}
	return links
}

func (self *boardModel) UpdateThread(messageID string, db Database) {
{'fraction_non_alphanumeric': 0.16407185628742516, 'fraction_numerical': 0.0023952095808383233, 'mean_word_length': 3.6210235131396957, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, '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': '4188586', 'n_tokens_mistral': 1254, 'n_tokens_neox': 1209, 'n_words': 323}