Documentation ¶
Overview ¶
Package imexport provides functions to import and export S&D templates and data sources. Folder and .zip archive imports and exports are supported at the moment.
Index ¶
- func ExportGenerator(gen snd.Generator, writer ExportWriter) error
- func ExportGeneratorFolder(tmpl snd.Generator, folder string) (string, error)
- func ExportGeneratorJSON(gen snd.Generator) ([]byte, error)
- func ExportGeneratorZIP(gen snd.Generator, writer io.Writer) (string, error)
- func ExportGeneratorZIPFile(gen snd.Generator, folder string) (string, error)
- func ExportSource(ds snd.DataSource, entries []snd.Entry, writer ExportWriter) error
- func ExportSourceFolder(ds snd.DataSource, entries []snd.Entry, folder string) (string, error)
- func ExportSourceJSON(ds snd.DataSource, entries []snd.Entry) ([]byte, error)
- func ExportSourceZIP(ds snd.DataSource, entries []snd.Entry, writer io.Writer) (string, error)
- func ExportSourceZIPFile(ds snd.DataSource, entries []snd.Entry, folder string) (string, error)
- func ExportTemplate(tmpl snd.Template, entries []snd.Entry, writer ExportWriter) error
- func ExportTemplateFolder(tmpl snd.Template, entries []snd.Entry, folder string) (string, error)
- func ExportTemplateJSON(tmpl snd.Template, entries []snd.Entry) ([]byte, error)
- func ExportTemplateZIP(tmpl snd.Template, entries []snd.Entry, writer io.Writer) (string, error)
- func ExportTemplateZIPFile(tmpl snd.Template, entries []snd.Entry, folder string) (string, error)
- func ImportDataSourceCSV(reader io.Reader) (snd.DataSource, []snd.Entry, error)
- func ImportGenerator(reader ImportReader) (snd.Generator, error)
- func ImportGeneratorFolder(folder string) (snd.Generator, error)
- func ImportGeneratorJSON(s string) (snd.Generator, error)
- func ImportGeneratorZIP(reader io.ReaderAt, size int64) (snd.Generator, error)
- func ImportGeneratorZIPFile(file string) (snd.Generator, error)
- func ImportSource(reader ImportReader) (snd.DataSource, []snd.Entry, error)
- func ImportSourceFolder(folder string) (snd.DataSource, []snd.Entry, error)
- func ImportSourceJSON(s string) (snd.DataSource, []snd.Entry, error)
- func ImportSourceZIP(reader io.ReaderAt, size int64) (snd.DataSource, []snd.Entry, error)
- func ImportSourceZIPFile(file string) (snd.DataSource, []snd.Entry, error)
- func ImportTemplate(reader ImportReader) (snd.Template, []snd.Entry, error)
- func ImportTemplateFolder(folder string) (snd.Template, []snd.Entry, error)
- func ImportTemplateJSON(s string) (snd.Template, []snd.Entry, error)
- func ImportTemplateZIP(reader io.ReaderAt, size int64) (snd.Template, []snd.Entry, error)
- func ImportTemplateZIPFile(file string) (snd.Template, []snd.Entry, error)
- type ExportWriter
- type FolderExportWriter
- type FolderImportReader
- type ImportReader
- type JSONExportWriter
- type JSONFolder
- type JSONImportReader
- type ZipExportWriter
- type ZipImportReader
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ExportGenerator ¶ added in v0.5.0
func ExportGenerator(gen snd.Generator, writer ExportWriter) error
ExportGenerator exports a template to a given ExportWriter interface instance.
Following files will be created: - meta.json - list.html.njk
func ExportGeneratorFolder ¶ added in v0.5.0
ExportGeneratorFolder exports the template and entries to the given folder. A new folder with the pattern gen_{tmpl.Autor}_{tmpl.Slug} will be created.
Following files will be created: - meta.json - print.html.njk
The function returns the name of the created folder.
func ExportGeneratorJSON ¶ added in v0.7.1
func ExportGeneratorZIP ¶ added in v0.5.0
ExportGeneratorZIP exports the generator and entries as a zip file.
Following files will be created in the zip: - meta.json - print.html.njk
The function returns the advised name for the zip file with the pattern "gen_{tmpl.Autor}_{tmpl.Slug}.zip".
func ExportGeneratorZIPFile ¶ added in v0.5.0
ExportGeneratorZIPFile exports the generator and entries as a zip file.
Following files will be created in the zip: - meta.json - print.html.njk
The function returns the location where the file was written to as "{folder}/gen_{tmpl.Autor}_{tmpl.Slug}.zip".
func ExportSource ¶ added in v0.6.0
func ExportSource(ds snd.DataSource, entries []snd.Entry, writer ExportWriter) error
ExportSource exports a data source from a given ExportWriter interface instance.
Following files are needed: - meta.json - entries.json
func ExportSourceFolder ¶ added in v0.6.0
ExportSourceFolder exports the data source and entries to the given folder. A new folder with the pattern ds_{tmpl.Autor}_{tmpl.Slug} will be created.
Following files will be created: - meta.json - entries.json
The function returns the name of the created folder.
func ExportSourceJSON ¶ added in v0.7.1
func ExportSourceZIP ¶ added in v0.6.0
ExportSourceZIP exports the data source and entries as a zip file.
Following files will be created in the zip: - meta.json - entries.json
The function returns the advised name for the zip file with the pattern "ds_{tmpl.Autor}_{tmpl.Slug}.zip".
func ExportSourceZIPFile ¶ added in v0.6.0
ExportSourceZIPFile exports the data source and entries as a zip file.
Following files will be created in the zip: - meta.json - entries.json
The function returns the advised name for the zip file with the pattern "ds_{tmpl.Autor}_{tmpl.Slug}.zip".
func ExportTemplate ¶
ExportTemplate exports a template to a given ExportWriter interface instance.
Following files will be created: - meta.json - print.html.njk - list.html.njk - skeleton.json - entries.json
func ExportTemplateFolder ¶
ExportTemplateFolder exports the template and entries to the given folder. A new folder with the pattern {tmpl.Autor}_{tmpl.Slug} will be created.
Following files will be created: - meta.json - print.html.njk - list.html.njk - skeleton.json - entries.json
The function returns the name of the created folder.
func ExportTemplateJSON ¶ added in v0.7.1
func ExportTemplateZIP ¶
ExportTemplateZIP exports the template and entries as a zip file.
Following files will be created in the zip: - meta.json - print.html.njk - list.html.njk - skeleton.json - entries.json
The function returns the advised name for the zip file with the pattern "{tmpl.Autor}_{tmpl.Slug}.zip".
func ExportTemplateZIPFile ¶ added in v0.5.0
ExportTemplateZIPFile exports the template and entries as a zip file.
Following files will be created in the zip: - meta.json - print.html.njk - list.html.njk - skeleton.json - entries.json
The function returns the location where the file was written to as "{folder}/{tmpl.Autor}_{tmpl.Slug}.zip".
func ImportDataSourceCSV ¶ added in v0.6.1
ImportDataSourceCSV will import a data source and entry data from a given csv file.
It expects the csv files to have a header with the basic information in the first two lines and after that the header with value names and values, example:
Name, Author, Slug, Description Cool Source, BigJk, cool-source, This is a cool source Name, Price, Weight Sword, 10gp, 10lb Mace, 22gp, 12lb ...
func ImportGenerator ¶ added in v0.5.0
func ImportGenerator(reader ImportReader) (snd.Generator, error)
ImportGenerator imports a generator from a given ImportReader interface instance.
Following files are needed: - meta.json - print.html.njk
func ImportGeneratorFolder ¶ added in v0.5.0
ImportGeneratorFolder will import template and entry data from a given folder.
Following files are needed: - meta.json - print.html.njk
func ImportGeneratorJSON ¶ added in v0.7.1
func ImportGeneratorZIP ¶ added in v0.5.0
ImportGeneratorZIP will import generator and entry data from a given zip.
Following files are needed in the zip: - meta.json - print.html.njk
func ImportGeneratorZIPFile ¶ added in v0.5.0
ImportGeneratorZIPFile will import generator from a given zip file.
Following files are needed: - meta.json - print.html.njk
func ImportSource ¶
func ImportSource(reader ImportReader) (snd.DataSource, []snd.Entry, error)
ImportSource imports a data source from a given ImportReader interface instance.
Following files are needed: - meta.json - entries.json
func ImportSourceFolder ¶
ImportSourceFolder will import data source and entry data from a given folder.
Following files are needed: - meta.json - entries.json
func ImportSourceJSON ¶ added in v0.7.1
func ImportSourceZIP ¶
ImportSourceZIP will import data source and entry data from a given zip.
Following files are needed: - meta.json - entries.json
func ImportSourceZIPFile ¶
ImportSourceZIPFile will import data source and entry data from a given zip file.
Following files are needed: - meta.json - entries.json
func ImportTemplate ¶
ImportTemplate imports a template from a given ImportReader interface instance.
Following files are needed: - meta.json - print.html.njk - list.html.njk - skeleton.json - entries.json
func ImportTemplateFolder ¶
ImportTemplateFolder will import template and entry data from a given folder.
Following files are needed: - meta.json - print.html.njk - list.html.njk - skeleton.json - entries.json
func ImportTemplateJSON ¶ added in v0.7.1
func ImportTemplateZIP ¶
ImportTemplateZIP will import template and entry data from a given zip.
Following files are needed in the zip: - meta.json - print.html.njk - list.html.njk - skeleton.json - entries.json
Types ¶
type ExportWriter ¶
ExportWriter represents an arbitrary file writer that can be used to export templates and sources.
type FolderExportWriter ¶
type FolderExportWriter struct {
// contains filtered or unexported fields
}
type FolderImportReader ¶
type FolderImportReader struct {
// contains filtered or unexported fields
}
type ImportReader ¶
ImportReader represents an arbitrary file reader that can be used to import templates and sources.
type JSONExportWriter ¶ added in v0.7.1
type JSONFolder ¶ added in v0.7.1
type JSONImportReader ¶ added in v0.7.1
type JSONImportReader struct {
// contains filtered or unexported fields
}
type ZipExportWriter ¶
type ZipExportWriter struct {
// contains filtered or unexported fields
}
ZipExportWriter represents a writer that writes files to a zip.
type ZipImportReader ¶
type ZipImportReader struct {
// contains filtered or unexported fields
}
ZipImportReader represents a reader that reads files from a zip.