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 » Sat Feb 26, 2005 9:24 pm

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?

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Is there a google search plugin?

Post by garvinhicking » Sun Feb 27, 2005 12:57 am

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 » Sun Feb 27, 2005 1:30 am

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 ..

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Is there a google search plugin?

Post by garvinhicking » Sun Feb 27, 2005 1:08 pm

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 » Sun Feb 27, 2005 1:52 pm

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

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking » Sun Feb 27, 2005 2:47 pm

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 » Sun Feb 27, 2005 3:02 pm

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..

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking » Sun Feb 27, 2005 3:23 pm

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 » Sun Feb 27, 2005 3:48 pm

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?

User avatar
garvinhicking
Core Developer
Posts: 30020
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking » Sun Feb 27, 2005 3:53 pm

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 » Sun Feb 27, 2005 3:55 pm

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 » Sun Feb 27, 2005 4:00 pm

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 » Sun Feb 27, 2005 4:02 pm

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