Comparing version 0.9.6 to 0.9.7
@@ -16,2 +16,5 @@ var fs = require("fs"), | ||
//the config object. | ||
var cfg; | ||
//the redis client. | ||
@@ -379,3 +382,3 @@ var client; | ||
try { | ||
metadata = JSON.parse(metadata) | ||
metadata = JSON.parse(metadata); | ||
} | ||
@@ -593,2 +596,6 @@ catch (parseErr) { | ||
reed.configure = function(config) { | ||
cfg = config; | ||
} | ||
reed.open = function(directory) { | ||
@@ -607,13 +614,56 @@ if (open === true || ready === true) { | ||
dir = directory; | ||
client = redis.createClient(); | ||
//declare all props that we want for redis | ||
var redisConf = { | ||
host: '127.0.0.1', | ||
port: 6379, | ||
password: null | ||
}; | ||
fs.watchFile(dir, function(curr, prev) { | ||
findNewFiles(); | ||
if (cfg) { | ||
//only take the props we are interested in | ||
//this way the user can specify only | ||
//host or only port leaving the rest | ||
// as defaults | ||
for (prop in redisConf) { | ||
if (cfg[prop]) { | ||
redisConf[prop] = cfg[prop]; | ||
} | ||
} | ||
} | ||
client = redis.createClient(redisConf.port, redisConf.host); | ||
// authentication may cause redis to fail | ||
// this ensures we see the problem if it occurs | ||
client.on('error', function(errMsg) { | ||
reed.emit('error', errMsg); | ||
}); | ||
reed.refresh(); | ||
var doOpen = function() { | ||
fs.watchFile(dir, function(curr, prev) { | ||
findNewFiles(); | ||
}); | ||
reed.refresh(); | ||
process.nextTick(function() { | ||
findNewFiles(true); | ||
}); | ||
}; | ||
process.nextTick(function() { | ||
findNewFiles(true); | ||
}); | ||
if (redisConf.password) { | ||
//if we are to auth we need to wait on callback before | ||
//starting to do work against redis | ||
client.auth(redisConf.password, function (err) { | ||
if (err) return reed.emit('error', err); | ||
doOpen(); | ||
}); | ||
} | ||
else { | ||
//no auth, just start | ||
doOpen(); | ||
} | ||
} | ||
@@ -620,0 +670,0 @@ |
@@ -7,3 +7,3 @@ { | ||
"tags": [ "redis", "blog" ], | ||
"version": "0.9.6", | ||
"version": "0.9.7", | ||
"homepage": "http://www.agnos.is/", | ||
@@ -10,0 +10,0 @@ "repository": { |
@@ -39,5 +39,4 @@ reed | ||
Make sure Redis 2.2 or greater is also installed and running. Currently, reed | ||
only supports the basic (non-authenticated) model for Redis. After Redis and | ||
reed are installed, use it thus: | ||
Make sure Redis 2.2 or greater is also installed and running. After | ||
Redis and reed are installed, use it thus: | ||
@@ -61,2 +60,34 @@ ```js | ||
Configuration | ||
------------- | ||
Reed can connect to Redis running on separate hosts, non-standard | ||
ports or using authentication. This requires the use of the | ||
`configure` function before calling `open`. | ||
```js | ||
var reed = require("reed"); | ||
//configure reed to connect to another redis | ||
//must be done *before* reed.open() | ||
reed.configure({ | ||
host: 'some.other.host.org', | ||
port: 1337, | ||
password: '15qe93rktkf39i4' | ||
}); | ||
reed.on("ready", function() { | ||
//ready. | ||
reed.get("a post", function(err, metadata, html) { | ||
//you have a post. | ||
}); | ||
}); | ||
reed.open("."); //looks for .md files in current directory. | ||
``` | ||
Any property not overridden in the configuration object will use the | ||
Redis defaults. For example, it is possible to override just the port. | ||
Retrieving Posts | ||
---------------- | ||
To retrieve an individual post and its associated metadata, use the `get` | ||
@@ -126,2 +157,6 @@ function: | ||
* `configure(options)`: Configures reed. The options object can be | ||
used to specify connection settings for Redis. Supported settings | ||
are `host`, `port` and `password`. Any such configuration must be done | ||
*before* calling `open`. | ||
* `open(dir)`: Opens the given path for reed. When first opened, reed will scan | ||
@@ -174,2 +209,5 @@ the directory for .md files and add them to redis. | ||
--------- | ||
*Note*: There is a known issue that prevents Pages from working if the blog | ||
portion of reed is not opened first. This will be fixed soon. | ||
Reed 0.9 introduces pages functionality. This operates similarly to the blog | ||
@@ -213,1 +251,12 @@ functionality. Each page is a markdown file in a specified directory, and | ||
* `updatePage`: Fired when a page is updated. | ||
Contributors | ||
============ | ||
These people have contributed to the development of reed in some way or another: | ||
* [ProjectMoon](https://github.com/ProjectMoon): primary author. | ||
* [algesten](https://github.com/algesten): bug fixes and redis conf. | ||
License | ||
======= | ||
MIT License. Detailed in the LICENSE file. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
43567
8
636
258