I'm not sure what the complexity of doing this within your docs…

Provide a form field for the user to populate (with possibly your intranet host, which could default to window.location.hostname) and combine it with something like mustache/handlebars/other HTML template system to provide a dynamic name into your docs. 

FWIW, you might be able to use the <body> content as the template and handle the merge with onload. Assuming you have jQuery & Mustache, you might be able to  run this 'once' per page after the  page fully loaded… 

$.ready(function () {
var view = {
hostname: window.location.hostname
};
var template = $("body").html();
$(body).html(Mustache.render(template,view));
}

This way your content is just a template that gets resolved.. worst case if the merge doesn't happen, users would see tokens like 
http://{{hostname}}/dbname/_design/myddoc/...

- Jim

Jim Klo
Senior Software Engineer
Center for Software Engineering
SRI International
t. @nsomnac

On Sep 27, 2012, at 10:54 AM, Kevin R. Coombes <kevin.r.coombes@gmail.com> wrote:

Hi,

I have now built several applications with CouchDB using a similar structure.  They use CouchApp to maintain the directory structure, and (in addition to the views, etc.) contain an _attachements folder that includes:
   index.html (the main web-based user interface to the app)
   myapp.js (the main JavaScript code that is loaded by index.html to do the work)
   docs.html (linked to from the main page to provide user documentation)

Part of the audience for the documentation includes statisticians and bioinformaticians who I am trying to educate about how to write their own programs to access the underlying data from the CouchDB database directly (as a web service, not through this web site).  So I include sample code that shows how to construct some of the URLs that they need.  Not surprisingly (at least to anyone who reads this mailing list), these all have the form
   http://MY.HOST.NAME/mydb/_design/whatever/blah

The question I have has to do with MY.HOST.NAME.  Right now, this is hard-coded into the docs.html attachment.  I recognize that this is a really dumb thing to do, especially  if I replicate this application to another host. (I even recognize that in doing so I could also change the databse name, but let's ignore that fact for now.)  I'm not sure of the best way to handle this, which is why I am posting this message.

QUESTION: What is the best way to get the "MY.HOST.NAME" part inside the docs.html file to be generated automatically from the host on which the database is being served?

Oh, and just to complicate things, you should assume the actual couch server is sitting behind a proxy, and I probably don't want the internal host name to percolate out into the public documentation. In that situation, I would want docs.html to show the name of the proxy server instead.

Thanks in advance for your help,
   Kevin