Contributions? #11
Replies: 2 comments 1 reply
-
This extension was primarily developed for editors of Wikimedia Foundation projects, so it may indeed be missing a lot of other skin behaviors. And also, it has to be said that the lack of consistent behavior constraints between different skins also makes them difficult to maintain.🫠 I'm honored to have your contribution. There is no particular preference, just keep the conversion process relatively simple and readable. And even if there are differences, I believe we can resolve them during the review stage. Thanks a lot! |
Beta Was this translation helpful? Give feedback.
-
Appreciate the feedback. I changed my approach to maintain your code path for skins that support addPortletLink() i.e const skinMapping: Record<string, { portletId: string; nextNode: string | undefined } | undefined> = {
'minerva': { portletId: 'p-tb', nextNode: '#ca-history' },
'monobook': { portletId: 'p-cactions', nextNode: '#ca-history' },
};
const skinName: string = window.mw.config.get('skin');
const launchUrl = `${scheme}://${extensionID}${actionPath}?${new URLSearchParams(args).toString()}`;
//#region Handlers
const handlePortletMappedSkin = () => {
window.mw.util.addPortletLink(
skinMapping[skinName]?.portletId || 'p-views',
launchUrl,
displayInfo['text'],
'wikitext-extension-gadget',
displayInfo['tooltip'],
undefined,
skinMapping[skinName]?.nextNode
);
};
const handleChameleonMappedSkin = (targetId: string) => {
const chameleonTarget = $('#' + targetId);
if (chameleonTarget.length) {
const vscodeLink = $("<a>")
.attr("href", launchUrl)
.attr("id", "ca-code")
.attr("title", displayInfo["tooltip"])
.text(displayInfo["text"])
.addClass("mw-list-item");
chameleonTarget.append(
$("<div>").addClass("mw-list-item").append(vscodeLink)
);
$("<style>")
.text('#wikitext-extension-gadget::before { content: "\\f121"; font-family: "Font Awesome 5 Free"; }')
.appendTo("head");
}
};
//#endregion
if (skinMapping[skinName]) {
handlePortletMappedSkin();
} else if (skinName === 'chameleon') {
handleChameleonMappedSkin('p-contentnavigation');
} If this approach seems good, I'll finish up and create a PR. |
Beta Was this translation helpful? Give feedback.
-
@Frederisk Do you have any preferences for contributions on this repo. There are some some popular skins that don't have the normal
portletTarget
orp-views
I have an edit that is working for chameleon, but it diverges from the skinMapping you've implemented. Let me know, and thanks for this awesome gadget and extension!
Beta Was this translation helpful? Give feedback.
All reactions