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/hgSession/hgSession.h src/hg/hgSession/hgSession.h index 8d6c7db61f2..f46c0336c92 100644 --- src/hg/hgSession/hgSession.h +++ src/hg/hgSession/hgSession.h @@ -1,94 +1,101 @@ /* hgSession - Manage information associated with a user identity. */ /* Copyright (C) 2008 The Regents of the University of California * See kent/LICENSE or http://genome.ucsc.edu/license/ for licensing information. */ #ifndef HGSESSION_H #define HGSESSION_H /* NOTE: some of the original contents have been moved up to cart.h for * sharing with hgTracks. */ #include "cart.h" /* Global variables - generally set during initialization and then read-only. */ extern struct cart *cart; /* This holds cgi and other variables between clicks. */ extern char *database; /* Current database, often but not always dbDatabase. */ /* hgSession form inputs */ #define hgsNewSessionName hgSessionPrefix "newSessionName" #define hgsNewSessionShare hgSessionPrefix "newSessionShare" #define hgsNewSessionDescription hgSessionPrefix "newSessionDescription" #define hgsDoNewSession hgSessionPrefix "doNewSession" +// AJAX endpoint behind the "Share a link" menu button (see topLinks.js). hgsShareAnon (when +// set, or when no user is logged in) saves under the reserved anonymous user "l". +#define hgsDoSaveSessionJson hgSessionPrefix "doSaveSessionJson" +#define hgsShareAnon hgSessionPrefix "shareAnon" +// Rename an existing session (hgsOldSessionName -> hgsNewSessionName) for the "Specify name" step. +#define hgsDoRenameSessionJson hgSessionPrefix "doRenameSessionJson" + #define hgsSharePrefix hgSessionPrefix "share_" #define hgsGalleryPrefix hgSessionPrefix "gallery_" #define hgsEditPrefix hgSessionPrefix "edit_" #define hgsLoadPrefix hgSessionPrefix "load_" #define hgsDeletePrefix hgSessionPrefix "delete_" #define hgsShowDownloadPrefix hgSessionPrefix "showDownload_" #define hgsMakeDownloadPrefix hgSessionPrefix "makeDownload_" #define hgsDoDownloadPrefix hgSessionPrefix "doDownload_" #define hgsSaveLocalBackupFileName hgSessionPrefix "saveLocalBackupFileName" #define hgsSaveLocalFileName hgSessionPrefix "saveLocalFileName" #define hgsSaveLocalFileCompress hgSessionPrefix "saveLocalFileCompress" #define hgsDoSaveLocal hgSessionPrefix "doSaveLocal" #define hgsLoadLocalFileName hgSessionPrefix "loadLocalFileName" #define hgsDoLoadLocal hgSessionPrefix "doLoadLocal" #define hgsLoadUrlName hgSessionPrefix "loadUrlName" #define hgsDoLoadUrl hgSessionPrefix "doLoadUrl" #define hgsDoMainPage hgSessionPrefix "doMainPage" #define hgsDoSessionDetail hgSessionPrefix "doSessionDetail" #define hgsOldSessionName hgSessionPrefix "oldSessionName" #define hgsDoSessionChange hgSessionPrefix "doSessionChange" #define hgsCancel hgSessionPrefix "cancel" #define hgsDo hgSessionPrefix "do" // Non-UI reachable function to load a session and save it, for the purpose of moving files // and tables out of trash/customTrash into userdata/customData after sessionData* params are // added to hg.conf. #define hgsDoReSaveSession hgSessionPrefix "doReSaveSession" // Back-door CGI param to randomize the suffix (usually day of month) for sessionDataDbPrefix. // This is for bulk re-saving old sessions to move files and tables to safe storage; // we don't want all of the old sessions' tables to end up in the same day-of-month database. #define hgsSessionDataDbSuffix hgSessionPrefix "sessionDataDbSuffix" char *cgiDecodeClone(char *encStr); /* Allocate and return a CGI-decoded copy of encStr. */ void startBackgroundWork(char *exec, char **pWorkUrl); /* deal with forking off child for background work * and setting up the trash file for communicating * from the child to the browser */ void getBackgroundStatus(char *url); /* fetch status as the latest complete html block available. * fetch progress info instead if background proc still running. */ // ----- htmlOpen void htmlOpen(char *format, ...); /* Start up a page that will be in html format. */ void htmlClose(); /* Close down html format page. */ void showDownloadSessionCtData(struct hashEl *downloadList); /* Show download page for the given session */ void makeDownloadSessionCtData(char *param1, char *backgroundProgress); /* Download tables and data to save save in compressed archive. */ void doDownloadSessionCtData(struct hashEl *downloadPathList); /* Download given table to browser to save. */ #endif /* HGSESSION_H */