couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r657926 - in /incubator/couchdb/trunk: etc/couchdb/ share/www/script/ src/couchdb/
Date Mon, 19 May 2008 19:20:20 GMT
Author: damien
Date: Mon May 19 12:20:19 2008
New Revision: 657926

URL: http://svn.apache.org/viewvc?rev=657926&view=rev
Log:
Changed temp view definition to always be jsonobjects with map/reduce source as members of
the object. Everywhere we used 'text/javascript' or 'application/javascript', we now just
use 'javascript'

Modified:
    incubator/couchdb/trunk/etc/couchdb/couch.ini.tpl.in
    incubator/couchdb/trunk/share/www/script/browse.js
    incubator/couchdb/trunk/share/www/script/couch.js
    incubator/couchdb/trunk/share/www/script/couch_tests.js
    incubator/couchdb/trunk/share/www/script/jquery.couch.js
    incubator/couchdb/trunk/src/couchdb/couch_doc.erl
    incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
    incubator/couchdb/trunk/src/couchdb/couch_view.erl

Modified: incubator/couchdb/trunk/etc/couchdb/couch.ini.tpl.in
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/etc/couchdb/couch.ini.tpl.in?rev=657926&r1=657925&r2=657926&view=diff
==============================================================================
--- incubator/couchdb/trunk/etc/couchdb/couch.ini.tpl.in (original)
+++ incubator/couchdb/trunk/etc/couchdb/couch.ini.tpl.in Mon May 19 12:20:19 2008
@@ -20,4 +20,4 @@
 
 [Couch Query Servers]
 
-text/javascript=%bindir%/%couchjs_command_name% %pkgdatadir%/server/main.js
+javascript=%bindir%/%couchjs_command_name% %pkgdatadir%/server/main.js

