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