summaryrefslogtreecommitdiffstats
path: root/source/inmemory.go
diff options
context:
space:
mode:
authorNoah Campbell <noahcampbell@gmail.com>2013-09-20 17:03:43 -0700
committerNoah Campbell <noahcampbell@gmail.com>2013-09-20 17:03:43 -0700
commit52e8c7a0ac76f4aa1fff8ff30a6d5074bd459347 (patch)
treefcabd15f6b496589edcf56be200f865177606a70 /source/inmemory.go
parent784077da4dcc3476f61bbf99c5f873b71694dd64 (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.go34
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
+}