Welcome Guest.   Make a donation to an author on the site December 21, 2014, 08:27:22 AM  *

Please login or register.
Or did you miss your validation email?


Login with username and password (forgot your password?)
Why not become a lifetime supporting member of the site with a one-time donation of any amount? Your donation entitles you to a ton of additional benefits, including access to exclusive discounts and downloads, the ability to enter monthly free software drawings, and a single non-expiring license key for all of our programs.


You must sign up here before you can post and access some areas of the site. Registration is totally free and confidential.
 
Learn about the DonationCoder.com microdonation system (DonationCredits).
   
   Forum Home   Thread Marks Chat! Downloads Search Login Register  
Pages: [1]   Go Down
  Reply  |  New Topic  |  Print  
Author Topic: Definr.com plugin - closed  (Read 12792 times)
czb
Moderator
*****
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« on: February 18, 2008, 03:07:05 AM »

This topic has been discontinued.
See:
http://www.donationcoder....m/index.php?topic=17153.0
« Last Edit: February 23, 2009, 09:49:18 AM by czb » Logged

My open-source online piano game: http://musicope.com/
mouser
First Author
Administrator
*****
Posts: 33,792



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #1 on: February 18, 2008, 03:15:23 AM »

nice!!!!!

ps. attention all plugin authors, please attach a screenshot when you post about your plugin, so i can more easily add it to the plugin list page:
http://www.donationcoder....re/Mouser/findrun/addons/
« Last Edit: February 18, 2008, 03:17:07 AM by mouser » Logged
czb
Moderator
*****
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #2 on: February 18, 2008, 03:30:26 AM »

Just an idea... could you please create any general CMS addons system (like firefox, miranda and others have)?
Now it is like that every coder has its own webpage.
Logged

My open-source online piano game: http://musicope.com/
czb
Moderator
*****
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #3 on: February 18, 2008, 03:37:34 AM »

This is very nice CMS for addons example:
http://extensions.services.openoffice.org/
it is based on Drupal Wink
Logged

My open-source online piano game: http://musicope.com/
Dr-Leech
Member
**
Posts: 151


Psychedelic Coder

View Profile WWW Give some DonationCredits to this forum member
« Reply #4 on: February 18, 2008, 08:27:13 AM »

Drupal projects is awesome.. also let you keep track of releases and issues.
Logged

taichimaster
Charter Member
***
Posts: 159



View Profile WWW Give some DonationCredits to this forum member
« Reply #5 on: February 19, 2008, 03:37:46 AM »

Cool!!!  I think this one is actually the most useful out of all your plugins!!!  Thanks.  *off to donate!*
Logged

Nod5
Supporting Member
**
Posts: 749



View Profile Give some DonationCredits to this forum member
« Reply #6 on: February 20, 2008, 01:56:43 PM »

Nice work czechboy! Very useful plugin!  Thmbsup

A small suggestion: it takes me more time to find the "," key compared to the space key. I managed to tweak your fscript.js so that "df football " triggers the search instead of "df football,". The plugin can still look up definitions for space separated phrases: "df foul ball ". It starts to search for "foul" but interrupts that when new non-space characters are entered and then searches the whole phrase "foul ball" when the next space is entered. I hope you'll consider using space for triggering the search in your official version.

I just changed:
[copy or print]
regexstr="^df (.*?),$";
scriptregex=/^df (.*?),$/;
To:
[copy or print]
regexstr="^df (.*?) $";
scriptregex=/^df (.*?) $/;

edit: I also decreased the font size (from f26 to f18) to lessen the number of linebreaks in the definition texts

« Last Edit: February 20, 2008, 02:05:38 PM by Nod5 » Logged
czb
Moderator
*****
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #7 on: February 21, 2008, 03:37:03 AM »

Good idea Wink I will change it to the space as well smiley
As to decreasing font size... I think, that each person might like different height. I will consider adding some option to the advanced plugin setting, but probably I will wait till new version of Javascript SDK is out where, hopefully, there will be more options for advanced plugin setting Wink
Logged

