// Code generated by qtc from "image.qtpl". DO NOT EDIT.
// See https://github.com/valyala/quicktemplate for details.

//line image.qtpl:1
package templates

//line image.qtpl:1
import "net/url"

//line image.qtpl:3
import "github.com/bakape/hydron/common"

//line image.qtpl:4
import "github.com/bakape/hydron/files"

//line image.qtpl:6
import (
	qtio422016 "io"

	qt422016 "github.com/valyala/quicktemplate"
)

//line image.qtpl:6
var (
	_ = qtio422016.Copy
	_ = qt422016.AcquireByteBuffer
)

//line image.qtpl:6
func StreamThumbnail(qw422016 *qt422016.Writer, img common.CompactImage, page common.Page, highlight bool) {
//line image.qtpl:6
	qw422016.N().S(`<figure data-href="`)
//line image.qtpl:7
	qw422016.N().S(files.NetSourcePath(img.SHA1, img.Type))
//line image.qtpl:7
	qw422016.N().S(`"`)
//line image.qtpl:7
	if highlight {
//line image.qtpl:7
		qw422016.N().S(` `)
//line image.qtpl:7
		qw422016.N().S(`class="highlight"`)
//line image.qtpl:7
	}
//line image.qtpl:7
	qw422016.N().S(`><input type="checkbox" name="img:`)
//line image.qtpl:8
	qw422016.N().S(img.SHA1)
//line image.qtpl:8
	qw422016.N().S(`"><div class="background"></div><a href="/image/`)
//line image.qtpl:10
	qw422016.N().S(img.SHA1)
//line image.qtpl:10
	qw422016.N().S(`?`)
//line image.qtpl:10
	qw422016.N().S(page.Query())
//line image.qtpl:10
	qw422016.N().S(`"><img width="`)
//line image.qtpl:11
	qw422016.N().D(int(img.Thumb.Width))
//line image.qtpl:11
	qw422016.N().S(`" height="`)
//line image.qtpl:11
	qw422016.N().D(int(img.Thumb.Height))
//line image.qtpl:11
	qw422016.N().S(`" src="`)
//line image.qtpl:11
	qw422016.N().S(files.NetThumbPath(img.SHA1))
//line image.qtpl:11
	qw422016.N().S(`"></a></figure>`)
//line image.qtpl:14
}

//line image.qtpl:14
func WriteThumbnail(qq422016 qtio422016.Writer, img common.CompactImage, page common.Page, highlight bool) {
//line image.qtpl:14
	qw422016 := qt422016.AcquireWriter(qq422016)
//line image.qtpl:14
	StreamThumbnail(qw422016, img, page, highlight)
//line image.qtpl:14
	qt422016.ReleaseWriter(qw422016)
//line image.qtpl:14
}

//line image.qtpl:14
func Thumbnail(img common.CompactImage, page common.Page, highlight bool) string {
//line image.qtpl:14
	qb422016 := qt422016.AcquireByteBuffer()
//line image.qtpl:14
	WriteThumbnail(qb422016, img, page, highlight)
//line image.qtpl:14
	qs422016 := string(qb422016.B)
//line image.qtpl:14
	qt422016.ReleaseByteBuffer(qb422016)
//line image.qtpl:14
	return qs422016
//line image.qtpl:14
}

//line image.qtpl:16
func StreamImagePage(qw422016 *qt422016.Writer, img common.Image, page common.Page) {
//line image.qtpl:17
	title := img.Name

//line image.qtpl:18
	if title == "" {
//line image.qtpl:19
		title = "hydron"

//line image.qtpl:20
	}
//line image.qtpl:21
	streamhead(qw422016, title)
//line image.qtpl:21
	qw422016.N().S(`<body><div id="image-view"><section id="tags">`)
//line image.qtpl:25
	if img.Name != "" {
//line image.qtpl:25
		qw422016.N().S(`<span class="image-name"><a href="/search?q=`)
//line image.qtpl:27
		qw422016.E().S(url.QueryEscape("name:") + img.Name)
//line image.qtpl:27
		qw422016.N().S(`" title="Search for name">Name:`)
//line image.qtpl:28
		qw422016.N().S(` `)
//line image.qtpl:28
		qw422016.E().S(img.Name)
//line image.qtpl:28
		qw422016.N().S(`</a></span>`)
//line image.qtpl:31
	}
//line image.qtpl:32
	org := organizeTags(img.Tags)

//line image.qtpl:33
	streamrenderTags(qw422016, org[common.Character], page)
//line image.qtpl:34
	streamrenderTags(qw422016, org[common.Series], page)
//line image.qtpl:35
	streamrenderTags(qw422016, org[common.Author], page)
//line image.qtpl:36
	streamrenderTags(qw422016, org[common.Rating], page)
//line image.qtpl:37
	streamrenderTags(qw422016, org[common.Meta], page)
//line image.qtpl:38
	streamrenderTags(qw422016, org[common.Undefined], page)
//line image.qtpl:38
	qw422016.N().S(`</section><div id="media-container">`)
//line image.qtpl:41
	src := files.NetSourcePath(img.SHA1, img.Type)

//line image.qtpl:42
	switch common.GetMediaType(img.Type) {
//line image.qtpl:43
	case common.MediaImage:
//line image.qtpl:43
		qw422016.N().S(`<img src="`)
//line image.qtpl:44
		qw422016.N().S(src)
//line image.qtpl:44
		qw422016.N().S(`">`)
//line image.qtpl:45
	case common.MediaVideo:
//line image.qtpl:45
		qw422016.N().S(`<video src="`)
//line image.qtpl:46
		qw422016.N().S(src)
//line image.qtpl:46
		qw422016.N().S(`" autoplay loop controls>`)
//line image.qtpl:47
	default:
//line image.qtpl:47
		qw422016.N().S(`<b>Display not supported for this file format</b>`)
//line image.qtpl:49
	}
//line image.qtpl:49
	qw422016.N().S(`</div></div></body>`)
//line image.qtpl:53
}

