2022-02-21 21:03:07 +00:00
const mustache = require ( 'mustache' ) ;
const fs = require ( 'fs' ) ;
2022-11-17 23:12:52 +00:00
const menuContents = fs . readFileSync ( 'includes/templates/MenuContents.mustache' , 'utf8' ) ;
2022-02-21 21:03:07 +00:00
const userLinksTemplate = fs . readFileSync ( 'includes/templates/UserLinks.mustache' , 'utf8' ) ;
2023-02-01 22:09:18 +00:00
const userLinksDropdownTemplate = fs . readFileSync ( 'includes/templates/UserLinksDropdown.mustache' , 'utf8' ) ;
2022-11-02 23:00:04 +00:00
const dropdownOpenTemplate = fs . readFileSync ( 'includes/templates/Dropdown/Open.mustache' , 'utf8' ) ;
const dropdownCloseTemplate = fs . readFileSync ( 'includes/templates/Dropdown/Close.mustache' , 'utf8' ) ;
2022-12-09 23:32:43 +00:00
const pinnedContainerOpenTemplate = fs . readFileSync ( 'includes/templates/PinnableContainer/Pinned/Open.mustache' , 'utf8' ) ;
const pinnedContainerCloseTemplate = fs . readFileSync ( 'includes/templates/PinnableContainer/Close.mustache' , 'utf8' ) ;
const unpinnedContainerOpenTemplate = fs . readFileSync ( 'includes/templates/PinnableContainer/Unpinned/Open.mustache' , 'utf8' ) ;
2022-11-28 21:08:40 +00:00
const pinnableElementOpenTemplate = fs . readFileSync ( 'includes/templates/PinnableElement/Open.mustache' , 'utf8' ) ;
const pinnableElementCloseTemplate = fs . readFileSync ( 'includes/templates/PinnableElement/Close.mustache' , 'utf8' ) ;
2022-11-04 19:45:33 +00:00
const pinnableHeaderTemplate = fs . readFileSync ( 'includes/templates/PinnableHeader.mustache' , 'utf8' ) ;
const menuTemplate = fs . readFileSync ( 'includes/templates/Menu.mustache' , 'utf8' ) ;
2023-02-17 22:53:02 +00:00
const linkTemplate = fs . readFileSync ( 'includes/templates/Link.mustache' , 'utf8' ) ;
2022-02-21 21:03:07 +00:00
const templateData = {
'is-wide' : false ,
2023-11-08 01:01:59 +00:00
'data-user-links-notifications' : {
id : 'p-personal-notifications' ,
class : '' ,
'html-items' : ` <li id="pt-notifications-alert" class="mw-list-item"><a href="/wiki/Special:Notifications" class="mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-bell mw-echo-notifications-badge-all-read" data-counter-num="0" data-counter-text="0" title="Your alerts"><span>Alerts (0)</span></a></li>
< li id = "pt-notifications-notice" class = "mw-list-item" > < a href = "/wiki/Special:Notifications" class = "mw-echo-notifications-badge mw-echo-notification-badge-nojs oo-ui-icon-tray mw-echo-notifications-badge-all-read" data - counter - num = "0" data - counter - text = "0" title = "Your notices" > < span > Notices ( 0 ) < / s p a n > < / a > < / l i > `
} ,
'data-user-links-preferences' : {
id : 'p-personal-preferences' ,
class : '' ,
'html-items' : '<li id="ca-uls" class="user-links-collapsible-item mw-list-item active"><a href="#" class="uls-trigger cdx-button cdx-button--weight-quiet"><span class="vector-icon mw-ui-icon-wikimedia-language"></span> <span>English</span></a></li>'
} ,
'data-user-links-user-page' : {
id : 'p-personal-user-page' ,
class : '' ,
'html-items' : '<li id="pt-userpage-2" class="user-links-collapsible-item mw-list-item"><a href="/wiki/User:Admin" class="cdx-button cdx-button--weight-quiet" title="Your user page [⌃⌥.]" accesskey="."><span>Admin</span></a></li>'
} ,
'data-user-links-overflow' : {
2022-02-21 21:03:07 +00:00
id : 'p-personal-more' ,
2022-04-19 17:50:01 +00:00
class : 'mw-portlet mw-portlet-vector-user-menu-overflow vector-user-menu-overflow' ,
2022-02-21 21:03:07 +00:00
label : 'Toggle sidebar' ,
'html-items' : `
2023-06-12 22:22:33 +00:00
< li id = "pt-watchlist-2" class = "user-links-collapsible-item mw-list-item" > < a href = "/wiki/Special:Watchlist" class = "cdx-button cdx-button--weight-quiet vector-icon cdx-button--icon-only mw-ui-icon-watchlist mw-ui-icon-wikimedia-watchlist" title = "A list of pages you are monitoring for changes [⌃⌥l]" accesskey = "l" > < span > Watchlist < / s p a n > < / a > < / l i >
2022-02-21 21:03:07 +00:00
`
} ,
2023-02-01 22:09:18 +00:00
'data-user-links-dropdown' : {
2023-02-16 17:06:22 +00:00
id : 'vector-user-links-dropdown' ,
2023-06-26 21:44:13 +00:00
class : 'vector-user-menu vector-user-menu-logged-in' ,
2023-01-06 01:45:38 +00:00
label : 'Personal tools'
} ,
2023-06-30 21:49:17 +00:00
'data-user-links-menus' : [ {
2023-02-16 17:06:22 +00:00
class : 'mw-portlet mw-portlet-personal' ,
id : 'p-personal' ,
2022-02-21 21:03:07 +00:00
'html-items' : `
2023-04-27 20:39:40 +00:00
< li id = "pt-userpage" class = "user-links-collapsible-item mw-list-item" > < a href = "/wiki/User:Admin" title = "Your user page [.]" accesskey = "." > < span class = "vector-icon mw-ui-icon-userAvatar mw-ui-icon-wikimedia-userAvatar" > < / s p a n > < s p a n > A d m i n < / s p a n > < / a > < / l i >
< li id = "pt-mytalk" class = "mw-list-item" > < a href = "/wiki/User_talk:Admin" title = "Your talk page [n]" accesskey = "n" > < span class = "vector-icon mw-ui-icon-userTalk mw-ui-icon-wikimedia-userTalk" > < / s p a n > < s p a n > T a l k < / s p a n > < / a > < / l i >
< li id = "pt-sandbox" class = "new mw-list-item" > < a href = "/w/index.php?title=User:Admin/sandbox&action=edit&redlink=1" title = "Your sandbox (page does not exist)" > < span class = "vector-icon mw-ui-icon-sandbox mw-ui-icon-wikimedia-sandbox" > < / s p a n > < s p a n > S a n d b o x < / s p a n > < / a > < / l i >
2023-11-23 10:19:44 +00:00
< li id = "pt-preferences" class = "mw-list-item" > < a href = "/wiki/Special:Preferences" title = "Your preferences" > < span class = "vector-icon mw-ui-icon-appearance mw-ui-icon-wikimedia-appearance" > < / s p a n > < s p a n > P r e f e r e n c e s < / s p a n > < / a > < / l i >
2023-04-27 20:39:40 +00:00
< li id = "pt-betafeatures" class = "mw-list-item" > < a href = "/wiki/Special:Preferences#mw-prefsection-betafeatures" title = "Beta features" > < span class = "vector-icon mw-ui-icon-labFlask mw-ui-icon-wikimedia-labFlask" > < / s p a n > < s p a n > B e t a < / s p a n > < / a > < / l i >
< li id = "pt-watchlist" class = "user-links-collapsible-item mw-list-item" > < a href = "/wiki/Special:Watchlist" title = "A list of pages you are monitoring for changes [l]" accesskey = "l" > < span class = "vector-icon mw-ui-icon-watchlist mw-ui-icon-wikimedia-watchlist" > < / s p a n > < s p a n > W a t c h l i s t < / s p a n > < / a > < / l i >
< li id = "pt-uploads" class = "mw-list-item" > < a href = "/w/index.php?title=Special:ListFiles/Admin&ilshowall=1" title = "List of files you have uploaded" > < span class = "vector-icon mw-ui-icon-imageGallery mw-ui-icon-wikimedia-imageGallery" > < / s p a n > < s p a n > U p l o a d s < / s p a n > < / a > < / l i >
< li id = "pt-mycontris" class = "mw-list-item" > < a href = "/wiki/Special:Contributions/Admin" title = "A list of your contributions [y]" accesskey = "y" > < span class = "vector-icon mw-ui-icon-userContributions mw-ui-icon-wikimedia-userContributions" > < / s p a n > < s p a n > C o n t r i b u t i o n s < / s p a n > < / a > < / l i >
2022-02-21 21:03:07 +00:00
< li id = "pt-custom" class = "mw-list-item mw-list-item-js" > Gadget added item < / l i >
`
2023-02-01 23:38:44 +00:00
} , {
2023-02-16 17:06:22 +00:00
id : 'p-user-menu-logout' ,
class : 'mw-portlet mw-portlet-user-menu-logout' ,
2023-02-01 23:38:44 +00:00
'html-items' : `
2023-04-27 20:39:40 +00:00
< li id = "ca-logout" class = "mw-list-item" > < a data - mw = "interface" href = "/w/index.php?title=Special:UserLogout&returnto=Main+Page" title = "Log out" > < span class = "vector-icon mw-ui-icon-logOut mw-ui-icon-wikimedia-logOut" > < / s p a n > < s p a n > L o g o u t < / s p a n > < / a > < / l i >
2023-02-01 23:38:44 +00:00
`
} ]
2022-02-21 21:03:07 +00:00
} ;
2022-11-02 23:00:04 +00:00
const dropdownPartials = {
2023-02-01 22:09:18 +00:00
UserLinksDropdown : userLinksDropdownTemplate ,
2022-11-02 23:00:04 +00:00
'Dropdown/Open' : dropdownOpenTemplate ,
'Dropdown/Close' : dropdownCloseTemplate ,
2022-12-09 23:32:43 +00:00
'PinnableContainer/Pinned/Open' : pinnedContainerOpenTemplate ,
'PinnableContainer/Close' : pinnedContainerCloseTemplate ,
'PinnableContainer/Unpinned/Open' : unpinnedContainerOpenTemplate ,
2022-11-28 21:08:40 +00:00
'PinnableElement/Open' : pinnableElementOpenTemplate ,
'PinnableElement/Close' : pinnableElementCloseTemplate ,
2022-11-04 19:45:33 +00:00
PinnableHeader : pinnableHeaderTemplate ,
2022-11-17 23:12:52 +00:00
Menu : menuTemplate ,
2023-01-06 01:45:38 +00:00
MenuContents : menuContents ,
2023-03-08 22:21:24 +00:00
Link : linkTemplate
2022-11-02 23:00:04 +00:00
} ;
const renderedHTML = mustache . render ( userLinksTemplate , templateData , dropdownPartials ) ;
2022-02-21 21:03:07 +00:00
module . exports = {
2022-11-02 23:00:04 +00:00
dropdownPartials ,
2022-02-21 21:03:07 +00:00
userLinksHTML : renderedHTML
} ;