diff --git a/base/dataset.go b/base/dataset.go index 5805f8fbb..7889d17d0 100644 --- a/base/dataset.go +++ b/base/dataset.go @@ -40,6 +40,11 @@ func OpenDataset(fsys qfs.Filesystem, ds *dataset.Dataset) (err error) { return } } + if ds.Viz != nil && ds.Viz.RenderedFile() == nil { + if err = ds.Viz.OpenRenderedFile(fsys); err != nil { + return + } + } return } @@ -60,6 +65,11 @@ func CloseDataset(ds *dataset.Dataset) (err error) { return } } + if ds.Viz != nil && ds.Viz.RenderedFile() != nil { + if err = ds.Viz.RenderedFile().Close(); err != nil { + return + } + } return } diff --git a/cmd/get.go b/cmd/get.go index cf334ede9..89f59a7f3 100644 --- a/cmd/get.go +++ b/cmd/get.go @@ -73,7 +73,7 @@ type GetOptions struct { } // isDatasetField checks if a string is a dataset field or not -var isDatasetField = regexp.MustCompile("(?i)^(commit|cm|structure|st|body|bd|meta|md|viz|vz|transform|tf)($|\\.)") +var isDatasetField = regexp.MustCompile("(?i)^(commit|cm|structure|st|body|bd|meta|md|viz|vz|transform|tf|rendered|rd)($|\\.)") // Complete adds any missing configuration that can only be added just before calling Run func (o *GetOptions) Complete(f Factory, args []string) (err error) { diff --git a/lib/datasets.go b/lib/datasets.go index 036f1c5b3..07dfa164a 100644 --- a/lib/datasets.go +++ b/lib/datasets.go @@ -155,6 +155,10 @@ func (r *DatasetRequests) Get(p *GetParams, res *GetResult) (err error) { // `qri get viz.script` loads the visualization script, as a special case res.Bytes, err = ioutil.ReadAll(ds.Viz.ScriptFile()) return err + } else if p.Selector == "rendered" && ds.Viz != nil && ds.Viz.RenderedFile() != nil { + // `qri get rendered` loads the rendered visualization script, as a special case + res.Bytes, err = ioutil.ReadAll(ds.Viz.RenderedFile()) + return err } else { var value interface{} if p.Selector == "" { diff --git a/rev/rev.go b/rev/rev.go index 7a5883090..ea69b53dd 100644 --- a/rev/rev.go +++ b/rev/rev.go @@ -66,6 +66,7 @@ var fieldMap = map[string]string{ "transform": "tf", "structure": "st", "body": "bd", + "rendered": "rd", "ds": "ds", "md": "md", @@ -73,4 +74,5 @@ var fieldMap = map[string]string{ "tf": "tf", "st": "st", "bd": "bd", + "rd": "rd", } diff --git a/rev/rev_test.go b/rev/rev_test.go index 7e7234f25..6f92874b8 100644 --- a/rev/rev_test.go +++ b/rev/rev_test.go @@ -15,6 +15,7 @@ func TestParseRevs(t *testing.T) { {"body", []*Rev{&Rev{"bd", 1}}, ""}, {"md", []*Rev{&Rev{"md", 1}}, ""}, {"ds", []*Rev{&Rev{"ds", 1}}, ""}, + {"rd", []*Rev{&Rev{"rd", 1}}, ""}, {"1", []*Rev{&Rev{"ds", 1}}, ""}, {"2", []*Rev{&Rev{"ds", 2}}, ""}, {"3", []*Rev{&Rev{"ds", 3}}, ""},