My open-source online piano game: http://musicope.com/
mouser
First Author
Administrator
*****
Posts: 33,792



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #8 on: February 21, 2008, 10:24:45 AM »

 = character would be good since its same as used with calc maybe?
Logged
jgpaiva
Global Moderator
*****
Posts: 4,717



Artificial Idiocy

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #9 on: February 21, 2008, 12:22:54 PM »

I very much prefer using space as a final character, since on my keyboard, = is only accessible through a shift-combo smiley
That's what i'm using with gcalc currently Wink
Logged

mouser
First Author
Administrator
*****
Posts: 33,792



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #10 on: February 21, 2008, 02:32:09 PM »

enter would be best i think, ive got a stack of todo items for FARR that i really need to get working on.
Logged
Nod5
Supporting Member
**
Posts: 749



View Profile Give some DonationCredits to this forum member
« Reply #11 on: February 21, 2008, 04:20:11 PM »

czechboy,
I've now testdriven the plugin some more. The searches are not always incredibly fast, despite what definr.com claim. Pretty often they take several seconds.

I found a similarly clean site, http://ninjawords.com/ , that seems faster (at least from my location). We're only talking slightly faster, but still. So I tried to learn from your fscript.js to grab definitions from ninjawords.com instead. The resulting code follows below. Do you spot any errors? It at least seems to run ok but I don't really know javascript or the FARR javascript SDK so there might be errors. The many replace functions look very messy but I'm not sure how to simplify them.

Also, a general question (maybe mouser or someone else can answer this too): is it possible to make some phrases in the grabbed text into hyperlinks when displayed in FARR?

