Gossamer Forum
Home : Products : Gossamer Links : Discussions :

Setup for plugin development

Quote Reply
Setup for plugin development
What is the best way to setup a development environment for the purpose of testing plugins with default (luna) templates?

For example:

I want to keep "luna" templates as a virgin setup and have my own templates set called "terra".
In this case, do I just duplicate the "luna" folder and rename it to "terra"?
Also would need to change references in css to point to "terra" template folder rather than luna.

Or better yet might be to put a complete set of luna templates into the default/local template set, thus overriding ALL of the 2.x templates with customized 3.x luna set.
Are there exactly the same files in a 2.x set and a 3.x set? This might be necessary for this method to work.

Please advise on the best way to set this up. I want to be able to just "switch" from virgin luna to my default set, back and forth during testing. I have no use at all for the 2.x templates. Can "luna" be made the "default"?

It makes a difference on installer too, like where to put the language.txt file?
# my $selected_dir = "$CFG->{admin_root_path}/templates/$CFG->{default_template_set}";
my $selected_dir = "$CFG->{admin_root_path}/templates/luna";


Thank you,
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Setup for plugin development In reply to
Actually, another question comes to mind...

When installing the plugin template files, do I put templates in:
luna or
luna/local

I would think to put custom plugin templates in "default" folder so that they can be overridden by user in "local".
But, will "custom" template files be overwritten by updates if they are in the default folder? Even if they don't exist from GT?

In addition, if I setup a dual template system for dev purposes, would I have to install the plugin twice?
Once with virgin "luna" as default, and once with "terra" as default? That would let the installer install templates and language.txt files into luna/local folder and then after switching sets, install to "terra/local". But this won't work because the .cgi and.pm files wouldn't need to be installed twice, just the language.txt and templates.

OK, so I am confused on how to install a plugin, and have the custom files available for more than one template set. Please advise.


Thank you,
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Setup for plugin development In reply to
In Reply To:
Or better yet might be to put a complete set of luna templates into the default/local template set, thus overriding ALL of the 2.x templates with customized 3.x luna set.
Why would you do this?

In Reply To:
Are there exactly the same files in a 2.x set and a 3.x set? This might be necessary for this method to work.
No, some 2.x templates have been removed and some added in 3.x

In Reply To:
Please advise on the best way to set this up. I want to be able to just "switch" from virgin luna to my default set, back and forth during testing. I have no use at all for the 2.x templates. Can "luna" be made the "default"?
I still don't see how the 'default' template set has anything to do with anything. If they want to continue using the 'default' template set, then that's their choice.

Back to the original question. If all you're doing is adding your own templates and modifying a few of the original templates, then I'd recommend creating your terra template set, which inherits from the luna template set. Then CSS wise, all you need to do is inherit from the luna template set as well (@import url(../luna/luna.css)). You won't need to copy any images, css or templates.

Adrian
Quote Reply
Re: [rgbworld] Setup for plugin development In reply to
First, the "default" template set is just a name, like any other, if you are referring to the directory of templates.

The *real* default set, is what is actually set as the default set in the Admin->config.

To prevent confusion, you could delete the default template directory, or rename it to "21x" and if you want to make it the default, select it in the admin. That would help get rid of confusion.

As to what is the best development method, *technically*, you should install the "default" (original" templates from your plugin into the /luna/ (or whatever) directory. When your user edits them, the copy is then put into the /luna/local/ directory.

When you upgrade, put all the new templates in the /luna/ directory, leaving the /local/ templates alone.

The inheritance is done via the .tplinfo file, which should contain:

Code:

{
inheritance => '../luna'
}


Missing templates are inherited from that directory.



PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Setup for plugin development In reply to
Ok well I have a completely restored luna template set.

I have created a new template set "terra" that inherits from luna:
{
inheritance => '../luna'
}

Everything works fine except some of the images.
The "star" and "powered by" logo do not display (maybe others).
I am getting the text alternative for these "missing" images.

Is there a way to inherit the images?

I know I can put copies of these images in terra/images,
but it seems as though I should be able to inherit them.

My terra.css is inheriting from:
@import url(../luna/luna.css);

Thank you
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Setup for plugin development In reply to
Hrmph, not really possible at this time. I need to modify Links::Utils::image_url to support inheritance as well.

Adrian
Quote Reply
Re: [brewt] Setup for plugin development In reply to
Here's a patch to make image_url support inheritance:
Code:
--- Utils.pm 28 Mar 2005 23:41:45 -0000 1.37
+++ Utils.pm 13 Apr 2005 00:20:23 -0000
@@ -515,7 +516,8 @@
# -------------------------------------------------------------------
# Takes an filename and using the current template set and theme, returns
# the url of the image. It first checks if the file exists in the theme's
-# image directory and then checks the template's image directory.
+# image directory, checks the template's image directory, and then tries
+# to check the template inheritance tree for more image directories.
#
my $image = shift;
my ($template, $theme) = Links::template_set();
@@ -523,6 +525,22 @@
if (-e "$CFG->{build_static_path}/$template/images/$theme/$image") {
return "$CFG->{build_static_url}/$template/images/$theme/$image";
}
+
+# Grab the inheritance tree of the template set and grab the basename of
+# each template set path (making an assumption that they won't do anything
+# crazy with their inheritance).
+ require GT::File::Tools;
+ require GT::Template::Inheritance;
+ my @paths = GT::Template::Inheritance->tree(path => "$CFG->{admin_root_path}/templates/$template", local => 0);
+ for (@paths) {
+ my $tpl = GT::File::Tools::basename($_);
+ next if $tpl eq 'browser';
+ if (-e "$CFG->{build_static_path}/$tpl/images/$image") {
+ return "$CFG->{build_static_url}/$tpl/images/$image";
+ }
+ }
+
+# The image doesn't exist here, but return it anyway
return "$CFG->{build_static_url}/$template/images/$image";
}

