perkeep/doc/publishing
mpl 65343d114d pkg/server/app: improve app handling
These improvements on the server app handler should help writing
and running stand-alone apps.

The two main goals are:
1) "simple" configurations should work automatically; the parameters for
the app are derived from the Listen and BaseURL of the Camlistore
server.
2) More advanced configurations, such as being behind a proxy, should be
easily configurable through the app's Listen, BackendURL, and ApiHost
parameters.

I had worked on them while doing the scanning cabinet app, and I am
backporting them now since we haven't landed the scanning cabinet yet,
and people have been having trouble setting up the publisher.

pkg/app/app_test.go is gone because app.ListenAddress is now dumb. The
hard work is done in pkg/server/app instead.

Fixes #818

Change-Id: Ice2610d6bac611b209cc3a928e67fa6093a41d3e
2016-07-04 22:21:16 +02:00
..
README.md pkg/server/app: improve app handling 2016-07-04 22:21:16 +02:00

README.md

Publishing

Camlistore delegates publishing to the publisher server application, which uses Go html templates (http://golang.org/pkg/text/template/) to publish pages.

Resources for publishing, such as go templates, javascript and css files should be placed in the application source directory - app/publisher/ - so they can be served directly when using the dev server or automatically embedded in production.

You should then specify the Go template to be used through the configuration file. The CSS files are automatically all available to the app. For example, there already is a go template (gallery.html), and css file (pics.css) that work together to provide publishing for image galleries. The dev server config (config/dev-server-config.json) already uses them. Here is how one would configure publishing for an image gallery in the server config ($HOME/.config/camlistore/server-config.json):

"publish": {
  "/pics/": {
    "camliRoot": "mypics",
    "cacheRoot": "/home/joe/var/camlistore/blobs/cache",
    "goTemplate": "gallery.html"
  }
}

The parameters for setting up the app's process ("listen", "backendURL", and "apiHost") are derived from the Camlistore server's "listen", and "baseURL", but should the need arise (e.g. with a proxy setup) they can be specified as well. See serverconfig.Publish type for the details.

If you want to provide your own (Go) template, see camlistore.org/pkg/publish for the data structures and functions available to the template.