The saga of the Add-on Manager

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,600
The saga of the Add-on Manager
« on September 13th, 2011, 03:31 PM »
It's been a while since we've posted anything on the blog, so I figured I'd do just that, heh.

Of recent times I've been playing with the replacement for the package manager, which while still rather incomplete, is taking form in the code - it even enables and disables simple add-ons right now (meaning that simple add-ons can actually be used in the spirit in which they are intended)

For those who haven't seen the pictures already posted on the subject, I present a screenshot that I took at the weekend.


It's close enough to how things are currently, with the difference that it actually works for both enabling and disabling simple add-ons (ones that don't create or modify the existing DB tables, that is)

I know it was left very much at a disjoint at the end of the last time I wrote about the replacement for the package manager, so I just want to cover off everything that's happened, because there's an awful lot of it, and it's why there haven't been any commits from me lately despite there being a lot of coding going on.

A lot of the stuff I talked about before as being almost whimsically answered is now pretty much finalised, so without further ado... I should point out that there were a surprising number of "Oh, that hadn't occurred to me" moments in the design, but I'm pleased to say that I think they've all been ironed out now.[1]

If you're not interested in technobabble, here's the point where you probably want to stop, with the understanding that it's being designed in a way that promotes add-ons that don't need file edits and should thus survive updates and so on a bit better.



There's an Addons/ folder, right up there next to Packages/, and each add-on gets its own folder in there. Doesn't matter how big or small it is, that's what happens. Everything that happens, happens in that folder. Sources, templates, language files, CSS, JS, images, etc. It's all in there.

I will write a proper tutorial on this sometime but here's the rundown of what the system does.

Here's where it gets really funky. You know as well as I do that users are unpredictable, and often prone to doing odd things, so I took care of that. It doesn't matter what folder an add-on is created with, it could be myaddon/ or my_addon_1.1/, it doesn't actually matter, because you never directly refer to it.

When you create the add-on, you give it an ID, that has the author and add-on name, e.g. Arantor:WedgeDesk, and it's *this* that's used. Everything that you do with an add-on will make use of this ID.

Let's say you have a big add-on that has multiple source files and multiple template files, arranged in src/ and tpl/ respectively, and just live in your add-on's folder. I'll use WedgeDesk as an example.

I want to load the main source: (The .php is added automatically.)
Code: [Select]
loadAddonSource('Arantor:WedgeDesk', 'src/WedgeDesk');

It doesn't matter what folder it's in, you never have to worry about it. Similar deal with loading templates and language files:
Code: [Select]
loadAddonTemplate('Arantor:WedgeDesk', 'tpl/WedgeDesk'); // loads tpl/WedgeDesk.template.php
loadAddonLanguage('Arantor:WedgeDesk', 'lang/WedgeDesk'); // loads the right file from lang/WedgeDesk.*.php

No more dumping files throughout the different folders - everything's in one place.

There is a caveat at this point: it does mean that an add-on can't magically have different templates for different themes and just drop them into the relevant folders. That's not to say that it can't be done, it just means having the multiple templates stored inside the add-on and making sure that the theme is checked before calling loadAddonTemplate.

There is more, since there's functions for loading CSS files from your add-on, plus JavaScript files, and in both cases they must be called so that the proper caching and substitution comes in.

Lastly, you may be wondering how you insert images, if you're not using $settings['images_url'] or $settings['default_images_url'], well, there's a method for that too.

Specifically, if you ever need to refer to an add-on by URL, the base URL (i.e. www.example.com/Addons/youraddon) is available in $context['addons_url']['addonid'], so I can always call WedgeDesk images through $context['addons_url']['Arantor:WedgeDesk'].

There's more, too. If an add-on uses only hooked files (the recommended method), when an error occurs, it's possible to attribute that error to that add-on in the error log, so you'll know if an add-on is acting up.

There's plenty more to do, of course, like provide facilities in the language editor for editing the language files in add-ons, but for now at least, there's an awful lot of work done to facilitate strong add-on support. There's also file editing to provide, plus quite a bit of the DB support, but it is coming along nicely now.

(Oh, and one last thing. If you rename an add-on's folder to something different, or just delete it, it should automatically disable. If it uses file edits, all bets are off, of course, but that's discouraged anyway.)
 1. This is why I've spent a lot of the last week converting SimpleDesk to run on WedgeDesk, wherein it has been renamed WedgeDesk. A good deal of this stuff only came to light when actually trying to use it in a real and practical sense. I've now done that, and altered the design accordingly.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,600
Re: The saga of the Add-on Manager
« Reply #16 on September 24th, 2011, 01:51 PM »
OK, so after this morning's hacking away at it, it should now be able to handle the case where it can actually remove add-ons, but only if it can grab permission to do so.

I haven't yet given it the ability to ask for FTP details in order to be able to make things writable. Though, if it can actually use chmod on it, it will do so (and do so correctly for folders vs files, it won't make everything 777, only files 666 and folders 777, as it should because it's well behaved - assuming has the power of chmod, of course...)

