I have been trying to setup a native development environment on Windows for Slashcode. I have made a lot of progress with Eclipse and Eclipse's EPIC plug-in, however when trying to test any of the Slash modules, references to other Slash modules fail to be located. Is this a hopeless effort? :/
It would appear to be a simple issue with Perl's @INC array, however after a full day of wrestling with it I am completely out of ideas...
I have discovered that by creating an environment variable called PERL5LIB, we can add items to the top of @INC without touching any code in the Slash project. Great.
On Windows (Using the default cmd.exe) you set the %PERL5LIB% variable by right-clicking 'My Computer', selecting 'Properties' and choosing the 'Advanced System Settings' on the left. Once you open a new cmd.exe, the changes will be reflected. If you're using a Bash shell on Windows (msysgit, for example) locate your profile which is likely Users\username\AppData\Local\Programs\Git\etc\profile
You can use the -V argument to display perl's extended info, including the @INC contents at the bottom:
$ perl -V
@INC:
/usr/lib/perl5/5.8.8/msys
/usr/lib/perl5/5.8.8
/usr/lib/perl5/site_perl/5.8.8/msys
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl
.
After adding /usr/share/slashcode:/usr/share/slashcode/Slash:/usr/share/slashcode/Slash/Constants to the PERL5LIB environment variable we get:
@INC:
/usr/share/slashcode
/usr/share/slashcode/Slash
/usr/share/slashcode/Slash/Constants
/usr/lib/perl5/5.8.8/msys
/usr/lib/perl5/5.8.8
/usr/lib/perl5/site_perl/5.8.8/msys
/usr/lib/perl5/site_perl/5.8.8
/usr/lib/perl5/site_perl
.
That's in a Git Bash shell on Windows, which is why it's formatted that way. I long gave up on cmd.exe for this because of how dependent slashcode is on a linux.
Even with the above absurd @INC, I get this from all Slash modules in one form or another:
michealpwalls@K75DE-WINDOWS ~
$ cd /usr/share/slashcode/Slash
michealpwalls@K75DE-WINDOWS /usr/share/slashcode/Slash (meh)
$ perl -e'use slash;'
Can't locate Slash/Constants.pm in @INC (@INC contains: /usr/share/slashcode /usr/share/slashcode/Slash /usr/share/slashcode/Slash/Constants /usr/lib/perl5/5.8.8/msys /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/msys /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl .) at /usr/share/slashcode/Slash/slash.pm line 32.
BEGIN failed--compilation aborted at /usr/share/slashcode/Slash/slash.pm line 32.
Compilation failed in require at -e line 1.
BEGIN failed--compilation aborted at -e line 1.
Any thoughts? :/
I discover that Slash's Template system is based off of Template-Toolkit v2.07. Therefor, a lot of useful information can be gained by reading that documentation.
I also discovered some old yet interesting discussions buried in the TT mailing list's archives. It wasn't easy to find the discussions, so I will post the links here.
Disclaimer: I'm not an expert, in fact I'm brand new to the Slash code-base. This information could be wrong or missing important parts. If you happen to find any mistakes or have any further insight to add, please comment.
Note about Terminology: I am not a PERL programmer. I read an O'Reilly book on the language and interpreter around 10 years ago, so you will have to excuse my Terminology, which will probably resemble Java more than PERL (For example, I don't think there technically is a "class" in Perl 5, however I still use this term).
Slash::Display
The Slash::Display class --essentially-- represents a customized instance of the Template module (Template-Toolkit). This custom instance encapsulates the full Slash Template system. Similar in focus to the original Template-Toolkit, from what I can understand the main focus of Slash's Template system is the ability to store template data (The "Providers") in Slash's MySQL database.
In Display.pm, the slashDisplay method calls get_template, which instantiates the Template object defined in the Templates module. The Slash::Display::Provider, Slash::Display::Plugins and Slash::Display::Directive objects are sent as arguments to the base Template class's constructor method (new).
The instance of Slash::Display::Provider (Along with any Slash::Display::Plugin objects it may have) is "compiled" (Unless already "compiled"/cached) and then run. This is all done using either the process method (Display.pm, line 218) or with the input method (Display.pm, line 215). Both of these methods are inherited from the base Template class (Display.pm, line 47).
Slash::Display::Provider
The Slash::Display::Provider class defines an object to represent (model) the data of a template that's stored in the Slash database.
Slash::Display::Provider is based on TT's Template::Provider class. Slash::Display::Provider inherits ("Subclasses") Template::Provider and then, --among other things-- overrides the fetch, load and refresh methods to add the ability of storing and loading templates from a Database (As Slashcode does.)
Note:On the same line that creates an instance of the base Template object, the Slash::Display::Provider object is instantiated (Display.pm, line 392) and passed in to the base Template object as an argument.
Slash::Display::Plugin
The Slash::Display::Plugin class defines an object to model a Template Plugin stored in a Database. Template Plugins --I think-- extend the functionality of Slash to support a particular feature or features that the template adds. Is this right? It is different from the primary Slash Plugin system, which I have yet to explore..
Slash::Display::Plugin is based on TT's Template::Plugins class. Slash::Display::Plugin inherits (Subclasses) and extends Template::Plugins and then, --among other things-- overrides the new ("Constructor", which instantiates an object) method and adds the display method. The display method displays output from the Plugin followed by a callback to the slashDisplay method, which displays output from the template.
Slash::Display::Directive
The Slash::Display::Directive class inherits from the base Template::Directive class. The purpose of this class seems to be to act as a container to encapsulate data ("Directives") used to control and configure the Template Parser.
The Slash::Display::Directive object is defined by an inner-class of the Slash::Display::Provider class (Provider.pm, line 201).