2013-10-28 15:59:07 +00:00
|
|
|
/*
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
Copyright 2013 The Perkeep Authors.
|
2013-10-28 15:59:07 +00:00
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Package publish exposes the types and functions that can be used
|
|
|
|
// from a Go template, for publishing.
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
package publish // import "perkeep.org/pkg/publish"
|
2013-10-28 15:59:07 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"html/template"
|
|
|
|
|
Rename import paths from camlistore.org to perkeep.org.
Part of the project renaming, issue #981.
After this, users will need to mv their $GOPATH/src/camlistore.org to
$GOPATH/src/perkeep.org. Sorry.
This doesn't yet rename the tools like camlistored, camput, camget,
camtool, etc.
Also, this only moves the lru package to internal. More will move to
internal later.
Also, this doesn't yet remove the "/pkg/" directory. That'll likely
happen later.
This updates some docs, but not all.
devcam test now passes again, even with Go 1.10 (which requires vet
checks are clean too). So a bunch of vet tests are fixed in this CL
too, and a bunch of other broken tests are now fixed (introduced from
the past week of merging the CL backlog).
Change-Id: If580db1691b5b99f8ed6195070789b1f44877dd4
2018-01-01 22:41:41 +00:00
|
|
|
"perkeep.org/pkg/blob"
|
|
|
|
"perkeep.org/pkg/search"
|
2013-10-28 15:59:07 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// SubjectPage is the data structure used when serving a
|
|
|
|
// publishing template. It contains the functions that can be called
|
|
|
|
// from the template.
|
|
|
|
type SubjectPage struct {
|
|
|
|
Header func() *PageHeader
|
|
|
|
File func() *PageFile
|
|
|
|
Members func() *PageMembers
|
|
|
|
}
|
|
|
|
|
|
|
|
// PageHeader contains the data available to the template,
|
|
|
|
// and relevant to the page header.
|
|
|
|
type PageHeader struct {
|
|
|
|
Title string // Page title.
|
|
|
|
CSSFiles []string // Available CSS files.
|
|
|
|
JSDeps []string // Dependencies (for e.g closure) that can/should be included as javascript files.
|
|
|
|
CamliClosure template.JS // Closure namespace defined in the provided js. e.g camlistore.GalleryPage from pics.js
|
2016-07-13 17:03:13 +00:00
|
|
|
Subject blob.Ref // Subject of this page (i.e the object which is described and published).
|
2013-10-28 15:59:07 +00:00
|
|
|
ViewerIsOwner bool // Whether the viewer of the page is also the owner of the displayed subject. (localhost check for now.)
|
2016-07-18 18:12:35 +00:00
|
|
|
PublishedRoot blob.Ref // Root permanode for this publisher. On camliRoot, camliPath:somePath = publishedRoot
|
2016-07-13 17:03:13 +00:00
|
|
|
// SubjectBasePath is the URL path up to the digest prefix of the
|
|
|
|
// subject. e.g. "/pics/foo/-/h341b133369" or "/pics/foo/-" if the subject
|
|
|
|
// is the published root itself.
|
|
|
|
SubjectBasePath string
|
2018-01-30 11:02:56 +00:00
|
|
|
// PathPrefix is the publisher app handler prefix on Perkeep, e.g.
|
|
|
|
// "/pics/", or "/" if the request was not proxied through Perkeep.
|
2016-07-13 17:03:13 +00:00
|
|
|
PathPrefix string
|
|
|
|
Host string
|
2013-10-28 15:59:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// PageFile contains the file related data available to the subject template,
|
|
|
|
// if the page describes some file contents.
|
|
|
|
type PageFile struct {
|
|
|
|
FileName string
|
|
|
|
Size int64
|
|
|
|
MIMEType string
|
|
|
|
IsImage bool
|
|
|
|
DownloadURL string
|
|
|
|
ThumbnailURL string
|
|
|
|
DomID string
|
|
|
|
Nav func() *Nav
|
|
|
|
}
|
|
|
|
|
|
|
|
// Nav holds links to the previous, next, and parent elements,
|
|
|
|
// when displaying members.
|
|
|
|
type Nav struct {
|
|
|
|
ParentPath string
|
|
|
|
PrevPath string
|
|
|
|
NextPath string
|
|
|
|
}
|
|
|
|
|
|
|
|
// PageMembers contains the data relevant to the members if the published subject
|
|
|
|
// is a permanode with members.
|
|
|
|
type PageMembers struct {
|
|
|
|
SubjectPath string // URL prefix path to the subject (i.e the permanode).
|
|
|
|
ZipName string // Name of the downloadable zip file which contains all the members.
|
|
|
|
Members []*search.DescribedBlob // List of the members.
|
|
|
|
Description func(*search.DescribedBlob) string // Returns the description of the given member.
|
|
|
|
Title func(*search.DescribedBlob) string // Returns the title for the given member.
|
|
|
|
Path func(*search.DescribedBlob) string // Returns the url prefix path to the given the member.
|
|
|
|
DomID func(*search.DescribedBlob) string // Returns the Dom ID of the given member.
|
|
|
|
FileInfo func(*search.DescribedBlob) *MemberFileInfo // Returns some file info if the given member is a file permanode.
|
|
|
|
}
|
|
|
|
|
|
|
|
// MemberFileInfo contains the file related data available for each member,
|
|
|
|
// if the member is the permanode for a file.
|
|
|
|
type MemberFileInfo struct {
|
|
|
|
FileName string
|
|
|
|
FileDomID string
|
|
|
|
FilePath string
|
|
|
|
FileThumbnailURL string
|
|
|
|
}
|