<commit_before>// Copyright © 2013 <NAME> <<EMAIL>>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package hugolib

import (
	"bitbucket.org/pkg/inflect"
	"bytes"
	"fmt"
	"github.com/spf13/nitro"
	"html/template"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"time"
	//"sync"
)

type Site struct {
	c           Config
	Pages       Pages
	Tmpl        *template.Template
	Indexes     IndexList
	Files       []string
	Directories []string
	Sections    Index
	Info        SiteInfo
	Shortcodes  map[string]ShortcodeFunc
	timer       *nitro.B
}

type SiteInfo struct {
	BaseUrl    template.URL
	Indexes    *OrderedIndexList
	Recent     *Pages
	LastChange time.Time
    Title      string
}

func (s *Site) getFromIndex(kind string, name string) Pages {
	return s.Indexes[kind][name]
}

func NewSite(config *Config) *Site {
	return &Site{c: *config, timer: nitro.Initalize()}
}

func (site *Site) Build() {
	site.Process()
	site.Render()
	site.Write()
}

func (site *Site) Analyze() {
	site.Process()
	site.checkDescriptions()
}

func (site *Site) Process() {
	site.initialize()
	site.prepTemplates()
	site.timer.Step("initialize & template prep")
	site.CreatePages()
	site.timer.Step("import pages")
	site.BuildSiteMeta()
	site.timer.Step("build indexes")
}

func (site *Site) Render() {
	site.RenderIndexes()
	site.timer.Step("render and write indexes")
	site.RenderLists()
	site.timer.Step("render and write lists")
	site.ProcessShortcodes()
	site.timer.Step("render shortcodes")
	site.AbsUrlify()
	site.timer.Step("absolute URLify")
	site.RenderPages()
	site.timer.Step("render pages")
	site.RenderHomePage()
	site.timer.Step("render and write homepage")
}

func (site *Site) Write() {
	site.WritePages()
	site.timer.Step("write pages")
}

func (site *Site) checkDescriptions() {
	for _, p := range site.Pages {
		if len(p.Description) < 60 {
			fmt.Print(p.FileName + " ")
		}
	}
}

func (s *Site) prepTemplates() {<commit_msg>Render shortcodes before index and section rss feeds<commit_after>// Copyright © 2013 <NAME> <<EMAIL>>.
//
// Licensed under the Simple Public License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// http://opensource.org/licenses/Simple-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

package hugolib

import (
	"bitbucket.org/pkg/inflect"
	"bytes"
	"fmt"
	"github.com/spf13/nitro"
	"html/template"
	"io/ioutil"
	"os"
	"path/filepath"
	"strings"
	"time"
	//"sync"
)

type Site struct {
	c           Config
	Pages       Pages
	Tmpl        *template.Template
	Indexes     IndexList
	Files       []string
	Directories []string
	Sections    Index
	Info        SiteInfo
	Shortcodes  map[string]ShortcodeFunc
	timer       *nitro.B
}

type SiteInfo struct {
	BaseUrl    template.URL
	Indexes    *OrderedIndexList
	Recent     *Pages
	LastChange time.Time
    Title      string
}

func (s *Site) getFromIndex(kind string, name string) Pages {
	return s.Indexes[kind][name]
}

func NewSite(config *Config) *Site {
	return &Site{c: *config, timer: nitro.Initalize()}
}

func (site *Site) Build() {
	site.Process()
	site.Render()
	site.Write()
}

func (site *Site) Analyze() {
	site.Process()
	site.checkDescriptions()
}

func (site *Site) Process() {
	site.initialize()
	site.prepTemplates()
	site.timer.Step("initialize & template prep")
	site.CreatePages()
	site.timer.Step("import pages")
	site.BuildSiteMeta()
	site.timer.Step("build indexes")
}

func (site *Site) Render() {
	site.ProcessShortcodes()
	site.timer.Step("render shortcodes")
	site.AbsUrlify()
	site.timer.Step("absolute URLify")
	site.RenderIndexes()
	site.timer.Step("render and write indexes")
	site.RenderLists()
	site.timer.Step("render and write lists")
	site.RenderPages()
	site.timer.Step("render pages")
	site.RenderHomePage()
	site.timer.Step("render and write homepage")
}

func (site *Site) Write() {
	site.WritePages()
	site.timer.Step("write pages")
}

func (site *Site) checkDescriptions() {
	for _, p := range site.Pages {
		if len(p.Description) < 60 {
			fmt.Print(p.FileName + " ")
		}
	}
}

func (s *Site) prepTemplates() {
{'fraction_non_alphanumeric': 0.12858596134282807, 'fraction_numerical': 0.0048830111902339775, 'mean_word_length': 3.7451737451737452, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, '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': '6562803', 'n_tokens_mistral': 1663, 'n_tokens_neox': 1619, 'n_words': 473}