mirror of https://github.com/perkeep/perkeep.git
publisher: restore SourceRoot configurability
This change allows the publisher to use resources from a SourceRoot directory, without having to rebuild the publisher binary, instead of only using embedded resources. Change-Id: Ife29e3015b8595a33f175a62d98fcf5ffa689134
This commit is contained in:
parent
588d31044e
commit
0367de7b61
|
@ -142,13 +142,12 @@ func newPublishHandler(conf *config) *publishHandler {
|
|||
}
|
||||
var CSSFiles, JSDeps []string
|
||||
if conf.SourceRoot != "" {
|
||||
appRoot := filepath.Join(conf.SourceRoot, "app", "publisher")
|
||||
Files = &fileembed.Files{
|
||||
DirFallback: appRoot,
|
||||
DirFallback: conf.SourceRoot,
|
||||
}
|
||||
// TODO(mpl): Can I readdir by listing with "/" on Files, even with DirFallBack?
|
||||
// Apparently not, but retry later.
|
||||
dir, err := os.Open(appRoot)
|
||||
dir, err := os.Open(conf.SourceRoot)
|
||||
if err != nil {
|
||||
logger.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -152,6 +152,9 @@ func (b *lowBuilder) addPublishedConfig(tlsO *tlsOpts) error {
|
|||
"cacheRoot": v.CacheRoot,
|
||||
"goTemplate": v.GoTemplate,
|
||||
}
|
||||
if v.SourceRoot != "" {
|
||||
appConfig["sourceRoot"] = v.SourceRoot
|
||||
}
|
||||
if v.HTTPSCert != "" && v.HTTPSKey != "" {
|
||||
// user can specify these directly in the publish section
|
||||
appConfig["httpsCert"] = v.HTTPSCert
|
||||
|
|
|
@ -134,6 +134,12 @@ type Publish struct {
|
|||
// caching blobserver (for images). No caching if empty.
|
||||
// An example value is Config.BlobPath + "/cache".
|
||||
CacheRoot string `json:"cacheRoot,omitempty"`
|
||||
|
||||
// SourceRoot optionally defines the directory where to look for some resources
|
||||
// such as HTML templates, as well as javascript, and CSS files. The
|
||||
// default is to use the resources embedded in the publisher binary, found
|
||||
// in the publisher app source directory.
|
||||
SourceRoot string `json:"sourceRoot,omitempty"`
|
||||
}
|
||||
|
||||
// invertedBool is a bool that marshals to and from JSON with the opposite of its in-memory value.
|
||||
|
|
Loading…
Reference in New Issue