Adding support for MinRead. Closed #106

This commit is contained in:
spf13 2013-10-15 09:32:21 -04:00
parent be5ace1588
commit 4263094d75
2 changed files with 6 additions and 0 deletions

View file

@ -60,6 +60,7 @@ type File struct {
type PageMeta struct {
WordCount int
FuzzyWordCount int
MinRead int
}
type Position struct {
@ -226,6 +227,7 @@ func ReadFrom(buf io.Reader, name string) (page *Page, err error) {
func (p *Page) analyzePage() {
p.WordCount = TotalWords(p.Plain())
p.FuzzyWordCount = int((p.WordCount+100)/100) * 100
p.MinRead = int((p.WordCount + 212) / 213)
}
func (p *Page) permalink() (*url.URL, error) {

View file

@ -277,6 +277,10 @@ func TestWordCount(t *testing.T) {
if p.FuzzyWordCount != 500 {
t.Fatalf("incorrect word count. expected %v, got %v", 500, p.WordCount)
}
if p.MinRead != 3 {
t.Fatalf("incorrect min read. expected %v, got %v", 3, p.MinRead)
}
}
func TestCreatePage(t *testing.T) {