Esempio n. 1
0
func webDsHomeHandler(w http.ResponseWriter, r *http.Request) {
	ds := requestDataset(r)
	h := data.NewHandle(ds)

	f, err := indexDB.GetDataset(h.Path())
	if err != nil {
		pErr("%s 404 not found\n", ds)
		http.NotFound(w, r)
		return
	}

	ref := f.Refs.ResolveRef(h.Version)
	df, err := DatafileForManifestRef(ref)
	if err != nil {
		pErr("Error loading Datafile: %s\n", err.Error())
		http.Error(w, "error loading Datafile", http.StatusInternalServerError)
		return
	}

	readme, err := FileForManifestRef(ref)
	if err != nil {
		pErr("Error finding Readme: %v\n", err)
		readme = noReadmeFile
	} else {
		if err := readme.Read(); err != nil {
			pErr("Error loading Readme: %v\n", err)
		}
	}

	webRenderPage(w, r, datasetTmplName, &WebPage{
		Title:       f.Path,
		Description: fmt.Sprintf("%s - %s", f.Path, f.Tagline),

		BodyPage: &DatasetWebPage{
			I:            f,
			D:            df,
			Readme:       string(readme.RenderedBytes()),
			EscapeReadme: !readme.CanBeRendered(),
		},
	})
}
Esempio n. 2
0
func (f *DatasetVersion) Handle() *data.Handle {
	return data.NewHandle(f.Dataset)
}
Esempio n. 3
0
func (f *Dataset) Handle() *data.Handle {
	return data.NewHandle(f.Path)
}