Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Disc: Plug In System

Quote Reply
Disc: Plug In System
The plug in system is done, and is working well. Here's how it works:

1. At the simplest level, templates can now run functions. So you can do:

<%Plugin::function%>

and it will return the output of that function in the template. Also, if the function returns a hash ref, it will make all those variables available in the template. So you could have a:

package Plugin::MyStuff;

sub globals {
return { foo => bar, alpha => beta };
}

file and then when you call:

<%Plugin::MyStuff::globals%>

you can then use <%foo%> and <%alpha%> anywhere on the page.

2. Plugins can register "hooks". There are numerous hooks in Links SQL. Each template is a hook, the search has a hook, etc. A plugin can register a piece of code to get run before or after a hook. So for instance, the keyword logger is a hook that gets run after a search.

The cool part is you can stack hooks. So for instance, you can have your keyword logger, and an altavista search both registered to run after the regular search.

Plugins can tell the program to either continue on with the rest of the plugins, or stop now. So if you have a plugin that replaces the default search, it would tell Links SQL not to continue (as you don't want to search twice).

The next snapshot should have a demo you can see, it will make much more sense. =)

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Disc: Plug In System In reply to
When you install the SearchCache, it caches searches so that the results can be retrieved more quickly in the future, however when more links are submitted to the directory will the cache not keep returning the old results or will it include the new ones too?

Paul Wilson.
(Dont blame me if I'm wrong!)
Quote Reply
Re: Disc: Plug In System In reply to
No, it will only have the old ones. This is the tradeoff, and is usually ok for large directories. However, the problem with the SearchCache in the example is the cache never empties. It should be modified so that cached results are cleared out after a ceartain time.

It's more an example then a quality cache.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Disc: Plug In System In reply to
Could you give me some help as to how I would go about clearing the cache?

Could you just run a perl script by cronjob that opened the cache file and erased it?


Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Disc: Plug In System In reply to
Yes, you could do it as a cronjob:

use Links qw/$DB/;
my $cache = $DB->table('SearchCache');
$cache->delete_all;

Would remove all the entries in the cache. Right now it doesn't store a date so your only options are to remove all.

Cheers,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Disc: Plug In System In reply to
So that code would go in a file with the ending .sh ?

Would it go in the admin directory?

Ive not really used cronjobs before so Im not sure how to do it.

....Ill have to do some research!

Oh....by the way...could you let me know either way if you are interested in the linkssql.com domain?

You can have it for under $100.


Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Disc: Plug In System In reply to
In Reply To:
So that code would go in a file with the ending .sh ?
Code:

# Delete Cache from SearchCache Table
use lib '/absolute/path/to/your/admindirectory/';
use Links qw/$DB/;
my $cache = $DB->table('SearchCache');
$cache->delete_all;


Save as deletecache.sh.

Then read the CRON FAQ located in the Resources section to find out how to set-up crontab in your server.


Regards,

Eliot Lee
Quote Reply
Re: Disc: Plug In System In reply to
In Reply To:
Save as deletecache.sh.
Actually, this is perl, so you should put
Code:
#!/usr/bin/perl
as your first line, and call it clear-cache.pl

The shell might have a bit of trouble running a perl script Perl!

Jason Rhinelander
Gossamer Threads
Quote Reply
Re: Disc: Plug In System In reply to
Thanks Eliot.

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Disc: Plug In System In reply to
Oh thanks for that...so instead of crontab could I just put a link in the admin area to clear-cache.pl and execute it like that?

I dont have telnet access you see.

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Disc: Plug In System In reply to
OK...I added the following to a file called clear-cache.pl...

#!/usr/bin/perl


lib '/home/audio/audio-grabber-www/cgi-bin/admin/';
use Links qw/$DB/;
my $cache = $DB->table('SearchCache');
$cache->delete_all;



....and it gave me an internal server error.

Am I doing something wrong?....Should it not be...


#!/usr/bin/perl

use strict;
use lib '/home/audio/audio-grabber-www/cgi-bin/admin/';
use Links qw/$DB/;
my $cache = $DB->table('SearchCache');
$cache->delete_all;


Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Disc: Plug In System In reply to
If you want it as a CGI script, you would do:

Code:
#!/usr/bin/perl

use lib '/home/audio/audio-grabber-www/cgi-bin/admin/';
use Links qw/$IN $DB/;
print $IN->header;
print Links::header ("Deleting SearchCache");
my $cache = $DB->table('SearchCache');
$cache->delete_all;
print "All Done!";
Hope that helps,

Alex

--
Gossamer Threads Inc.
Quote Reply
Re: Disc: Plug In System In reply to
Spot on as usual..

Its cool how you have those headers set up so you can use a global design but change the words that appear.

Like that example says "Deleting Cache".

Nice one!

...any advance on the email mystery?...I keep having to validate links and sending blank emails to people!

Paul Wilson. Shocked
(Dont blame me if I'm wrong!)
Quote Reply
Re: Disc: Plug In System In reply to
Wow, I just installed the SearchLogger plugin and it was WAY too easy. I thought I would have at least a "little" problem but it was smooth as silk. =)

My search engine is now working almost exactly like I want it to, now I just need a plugin that will work like a metasearch to produce alternate search results from multiple affiliate search engines. Any ideas on ETA? ;)



Rob Bartlett
AAA Internet Publishing, Inc.
http://www.AAAInternet.com