imexport

package
v1.0.0-rc6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 17, 2024 License: MIT Imports: 13 Imported by: 0

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

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

func ExportGeneratorFolder(tmpl snd.Generator, folder string) (string, error)

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 ExportGeneratorJSON(gen snd.Generator) ([]byte, error)

func ExportGeneratorZIP added in v0.5.0

func ExportGeneratorZIP(gen snd.Generator, writer io.Writer) (string, error)

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

func ExportGeneratorZIPFile(gen snd.Generator, folder string) (string, error)

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

func ExportSourceFolder(ds snd.DataSource, entries []snd.Entry, folder string) (string, error)

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 ExportSourceJSON(ds snd.DataSource, entries []snd.Entry) ([]byte, error)

func ExportSourceZIP added in v0.6.0

func ExportSourceZIP(ds snd.DataSource, entries []snd.Entry, writer io.Writer) (string, error)

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

func ExportSourceZIPFile(ds snd.DataSource, entries []snd.Entry, folder string) (string, error)

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

func ExportTemplate(tmpl snd.Template, entries []snd.Entry, writer ExportWriter) error

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

func ExportTemplateFolder(tmpl snd.Template, entries []snd.Entry, folder string) (string, error)

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 ExportTemplateJSON(tmpl snd.Template, entries []snd.Entry) ([]byte, error)

func ExportTemplateZIP

func ExportTemplateZIP(tmpl snd.Template, entries []snd.Entry, writer io.Writer) (string, error)

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

func ExportTemplateZIPFile(tmpl snd.Template, entries []snd.Entry, folder string) (string, error)

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

func ImportDataSourceCSV(reader io.Reader) (snd.DataSource, []snd.Entry, error)

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

func ImportGeneratorFolder(folder string) (snd.Generator, error)

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 ImportGeneratorJSON(s string) (snd.Generator, error)

func ImportGeneratorZIP added in v0.5.0

func ImportGeneratorZIP(reader io.ReaderAt, size int64) (snd.Generator, error)

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

func ImportGeneratorZIPFile(file string) (snd.Generator, error)

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

func ImportSourceFolder(folder string) (snd.DataSource, []snd.Entry, error)

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 ImportSourceJSON(s string) (snd.DataSource, []snd.Entry, error)

func ImportSourceZIP

func ImportSourceZIP(reader io.ReaderAt, size int64) (snd.DataSource, []snd.Entry, error)

ImportSourceZIP will import data source and entry data from a given zip.

Following files are needed: - meta.json - entries.json

func ImportSourceZIPFile

func ImportSourceZIPFile(file string) (snd.DataSource, []snd.Entry, error)

ImportSourceZIPFile will import data source and entry data from a given zip file.

Following files are needed: - meta.json - entries.json

func ImportTemplate

func ImportTemplate(reader ImportReader) (snd.Template, []snd.Entry, error)

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

func ImportTemplateFolder(folder string) (snd.Template, []snd.Entry, error)

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 ImportTemplateJSON(s string) (snd.Template, []snd.Entry, error)

func ImportTemplateZIP

func ImportTemplateZIP(reader io.ReaderAt, size int64) (snd.Template, []snd.Entry, error)

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

func ImportTemplateZIPFile

func ImportTemplateZIPFile(file string) (snd.Template, []snd.Entry, error)

ImportTemplateZIPFile will import template and entry data from a given zip file.

Following files are needed in the zip: - meta.json - print.html.njk - list.html.njk - skeleton.json - entries.json

Types

type ExportWriter

type ExportWriter interface {
	WriteFile(string, []byte) error
}

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
}

func (*FolderExportWriter) WriteFile

func (f *FolderExportWriter) WriteFile(file string, data []byte) error

type FolderImportReader

type FolderImportReader struct {
	// contains filtered or unexported fields
}

func (*FolderImportReader) ReadFile

func (f *FolderImportReader) ReadFile(s string) ([]byte, error)

type ImportReader

type ImportReader interface {
	ReadFile(string) ([]byte, error)
}

ImportReader represents an arbitrary file reader that can be used to import templates and sources.

type JSONExportWriter added in v0.7.1

type JSONExportWriter struct {
	Files map[string]string `json:"files"`
	Name  string            `json:"name"`
}

func (*JSONExportWriter) WriteFile added in v0.7.1

func (f *JSONExportWriter) WriteFile(file string, data []byte) error

type JSONFolder added in v0.7.1

type JSONFolder struct {
	Files map[string]string `json:"files"`
	Name  string            `json:"name"`
}

type JSONImportReader added in v0.7.1

type JSONImportReader struct {
	// contains filtered or unexported fields
}

func (*JSONImportReader) ReadFile added in v0.7.1

func (f *JSONImportReader) ReadFile(name string) ([]byte, error)

type ZipExportWriter

type ZipExportWriter struct {
	// contains filtered or unexported fields
}

ZipExportWriter represents a writer that writes files to a zip.

func (*ZipExportWriter) WriteFile

func (z *ZipExportWriter) WriteFile(file string, data []byte) error

type ZipImportReader

type ZipImportReader struct {
	// contains filtered or unexported fields
}

ZipImportReader represents a reader that reads files from a zip.

func (*ZipImportReader) ReadFile

func (z *ZipImportReader) ReadFile(s string) ([]byte, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL