Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2005-03-04 15:18:48

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Standard location for plugin support files

As plugins get more complex it would be nice to have a standard convention for where external support files should live.

For example let’s say I have a plugin that requires certain images for it to work properly, currently we have to instruct users where to place the files (Greenrift’s plugins for instance require his library be in /textpattern/lib/). It seems that as plugins become more complex there should be a standard approach to packaging the suport files for a plugin.

I’d like to propose that we could start using a standard Plugins location for support files. The standard could be that each plugin that had support files would be in a folder with the plugin name in the plugins folder. So any support items for zem_nav for example would be in /textpattern/plugins/zem_nav/. Perhaps a standard variable could be established to point to the plugin path so it could be used to call external javascript files, images or even PHP libraries. Alot of extension systems for other tools use something similar to this.

Anyone have any thoughts?


Shoving is the answer – pusher robot

Offline

#2 2005-03-07 02:17:23

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Standard location for plugin support files

My feeling is that if it requires an external file, it isn’t really a plugin.

For things like javascript and image files, it’s possible (and preferable) to embed them within the plugin itself.


Alex

Offline

#3 2005-03-07 21:32:21

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Standard location for plugin support files

Well that seems like a matter of how one chooses to define a plugins. It seems to me that anything that extends the core system through a provided mechanism or API that does not involve hacking the core is a plugin or a module or whatever. Various other systems use plugins or modules that are nothing but external files that get called into the core.

That being said TXP does put more things in the DB then other systems do (like templates) so keeping plugins free of external files is consistent with how the system works. How would one go about embedding javascript and images in the plugin itself and thena ccessing that information? A quick explanation of how to approach this or a pointer to where one could find information on this would be helpful.


Shoving is the answer – pusher robot

Offline

#4 2005-03-08 04:14:08

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Standard location for plugin support files

Zem,

Did some poking on my own. Are you suggesting including the files in the plugin code encoded in base64? Would the fact that the whole plugin gets base64’edcause any problems with this? Or am I nowhere close on this?


Shoving is the answer – pusher robot

Offline

#5 2005-03-09 01:18:13

zem
Developer Emeritus
From: Melbourne, Australia
Registered: 2004-04-08
Posts: 2,579

Re: Standard location for plugin support files

> Did some poking on my own. Are you suggesting including the files in the plugin code encoded in base64?

More or less, yeah. Roughly:

<pre><code>
if (gps(‘file’) == ‘myfile.js’) {
echo <<<EOF;
[javascript]
EOF;
}
</code></pre>

..then use ‘http://example.com/index.php?file=myfile.js’ to include the file. You can use base64 to encode images and other binary files.


Alex

Offline

#6 2005-03-10 19:53:20

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Standard location for plugin support files

Ahh ok I see it. I was trying to figure out how to call the javascript like css.php does for the style sheets. Your example cleared it up perfectly.

And I do think this is a really clean way of implementing the plugin system. Thanks for the help. I’m glad I decided to bring this topic up.


Shoving is the answer – pusher robot

Offline

#7 2005-05-19 22:10:00

domfucssion
Plugin Author
Registered: 2004-10-23
Posts: 39

Re: Standard location for plugin support files

I am trying to include a small image in a plugin that would be added to an article in a link.

I can encode it ok but how do I call it from a page? ie in an amage tag.

Offline

#8 2005-05-19 23:58:29

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Standard location for plugin support files

Call index.php with a unique url parameter then check for it in you plugin.

for example:

Call index.php?img=myimage

<code>
if (gps(‘img’) == ‘myimage’) { header(‘Content-type: image content type which I can’t remember); echo function_that_displays_image(); exit(0); }
</code>


Shoving is the answer – pusher robot

Offline

#9 2005-05-20 01:45:42

domfucssion
Plugin Author
Registered: 2004-10-23
Posts: 39

Re: Standard location for plugin support files

thanks hakjoon,

I got there in the end, it was difficult to type what I was really trying to do, but this is how I did it in the end:
<code>
$encoded=‘base64stringhere’;
$dimg= ‘<img src=“data:image/gif;base64,’.$encoded.’ “>’;
</code>

and then just returned that with the rest of the plugin’s output…

Offline

#10 2005-05-20 18:37:26

hakjoon
Member
From: Arlington, VA
Registered: 2004-07-29
Posts: 1,634
Website

Re: Standard location for plugin support files

That’s cool. I didn’t know you could do it that way.


Shoving is the answer – pusher robot

Offline

#11 2005-05-20 19:16:39

Sencer
Archived Developer
From: cgn, de
Registered: 2004-03-23
Posts: 1,803
Website

Re: Standard location for plugin support files

Yeah, data: URIs are pretty cool. Unfortunately MSIE doesn’t understand them, which for some people will make them only suitable for back-end stuff. Here is an online converter: http://software.hixie.ch/utilities/cgi/data/data

Last edited by Sencer (2005-05-20 19:16:55)

Offline

#12 2005-10-10 17:46:39

Skubidu
Archived Plugin Author
Registered: 2004-10-23
Posts: 611
Website

Re: Standard location for plugin support files

Okay, I never tried something like this before. Perhaps someone could help me with this problem:
I need some CSS with background images for a plugin. How do I integrate images in the stylesheets?

Thanks for help!
Nils

Offline

Board footer

Powered by FluxBB