migrator

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2019 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package migrator provides import/export functionality. It defines Importer and Exporter interfaces amd implements for disqus (importer only) and "native" remark (both importer and exporter). Also implements AutoBackup scheduler running exports as backups and saving them locally.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ImportComments

func ImportComments(p ImportParams) (int, error)

ImportComments imports from given provider format and saves to store

Types

type AutoBackup

type AutoBackup struct {
	Exporter       Exporter
	BackupLocation string
	SiteID         string
	KeepMax        int
	Duration       time.Duration
}

AutoBackup struct handles daily backups params for siteID

func (AutoBackup) Do

func (ab AutoBackup) Do(ctx context.Context)

Do runs daily export to local files, keeps up to keepMax backups for given siteID

type Disqus

type Disqus struct {
	DataStore Store
}

Disqus implements Importer from disqus xml

func (*Disqus) Import

func (d *Disqus) Import(r io.Reader, siteID string) (size int, err error)

Import from disqus and save to store

type Exporter

type Exporter interface {
	Export(w io.Writer, siteID string) (int, error)
}

Exporter defines interface to export comments from internal store

type ImportParams

type ImportParams struct {
	DataStore Store
	InputFile string
	Provider  string
	SiteID    string
}

ImportParams defines everything needed to run import

type Importer

type Importer interface {
	Import(r io.Reader, siteID string) (int, error)
}

Importer defines interface to convert posts from external sources

type Native

type Native struct {
	DataStore Store
}

Native implements exporter and importer for internal store format {"version": 1, comments:[{...}\n,{}], meta: {meta}} each comments starts from the new line

func (*Native) Export

func (n *Native) Export(w io.Writer, siteID string) (size int, err error)

Export all comments to writer as json strings. Each comment is one string, separated by "\n" The final file is a valid json

func (*Native) Import

func (n *Native) Import(reader io.Reader, siteID string) (size int, err error)

Import comments from json strings produced by Remark.Export

type Store

type Store interface {
	Create(comment store.Comment) (commentID string, err error)
	Find(locator store.Locator, sort string) ([]store.Comment, error)
	List(siteID string, limit int, skip int) ([]store.PostInfo, error)
	DeleteAll(siteID string) error
	Metas(siteID string) (umetas []service.UserMetaData, pmetas []service.PostMetaData, err error)
	SetMetas(siteID string, umetas []service.UserMetaData, pmetas []service.PostMetaData) error
}

Store defines minimal interface needed to export and import comments

type WordPress

type WordPress struct {
	DataStore Store
}

WordPress implements Importer from WP xml

func (*WordPress) Convert

func (w *WordPress) Convert(text string) string

Convert satisfies formatter.CommentConverter

func (*WordPress) Import

func (w *WordPress) Import(r io.Reader, siteID string) (size int, err error)

Import comments from WP and save to store

Jump to

Keyboard shortcuts

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