//line image.qtpl:53
func WriteImagePage(qq422016 qtio422016.Writer, img common.Image, page common.Page) {
//line image.qtpl:53
	qw422016 := qt422016.AcquireWriter(qq422016)
//line image.qtpl:53
	StreamImagePage(qw422016, img, page)
//line image.qtpl:53
	qt422016.ReleaseWriter(qw422016)
//line image.qtpl:53
}

//line image.qtpl:53
func ImagePage(img common.Image, page common.Page) string {
//line image.qtpl:53
	qb422016 := qt422016.AcquireByteBuffer()
//line image.qtpl:53
	WriteImagePage(qb422016, img, page)
//line image.qtpl:53
	qs422016 := string(qb422016.B)
//line image.qtpl:53
	qt422016.ReleaseByteBuffer(qb422016)
//line image.qtpl:53
	return qs422016
//line image.qtpl:53
}

// Render tag adition and direct tag query links

//line image.qtpl:56
func streamrenderTags(qw422016 *qt422016.Writer, tags []common.Tag, page common.Page) {
//line image.qtpl:57
	page.Page = 0

//line image.qtpl:58
	init := page.Filters

//line image.qtpl:59
	for _, t := range tags {
//line image.qtpl:60
		page.Filters = init

//line image.qtpl:61
		filter := common.TagFilter{TagBase: t.TagBase}

//line image.qtpl:62
		page.Filters.Tag = append(page.Filters.Tag, filter)

//line image.qtpl:62
		qw422016.N().S(`<span class="spaced tag-`)
//line image.qtpl:63
		qw422016.N().Z(common.BufferWriter(t.Type))
//line image.qtpl:63
		qw422016.N().S(`"><a href="`)
//line image.qtpl:64
		qw422016.N().S(page.URL())
//line image.qtpl:64
		qw422016.N().S(`" class="char-button" title="Add to search">+</a>`)
//line image.qtpl:67
		page.Filters.Tag[len(page.Filters.Tag)-1].Negative = true

//line image.qtpl:67
		qw422016.N().S(`<a href="`)
//line image.qtpl:68
		qw422016.N().S(page.URL())
//line image.qtpl:68
		qw422016.N().S(`" class="char-button" title="Remove from search">-</a>`)
//line image.qtpl:71
		page.Filters = common.FilterSet{
			Tag: []common.TagFilter{filter},
		}

//line image.qtpl:73
		qw422016.N().S(`<a href="`)
//line image.qtpl:74
		qw422016.N().S(page.URL())
//line image.qtpl:74
		qw422016.N().S(`" title="Search for`)
//line image.qtpl:74
		qw422016.N().S(` `)
//line image.qtpl:74
		qw422016.E().S(t.Tag)
//line image.qtpl:74
		qw422016.N().S(`">`)
//line image.qtpl:75
		if t.Type == common.Rating {
//line image.qtpl:75
			qw422016.N().S(`rating:`)
//line image.qtpl:76
			qw422016.N().S(` `)
//line image.qtpl:77
		}
//line image.qtpl:78
		qw422016.E().S(t.Tag)
//line image.qtpl:78
		qw422016.N().S(`</a></span>`)
//line image.qtpl:81
	}
//line image.qtpl:82
}

//line image.qtpl:82
func writerenderTags(qq422016 qtio422016.Writer, tags []common.Tag, page common.Page) {
//line image.qtpl:82
	qw422016 := qt422016.AcquireWriter(qq422016)
//line image.qtpl:82
	streamrenderTags(qw422016, tags, page)
//line image.qtpl:82
	qt422016.ReleaseWriter(qw422016)
//line image.qtpl:82
}

//line image.qtpl:82
func renderTags(tags []common.Tag, page common.Page) string {
//line image.qtpl:82
	qb422016 := qt422016.AcquireByteBuffer()
//line image.qtpl:82
	writerenderTags(qb422016, tags, page)
//line image.qtpl:82
	qs422016 := string(qb422016.B)
//line image.qtpl:82
	qt422016.ReleaseByteBuffer(qb422016)
//line image.qtpl:82
	return qs422016
//line image.qtpl:82
}
