A Nanoc::DataSource
for loading site data items from a CouchDB server.
-
Creates a new item (document) in the CouchDB according to the given identifier:
nanoc create_item identifier
-
Loads documents from a CouchDB, creating nanoc items (with attributes).
-
Configuration options (in site's
config.yaml
):-
The Url of the CouchDB server.
-
The CouchDB database name.
-
Mapping of CouchDB document field names to default nanoc item attributes:
title
,body
-
Allow for custom nanoc identifier by providing document field
identifier
, defaults to document_id
. -
Views used for querying the CouchDB documents.
-
-
CouchRest, a RESTful CouchDB client based on Heroku's RestClient and Couch.js:
sudo gem install couchrest
Copy the file lib/couchdb.rb
into your site's lib
folder.
Example configuration for section data_sources
in site's config.yaml
:
data_sources:
-
# A data source for loading site data items from CouchDB server.
type: couchdb
config:
# The url of the CouchDB server.
couch: 'http://admin:[email protected]:5984/'
# The CouchDB database name.
db: 'example_com_prelive'
# Mapping of CouchDB document field names to nanoc item attributes.
fields:
item_title: 'title'
item_content: 'body'
# Views used for querying the CouchDB documents.
views:
all_items:
map: >
function(doc) {
// if (doc.type == "page") {
emit(doc._id, doc);
// }
}