Modified: incubator/couchdb/trunk/share/www/script/browse.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/browse.js?rev=657926&r1=657925&r2=657926&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/browse.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/browse.js [utf-8] Mon May 19 12:20:19 2008
@@ -277,7 +277,7 @@
           var viewCode = $("#viewcode textarea").val();
           var docId = ["_design", data.docid].join("/");
           function save(doc) {
-            if (!doc) doc = {_id: docId, language: "text/javascript"};
+            if (!doc) doc = {_id: docId, language: "javascript"};
             if (doc.views === undefined) doc.views = {};
             doc.views[data.name] = viewCode;
             db.saveDoc(doc, {

Modified: incubator/couchdb/trunk/share/www/script/couch.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch.js?rev=657926&r1=657925&r2=657926&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch.js [utf-8] Mon May 19 12:20:19 2008
@@ -98,8 +98,8 @@
     if (typeof(mapFun) != "string")
       mapFun = mapFun.toSource ? mapFun.toSource() : "(" + mapFun.toString() + ")";
     var req = request("POST", this.uri + "_temp_view" + encodeOptions(options), {
-      headers: {"Content-Type": "text/javascript"},
-      body: JSON.stringify(mapFun)
+      headers: {"Content-Type": "application/json"},
+      body: JSON.stringify({language:"javascript",map:mapFun})
     });
     var result = JSON.parse(req.responseText);
     if (req.status != 200)
@@ -114,8 +114,8 @@
     if (typeof(reduceFun) != "string")
       reduceFun = reduceFun.toSource ? reduceFun.toSource() : "(" + reduceFun.toString()
+ ")";
     var req = request("POST", this.uri + "_temp_view" + encodeOptions(options), {
-      headers: {"Content-Type": "text/javascript"},
-      body: JSON.stringify({map:mapFun, reduce:reduceFun})
+      headers: {"Content-Type": "application/json"},
+      body: JSON.stringify({language:"javascript",map:mapFun,reduce:reduceFun})
     });
     var result = JSON.parse(req.responseText);
     if (req.status != 200)

Modified: incubator/couchdb/trunk/share/www/script/couch_tests.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/couch_tests.js?rev=657926&r1=657925&r2=657926&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/couch_tests.js [utf-8] Mon May 19 12:20:19 2008
@@ -436,7 +436,7 @@
 
     var designDoc = {
       _id:"_design/test",
-      language: "text/javascript",
+      language: "javascript",
       views: {
         all_docs: "function(doc) { map(doc.integer, null) }",
         no_docs: "function(doc) {}",

Modified: incubator/couchdb/trunk/share/www/script/jquery.couch.js
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/share/www/script/jquery.couch.js?rev=657926&r1=657925&r2=657926&view=diff
==============================================================================
--- incubator/couchdb/trunk/share/www/script/jquery.couch.js [utf-8] (original)
+++ incubator/couchdb/trunk/share/www/script/jquery.couch.js [utf-8] Mon May 19 12:20:19 2008
@@ -179,7 +179,7 @@
             fun = fun.toSource ? fun.toSource() : "(" + fun.toString() + ")";
           $.ajax({
             type: "POST", url: this.uri + "_temp_view" + encodeOptions(options),
-            contentType: "text/javascript", data: fun, dataType: "json",
+            contentType: "javascript", data: fun, dataType: "json",
             complete: function(req) {
               var resp = $.httpData(req, "json");
               if (req.status == 200 && options.success) {

Modified: incubator/couchdb/trunk/src/couchdb/couch_doc.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_doc.erl?rev=657926&r1=657925&r2=657926&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_doc.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_doc.erl Mon May 19 12:20:19 2008
@@ -172,7 +172,7 @@
     Bin.
 
 get_view_functions(#doc{body={obj, Fields}}) ->
-    Lang = proplists:get_value("language", Fields, "text/javascript"),
+    Lang = proplists:get_value("language", Fields, "javascript"),
     {obj, Views} = proplists:get_value("views", Fields, {obj, []}),
     {Lang, [{ViewName, Value} || {ViewName, Value} <- Views, is_list(Value)]};
 get_view_functions(_Doc) ->

Modified: incubator/couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=657926&r1=657925&r2=657926&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_httpd.erl Mon May 19 12:20:19 2008
@@ -397,30 +397,30 @@
         end_docid = EndDocId
     } = QueryArgs = parse_view_query(Req),
 
-    ContentType = case Req:get_primary_header_value("content-type") of
-        undefined ->
-            "text/javascript";
-        Else ->
-            Else
-    end,
-    case cjson:decode(Req:recv_body()) of
-    {obj, Props} ->
-        MapSrc = proplists:get_value("map",Props),
-        RedSrc = proplists:get_value("reduce",Props),
-        {ok, View} = couch_view:get_reduce_view(
-                {temp, DbName, ContentType, MapSrc, RedSrc}),
-        {ok, Value} = couch_view:reduce(View, {StartKey, StartDocId}, {EndKey, EndDocId}),
-        send_json(Req, {obj, [{ok,true}, {result, Value}]});
-    Src when is_list(Src) ->
-        
-        {ok, View} = couch_view:get_map_view({temp, DbName, ContentType, Src}),
+    case Req:get_primary_header_value("content-type") of
+        undefined -> ok;
+        "application/json" -> ok;
+        Else -> throw({incorrect_mime_type, Else})
+    end,
+    {obj, Props} = cjson:decode(Req:recv_body()),
+    Language = proplists:get_value("language", Props, "javascript"),
+    MapSrc = proplists:get_value("map", Props),
+    case proplists:get_value("reduce", Props, null) of
+    null ->
+        {ok, View} = couch_view:get_map_view({temp, DbName, Language, MapSrc}),
         Start = {StartKey, StartDocId},
         {ok, TotalRows} = couch_view:get_row_count(View),
         FoldlFun = make_view_fold_fun(Req, QueryArgs, TotalRows,
                 fun couch_view:reduce_to_count/1),
         FoldAccInit = {Count, SkipCount, undefined, []},
         FoldResult = couch_view:fold(View, Start, Dir, FoldlFun, FoldAccInit),
-        finish_view_fold(Req, TotalRows, FoldResult)
+        finish_view_fold(Req, TotalRows, FoldResult);
+
+    RedSrc ->
+        {ok, View} = couch_view:get_reduce_view(
+                {temp, DbName, Language, MapSrc, RedSrc}),
+        {ok, Value} = couch_view:reduce(View, {StartKey, StartDocId}, {EndKey, EndDocId}),
+        send_json(Req, {obj, [{ok,true}, {result, Value}]})
     end;
 
 handle_db_request(_Req, _Method, {_DbName, _Db, ["_temp_view"]}) ->

Modified: incubator/couchdb/trunk/src/couchdb/couch_view.erl
URL: http://svn.apache.org/viewvc/incubator/couchdb/trunk/src/couchdb/couch_view.erl?rev=657926&r1=657925&r2=657926&view=diff
==============================================================================
--- incubator/couchdb/trunk/src/couchdb/couch_view.erl (original)
+++ incubator/couchdb/trunk/src/couchdb/couch_view.erl Mon May 19 12:20:19 2008
@@ -153,7 +153,7 @@
                 
 
 design_doc_to_view_group(#doc{id=Id,body={obj, Fields}}) ->
-    Language = proplists:get_value("language", Fields, "text/javascript"),
+    Language = proplists:get_value("language", Fields, "javascript"),
     {obj, RawViews} = proplists:get_value("views", Fields, {obj, []}),
     
     % extract the map/reduce views from the json fields and into lists



Mime
View raw message