Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Try Vanilla Forums Cloud product

In this Discussion

Vanilla 2.6 is here! It includes security fixes and requires PHP 7.0. We have therefore ALSO released Vanilla 2.5.2 with security patches if you are still on PHP 5.6 to give you additional time to upgrade.

Introducing Gdn_PScaffold a plugin scaffold/mini framework for your convenience

x00x00 MVP
edited May 2013 in Development

I'm releasing Gdn_Scaffold shortly on an MIT licence, which is a utility/script which will help your organise, often cluttered plugins.

https://github.com/x00/Gdn_PScaffold

Requires php >= 5.2 to run

For those that already have IDE templating and automation regimes, you probably don't need this. You might want to look at the utility methods though.

What it is NOT for:

  • Plugins that only have one or two files and a few lines of code (as it will create extra files).
  • Plugns that already have a more specific organised structure

You can use on a plugin that needs some organisation, or a new project.

It is a scaffold it does not make your plugin automatically work, you need to implement along the lines suggested.

Treat it like beta software. It does backup within the plugin file, but it is not substitute for an external backup regime.

This is a tool/helper, don't trust it to be perfect.

grep is your friend.

KasperUnderDog

Comments

  • Don't forget to implement required method PluginSetup in your plugin file even if empty.

    grep is your friend.

  • x00x00 MVP
    edited May 2013

    pluggability should now work in the mini dispatcher

    So not only can you do stuff like

     protected function Name_PseudoController($Sender, &$Args){
        $this->AddCssFile($this->GetResource('design/somestyle.css', FALSE, FALSE));
        $this->AddCssFile($this->GetResource('js/somescript.js', FALSE, FALSE));
        $this->MiniDispatcher($Sender,'PseudoController','PseudoController');
     }
    
     public function PseudoController_Index($Sender){
        $Sender->Render($this->ThemeView('index'));
     }
    
     public function PseudoController_Browse($Sender){
        $Sender->Render($this->ThemeView('browse'));
     }
    

    but in another plugin you can do

     public function PseudoController_AllNewMethod_Create($Sender){
        ....
     }
    

    if you need the updated class.utility.php class grab the latest copy of Gdn_PScaffold, make, remove the old and run gdn_ps

    grep is your friend.

  • x00x00 MVP
    edited May 2013

    I have added a new utility method DynamicRoute

      /**
       *  @@ GDN Plugin Scaffold @@
       *  
       *  Add a route on the fly
       *  
       *  Typically set in Base_BeforeLoadRoutes_Handler
       *  
       *  @param string &$Routes loaded
       *  @param string $Route RegExp of route
       *  @param string $Destination to rout to
       *  @param string $Type of redirect (optional), default 'Internal' options Internal,Temporary,Permanent,NotAuthorized,NotFound 
       *  @param bool $OneWay if an Internal request prevents direct access to destination  (optional), default FALSE
       *  
       *  @return void
       */
    
      protected function DynamicRoute(&$Routes, $Route, $Destination, $Type = 'Internal', $Oneway = FALSE)
    

    You can add a new route like so (note due to $OneWay = TRUE direct access to destination is blocked).

      public function VanillaController_SomePage_Create($Sender){
         exit('hello world!');
       }
    
       public function Base_BeforeLoadRoutes_Handler($Sender, &$Args){
         $this->DynamicRoute($Args['Routes'],C('Plugins.TestPlugin.SomePageURI', 'somepage'),'vanilla/somepage','Internal', TRUE);
       }
    

    I've made gdn_ps's --dir argument friendlier, it should be able to use absolute, relative urls and does posix tilde expansion.

    grep is your friend.

  • x00x00 MVP
    edited May 2013

    I have created a --light to create stripped down plugins

    • ./class.yourplugin.php
    • ./class.ui.php
    • [optional additional abstract classes]
    • ./class.utility.php
    • ./icon.png
    • ./readme.markdown

    grep is your friend.

    hgtonightlifeisfoo
  • lifeisfoolifeisfoo Zombie plugins finder ✭✭✭

    I'll try it for my next plugin.

    Need a custom plugin? Contact me via vanilla private messages | Explore my GitHub repository | See my latest vanilla plugins

  • cool what OS do you develop on?

    grep is your friend.

  • lifeisfoolifeisfoo Zombie plugins finder ✭✭✭

    On Ubuntu 12.10 (to be updated to 13.04 in some weeks, maybe...).

    Need a custom plugin? Contact me via vanilla private messages | Explore my GitHub repository | See my latest vanilla plugins

  • ok that should work

    grep is your friend.

  • x00x00 MVP
    edited May 2013

    a few gremlins with the path and mini dispatcher to be expected....

    grep is your friend.

  • x00x00 MVP
    edited May 2013

    If there are going to be a lot of utility functions, it would make sense to put them in a special plugin that loads that class to keep things DRY.

    Then they could be overridden in YourPluginUtility if necessary.

    The problem is that, this is released MIT, which fine as it is standalone generation function, but it uses templates.

    The code generated, and the templates, I don't want it to be too restrictive for those that use it. I'm going to make a new post concerning the continue lack of clarity extension licensing.

    In parallel, where this plugin would be primarily a garden extension, so I don't think would an issue, however GPl complicates things more than people like to admit.

    Also is this going to be annoying, or you think it is fine, requiring such a plugin? It would mean it would automatically require it to be there. It won't have to be enabled.

    At the moment it is just a handful of convenience methods, so it probably isn't worth doing.

    grep is your friend.

  • lifeisfoolifeisfoo Zombie plugins finder ✭✭✭

    Are there any plugin that use this? (from yours plugins @x00)

    I'll trying it but with a working example everything should be easier. Thank you.

    Need a custom plugin? Contact me via vanilla private messages | Explore my GitHub repository | See my latest vanilla plugins

Sign In or Register to comment.