Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions ERRATA.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
Errata
==========

* The code as I found it is considerably out of sync with *CouchDB:
The Definitive Guide*. (But then the book seems to be in need of an
update for other reasons anyway.)

* **Sofa** requires CouchDB version >= 1.1.0 in order for `require`d
code in view `map`s to be actually included. In earlier versions
of CouchDB, the `map` will, from the point of view of the user,
silently fail and mysteriously (to the user) no results are
returned. Furthermore, in the versions I have seen that **do**
support this, the code to be `require`d **must be** in
`views/libs/`. `Require`ing code in other locations will, again
silently, fail.

* There are now 3 copies of `md5.js` shipped with **Sofa** -- I had to
add one into `views/libs/` so that the `views/comments/map.js`
didn't fail (silently, as above).

* **Sofa** can be successfully initially deployed via `couchapp.py`,
but **not** via `erica`: the latter fails to correctly install
`_attachments/`, complaining thus:

> <<"{\"error\":\"bad_request\",\"reason\":\"Attachment name can't start with '_'\"}\n">>}}}

(full stack trace may be found at the end of this file). However,
after the initial deployment, I was able to use `erica`.

* `jquery.scrollTo` seems to work only intermittently, but since it is
used only by the 'preview' functionality as a (cool!) convenience, I
didn't wish to spend much time on it.

* Some versions of `CouchDB` (pre-1.1.0?) do *not* like the
`views/lib/` directory to *not* have a `map.js` file in it, and go
so far as to return an `undefined` in its place. I just put a
**valid but unused** `map.js` in the `views/lib/` directory to get
around this. If one doesn't do this, `CouchDB` will complain thusly:

> [{view,0,
> [<<"lib">>],
> undefined,
> {btree,<0.8974.16>,nil,
> #Fun<couch_btree.3.83553141>,
> #Fun<couch_btree.4.30790806>,
> #Fun<couch_view.less_json_ids.2>,
> #Fun<couch_view_group.10.120246376>},
> [],[]},
> {view,1,
> [<<"recent-posts">>],
> <<"function(doc) {\n if (doc.type == \"post\") {\n emit(new Dat
> e(doc.created_at), doc);\n }\n};\n">>,
> {btree,<0.8974.16>,nil,
> #Fun<couch_btree.3.83553141>,
> #Fun<couch_btree.4.30790806>,
> #Fun<couch_view.less_json_ids.2>,
> #Fun<couch_view_group.10.120246376>},
> [],[]},

and the web broweser will display:

> {"error":"compilation_error","reason":"Expression does not eval to a function. ((new String(\"undefined\")))"}


Full`erica` deployment attempt stack trace:

> DEBUG: push /my/home/dir/dev/couchdb/test/sofatest => iristest
> DEBUG: Detected Style: traditional
> DEBUG: File '".gitignore"' ignored.
> ERROR: push failed while processing /my/home/dir/dev/couchdb/test/sofatest: {'EXIT',{{badmatch,{error,{ok,"400",
> [{"Server","CouchDB/1.5.0 (Erlang OTP/R15B03)"},
> {"Date","Sun, 30 Aug 2015 07:44:11 GMT"},
> {"Content-Type","application/json"},
> {"Content-Length","72"},
> {"Cache-Control","must-revalidate"}],
> <<"{\"error\":\"bad_request\",\"reason\":\"Attachment name can't start with '_'\"}\n">>}}},
> [{erica_push,do_push,4,[]},
> {erica_push,push2,3,[]},
> {erica_push,push1,3,[]},
> {erica_core,run_modules,4,[]},
> {erica_core,execute,4,[]},
> {erica,main,1,[]},
> {escript,run,2,[{file,"escript.erl"},{line,747}]},
> {escript,start,1,[{file,"escript.erl"},{line,277}]}]}}
7 changes: 7 additions & 0 deletions _attachments/script/md5.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ function md5_vm_test()

/*
* Calculate the MD5 of an array of little-endian words, and a bit length
keep
*/
function core_md5(x, len)
{
Expand Down Expand Up @@ -197,6 +198,7 @@ function bit_rol(num, cnt)
/*
* Convert a string to an array of little-endian words
* If chrsz is ASCII, characters >255 have their hi-byte silently ignored.
keep
*/
function str2binl(str)
{
Expand All @@ -221,6 +223,7 @@ function binl2str(bin)

/*
* Convert an array of little-endian words to a hex string.
keep
*/
function binl2hex(binarray)
{
Expand Down Expand Up @@ -254,3 +257,7 @@ function binl2b64(binarray)
}
return str;
}

if (typeof exports != 'undefined') {
exports.hex = hex_md5;
};
2 changes: 1 addition & 1 deletion evently/profile/profileReady/selectors/#preview/click.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ function() {
name : $$("#profile").profile.nickname,
url : $$("#profile").profile.url,
avatar : $$("#profile").profile.gravatar_url,
html : markdown.encode(Mustache.escape($("[name=comment]", f).val())),
html : markdown.encode(Mustache.escape($("[name=comment]").val())),
created_at : JSON.parse(JSON.stringify(new Date()))
};

Expand Down
4 changes: 3 additions & 1 deletion helpers/md5.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,4 +256,6 @@ function binl2b64(binarray)
}
}
return str;
}
}

exports.hex = hex_md5;
2 changes: 1 addition & 1 deletion lists/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function(head, req) {
assets : path.asset(),
posts : List.withRows(function(row) {
var post = row.value;
key = row.key;
key = row.key[0];
return {
title : post.title,
author : post.author,
Expand Down
2 changes: 1 addition & 1 deletion templates/edit.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<div id="tagcloud"></div>
<div id="content">
<!-- form to create a post -->
<form id="new-post" action="new.html" method="post">
<form id="new-post" action="post.html" method="post">
<h1>{{pageTitle}}</h1>
<p><label>Title</label>
<input type="text" size="50" name="title" value="{{title}}"></p>
Expand Down
2 changes: 2 additions & 0 deletions templates/post.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@ <h1>{{ title }}</h1>
</ul>
<div id="profile"></div>
</div>
<div id="comment-preview"></div>
</div>
</body>
{{>scripts}}
<script src="../../script/jquery.scrollTo.js"></script>
<script type="text/javascript" charset="utf-8">
$.CouchApp(function(app) {
app.post_id = "{{post_id}}";
Expand Down
4 changes: 2 additions & 2 deletions views/lib/comments.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// !code helpers/md5.js
var md5 = require("views/lib/md5");

exports.withGravatar = function(doc) {
if (doc.commenter && doc.commenter.email && !doc.commenter.gravatar_url) {
var hashed = hex_md5(doc.commenter.email);
var hashed = md5.hex(doc.commenter.email);
var k, newDoc = {};
for (k in doc) {
if (doc.hasOwnProperty(k)) {
Expand Down
Loading