This will be included in the next release.

Adrian
Quote Reply
Re: [rgbworld] Setup for plugin development In reply to
See, all Adrian needs is a little nudge in the right direction.... and viola!


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Setup for plugin development In reply to
Image inheritance works perfectly of course. Thanks Adrian.

I have my GLinks 3.0 site mostly done if anyone cares to check it out. Probably a few more days of tweeking, but I think everything works. Including my comment plugin which I will package up in a few days for the community.

www.supportmusicians.com

Cheers,
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Setup for plugin development In reply to
Not sure whether you're still tweaking - but the Categories menu is currently in the middle of the page (over the top of Home, Add a Link) and only partially visible when viewing in IE.
Quote Reply
Re: [afinlr] Setup for plugin development In reply to
Thanks, thats my next step (verifying different browser compatability).
So far... Firefox and safari on Mac do a nice job. I will have to check PC browsers.

It is messed up on IE Mac too, but differently than you describe. I hate IE.

Thank you!
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Setup for plugin development In reply to
Looks fine in Firefox - I added my own link!!

Cheers,
Piers
Quote Reply
Re: [rgbworld] Setup for plugin development In reply to
Nice site.

Brings back memories of when I was running a celebrity image database, and one of the sets of promo shots was an up and coming girl band called "The Dixie Chicks" :) A fan uploaded them, and said they were going to be big. That was back in 1992/93 I think.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [pugdog] Setup for plugin development In reply to
I still need clarification on where a plugin should install it's templates.
More specifically which template set should be set as build_default_tpl
in Setup>Build Options when installing a plugin.

The way I see it, a plugin should install it's templates to: /admin/templates/luna
regardless of the build_default_tpl location. Here's why...

I have a custom template set (terra) that inherits from luna.
build_default_tpl is set in Admin to use my terra templates.
I would suspect that most users installs are setup this way.
Or else they are simply using luna and putting edits in /luna/local.

Example 1: build_default_tpl = terra (the way I am setup)
If I install while the setting is terra, my templates will go to /admin/templates/terra
If (as a plugin user) I wanted to override them, I put a copy into /admin/templates/terra/local
The problem (i think) is that the templates are NOT available if I was to
switch the build_default_tpl to luna after installing the plugin.

Example 2: build_default_tpl = luna
If I install while the setting is luna, my templates will go to /admin/templates/luna
If (as a plugin user) I wanted to override them, I put a copy into /admin/templates/luna/local
The nice thing (i think) about installing to luna is that my custom template set (terra)
inherits from luna, so even though "my" build_default_tpl = terra, the templates
would be available through inheritance. I would only need to make a copy of the file
from /templates/luna, and put it into /templates/terra and modify to my liking.

I think Ex 2 puts my plugin template at the same "level" as the entire GT install scheme.
That is, if users want to override, they make a copy in local directory.
If someone (like me) uses a custom template set that inherits from luna,
the plugin's custom templates are available to the custom template set
as well as the luna set. This allows me to switch back and forth between
template sets on the fly. Plugin templates are avail to both template sets.

Please let me know if Ex. 2 sounds like the correct/better way of doing things.

This brings up 1 very important question about template inheritance...
If there is a copy of a default template or a plugin's template in the "local" directory of luna,
will my template set inherit the "default" copy, or the "local" copy of the template?

Thanks for any help clarifying this issue for me. I am installing plugins into
a development install, and I will switch my build_default_tpl setting from terra
to luna, install the plugin, and switch the setting back to terra after install.

I think for future plugins, I will install to luna regardless of build_default_tpl if this works.

Thank you,
Chris
RGB World, Inc. - Software & Web Development.
rgbworld.com
Quote Reply
Re: [rgbworld] Setup for plugin development In reply to
You'll need to ask Brewt about inherting template sets, what I tried, on a project, didn't work as advertised, IMHO.

As for where to install templates, the *ideal* would be to ask the user to where they want them installed: eg: default (and the name) and/or Luna

When installing, if you want the user to be able to 'default' back to a previous copy, install one copy in the template name directory. You don't need to install into the local directory, unless you want the user to use some pre-modified copy. Since "luna" is the base set of templates, installing a copy there, even if the user is using a different default, would make sense, especially if you gave the user a chance to opt-out of that action.


In upgrading, the program will _overwrite_ templates, but should not delete any that are in your directory.

The way the overwrite works, it sort of has to do that. But it doesn't need to remove any.

Just installing to the "local" directory, doesn't give the user a copy to revert back to if something goes wrong.

It's extra work in the installer, but it's worth it, in the long run, especially if you will be updating the program regularly.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.