c5a326f3cc42beca0b59c284a2819763548c166a
max
  Wed Jul 8 05:31:13 2026 -0700
Add top-right "Share a link" and "Login" links to the menu bar, refs #10138

New js/topLinks.js drives two links at the top-right of the menu bar on all pages:

- Login: links to the login page when logged out; when logged in it shows the
username and opens an account dialog (My Sessions / My Custom Tracks /
My Track Hubs, change password, sign out).
- Share a link: on hgTracks, one click saves the current view as a session and
shows a copyable short link, with an optional "Specify name" rename step; works
logged-in or anonymously (reserved user "l"). On hgTrackUi and the hgc/hgGene
item-details popup it instead shares the page URL with the hgsid stripped and
the db argument kept.

hgSession gains two JSON endpoints (hgS_doSaveSessionJson, hgS_doRenameSessionJson)
that reuse saveCartAsSession() and addSessionLink(). The menu bar is patched in
lib/web.c (CGI pages) and hgMenubar.c (static pages) via comment placeholders in
globalNavBar.inc. On narrow/phone screens the links collapse into a menu icon with
a dropdown so they no longer overlap the menu.

diff --git src/hg/htdocs/inc/globalNavBar.inc src/hg/htdocs/inc/globalNavBar.inc
index 393350ba2cb..601f39de0a5 100644
--- src/hg/htdocs/inc/globalNavBar.inc
+++ src/hg/htdocs/inc/globalNavBar.inc
@@ -1,18 +1,23 @@
 <a href="#mainContent" class="skipNav" tabindex="-1">Skip to main content</a>
 <div id="main-menu-whole">
 
+<!-- Top-right links (Share a link, Login).  These comment placeholders are replaced at runtime by
+     menuBar() in lib/web.c (CGI pages) and by hgMenubar.c (static pages).  They sit in their own
+     absolutely-positioned container at the top-right of the bar, not inside the menu list. -->
+<div id="topRightLinks"><button type="button" id="trToggle" aria-label="Menu" aria-expanded="false">&#9776;</button><!-- SHARE_LINK --><!-- LOGIN_LINK --></div>
+
 		<div id="main-menu"><div id="block-nice_menus-1" class="clear-block block block-nice_menus">
 
 	<div class="upcorner"></div>
 	<div class="blockbg">
 		<div class="blockcontent">
 						<div class="content">
 
 <nav aria-label="Main menu"><ul class="nice-menu nice-menu-down sf-js-enabled" id="nice-menu-1">
 
 <li class="first even" id="home"><a href="../index.html" ><span id="home-link">Home</span></a></li> 
 
 <li class="menuparent" id="tools1"><a href="../cgi-bin/hgGateway" aria-expanded="false">Genomes</a>
 	<ul style="display: none; visibility: hidden;">
 	<li class="first defaultDropdownLink"><a href="../cgi-bin/hgTracks?db=hg38&amp;position=lastDbPos">Human GRCh38/hg38</a></li>
 	<li class="defaultDropdownLink"><a href="../cgi-bin/hgTracks?db=hg19&amp;position=lastDbPos">Human GRCh37/hg19</a></li>