lib not library

This commit is contained in:
Chris Anderson 2009-01-01 23:33:14 -08:00
parent 8733b631e3
commit b8856771f7
4 changed files with 5 additions and 33 deletions

View file

@ -26,7 +26,7 @@ module CouchRest
attachdir = File.join(appdir,"_attachments")
fields = dir_to_fields(appdir)
library = fields["library"]
library = fields["lib"]
package_forms(fields["forms"], library)
package_views(fields["views"], library)
@ -153,14 +153,14 @@ module CouchRest
def package_forms(funcs, library)
if library
lib = "var library = #{library.to_json};"
lib = "var lib = #{library.to_json};"
apply_lib(funcs, lib)
end
end
def package_views(views, library)
if library
lib = "var library = #{library.to_json};"
lib = "var lib = #{library.to_json};"
views.each do |view, funcs|
apply_lib(funcs, lib) if lib
end
@ -169,6 +169,7 @@ module CouchRest
def apply_lib(funcs, lib)
funcs.each do |k,v|
next unless v.is_a?(String)
funcs[k] = v.sub(/(\/\/|#)\ ?include-lib/,lib)
end
end

View file

@ -1,3 +0,0 @@
function aHelperFunction() {
return "help";
};

View file

@ -1,26 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<title>Generated CouchApp Form Template</title>
</head>
<body>
<div id="header">
<h2><a href="index.html">Back to index</a></h2>
</div>
<div id="content">
<h1><% doc.title %></h1>
</div>
</body>
<script src="/_utils/script/json2.js"></script>
<script src="/_utils/script/jquery.js?1.2.6"></script>
<script src="/_utils/script/jquery.couch.js?0.8.0"></script>
<script src="jquery.couchapp.js"></script>
<script src="blog.js"></script>
<script type="text/javascript" charset="utf-8">
$.CouchApp(function(app) {
var docid = document.location.pathname.split('/').pop();
// hey you could run a query to load more information from views
});
</script>
<script src="showdown.js"></script>
</html>

View file

@ -34,7 +34,7 @@ describe "couchapp" do
end
it "should create a forms and libs" do
Dir["#{@fixdir}/my-app/forms/*"].select{|x|x =~ /example-form.js/}.length.should == 1
Dir["#{@fixdir}/my-app/library/templates/*"].select{|x|x =~ /example-template.html/}.length.should == 1
Dir["#{@fixdir}/my-app/lib/templates/*"].select{|x|x =~ /example-template.html/}.length.should == 1
end
end