diff --git a/cmd/present/static/styles.css b/cmd/present/static/styles.css index 5cb2953b..f8673899 100644 --- a/cmd/present/static/styles.css +++ b/cmd/present/static/styles.css @@ -384,6 +384,20 @@ article > .image { margin-top: 40px; } +article > .background { + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + z-index: -1; +} + +article > .background > img { + max-height: 100%; + max-width: 100%; +} + table { width: 100%; border-collapse: collapse; diff --git a/cmd/present/templates/action.tmpl b/cmd/present/templates/action.tmpl index 2893058d..609dc11e 100644 --- a/cmd/present/templates/action.tmpl +++ b/cmd/present/templates/action.tmpl @@ -37,6 +37,12 @@ It determines how the formatting actions are rendered. {{end}} +{{define "background"}} +
+ +
+{{end}} + {{define "iframe"}} {{end}} @@ -45,4 +51,4 @@ It determines how the formatting actions are rendered. {{define "html"}}{{.HTML}}{{end}} -{{define "caption"}}
{{style .Text}}
{{end}} \ No newline at end of file +{{define "caption"}}
{{style .Text}}
{{end}} diff --git a/present/background.go b/present/background.go new file mode 100644 index 00000000..0a6216ab --- /dev/null +++ b/present/background.go @@ -0,0 +1,25 @@ +// Copyright 2016 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package present + +import ( + "strings" +) + +func init() { + Register("background", parseBackground) +} + +type Background struct { + URL string +} + +func (i Background) TemplateName() string { return "background" } + +func parseBackground(ctx *Context, fileName string, lineno int, text string) (Elem, error) { + args := strings.Fields(text) + background := Background{URL: args[1]} + return background, nil +} diff --git a/present/doc.go b/present/doc.go index 584e0c1c..fa39648a 100644 --- a/present/doc.go +++ b/present/doc.go @@ -58,6 +58,7 @@ After that come slides/sections, each after a blank line: .code x.go /^func main/,/^}/ .play y.go .image image.jpg + .background image.jpg .iframe http://foo .link http://foo label .html file.html @@ -177,6 +178,12 @@ preserves the aspect ratio of the image when scaling. .image images/janet.jpg _ 300 +background: + +The template uses the function "background" to set the background image for +a slide. The only argument is the file name of the image. + + .background images/susan.jpg caption: