Is there a google search plugin?

Creating and modifying plugins.
Post Reply
leonardb
Regular
Posts: 53
Joined: Fri Jan 14, 2005 10:27 pm

Is there a google search plugin?

Post 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?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Is there a google search plugin?

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
leonardb
Regular
Posts: 53
Joined: Fri Jan 14, 2005 10:27 pm

Re: Is there a google search plugin?

Post 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 ..
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Is there a google search plugin?

Post 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! :-)
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
leonardb
Regular
Posts: 53
Joined: Fri Jan 14, 2005 10:27 pm

Post 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
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
leonardb
Regular
Posts: 53
Joined: Fri Jan 14, 2005 10:27 pm

Post 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..
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
leonardb
Regular
Posts: 53
Joined: Fri Jan 14, 2005 10:27 pm

Post 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?
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post 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?
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
leonardb
Regular
Posts: 53
Joined: Fri Jan 14, 2005 10:27 pm

Post 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?
leonardb
Regular
Posts: 53
Joined: Fri Jan 14, 2005 10:27 pm

Post 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
leonardb
Regular
Posts: 53
Joined: Fri Jan 14, 2005 10:27 pm

Post 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>", 
Post Reply