From b9f746c510638fd4d402d01988f199ffd5d2cffa Mon Sep 17 00:00:00 2001 From: "mr.Shu" Date: Tue, 22 Nov 2011 23:01:49 +0000 Subject: [PATCH 1/4] first commit for alt.to --- alternative_to/spice.html | 18 ++++++++++++++++++ alternative_to/spice.js | 24 ++++++++++++++++++++++++ alternative_to/spice.namespace | 1 + alternative_to/spice.pl | 4 ++++ 4 files changed, 47 insertions(+) create mode 100644 alternative_to/spice.html create mode 100644 alternative_to/spice.js create mode 100644 alternative_to/spice.namespace create mode 100644 alternative_to/spice.pl diff --git a/alternative_to/spice.html b/alternative_to/spice.html new file mode 100644 index 0000000000..a9881b9b79 --- /dev/null +++ b/alternative_to/spice.html @@ -0,0 +1,18 @@ + + + + + Alternative.to test + + + + +
+ + + diff --git a/alternative_to/spice.js b/alternative_to/spice.js new file mode 100644 index 0000000000..3e975b91d9 --- /dev/null +++ b/alternative_to/spice.js @@ -0,0 +1,24 @@ +function nrat(alts) +{ + console.log(alts); + + // validity check + if (alts['Items']) { + + var items = new Array(); + var i = 0; + + for (item in alts['Items']) { + + items[i] = new Array(); + items[i]['a'] = alts['Items'][i]['Name']; + + i++; + } + + + console.log(items[0]['a']); + nra(items); + } +} + diff --git a/alternative_to/spice.namespace b/alternative_to/spice.namespace new file mode 100644 index 0000000000..5f5a107e03 --- /dev/null +++ b/alternative_to/spice.namespace @@ -0,0 +1 @@ +fl \ No newline at end of file diff --git a/alternative_to/spice.pl b/alternative_to/spice.pl new file mode 100644 index 0000000000..50a0a3ad2a --- /dev/null +++ b/alternative_to/spice.pl @@ -0,0 +1,4 @@ +if ($q_check_lc eq 'flash version') { + $call_ext = qq(/js/nrfl.js); + $is_kill_pre_results = 1; +} From 38fb59bd9cbde7eca048f1c9beed978dd5f8eaed Mon Sep 17 00:00:00 2001 From: "mr.Shu" Date: Fri, 25 Nov 2011 04:47:33 +0000 Subject: [PATCH 2/4] first version of alternativeto.net spice --- alternative_to/spice.html | 3 ++- alternative_to/spice.js | 43 +++++++++++++++++++++++++++++++-------- 2 files changed, 36 insertions(+), 10 deletions(-) diff --git a/alternative_to/spice.html b/alternative_to/spice.html index a9881b9b79..b3e4ec9f27 100644 --- a/alternative_to/spice.html +++ b/alternative_to/spice.html @@ -6,13 +6,14 @@
+ + diff --git a/alternative_to/spice.js b/alternative_to/spice.js index 3e975b91d9..f227748998 100644 --- a/alternative_to/spice.js +++ b/alternative_to/spice.js @@ -1,23 +1,48 @@ +d = document; function nrat(alts) { - console.log(alts); + // console.log(alts); + var out, tmp; + out = ""; // validity check if (alts['Items']) { - var items = new Array(); - var i = 0; + for (i in alts['Items']) { + var item = alts['Items'][i]; + + wrapper = d.createElement("div"); + box = d.createElement("div"); + + link = d.createElement("a"); + link.href = item['Url']; + link.innerHTML = item['Name']; - for (item in alts['Items']) { + img = d.createElement("img"); + img.src = item['IconUrl']; - items[i] = new Array(); - items[i]['a'] = alts['Items'][i]['Name']; + box.appendChild(img); + box.appendChild(d.createElement("br")); + box.appendChild(link); + + YAHOO.util.Dom.setStyle(box, "text-align", "center"); - i++; - } + YAHOO.util.Dom.setStyle(box, "float", "left"); + YAHOO.util.Dom.setStyle(box, "margin", "10px"); + YAHOO.util.Dom.setStyle(box, "width", "60px"); + wrapper.appendChild(box); + + out += wrapper.innerHTML; + + } - console.log(items[0]['a']); + items = new Array(); + items[0] = new Array(); + items[0]['a'] = out; + items[0]['h'] = ''; + items[0]['s'] = 'AlternativeTo'; + items[0]['u'] = alts['Url']; nra(items); } } From 8f7e6ca5e3e85ca708b807117cb32ad8d791c374 Mon Sep 17 00:00:00 2001 From: "mr.Shu" Date: Fri, 25 Nov 2011 05:14:01 +0000 Subject: [PATCH 3/4] Added (probably) working spice.pl --- alternative_to/spice.namespace | 2 +- alternative_to/spice.pl | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/alternative_to/spice.namespace b/alternative_to/spice.namespace index 5f5a107e03..48b483f295 100644 --- a/alternative_to/spice.namespace +++ b/alternative_to/spice.namespace @@ -1 +1 @@ -fl \ No newline at end of file +at diff --git a/alternative_to/spice.pl b/alternative_to/spice.pl index 50a0a3ad2a..c7821a2b90 100644 --- a/alternative_to/spice.pl +++ b/alternative_to/spice.pl @@ -1,4 +1,8 @@ -if ($q_check_lc eq 'flash version') { - $call_ext = qq(/js/nrfl.js); - $is_kill_pre_results = 1; +if ($q_check =~ /^alternatives? to ([\w\-]+)$/) { + #$call_extf = qq(/js/nrxk102.js); + if ($1) { + $call_ext = qq(/iat/software/$1); + } + $is_kill_pre_results = 1; } + From 7cb7eb687ba0f54ea415cd8357b8bbf2c01387ea Mon Sep 17 00:00:00 2001 From: "mr.Shu" Date: Mon, 28 Nov 2011 16:27:26 +0000 Subject: [PATCH 4/4] Better regex for alternativeTo The regex should now be able to process queries like: -> free alternative to firefox for mac -> opensource omnigraffle -> TextMate for windows -> alternative to gmail --- alternative_to/spice.html | 2 +- alternative_to/spice.pl | 30 ++++++++++++++++++++++++------ 2 files changed, 25 insertions(+), 7 deletions(-) diff --git a/alternative_to/spice.html b/alternative_to/spice.html index b3e4ec9f27..f03f0ce68b 100644 --- a/alternative_to/spice.html +++ b/alternative_to/spice.html @@ -14,6 +14,6 @@
- + diff --git a/alternative_to/spice.pl b/alternative_to/spice.pl index c7821a2b90..a91ebefc04 100644 --- a/alternative_to/spice.pl +++ b/alternative_to/spice.pl @@ -1,8 +1,26 @@ -if ($q_check =~ /^alternatives? to ([\w\-]+)$/) { - #$call_extf = qq(/js/nrxk102.js); - if ($1) { - $call_ext = qq(/iat/software/$1); - } - $is_kill_pre_results = 1; +if ($q_check_lc =~ /^(?:(free|opensource|commercial))?\s*(?:alternatives?\s*to\s*)?([\w\-]+)(?:\sfor\s(.*))?$/i) { + #$call_extf = qq(/js/nrat.js); + if ($1 and $4) { + # license and platform specified - queries like: + # -> free alternative to firefox for mac + # -> opensource matlab for linux + $call_ext = qq(/iat/software/$3/?platform=$4&license=$1); + } elsif ($1) { + # lincense secified only: + # -> free nod32 + # -> opensource alternative to omnigraffle + $call_ext = qq(/iat/software/$3/?license=$1); + } elsif ($4) { + # platform specified: + # -> TextMate for windows + # -> alternative to vim for linux + $call_ext = qq(/iat/software/$3/?platform=$4); + } elsif($2) { + # license and platform not specified + # in this case we need to match 'alternative(s) to': + # -> alternative to firefox + $call_ext = qq(/iat/software/$3); + } + $is_kill_pre_results = 1; }