edit: I tweaked it some more so that it now supports multiple lookups at once. Just type "nw word1,word2 " (see http://ninjawords.com/info/about/ for more on that)

[copy or print]
// plugin script :
displayname="ninjawords.com";
versionstring="1.0.0";
releasedatestring="21.2.2008";
author="nod5 (based on Definr plugin by Oldrich Svec)";
updateurl="";
homepageurl="";
shortdescription="ninjawords.com";
longdescription="defines words through http://ninjawords.com";
advconfigstring="ninjawords.com";
readmestring="ninjawords.com";
iconfilename="";

aliasstr="nw";
regexstr="^nw (.*?) $";
scriptregex=/^nw (.*?) $/;
regexfilterstr="";
keywordstr="";
scorestr="300";

// type
UNKNOWN=0; FILE=1; FOLDER=2; ALIAS=3; URL=4; PLUGIN=5; CLIP=5;
// Postprocessing
IMMEDIATE_DISPLAY=0; ADDSCORE=1; MATCH_AGAINST_SEARCH=2;
// search state
STOPPED=0; SEARCHING=1;

var pre_string = "{\\rtf1\\ansi\\ansicpg1250\\deff0\\deftab709{\\fonttbl{\\f0\\fnil\\fcharset0 Arial;}}{\\colortbl ;\\red255\\green0\\blue0;}{\\*\\generator Msftedit 5.41.15.1507;}\\viewkind4\\uc1\\pard\\lang2057\\f0\\fs18 ";
var post_string = "\\par\n}";

function doQuery(querykey,querynokeyword){
    var url = "http://ninjawords.com/"+querynokeyword;
    var xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
    xmlhttp.onreadystatechange = function(){
      if (xmlhttp.readyState == 4) {
        var string = xmlhttp.responseText;
string = string.replace(/\n/g,'\\par');
var splitString = string.split('<dt class="title-word">');
       
        var string ="";

for ( var i=1, len=splitString.length; i<len; ++i ){

    if (i > 1) {
               string +="\\par -----------------------------\\par ";
               }
        splitString[i] = splitString[i].replace(/<\/dl>.*?$/,"");
splitString[i] = splitString[i].replace(/<dd.*?>/g,'\\doublepar ');
        splitString[i] = splitString[i].replace(/ :<\/span>/g,": ");
splitString[i] = splitString[i].replace(/more&raquo;/g,'');
splitString[i] = splitString[i].replace(/&mdash;/g,'-');
        splitString[i] = splitString[i].replace(/<.*?>/g,"");
splitString[i] = splitString[i].replace(/\t/g,'');
splitString[i] = splitString[i].replace(/\\par\s*?(\S)/g,'\\par$1');
splitString[i] = splitString[i].replace(/\\par/g,'');
splitString[i] = splitString[i].replace(/\\doublepar/g,'\\par\\par');
string += splitString[i];
}
         
        FARR.setStrValue("statusbar","Define");
        FARR.setStrValue("window.richeditmode",pre_string+string+post_string);
      }
    }
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

function onSearchBegin(querykey, explicit, queryraw, querynokeyword) {
  if(!explicit) {
    if(aliasstr.indexOf(querynokeyword)!=-1) {
      FARR.setState(querykey,1);
      FARR.emitResult(querykey,aliasstr, aliasstr, iconfilename,ALIAS,IMMEDIATE_DISPLAY,300);
      FARR.setState(querykey,0);
    }
    return;
  }
  FARR.setStrValue("statusbar","Define");
  FARR.setStrValue("window.richeditmode",pre_string+"Type what you want to search and hit Space"+post_string);
}

function onRegexSearchMatch(querykey,querynokeyword) {
  FARR.setStrValue("statusbar","Define");
  FARR.setStrValue("window.richeditmode",pre_string+"Please wait..."+post_string);
  var match_reg = querynokeyword.match(scriptregex);
  doQuery(querykey,match_reg[1]);
}

« Last Edit: February 21, 2008, 05:37:39 PM by Nod5 » Logged
czb
Moderator
*****
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #12 on: February 22, 2008, 02:12:00 AM »

Hi,
realy cool Wink I will use this website instead thumbs up
I have also tried to write my own script (for comparative reasons, so that we can learn from each other) and here it is:
Quote
function doQuery(querykey,querynokeyword){
    var output="";
    var url = "http://ninjawords.com/"+querynokeyword;
    var xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
    xmlhttp.onreadystatechange = function(){
      if (xmlhttp.readyState == 4) {
        var string = xmlhttp.responseText;
         string = string.replace(/\n|\t/g,'');
         string = string.match(/<dl class="word" id="word-.*?">.*?<\/dl>/g);
         for(k=0;k<string.length;k++){
          heading = string[k].match(/<dt class="title-word">.*?<a href=.*?>(.*?)<\/a>.*?<\/dt>/);
          if(heading && heading[1])
            output += "\\b "+heading[1]+"\\b0\\par\\par\n";
          var body = string[k].match(/<dd class="entry.*?">.*?<\/dd>/g);
          if(body)
            for(i = 0;i<body.length;i++){
              body = body.replace(/<a title="synonyms">more&raquo;<\/a>/g,"");
              output += body.replace(/<.*?>/g,"")+"\\par\\par\n";
            }
          else output = "Nothing found";
        }
        FARR.setStrValue("statusbar","Define");
        FARR.setStrValue("window.richeditmode",pre_string+output+post_string);
      }
    }
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

I must say, that I am NOT coder either. FARR JS plugins are nearly my first touch of JS Wink So I am not the right person to revise your code embarassed But it works perfectly Thmbsup

As to hyperlinks: I have tried to use hyperlinks in RTF but it does not display them as hyperlinks. So I guess we have to wait till there will be HTML support in FARR Wink

EDIT: just one remark. Are you goining to publish this ninjawords plugin (so that others can use it too), or shall I do it?
« Last Edit: February 22, 2008, 02:17:22 AM by czechboy » Logged

My open-source online piano game: http://musicope.com/
Nod5
Supporting Member
**
Posts: 749



View Profile Give some DonationCredits to this forum member
« Reply #13 on: February 22, 2008, 04:08:44 AM »

czechboy,
It's better that you do it since I based my version on your code and you have a page set up already.

I'm myself more and more convinced that ninjawords is better than definr. It is noticeably faster from my location. It also gives definitions that are shorter and more to the point (which is almost always enough). It also allows multiple lookups in one search. The only drawback I can find with ninjawords is that it gives errors when the search phrase contains dots (try searching for "i.e."). I'll email the ninjawords dev about that.

Perhaps in the future your plugin could be expanded with some option where the user can choose what definition site to use (Definr, ninjawords, possibly others...)? Since some might still prefer definr.

I also must make a general exclamation: these javascript plugins (and the underlying javascript SDK) has really opened up my eyes to how great FARR can be at interacting with the web (doing queries, grabbing content...).  Thmbsup
« Last Edit: February 22, 2008, 04:12:35 AM by Nod5 » Logged
czb
Moderator
*****
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #14 on: February 22, 2008, 04:36:35 AM »

Ok, I will do it. I also think that in JS there is a huge potential. It is easy to learn and you can do anything smiley
I also thought about making a plugin which would extract from any site content according to provided XML. You would provide URL and XML like that:
Formatted for XML with the GeSHI Syntax Highlighter [copy or print]
  1. <?xml version="1.0" encoding="windows-1250"?>
  2. <feed>
  3.  <match what="<span style="font-size:1\.2em">(.*?)<\/span>">
  4.    <couple>
  5.      <first>
  6.          <match what="<strong>(.*?)</strong>">
  7.          </match>
  8.      </first>
  9.      <second>
  10.          <match what="</b>(.*?)<b>" modifiers="g">
  11.            <replace what="<.*?>" with="">
  12.            </replace>
  13.          </match>
  14.      </second>
  15.    </couple>
  16.  </match>
  17.  <match what="<table cellpadding=0 cellspacing=0 border=0>(.*?)</table>">
  18.    <match what="<td align=left valign="top" width="30%">(.*?)</td>" modifiers="g">
  19.      <couple>
  20.        <first what="<strong>(.*?)</strong>">
  21.        </first>
  22.        <second what="</b>(.*?)<b>" list="list">
  23.          <replace what="<.*?>" with="">
  24.          </replace>
  25.        </second>
  26.      </couple>
  27.    </match>
  28.  </match>
  29. </feed>
and it would display a content to you. But it seams as complex problem and I am not sure, I have enough skills to code it...
Logged

My open-source online piano game: http://musicope.com/
Nod5
Supporting Member
**
Posts: 749



View Profile Give some DonationCredits to this forum member
« Reply #15 on: February 22, 2008, 07:14:23 AM »

I just tried your version of the Ninjawords script. It did not run here. After entering the search string I get "please wait..." and then nothing happens. Not sure why. Does it work for you? I updated my version some more based on your code (simplified the replace steps, made each search phrase bold). Feel free to use it.
[copy or print]
function doQuery(querykey,querynokeyword){
    var url = "http://ninjawords.com/"+querynokeyword;
    var xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
    xmlhttp.onreadystatechange = function(){
      if (xmlhttp.readyState == 4) {
        var string = xmlhttp.responseText;
string = string.replace(/\n|\t/g,'');
var splitString = string.split('<dt class="title-word">');
       
        var string ="";

for (var i=1;i<splitString.length; ++i){

    if (i > 1) {
               string +="\\par -----------------------------\\par ";
               }
splitString[i] = "\\b " + splitString[i]
        splitString[i] = splitString[i].replace(/<\/dl>.*?$/,"");
splitString[i] = splitString[i].replace(/<dd.*?>/g,'\\b0 \\par\\par ');
        splitString[i] = splitString[i].replace(/ :<\/span>/g,": ");
splitString[i] = splitString[i].replace(/more&raquo;/g,'');
splitString[i] = splitString[i].replace(/&mdash;/g,'-');
        splitString[i] = splitString[i].replace(/<.*?>/g,"");
string += splitString[i];
}
         
        FARR.setStrValue("statusbar","Define");
        FARR.setStrValue("window.richeditmode",pre_string+string+post_string);
      }
    }
    xmlhttp.open("GET",url,true);
    xmlhttp.send(null);
}

I forgot to mention one more advantage with Ninjawords: if you spell a word wrong it automatically guesses the word and shows the definition - try "nw footbaall ". Definr on the other hand shows a list of terms and forces the users to choose one.

As for that XML thing I think I understand what you mean. Promising. I can already think of several websites that I'd want FARR to grab specific content from and display to me in an instant. But I'm not sure if people will prefer that over site specific plugins. And I don't know how to write XML so I can't help much I'm afraid.

edit: I now saw that you created a new thread ( http://www.donationcoder....m/index.php?topic=12421.0 ). The ninjawords version on your page does return definitions. But I think there is some error in the parsing code. Try "nw test,gone " and "nw gone,test ". In the first case, the bold "gone" is missing. In the second case, both "gone" and it's definition is missing. I'm not sure what the cause of that is.
« Last Edit: February 22, 2008, 07:43:21 AM by Nod5 » Logged
czb
Moderator
*****
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #16 on: February 22, 2008, 07:32:55 AM »

Ok I have updated to your version Thmbsup Thanks for pointing out Wink

btw: ninjawords really seams promising smiley

EDIT: If you wanted to make it even faster you can try this url:
http://ninjawords.com/definitions/getdef/test
instead. It is what ninjawords.com uses to send ajax reguest Wink
« Last Edit: February 22, 2008, 07:37:14 AM by czechboy » Logged

My open-source online piano game: http://musicope.com/
Nod5
Supporting Member
**
Posts: 749



View Profile Give some DonationCredits to this forum member
« Reply #17 on: February 22, 2008, 07:43:55 AM »

Great. I'll try it now.  edit: works fine"  Thmbsup

Two more things:
- the ninjawords plugin page says "nw - to start Definr plug-in" when you really mean "nw - to start Ninjawords plug-in".
- note that: "nw school, wall " is not needed for multiple lookups. "nw school,wall " is enough. That way the plugin accesses the Ninjawords site only once compared to twice.

Using http://ninjawords.com/definitions/getdef/test from the beginning would probably have been best, but I'm not sure if its needed now.
How many milliseconds do you think we'll save by using it? Grin
« Last Edit: February 22, 2008, 07:49:04 AM by Nod5 » Logged
czb
Moderator
*****
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #18 on: February 22, 2008, 07:55:21 AM »

You are right embarassed
All suggestions corrected (hopefully) smiley
Logged

My open-source online piano game: http://musicope.com/
Nod5
Supporting Member
**
Posts: 749



View Profile Give some DonationCredits to this forum member
« Reply #19 on: February 22, 2008, 08:29:28 AM »

I gave the alternative page for grabbing the definitions ( http://ninjawords.com/definitions/getdef/test ) a go after all. Do you notice any difference in speed? Also, since the definitions are grabbed blazingly fast, maybe it's best to remove the "Please wait..." text completely? It just causes FARR to flicker a very brief moment but is almost not readable.

edit: this cuts off some words it seems, will troubleshoot that later. edit2: works now, I earlier forgot to escape \ at one place
[copy or print]
function doQuery(querykey,querynokeyword){
  var url = "http://ninjawords.com/definitions/getdef/"+querynokeyword;
  var xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
  xmlhttp.onreadystatechange = function(){
    if (xmlhttp.readyState == 4) {
      var string = xmlhttp.responseText;
      string = string.replace(/\\n|\\t/g,'');
      var splitString = string.split('\\074dt class=\\"title-word\\"\\076');
      var string ="";
      for (var i=1;i<splitString.length; ++i){
        if (i > 1) {
          string +="\\par -----------------------------\\par ";
        }
        splitString[i] = "\\b " + splitString[i];
        splitString[i] = splitString[i].replace(/", query: ".*?$/,"");
        splitString[i] = splitString[i].replace(/\\074dd.*?\\076/g,'\\b0 \\par\\par ');
        splitString[i] = splitString[i].replace(/ :\\074\/span\\076/g,": ");
        splitString[i] = splitString[i].replace(/\\074div class=\\"examples\\"\\076/g,"\. ");
        splitString[i] = splitString[i].replace(/\\074.*?\\076/g,"");
        splitString[i] = splitString[i].replace(/\\u2014/g,"-");
        splitString[i] = splitString[i].replace(/\\u2019/g,"'");
        splitString[i] = splitString[i].replace(/&mdash/g,"-");
        splitString[i] = splitString[i].replace(/more&raquo;\,/g,"");
        string += splitString[i];
      }
      FARR.setStrValue("statusbar","Define");
      FARR.setStrValue("window.richeditmode",pre_string+string+post_string);
      }
    }
  xmlhttp.open("GET",url,true);
  xmlhttp.send(null);
}
« Last Edit: February 22, 2008, 09:47:37 AM by Nod5 » Logged
mouser
First Author
Administrator
*****
Posts: 33,792



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #20 on: February 22, 2008, 08:44:38 AM »

you could put the please wait in the status bar.

ps. i've added to my todo list to try to be smarter about resizing the window to avoid the flicker.
Logged
czb
Moderator
*****
Posts: 335



see users location on a map View Profile WWW Give some DonationCredits to this forum member
« Reply #21 on: February 22, 2008, 09:51:11 AM »

I have tried to leave "please wait" in status bar but it is not visible either... so I will erase it completely and update the plugin.
Btw: I must say that the upload plugin saves me a lot of time! Uploading new version takes 1-2seconds Cool

Offtopic:
I can see your todo list is getting pretty loooooong tongue Is it only you programming FARR? I wonder is FARR opensource, so that anybody can help a little? smiley
« Last Edit: February 22, 2008, 09:53:44 AM by czechboy » Logged

My open-source online piano game: http://musicope.com/
mouser
First Author
Administrator
*****
Posts: 33,792



see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #22 on: February 22, 2008, 10:53:24 AM »

it's only me.
FARR is not open source unfortunately Sad  most of my big programs aren't.  it's something i'd like to do more of once i can convince myself it wouldn't make donations go from very little to even less smiley

the main reason the todo list is getting so long is because i've been working on a paid job for the last couple of months and will be on it for another 2 months full time.  so i only have a little bit of time here and there.

BUT after i get a little break in april or so, i'm really looking forward to getting back and doing a lot of work on FARR and a few others, as well as a couple more programs i am interested in writing.  so until DC becomes a full time job, i have to take breaks now and then to pay the bills.

it does have the advantage though of having the ideas have time to marinate a little and see the patterns in the requests.

so please everyone who is waiting for new features and fixes keep in mind that FARR development has not slowed, i just have to work on it in bursts with some delays for now.
Logged
icekin
Supporting Member
**
Posts: 263

see users location on a map View Profile WWW Read user's biography. Give some DonationCredits to this forum member
« Reply #23 on: February 25, 2008, 06:52:34 PM »

I created a folder called Definr inside plugins and then extracted the files into that folder before exiting and restarting FARR. I got the following error.



Logged
Pages: [1]   Go Up
  Reply  |  New Topic  |  Print  
 
Jump to:  
   Forum Home   Thread Marks Chat! Downloads Search Login Register  

DonationCoder.com | About Us
DonationCoder.com Forum | Powered by SMF
[ Page time: 0.07s | Server load: 0.21 ]