Page 1 of 1

Is there a google search plugin?

Posted: Sat Feb 26, 2005 9:24 pm
by leonardb
not a good way to describe it but pretty simple to explain it.

is there a plugin when i say something refering to somethg in my post that i can creat a link to search google?

EXAMPLE

this [google]plugin[/google] is what im talking about

possible? or available already?

Re: Is there a google search plugin?

Posted: Sun Feb 27, 2005 12:57 am
by garvinhicking
A plugin similar to thise is the "Content Rewrite" plugin. You could use [googlestart]bla[googleend] and then rewrite [googlestart] to the start

Code: Select all

<a href="google.com/search?word=
" html code and [googleend] to

Code: Select all

">
tags.

Of course this is a bit hacky and I would suggest to create a special plugin for this. Or enhance the "bbcode" markup for this. In either case the BBCode plugin is a good starting point. Have a go! :-)

Regards,
Garvin

Re: Is there a google search plugin?

Posted: Sun Feb 27, 2005 1:30 am
by leonardb
garvinhicking wrote:A plugin similar to thise is the "Content Rewrite" plugin. You could use [googlestart]bla[googleend] and then rewrite [googlestart] to the start

Code: Select all

<a href="google.com/search?word=
" html code and [googleend] to

Code: Select all

">
tags.

Of course this is a bit hacky and I would suggest to create a special plugin for this. Or enhance the "bbcode" markup for this. In either case the BBCode plugin is a good starting point. Have a go! :-)

Regards,
Garvin
garvin,

thanks for the reply and solution, but im not too educated with treating this plugin to do what you said ..

can i bother your for a more clearer setup of this plugin?

Thanks again ..

Re: Is there a google search plugin?

Posted: Sun Feb 27, 2005 1:08 pm
by garvinhicking
I hjave just patched and committed the BBCode plugin.

You can do so easily by opening your plugins/serendipity_event_bbcode/serendipity_event_bbcode.php file.

Search for this block:

Code: Select all

          // [url]
          '/(?<!\\\\)\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si'        => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
          '/(?<!\\\\)\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si'             => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
          '/(?<!\\\\)\[url(?::\w+)?=(.*?)?\](.*?)\[\/url(?::\w+)?\]/si'      => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\2</a>",
and add the google block so that it looks like:

Code: Select all

          // [url]
          '/(?<!\\\\)\[(google|search)\](.*?)\[\/(google|search)\]/si'       => "<a href=\"http://www.google.de/search?q=\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
          '/(?<!\\\\)\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si'        => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
          '/(?<!\\\\)\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si'             => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
          '/(?<!\\\\)\[url(?::\w+)?=(.*?)?\](.*?)\[\/url(?::\w+)?\]/si'      => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\2</a>",
Have fun! :-)

Posted: Sun Feb 27, 2005 1:52 pm
by leonardb
Garvin,

Excellent job and thank you much, but on last stupid question..

how do i get this all to work now that i edit the file and mad ethe suggested changes?

again please excuse my ignorance ..

thanks..

Lenny

Posted: Sun Feb 27, 2005 2:47 pm
by garvinhicking
Oh, my bad. I'm really sorry! :-)

You type your entries like this:

Code: Select all

Here's a link to know more about it: [google]Serendipity[/google]
Have fun! :)

Regards,
Garvin

Posted: Sun Feb 27, 2005 3:02 pm
by leonardb
Garvin,

thanks.. and here come the problems ..

i used your example.. [google]example[/google]

in the post the word where i put [google] around, now reads google with a link to search google for the word google :)

any ideas?

thanks again..

Posted: Sun Feb 27, 2005 3:23 pm
by garvinhicking
Hi learonard.

I guess this is not my lucky sundy today :)

In the code you pasted, please replace "\\1" with "\\2" and then all should be well :)

Regards,
Garvin

Posted: Sun Feb 27, 2005 3:48 pm
by leonardb
garvin,

so in all the places that "\\1" existsed i have replaced it with "\\2"

tried this again and still does the same thing ..

should i be loading any plugins?

Posted: Sun Feb 27, 2005 3:53 pm
by garvinhicking
Hm, I suppose you then replaced the wrong ones?! Here's how it's supposed to look like:

Code: Select all

'/(?<!\\\\)\[(google|search)\](.*?)\[\/(google|search)\]/si'       => "<a href=\"http://www.google.de/search?q=\\2\" target=\"_blank\" class=\"bb-url\">\\2</a>",
What's your URL so I can look at it?

Posted: Sun Feb 27, 2005 3:55 pm
by leonardb
actually what it does now is turn the word to "google" but if you click the word it will search google for the correct word .. odd to explain.

understand?

Posted: Sun Feb 27, 2005 4:00 pm
by leonardb
garvinhicking wrote:Hm, I suppose you then replaced the wrong ones?! Here's how it's supposed to look like:

Code: Select all

'/(?<!\\\\)\[(google|search)\](.*?)\[\/(google|search)\]/si'       => "<a href="http://www.google.de/search?q=\\2" target="_blank" class="bb-url">\\2</a>",
What's your URL so I can look at it?
I guess it was my error .. or i misunderstood ..

i changed all the lines to \\2 .. after reapplying the original code you gave me and then changing the line you defined above, all is well now.. thanks garvin ..

the link to look at it all is ..
http://www.leonarddbernstein.com/index. ... l#extended

see if you can spot where its at :wink:

thanks much again garvin ..

Lenny

Posted: Sun Feb 27, 2005 4:02 pm
by leonardb
BTW ..

the final code..

Code: Select all

// [url]
          '/(?<!\\\\)\[(google|search)\](.*?)\[\/(google|search)\]/si'       => "<a href=\"http://www.google.de/search?q=\\2\" target=\"_blank\" class=\"bb-url\">\\2</a>",
          '/(?<!\\\\)\[url(?::\w+)?\]www\.(.*?)\[\/url(?::\w+)?\]/si'        => "<a href=\"http://www.\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
          '/(?<!\\\\)\[url(?::\w+)?\](.*?)\[\/url(?::\w+)?\]/si'             => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\1</a>",
          '/(?<!\\\\)\[url(?::\w+)?=(.*?)?\](.*?)\[\/url(?::\w+)?\]/si'      => "<a href=\"\\1\" target=\"_blank\" class=\"bb-url\">\\2</a>",