From 567c1a5fffe99776c010da3997d92d16ef17b5d5 Mon Sep 17 00:00:00 2001 From: Jason Dorweiler Date: Sun, 1 Jun 2014 08:28:10 -0400 Subject: [PATCH 1/3] update record template IAs --- share/spice/code_search/code_search.js | 4 +++- share/spice/meta_cpan/meta_cpan.js | 4 +++- share/spice/urban_dictionary/urban_dictionary.js | 6 ++++-- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/share/spice/code_search/code_search.js b/share/spice/code_search/code_search.js index ddd43587cb..c254133726 100644 --- a/share/spice/code_search/code_search.js +++ b/share/spice/code_search/code_search.js @@ -12,7 +12,9 @@ Spice.add({ id: 'code_search', name: "Software", - data: api_result.results[0].lines, + data: { + record_data: api_result.results[0].lines + }, meta: { sourceUrl: 'http://searchco.de/?q=' + query + '&cs=true', sourceName: 'searchcode' diff --git a/share/spice/meta_cpan/meta_cpan.js b/share/spice/meta_cpan/meta_cpan.js index d46cf1fffa..600b6c4c0b 100644 --- a/share/spice/meta_cpan/meta_cpan.js +++ b/share/spice/meta_cpan/meta_cpan.js @@ -15,7 +15,9 @@ Spice.add({ id: "meta_cpan", name: "Software", - data: api_result, + data: { + record_data: api_result + }, meta: { sourceName: "MetaCPAN", sourceUrl: 'https://metacpan.org/' + link diff --git a/share/spice/urban_dictionary/urban_dictionary.js b/share/spice/urban_dictionary/urban_dictionary.js index 1953ae8020..848592c043 100644 --- a/share/spice/urban_dictionary/urban_dictionary.js +++ b/share/spice/urban_dictionary/urban_dictionary.js @@ -16,7 +16,9 @@ Spice.add({ id: "urban_dictionary", name: "Dictionary", - data: response.list[0], + data: { + record_data: response.list[0] + }, meta: { sourceUrl: 'http://www.urbandictionary.com/define.php?term=' + word, sourceName: 'Urban Dictionary' @@ -30,7 +32,7 @@ }, normalize : function(item){ return{ - definition: item.definition.replace(/(\r?\n)+/gi, ''), + definition: item.record_data.definition.replace(/(\r?\n)+/gi, ''), record_keys: ['word', 'definition', 'example'], }; } From 6a4cf4f25be9d73e045cfd734937542bb6c702ba Mon Sep 17 00:00:00 2001 From: Jason Dorweiler Date: Sun, 1 Jun 2014 08:35:57 -0400 Subject: [PATCH 2/3] code_search: update for record template --- share/spice/code_search/code_search.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/share/spice/code_search/code_search.js b/share/spice/code_search/code_search.js index c254133726..2171a91b98 100644 --- a/share/spice/code_search/code_search.js +++ b/share/spice/code_search/code_search.js @@ -23,7 +23,7 @@ var keys = []; - $.each(item, function(k, v){ + $.each(item.record_data, function(k, v){ keys.push(k) }); From 1d8777db09446f03a9e04691cd88f6bfd04b7a30 Mon Sep 17 00:00:00 2001 From: Jason Dorweiler Date: Mon, 2 Jun 2014 12:04:54 -0400 Subject: [PATCH 3/3] record IAs, more keys out of normalize --- share/spice/code_search/code_search.js | 21 +++++++------------ share/spice/meta_cpan/meta_cpan.js | 8 ++----- .../urban_dictionary/urban_dictionary.js | 6 +++--- 3 files changed, 13 insertions(+), 22 deletions(-) diff --git a/share/spice/code_search/code_search.js b/share/spice/code_search/code_search.js index 2171a91b98..eec80c8df5 100644 --- a/share/spice/code_search/code_search.js +++ b/share/spice/code_search/code_search.js @@ -9,28 +9,23 @@ var query = encodeURIComponent(api_result.query); + var keys = []; + + $.each(api_result.results[0].lines, function(k, v){ + keys.push(k) + }); + Spice.add({ id: 'code_search', name: "Software", data: { - record_data: api_result.results[0].lines + record_data: api_result.results[0].lines, + record_keys: keys }, meta: { sourceUrl: 'http://searchco.de/?q=' + query + '&cs=true', sourceName: 'searchcode' }, - normalize: function(item){ - - var keys = []; - - $.each(item.record_data, function(k, v){ - keys.push(k) - }); - - return{ - record_keys: keys - }; - }, templates: { group: 'base', options: { diff --git a/share/spice/meta_cpan/meta_cpan.js b/share/spice/meta_cpan/meta_cpan.js index 600b6c4c0b..5d5beb5aac 100644 --- a/share/spice/meta_cpan/meta_cpan.js +++ b/share/spice/meta_cpan/meta_cpan.js @@ -16,7 +16,8 @@ id: "meta_cpan", name: "Software", data: { - record_data: api_result + record_data: api_result, + record_keys: ['abstract','author','version','description'] }, meta: { sourceName: "MetaCPAN", @@ -28,11 +29,6 @@ content: 'record', moreAt: true } - }, - normalize: function(item){ - return{ - record_keys: ['abstract','author','version','description'] - }; } }); } diff --git a/share/spice/urban_dictionary/urban_dictionary.js b/share/spice/urban_dictionary/urban_dictionary.js index 848592c043..f695d98f7d 100644 --- a/share/spice/urban_dictionary/urban_dictionary.js +++ b/share/spice/urban_dictionary/urban_dictionary.js @@ -17,7 +17,8 @@ id: "urban_dictionary", name: "Dictionary", data: { - record_data: response.list[0] + record_data: response.list[0], + record_keys: ['word', 'definition', 'example'] }, meta: { sourceUrl: 'http://www.urbandictionary.com/define.php?term=' + word, @@ -32,8 +33,7 @@ }, normalize : function(item){ return{ - definition: item.record_data.definition.replace(/(\r?\n)+/gi, ''), - record_keys: ['word', 'definition', 'example'], + definition: item.record_data.definition.replace(/(\r?\n)+/gi, '') }; } });