2c8912b056f0460badfcad9cce2e5c0a8c290c6d kent Tue Jan 12 18:06:55 2021 -0800 Refactoring code so that in both hubs and in built in tracks the same trackDb fields are D substituted for file names so they don't have to be maintained in parallel. Build a new trackSettingIsFile routine to enable this and am calling it in the two places that used to decide whether to do a substitution. diff --git src/hg/makeDb/hgTrackDb/hgTrackDb.c src/hg/makeDb/hgTrackDb/hgTrackDb.c index 43a09f3..5c736a3 100644 --- src/hg/makeDb/hgTrackDb/hgTrackDb.c +++ src/hg/makeDb/hgTrackDb/hgTrackDb.c @@ -1,36 +1,36 @@ /* hgTrackDb - Create trackDb table from text files. */ + /* Copyright (C) 2013 The Regents of the University of California * See README in this or parent directory for licensing information. */ #include "common.h" #include "linefile.h" #include "hash.h" #include "options.h" #include "sqlList.h" #include "jksql.h" #include "trackDb.h" #include "hui.h" #include "hdb.h" #include "hVarSubst.h" #include "obscure.h" #include "portable.h" #include "dystring.h" #include "regexHelper.h" - void usage() /* Explain usage and exit. */ { errAbort( "hgTrackDb - Create trackDb table from text files.\n\n" "Note that the browser supports multiple trackDb tables, usually\n" "in the form: trackDb_YourUserName. Which particular trackDb\n" "table the browser uses is specified in the hg.conf file found\n" "either in your home directory file '.hg.conf' or in the web server's\n" "cgi-bin/hg.conf configuration file with the setting: db.trackDb=trackDb\n" "see also: src/product/ex.hg.conf discussion of this setting.\n" "usage:\n" " hgTrackDb [options] org database trackDb trackDb.sql hgRoot\n" "\n" "Options:\n" @@ -443,35 +443,35 @@ { td->html = readHtmlRecursive(fileName, database); // Check for note ASCII characters at higher levels of verboseness. // Normally, these are acceptable ISO-8859-1 characters if ((verboseLevel() >= 2) && hasNonAsciiChars(td->html)) verbose(2, "Note: non-printing or non-ASCII characters in %s\n", fileName); } } } } static char *subsituteVariables(struct hashEl *el, char *database) /* substitute variables where supported */ { char* val = (char*)el->val; +char *name = el->name; /* Only some attribute support variable substitution, at least for now * Just leak memory when doing substitution. */ -if (sameString(el->name, "bigDataUrl") || sameString(el->name, "searchTrix") || - sameString(el->name, "xrefDataUrl") || sameString(el->name, "barChartStatsUrl")) +if (trackSettingIsFile(name)) { val = replaceChars(val, "$D", database); } return val; } static char *settingsFromHash(struct hash *hash, char* database) /* Create settings string from settings hash. */ { if (hash == NULL) return cloneString(""); else { struct dyString *dy = dyStringNew(1024); @@ -739,30 +739,31 @@ tdbList = trackDbLinkUpGenerations(tdbList); rSetTrackDbFields(tdbList); /* Fill in any additional missing info from defaults. */ rPolish(tdbList); polishSupers(tdbList); /* Optionally check for tables/tracks that actually exist and get rid of ones that don't. */ if (strict) tdbList = pruneStrict(tdbList, database); tdbList = pruneEmptyContainers(tdbList); checkSubGroups(database,tdbList,strict); trackDbPrioritizeContainerItems(tdbList); + return tdbList; } static struct trackDb *flatten(struct trackDb *tdbForest) /* Convert our peculiar forest back to a list. * This for now rescues superTracks from the heavens. */ { struct hash *superTrackHash = hashNew(0); struct slRef *ref, *refList = trackDbListGetRefsToDescendants(tdbForest); struct trackDb *tdbList = NULL; for (ref = refList; ref != NULL; ref = ref->next) { struct trackDb *tdb = ref->val; struct trackDb *parent = tdb->parent;