const mustache = require( 'mustache' ); const fs = require( 'fs' ); const menuContents = fs.readFileSync( 'includes/templates/MenuContents.mustache', 'utf8' ); const userLinksTemplate = fs.readFileSync( 'includes/templates/UserLinks.mustache', 'utf8' ); const userLinksDropdownTemplate = fs.readFileSync( 'includes/templates/UserLinksDropdown.mustache', 'utf8' ); const dropdownOpenTemplate = fs.readFileSync( 'includes/templates/Dropdown/Open.mustache', 'utf8' ); const dropdownCloseTemplate = fs.readFileSync( 'includes/templates/Dropdown/Close.mustache', 'utf8' ); 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' ); const pinnableElementOpenTemplate = fs.readFileSync( 'includes/templates/PinnableElement/Open.mustache', 'utf8' ); const pinnableElementCloseTemplate = fs.readFileSync( 'includes/templates/PinnableElement/Close.mustache', 'utf8' ); const pinnableHeaderTemplate = fs.readFileSync( 'includes/templates/PinnableHeader.mustache', 'utf8' ); const menuTemplate = fs.readFileSync( 'includes/templates/Menu.mustache', 'utf8' ); const linkTemplate = fs.readFileSync( 'includes/templates/Link.mustache', 'utf8' ); const templateData = { 'is-wide': false, 'data-user-links-notifications': { id: 'p-personal-notifications', class: '', 'html-items': `
  • Alerts (0)
  • Notices (0)
  • ` }, 'data-user-links-preferences': { id: 'p-personal-preferences', class: '', 'html-items': '' }, 'data-user-links-user-page': { id: 'p-personal-user-page', class: '', 'html-items': '' }, 'data-user-links-overflow': { id: 'p-personal-more', class: 'mw-portlet mw-portlet-vector-user-menu-overflow vector-user-menu-overflow', label: 'Toggle sidebar', 'html-items': ` ` }, 'data-user-links-dropdown': { id: 'vector-user-links-dropdown', class: 'vector-user-menu vector-user-menu-logged-in', label: 'Personal tools' }, 'data-user-links-menus': [ { class: 'mw-portlet mw-portlet-personal', id: 'p-personal', 'html-items': `
  • Talk
  • Sandbox
  • Preferences
  • Beta
  • Uploads
  • Contributions
  • Gadget added item
  • ` }, { id: 'p-user-menu-logout', class: 'mw-portlet mw-portlet-user-menu-logout', 'html-items': `
  • Log out
  • ` } ] }; const dropdownPartials = { UserLinksDropdown: userLinksDropdownTemplate, 'Dropdown/Open': dropdownOpenTemplate, 'Dropdown/Close': dropdownCloseTemplate, 'PinnableContainer/Pinned/Open': pinnedContainerOpenTemplate, 'PinnableContainer/Close': pinnedContainerCloseTemplate, 'PinnableContainer/Unpinned/Open': unpinnedContainerOpenTemplate, 'PinnableElement/Open': pinnableElementOpenTemplate, 'PinnableElement/Close': pinnableElementCloseTemplate, PinnableHeader: pinnableHeaderTemplate, Menu: menuTemplate, MenuContents: menuContents, Link: linkTemplate }; const renderedHTML = mustache.render( userLinksTemplate, templateData, dropdownPartials ); module.exports = { dropdownPartials, userLinksHTML: renderedHTML };