Beispiel #1
0
func (r *StaticRepresenter) AddGallery(gallery *Gallery) error {
	log.Tracef("AddGallery(%q)", gallery)
	for i, pic := range gallery.Pics {
		if pic.isWide && ((i+1)%2 == 0) {
			return fmt.Errorf("pic #%d in gallery %q (%q) is wide and must be on an uneven position", i+1, pic.originalPath, gallery.Name)
		}
	}
	log.Trace("appending gallery")
	r.galleries = append(r.galleries, gallery)
	log.Trace("appended gallery", r.galleries)
	return nil
}
Beispiel #2
0
func (fc *FsCreator) Create() error {
	var err error
	var pics []*Pic
	var galleries []*Gallery
	var stories []*Story

	pics, err = parsePics(fc.sourceDir)
	if err != nil {
		return err
	}

	galleries, err = parseGalleries(fc.sourceDir, pics)
	if err != nil {
		return err
	}

	stories, err = parseStories(fc.sourceDir, pics)
	if err != nil {
		return err
	}

	for _, pic := range pics {
		if err := fc.repr.AddPic(pic); err != nil {
			return err
		}
	}

	for _, gallery := range galleries {
		if err := fc.repr.AddGallery(gallery); err != nil {
			return err
		}
		log.Trace("fc.repr", fc.repr)
	}
	for _, story := range stories {
		if err := fc.repr.AddStory(story); err != nil {
			return err
		}
	}

	log.Trace("fc.repr", fc.repr)

	return fc.repr.Reprezent()
}
Beispiel #3
0
func (r *StaticRepresenter) Reprezent() error {
	log.Trace("in Reprezent", r.galleries)
	for _, gallery := range r.galleries {
		log.Debugf("writing gallery %q", gallery)
		if err := writeGallery(r.targetDir, gallery); err != nil {
			return err
		}
	}
	return nil
}