Section is determined by the source, not the url

This change allows for top level html content to exists.
This commit is contained in:
Noah Campbell 2013-09-20 17:03:43 -07:00
parent 784077da4d
commit 52e8c7a0ac
12 changed files with 265 additions and 142 deletions

34
source/inmemory.go Normal file
View file

@ -0,0 +1,34 @@
package source
import (
"bytes"
"fmt"
"path"
)
type ByteSource struct {
Name string
Content []byte
Section string
}
func (b *ByteSource) String() string {
return fmt.Sprintf("%s %s %s", b.Name, b.Section, string(b.Content))
}
type InMemorySource struct {
ByteSource []ByteSource
}
func (i *InMemorySource) Files() (files []*File) {
files = make([]*File, len(i.ByteSource))
for i, fake := range i.ByteSource {
files[i] = &File{
LogicalName: fake.Name,
Contents: bytes.NewReader(fake.Content),
Section: fake.Section,
Dir: path.Dir(fake.Name),
}
}
return
}