Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension support #11

Open
1 of 71 tasks
xbony2 opened this issue Oct 31, 2015 · 9 comments
Open
1 of 71 tasks

Extension support #11

xbony2 opened this issue Oct 31, 2015 · 9 comments

Comments

@xbony2
Copy link
Member

xbony2 commented Oct 31, 2015

How are we going to deal with the support of extensions? I'd like to be able to stuff like this.

Eli edit:

Here are all the extensions we should support by the first release including this feature. It was a combined list of all the extensions on FTB, Wikipedia, and MediaWiki. I have removed all extensions (and skins) with no API. Many of the CurseGamepedia extensions have no docs, so I'm not sure if they have APIs or not. I'll ask Alexia when we get to them

@elifoster
Copy link
Member

I don't know. We should figure that our probably.

@elifoster
Copy link
Member

Branch: extension

@elifoster
Copy link
Member

@xbony2 We should finish up the two extensions we started supporting, because I'd really like to be able to interact with the new Tilesheets API and the upcoming OreDict API.

@xbony2
Copy link
Member Author

xbony2 commented Jun 20, 2017

@elifoster I don't think we really have to finish this for 2.0.0. We're both waiting on 2.0.0 features that aren't this, and doing this will probably take a long time.

@elifoster
Copy link
Member

Yeah I've been thinking this too. It won't break any existing things to add this feature so it should be fine as 2.1 or whatever.

@elifoster elifoster removed this from the 2.0.0 milestone Jun 20, 2017
@elifoster
Copy link
Member

Just thought of a nice way to automatically handle the loading of extension modules

in initialize:

# ...
get_all_extensions.each do |extension_name|
  include MediaWiki::Extensions::Object.const_get(extension_name.delete(' '))
end
# ...

or something along those lines.

@elifoster
Copy link
Member

@xbony2 For how to enable modules, what do you think about

# lib/mediawiki/butt.rb
module MediaWiki
  class Butt
    ...
    def enable_extension(ext_module)
      if ext_module.include?(MediaWiki::Extensions::ExtensionModule)
        extend(ext_module)
      else
        raise NotAnExtensionModuleError.new(ext_module)
      end
    end
  end
end

# lib/mediawiki/extensions/extension_module.rb
module MediaWiki
  module Extensions
    class ExtensionModule
    end
  end
end

# lib/mediawiki/extensions/oredict.rb
require_relative 'extension_module'
module MediaWiki
  module Extensions
    module OreDict
      include MediaWiki::Extensions::ExtensionModule
      def get_oredict_whatever_stub; end
    end
  end
end

# script.rb
require 'mediawiki/butt'
require 'mediawiki/extensions/oredict'

@mw = MediaWiki::Butt.new(...)
@mw.enable_extension(MediaWiki::Extensions::OreDict)
@mw.get_oredict_whatever_stub

@xbony2
Copy link
Member Author

xbony2 commented Nov 16, 2019

Seems fine to me

elifoster added a commit that referenced this issue Nov 21, 2019
Extensions are now enableable by calling MediaWiki::Butt#enable_extension which takes a single argument, a module which includes the ExtensionModule module. Passing anything that does not include that module will cause an error.
This was described last week in #11 issuecomment 553074600.
@elifoster
Copy link
Member

elifoster commented Mar 2, 2024

I think it may be better to split extensions up into their own separate gems, but can still be in this repo. So instead of getting every extension imaginable when you download the gem you only download the ones you actually need. It would also mean all the base gem needs is native support for enabling extensions (which it already has in the extension branch). Extension APIs could be created as we need them and the rest, well if someone needs them they can create them. The basic implementation we have would basically stay the same, except you would need to add the extension to your Gemfile and our dir tree would look like

docs/...
lib/
  mediawiki/
    extensions/
      extensions_module.rb
extensions/
  tilesheets/
    lib/
      mediawiki/
        extensions/
          tilesheets.rb
    mediawiki-butt-extensions-tilesheets.gemspec
mediawiki-butt.gemspec
...

How this would interact with our docs I'm not sure.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants