diff options
author | Noah Campbell <noahcampbell@gmail.com> | 2013-09-20 17:03:43 -0700 |
---|---|---|
committer | Noah Campbell <noahcampbell@gmail.com> | 2013-09-20 17:03:43 -0700 |
commit | 52e8c7a0ac76f4aa1fff8ff30a6d5074bd459347 (patch) | |
tree | fcabd15f6b496589edcf56be200f865177606a70 /source/inmemory.go | |
parent | 784077da4dcc3476f61bbf99c5f873b71694dd64 (diff) |
Section is determined by the source, not the url
This change allows for top level html content to exists.
Diffstat (limited to 'source/inmemory.go')
-rw-r--r-- | source/inmemory.go | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/source/inmemory.go b/source/inmemory.go new file mode 100644 index 000000000..7c76469fe --- /dev/null +++ b/source/inmemory.go @@ -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 +} |