So, I committed very basic plugin support for adding an admin controller. Try it, let's see if it works out. I can't guarantee any of this is going to stick though. I'm worried that this will turn Mephisto in a hacked frankenstein project, and that's just not something I'm interested in working on. I would just like to put in enough to let some of you adventurous hackers tear into it without having to bug me if stuff breaks.
This is just one of a few types of Mephisto plugins I can think of. Future possibilities include plugins that add settings, plugins that tweak admin forms, etc. We've discussed this previously on the list, but I wasn't far enough along in Mephisto to start writing code. Now that I have, feel free to tear it apart (followed closely with suggestions...).
Some items I'm already thinking of:
- add a way to specify where to add the admin tab - full migration support? - Plugins page in the settings area, storing plugin migration version, plugin settings, etc.
On 11/13/06, Rick Olson <technowee...@gmail.com> wrote:
> Some items I'm already thinking of:
> - add a way to specify where to add the admin tab > - full migration support? > - Plugins page in the settings area, storing plugin migration version, > plugin settings, etc.
Rick,
I'm currently writing "Migration Extensions" plugin. It's going to change the way people use migrations (well, overcome some obstacles at least) by allowing separate migration sets as well as migrations from plugins - there is already a new plugin for that some guys wrote, but my will supersede it.
If you remember, I'm writing the plugin because of my need to extend Mephisto which we discussed some time ago. I will let you know about the first release for you to consider adding it to Mephisto as a part of the future plugin system.
Is the "mephisto_" preface going to be the convention? Obviously, plugins relying on the mephisto plugin need to come alphabetically after it, so that may be a good way to ensure they're loaded after it, until rails implements plugin load ordering. Seems pretty rigid though, and drastically reduces the available namespace... not that I have a better alternative though.
After a minor patch [1] to add the .rb extension to the path name, the installation still produces errors:
[11:22:31][caudill@lazuli][trunk]$ script/runner -e production 'Mephisto::Plugin.install :foo_bar' -- create_table("foo_bars", {:force=>true}) -> 0.6597s ./script/../config/../vendor/rails/railties/lib/commands/runner.rb: 47: ./script/../config/../vendor/rails/activerecord/lib/../../ activesupport/lib/active_support/dependencies.rb:471:in `const_missing': uninitialized constant FooBar::Schema (NameError) from ./script/../config/../vendor/plugins/mephisto/lib/ mephisto_core/plugin.rb:56:in `find_plugin_migration' from ./script/../config/../vendor/plugins/mephisto/lib/ mephisto_core/plugin.rb:17:in `install' from (eval):1 from script/runner:3:in `eval' from ./script/../config/../vendor/rails/railties/lib/ commands/runner.rb:47 from script/runner:3
Not too sure where it's looking for FooBar::Schema or what it would be if I knew where it should be... The install *does* however create the table though, errors and all. The uninstall doesn't remove the table though:
[11:32:12][caudill@lazuli][trunk]$ script/runner -e production 'Mephisto::Plugin.uninstall :foo_bar' -- create_table("foo_bars", {:force=>true}) -> 0.6953s ./script/../config/../vendor/rails/railties/lib/commands/runner.rb: 47: ./script/../config/../vendor/rails/activerecord/lib/../../ activesupport/lib/active_support/dependencies.rb:471:in `const_missing': uninitialized constant FooBar::Schema (NameError) from ./script/../config/../vendor/plugins/mephisto/lib/ mephisto_core/plugin.rb:56:in `find_plugin_migration' from ./script/../config/../vendor/plugins/mephisto/lib/ mephisto_core/plugin.rb:22:in `uninstall' from (eval):1 from script/runner:3:in `eval' from ./script/../config/../vendor/rails/railties/lib/ commands/runner.rb:47 from script/runner:3
Same error.
After running things down for a while, I got a basic admin plugin [2] working (well, after a fashion, visiting the controller in the admin pulls up fine the first time, but throws errors every time it's loaded after that), but I had to do something odd in the controller to avoid this:
vendor/plugins/mephisto_foo_bar/lib/foo_bar_controller.rb to define FooBarController
Apparently, the `returning Mephisto::Plugin.controller` call in Mephisto::Admin to instantiate the controller causes it to expect both:
Module Admin class FooBarController; end end
-- and --
class FooBarController; end
which makes for a wacky looking controller :)
I'll keep digging around tomorrow and see if I can provide more feedback and patches.
> So, I committed very basic plugin support for adding an admin > controller. Try it, let's see if it works out. I can't guarantee any > of this is going to stick though. I'm worried that this will turn > Mephisto in a hacked frankenstein project, and that's just not > something I'm interested in working on. I would just like to put in > enough to let some of you adventurous hackers tear into it without > having to bug me if stuff breaks.
> This is just one of a few types of Mephisto plugins I can think of. > Future possibilities include plugins that add settings, plugins that > tweak admin forms, etc. We've discussed this previously on the list, > but I wasn't far enough along in Mephisto to start writing code. Now > that I have, feel free to tear it apart (followed closely with > suggestions...).
> Some items I'm already thinking of:
> - add a way to specify where to add the admin tab > - full migration support? > - Plugins page in the settings area, storing plugin migration version, > plugin settings, etc.
> Is the "mephisto_" preface going to be the convention? Obviously, > plugins relying on the mephisto plugin need to come alphabetically > after it, so that may be a good way to ensure they're loaded after > it, until rails implements plugin load ordering. Seems pretty rigid > though, and drastically reduces the available namespace... not that I > have a better alternative though.
Yup, there's a mephisto plugin now that does some basic monkey patching, and adds the Mephisto::Plugin and Mephisto::Admin classes. I don't see rails getting plugin load ordering behind alphabetical any time soon.
> After a minor patch [1] to add the .rb extension to the path name, > the installation still produces errors:
Why do you need the .rb extension?
This is what you need for the schema. module FooBar class Schema < ActiveRecord::Migration def install end def uninstall end end end
> After running things down for a while, I got a basic admin plugin [2] > working (well, after a fashion, visiting the controller in the admin > pulls up fine the first time, but throws errors every time it's > loaded after that), but I had to do something odd in the controller > to avoid this:
> vendor/plugins/mephisto_foo_bar/lib/foo_bar_controller.rb to define > FooBarController
lib/admin/foo_bar_controller.rb
module Admin class FooBarController < Admin::BaseController end end
Probably would have helped if I had included a reference plugin to go by. It's just not ready for release yet.
>> After a minor patch [1] to add the .rb extension to the path name, >> the installation still produces errors:
> Why do you need the .rb extension?
Apparently I didn't :P I didn't note the fact that that was a require, I was just hunting down errors in the console and I thought that solved a problem I was having. reverted the change and it works fine.
> This is what you need for the schema. > module FooBar > class Schema < ActiveRecord::Migration > def install > end > def uninstall > end > end > end
Still can't get this working... Here's the latest version of the schema:
[12:16:11][caudill@lazuli][trunk]$ script/runner -e production 'Mephisto::Plugin.install :foo_bar' ./script/../config/../vendor/rails/railties/lib/commands/runner.rb: 47: /Users/caudill/Desktop/trunk/vendor/plugins/mephisto_foo_bar/lib/ mephisto_foo_bar/schema.rb:1: FooBar is not a module (TypeError)
>> vendor/plugins/mephisto_foo_bar/lib/foo_bar_controller.rb to define >> FooBarController
> lib/admin/foo_bar_controller.rb
> module Admin > class FooBarController < Admin::BaseController > end > end
Weird. I could swear that I did that in one of my attempts. Oh well, works now :)
> So, I committed very basic plugin support for adding an admin > controller. Try it, let's see if it works out. I can't guarantee any > of this is going to stick though. I'm worried that this will turn > Mephisto in a hacked frankenstein project, and that's just not > something I'm interested in working on. I would just like to put in > enough to let some of you adventurous hackers tear into it without > having to bug me if stuff breaks.
> This is just one of a few types of Mephisto plugins I can think of. > Future possibilities include plugins that add settings, plugins that > tweak admin forms, etc. We've discussed this previously on the list, > but I wasn't far enough along in Mephisto to start writing code. Now > that I have, feel free to tear it apart (followed closely with > suggestions...).
> Some items I'm already thinking of:
> - add a way to specify where to add the admin tab > - full migration support? > - Plugins page in the settings area, storing plugin migration version, > plugin settings, etc.