Ejemplo n.º 1
0
func (c App) renderDirectory(directory string) revel.Result {
	image_url, found := revel.Config.String("image_url")
	if !found {
		return c.RenderText("Could not find image url")
	}
	events := library.MakeFileSystemEvents([]string{".jpg", ".png", ".mov", ".avi"})
	event, err := events.Find(directory)

	rootDir, _ := revel.Config.String("root_dir")
	eventWithThumbnails := event.ReplaceMissingThumbnailsWithTemp()
	relativeEvents := eventWithThumbnails.ImagesRelativeTo(rootDir)

	if err != nil {
		return c.RenderError(err)
	} else {
		c.RenderArgs["root_url"] = image_url
		c.RenderArgs["images"] = relativeEvents.Images
		c.RenderArgs["directories"] = relativeEvents.Events
		return c.RenderTemplate("App/Show.html")
	}
}
Ejemplo n.º 2
0
	"html/template"
	"net/http"
	"strconv"
)

var index = template.Must(template.ParseFiles(
	"templates/index.html",
))

type ThumbnailGenerator interface {
	generateThumbnailsForDirectoryAndDuration(directory string, duration int)
}

var makeCommand = func() ThumbnailGenerator {
	logger := new(GoLogger)
	return MakeGenerateThumbnailCommandWithLogger(library.MakeFileSystemEvents([]string{".jpg", ".png"}),
		logger)
}

func GenerateThumbnailsPost(w http.ResponseWriter, r *http.Request) {
	r.ParseForm()
	requestBody := r.FormValue("directory")
	duration, _ := strconv.Atoi(r.FormValue("duration"))

	obj := makeCommand()
	obj.generateThumbnailsForDirectoryAndDuration(requestBody, duration)
}

func GenerateThumbnails(w http.ResponseWriter, r *http.Request) {
	decoder := json.NewDecoder(r.Body)
	var request thumbnailrequest.Request