Merge "share: allow configuration of URL prefix"

This commit is contained in:
Brad Fitzpatrick 2013-07-20 01:33:46 +00:00 committed by Gerrit Code Review
commit 283301a6d7
7 changed files with 33 additions and 24 deletions

View File

@ -36,12 +36,12 @@ const (
// various parameters derived from the high-level user config
// and needed to set up the low-level config.
type configPrefixesParams struct {
secretRing string
keyId string
indexerPath string
blobPath string
searchOwner *blobref.BlobRef
shareHandler bool
secretRing string
keyId string
indexerPath string
blobPath string
searchOwner *blobref.BlobRef
shareHandlerPath string
}
var tempDir = os.TempDir
@ -338,8 +338,8 @@ func genLowLevelPrefixes(params *configPrefixesParams, ownerName string) (m json
"handler": "status",
}
if params.shareHandler {
m["/share/"] = map[string]interface{}{
if params.shareHandlerPath != "" {
m[params.shareHandlerPath] = map[string]interface{}{
"handler": "share",
"handlerArgs": map[string]interface{}{
"blobRoot": "/bs/",
@ -425,10 +425,14 @@ func genLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
tlsKey = conf.OptionalString("HTTPSKeyFile", "")
// Blob storage options
blobPath = conf.OptionalString("blobPath", "")
s3 = conf.OptionalString("s3", "") // "access_key_id:secret_access_key:bucket"
gstorage = conf.OptionalString("google", "") // "clientId:clientSecret:refreshToken:bucket"
shareHandler = conf.OptionalBool("shareHandler", true) // enable the share handler
blobPath = conf.OptionalString("blobPath", "")
s3 = conf.OptionalString("s3", "") // "access_key_id:secret_access_key:bucket"
gstorage = conf.OptionalString("google", "") // "clientId:clientSecret:refreshToken:bucket"
// Enable the share handler. If true, and shareHandlerPath is empty,
// then shareHandlerPath defaults to "/share/".
shareHandler = conf.OptionalBool("shareHandler", false)
// URL prefix for the share handler. If set, overrides shareHandler.
shareHandlerPath = conf.OptionalString("shareHandlerPath", "")
// Index options
runIndex = conf.OptionalBool("runIndex", true) // if false: no search, no UI, etc.
@ -523,13 +527,17 @@ func genLowLevelConfig(conf *Config) (lowLevelConf *Config, err error) {
return nil, errors.New("You need at least one of blobPath (for localdisk) or s3 or google configured for a blobserver.")
}
if shareHandler && shareHandlerPath == "" {
shareHandlerPath = "/share/"
}
prefixesParams := &configPrefixesParams{
secretRing: secretRing,
keyId: keyId,
indexerPath: indexerPath,
blobPath: blobPath,
searchOwner: blobref.SHA1FromString(armoredPublicKey),
shareHandler: shareHandler,
secretRing: secretRing,
keyId: keyId,
indexerPath: indexerPath,
blobPath: blobPath,
searchOwner: blobref.SHA1FromString(armoredPublicKey),
shareHandlerPath: shareHandlerPath,
}
prefixes := genLowLevelPrefixes(prefixesParams, ownerName)

View File

@ -11,5 +11,5 @@
"replicateTo": [],
"publish": {},
"ownerName": "Brad",
"shareHandler": true
"shareHandlerPath": "/share/"
}

View File

@ -6,5 +6,5 @@
"identity": "26F5ABDA",
"identitySecretRing": "/path/to/secring",
"runIndex": false,
"shareHandler": true
"shareHandlerPath": "/share/"
}

View File

@ -8,5 +8,5 @@
"s3": "key:secret:bucket",
"replicateTo": [],
"publish": {},
"shareHandler": true
"shareHandlerPath": "/share/"
}

View File

@ -15,5 +15,5 @@
}
},
"replicateTo": [],
"shareHandler": true
"shareHandlerPath": "/share/"
}

View File

@ -15,5 +15,5 @@
}
},
"replicateTo": [],
"shareHandler": true
"shareHandlerPath": "/share/"
}

View File

@ -33,7 +33,8 @@ web browser and restart the server.</p>
<li><b><code>identity</code></b>: your GPG fingerprint. A keypair is created for new users on start, but this may be changed if you know what you're doing.</li>
<li><b><code>identitySecretRing</code></b>: your GnuPG secret keyring file. A new keyring is created on start for new users, but may be changed if you know what you're doing.</li>
<li><b><code>listen</code></b>: The port (like "80" or ":80") or IP & port (like "10.0.0.2:8080") to listen for HTTP(s) connections on.</li>
<li><b><code>shareHandler</code></b>: if "true", the server's sharing functionality is enabled, letting your friends have access to any content you've specifically shared.</li>
<li><b><code>shareHandler</code></b>: if true, the server's sharing functionality is enabled, letting your friends have access to any content you've specifically shared. Its URL prefix path defaults to "<code>/share/</code>".</li>
<li><b><code>shareHandlerPath</code></b>: Optional. If non-empty, it specifies the URL prefix path to the share handler, and the <b><code>shareHandler</code></b> value is ignored (i.e the share handler is enabled). Example: "<code>/public/</code>".</li>
<li><b><code>runIndex</code></b>: defaults to true. If "false", no search, no UI, no indexing. (These can be controlled at a more granular level by writing a low-level config file)</li>
<li><b><code>sourceRoot</code></b>: Optional. If non-empty, it specifies the path to an alternative Camlistore source tree, in order to override the embedded UI and/or Closure resources. The UI files will be expected in <code><b>&lt;sourceRoot&gt;</b>/server/camlistored/ui</code> and the Closure library in <code><b>&lt;sourceRoot&gt;</b>/third_party/closure/lib</code>.</li>
</ul>