File permissions are a big pain in the arse, and one reason why I'm so keen to avoid having to do file edits generally...
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


billy2

  • We-Gen
  • Trying to earn brownie points for a lads trip to the Red Sea. Minus 1 already - just for asking!!
  • Posts: 348
Re: The saga of the Add-on Manager
« Reply #17 on September 26th, 2011, 08:13 AM »
I love the plain, straight talking instructions - "Press this button and this happens"

<br /><br />cough, cough.

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,600
Re: The saga of the Add-on Manager
« Reply #18 on September 26th, 2011, 08:48 AM »
That's the beauty of it, because more and more add-ons don't do file edits, add-ons just need to be enabled rather than complex chains of scary looking instructions...
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Powerbob

  • We-Gen
  • @Arantor nice to see post on FB :)
  • Posts: 102
Re: The saga of the Add-on Manager
« Reply #19 on September 26th, 2011, 11:17 AM »
Quote from Arantor on September 26th, 2011, 08:48 AM
That's the beauty of it, because more and more add-ons don't do file edits, add-ons just need to be enabled rather than complex chains of scary looking instructions...
+1  :cool:

Nao

  • With a Box
  • If you say so.....
  • Posts: 12,894
Re: The saga of the Add-on Manager
« Reply #20 on September 26th, 2011, 01:07 PM »
So we might as well make files NON-editable... :niark:
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,600
Re: The saga of the Add-on Manager
« Reply #21 on September 26th, 2011, 01:49 PM »
Don't tempt me, after all the valid debate Unknown gave on it...
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,894
Re: The saga of the Add-on Manager
« Reply #22 on September 26th, 2011, 02:51 PM »
He's no longer here. French proverb. Those missing are always wrong :P
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,600
Re: The saga of the Add-on Manager
« Reply #23 on September 26th, 2011, 03:51 PM »
Heh, that said, he did make a valid point about it...
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Dismal Shadow

  • Madman in a Box
  • Talking Head
  • Me: Who is Arantor? Cleverbot: It stands for time and relative dimensions in space.
  • Posts: 1,184
Re: The saga of the Add-on Manager
« Reply #24 on September 26th, 2011, 04:21 PM »
He left? I can see that he's not active for over 2 months...
“I will stand on my ground as an atheist until your god shows up...If my irreligious bothers you much, and if you think everything I do is heresy to your god I don't care. Heresy is for those who believe, I don't. So, it isn't heresy at all!


   Jack in, Wedge,
   EXECUTE!

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,600
Re: The saga of the Add-on Manager
« Reply #25 on September 26th, 2011, 05:53 PM »
I don't know if he left or is simply busy, but whatever, he made a valid argument that I saw the wisdom of, and wanted to account for. I still think the majority of the time, it's not going to be a problem because I think the warning I have yet to place on it will put people off using it :niark:

Dragooon's been looking over how to make queries extensible (which I'm loving, by the way) and my next task is how to make permissions work so that you can handle files and delete them without the usual faff associated with it.

I am hoping, though not sure I'll be able to pull it off yet, that you'll be able to use not only FTP but also SSH to log in and perform changes (that you just give it your details and it'll do the rest, and reinstate the original permissions so that you don't get left open accidentally, even with just uploading add-ons)


Honestly, though, the whole mentality behind what I'm pushing here is keeping it straightforward enough to be usable and that users can feel comfortable about doing it - most users will not care what files are being edited unless they have to do it themselves.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


rh

  • Posts: 1
Re: The saga of the Add-on Manager
« Reply #26 on March 2nd, 03:59 PM »
please help me, I want to publish a question for the admin, but I have trouble finding a place to publish.

thanks

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,600
Re: The saga of the Add-on Manager
« Reply #27 on March 2nd, 04:04 PM »
What question are you trying to ask? Ask it here, then I'll break this into a new thread for you (as here is almost certainly not the right place!)
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Farjo

  • "genuinely interested"
  • We-Gen
  • Posts: 245
Re: The saga of the Add-on Manager
« Reply #28 on March 2nd, 05:47 PM »
I think it's spam :)
We've moved on - will you come with us?

Arantor

  • With a Box
  • As long as the planets are turning, as long as the stars are burning, as long as your dreams are coming true...
  • Posts: 13,600
Re: The saga of the Add-on Manager
« Reply #29 on March 2nd, 05:50 PM »
Maybe. Maybe not. There's no signature, there's an avatar and some other things - these are not things usually added by a would-be spammer.
  When we unite against a common enemy that attacks our ethos, it nurtures group solidarity. Trolls are sensational, yes, but we keep everyone honest.


Nao

  • With a Box
  • If you say so.....
  • Posts: 12,894
Re: The saga of the Add-on Manager
« Reply #30 on March 2nd, 06:34 PM »
Spam. Pretty sure about it... old topic + unrelated post + generic content + commercial website link but no forum in it...
...« I say wedge wedge (in the butt) »
 « Everyone knows rock attained perfection in 1974. It's a scientific fact. » (Homer Simpson)