tosher / Mediawiker

A plugin for Sublime Text editor that adds possibility to use it as Wiki Editor on MediaWiki-based sites like Wikipedia and many other.
Other
137 stars 27 forks source link

Pick template from dropdown #160

Closed RheingoldRiver closed 3 years ago

RheingoldRiver commented 4 years ago

Hi! I've been using the jinja template but now I have a problem: Sometimes I can't pattern match on the name for the template I want.

Example: Scoreboard/i18n needs i18n prefill, no problem, I have if/elif/elif to create all the new page types.

But Module:Champion, Module:Role, Module:Item all subclass Module:EntityAbstract and need the same prefill, there's no way to determine this in the single template.

What I'd like is option to "create new page with template...." and then pick a template from the dropdown to fill the page with. Though, maybe at this point, I should be using another tool for this (clipboard manager or snippets or something), so if you think this is out of scope of Mediawiker, that's ok, I can find another option instead!

Thanks!

tosher commented 4 years ago

Module:Champion, Module:Role, Module:Item all subclass Module:EntityAbstract, etc. - is a fixed list of special modules or not?

RheingoldRiver commented 4 years ago

Basically Module:EntityAbstract, Module:EntityListAbstract, is a fixed list that each generates their own prefills. When I create new modules subclassing these (for example, Champion subclasses EntityAbstract, and ChampionList subclasses EntityListAbstract, etc) I want to choose the right prefill from a list. But, I can't do this for Champion because there's no name matching from Champion to EntityListAbstract.

Right now the only "special" module like this where I have a problem that I can't title pattern match is for modules subclassing EntityAbstract, since for EntityListAbstract it will always have "List" in the name....basically the idea is, an alternative way to make a new page, with a second hotkey, that uses a dropdown list of templates instead of the Jinja pattern matching on title, for cases when I can't pattern match on title.

tosher commented 4 years ago

Please, try the new version: https://github.com/tosher/Mediawiker/releases/tag/v3.6.3

Just for test...

Open page as PageName<-SomeSuffixOrAbstractClass and check it by inherit_suffix variable inside template.

RheingoldRiver commented 4 years ago

I can't tell if anything is implemented yet but if I could do this, yes it would be perfect!

    {
        "caption": "MediaWiker: Open EntityAbstract",
        "command": "mediawiker_open_page",
        "args": {
            "page_inherit": "EntityAbstract",
        }
    }
    #}{%- elif page_inherit == "EntityAbstract" -%}{#

        ----------------------------------------- 
                 -------- EntityAbstract --------- 
        ----------------------------------------- 

#}local util_vars = require("Module:VarsUtil")

local p = require('Module:EntityAbstract'):extends()
local h = {}

p.objectType = ''
p.imagelength = ''
p.defaultlength = ''
p.cssClass = ''

return p{# end
-----------------------

    #}
tosher commented 4 years ago

In this version only suffix like <-AbstractClass in page title, and inherit_suffix (was typo in my message) in template.

RheingoldRiver commented 4 years ago

Ahh ok. Is the goal in the end to have it work like in my snippets? If so that's much better than any implementation I could have designed! It would be perfect!