Page MenuHomePhabricator

documentation: Document how to create a basic "Hello World" Gadget using Vue & Codex
Closed, ResolvedPublic

Description

  • "Hello World" Dialog example as user script and Gadget exists
    • The state of information about this use case is downright pathetic at the moment. Just having a completely basic "This is how a Gadget can display a Hello World dialog using Codex" example would be a dramatic improvement.

Having a basic tutorial or example Gadget using Codex would give community developers a basic project outline they could follow.

As far as code organization is concerned, I'd recommend the following:

  • A top-level init.js file that serves as the PackageFiles entry point; this file would be in charge of mounting your Vue app to the appropriate part of the page, etc
  • An App.vue component (which gets mounted in the above file) that pulls in any other necessary components
  • Other components in single-file component (.vue) format. The script part should define module.exports = { /* vue component options */ }
  • Other stand-alone JS and CSS files as necessary. Examples of LESS usage inside SFCs (pulling in design tokens, etc) would be ideal.

This info would need to be published in the appropriate location on-wiki (where Gadget authors could find it easily).

Event Timeline

Restricted Application triaged this task as High priority. · View Herald TranscriptApr 12 2023, 8:56 PM

My first stab at this: a simple gadget that displays a button and a dialog. I made one version that uses the existing infrastructure as-is, and another version that uses the improvements proposed in T330349. A live version of the latter can be viewed on the patchdemo wiki for T330349.

Tomorrow, I'll add more comments and explanations of what the code does, and I'll also try to demonstrate best practices for not loading the gadget except on pages where it's needed (I'll look at other gadgets to discover how that's generally done).

@Catrope That's awsome. Thanks!

But this is also quite a lot of Vue-specific code and concepts. Any chance of tutorial-level (or thereabouts) comments in the code to help understand how it hangs together, what's Vue, what's Codex, what's MediaWiki, etc.?

Thoughts on what bits might be made generic and reusable either per-user, per-project, or upstreamed to WMF/MW? Such as MediaWiki:Gadget-codextest-ChangeNameDialog.vue. Could that be a reusable component that all Gadgets / on a project add a RL dep on and require() to get a simple dialog?

PS. I think the first demo of a running Codex-based Gadget would be a good topic for a Tech Blog (how does it work, what can you do now, what will be possible in the future, how does it relate to other technology, etc.). Whether that's when it's a Patchdemo or when it can live on Wikitech or mediawiki.org or something I can't say, but I think it'd be an interesting and useful topic to start generating interest and enthusiasm for Codex.

Tomorrow, I'll add more comments and explanations of what the code does, and I'll also try to demonstrate best practices for not loading the gadget except on pages where it's needed (I'll look at other gadgets to discover how that's generally done).

Unfortunately this didn't happen due to stuff in my personal life, and we are now closing this task because the main thing we set out to achieve is done, and properly supporting Gadgets requires more infrastructure work than we can take on for the moment (though we'll likely come back to it in the future).

I'm adding a summary of (and a link to) @Xover's comment above to the parent task (T313945) so that those things aren't forgotten and can be done when we come back to this topic.