Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v3.2.2 - Xenotime #1037

Merged
merged 88 commits into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
ac5a74a
updates a few global colors
davelandry Jul 1, 2022
c33dbea
refactors homeRoute to pull pageviews per profile
davelandry Jul 1, 2022
2ea4aa4
adds global .arrow-link class styles and icons
davelandry Jul 1, 2022
bd8f88e
adds min-width to all d3plus tooltips
davelandry Jul 1, 2022
05f3757
adds 500 font-weight to Palanquin google font load
davelandry Jul 1, 2022
0c49a2d
replaces " - Color" dimension SVGs with CSS coloring
davelandry Jul 1, 2022
f533f4b
restyles Tile component
davelandry Jul 1, 2022
718d98f
renames "sponsors" className to get around AdBlock
davelandry Jul 1, 2022
41a6688
implements new Home design
davelandry Jul 1, 2022
af6f59c
changes logiclayer cube logic to always prefer 5 year cubes
davelandry Jul 1, 2022
6f42fa4
Merge pull request #976 from DataUSA/feature/homepage-redesign
hermosillajelmy Jul 8, 2022
8320c3c
Merge pull request #977 from DataUSA/tweaks/prefer-5-year
hermosillajelmy Jul 8, 2022
3b6a03b
removes stories (#979)
davelandry Jul 20, 2022
79c3a42
renames "profiles" to "reports" in front-end texts (#979)
davelandry Jul 20, 2022
6f93f11
adds profile colors to home splash tiles
davelandry Jul 20, 2022
1c0c226
implements Danae's new navigation design
davelandry Jul 21, 2022
4a9d329
adds COVID stripe in homepage
davelandry Jul 21, 2022
677c573
removes logos from Hamburger menu
davelandry Jul 27, 2022
c452f27
shows Cart on mobile Nav, logo when there is no page title, and left-…
davelandry Jul 27, 2022
af11a5b
bumps pums_1 to pums_5 for parents cache
davelandry Jul 27, 2022
ea6645c
Merge pull request #985 from DataUSA/tweak/nav-design-story-removal
hermosillajelmy Jul 27, 2022
bc0a0f2
implements Danae's profile design tweaks
davelandry Jul 27, 2022
50135e2
centers profile SubNav
davelandry Jul 27, 2022
ecf5c0a
changes stat font
davelandry Jul 27, 2022
5bec2fc
fixes category title position with columns
davelandry Jul 27, 2022
3db2abf
uploads new icons for Transportation Means
davelandry Aug 9, 2022
74c9304
updates Colors JSON with all/new values
davelandry Aug 9, 2022
d9e0591
fixes About section background-color
davelandry Aug 9, 2022
ae4cea0
hides certain Splash stats in geo profile
davelandry Aug 9, 2022
dea9518
passes color mapping in customAttributes
davelandry Aug 9, 2022
aaf3743
tweaks Tile subtitle style
davelandry Aug 9, 2022
3bed689
changes Home tagline
davelandry Aug 10, 2022
0382b97
updates share image (closes #986)
davelandry Aug 10, 2022
38a520a
applies responsive CSS to Home page (closes #983)
davelandry Aug 10, 2022
eac738c
Merge pull request #991 from DataUSA/fix/mobile-css
hermosillajelmy Aug 16, 2022
786ab41
hides SideNav bubble when sections are hidden
davelandry Aug 16, 2022
9e2274a
removes console statement
davelandry Aug 16, 2022
d2f0c69
fixes duplicate and missing colors
davelandry Aug 16, 2022
beba160
updates minor d3plus dependencies to bring in various bug fixes
davelandry Aug 16, 2022
4e43b20
Merge pull request #990 from DataUSA/feature/profile-css
hermosillajelmy Aug 16, 2022
6593eb7
bumps version number
davelandry Aug 17, 2022
ff50da3
replaces pslug and pid with slug and id to fix profile redirects (clo…
davelandry Oct 4, 2022
4db8120
small design improvements to NotFound component
davelandry Oct 4, 2022
22474e4
adds 404 catch route
davelandry Oct 4, 2022
490ea5a
inverts Loading colors to prevent white flash
davelandry Oct 4, 2022
7574672
Merge pull request #1004 from DataUSA/fix-redirects
hermosillajelmy Oct 7, 2022
dce1bc4
adjusts padding on nav logo to better align with page titles
davelandry Oct 13, 2022
b244378
updates to latest canon-core and canon-cms
davelandry Oct 13, 2022
2dabe60
adds Icon support to Section titles
davelandry Oct 13, 2022
f16f430
replaces Profile SubNav and SideNav with the canon-cms Subnav component
davelandry Oct 13, 2022
88f817d
removes old Splash section icons and improves height logic
davelandry Oct 13, 2022
9453ddd
creates SubGrouping section to enable Subnav dropdowns
davelandry Oct 13, 2022
16d96da
new style for footer
hermosillajelmy Oct 3, 2022
2f6c458
add a new icon and minor changes to the footer style
hermosillajelmy Nov 4, 2022
e6f759a
Merge pull request #1006 from DataUSA/cms-subnav
hermosillajelmy Nov 10, 2022
5e9a90c
change in tooltip styles
hermosillajelmy Nov 2, 2022
0aa1d86
add icon and fix styles for footer and tbody
hermosillajelmy Nov 8, 2022
351d699
add footer icon and subtitle
hermosillajelmy Nov 9, 2022
58f9918
add dimension icon
hermosillajelmy Nov 9, 2022
4197e11
fix icon position
hermosillajelmy Nov 9, 2022
0fcc061
add product icon
hermosillajelmy Nov 10, 2022
672a7f4
minor change
hermosillajelmy Nov 10, 2022
43b0679
minor changes for icons in different dimensions
hermosillajelmy Nov 10, 2022
33358f3
add industry icons
hermosillajelmy Nov 14, 2022
60cb744
add colors to style.yml
hermosillajelmy Nov 14, 2022
974a622
move styling from d3plus.css to d3plus.js
hermosillajelmy Nov 15, 2022
d8f83ae
add function for tooltip title
hermosillajelmy Nov 15, 2022
38a4e96
minor changes in colors
hermosillajelmy Nov 15, 2022
b456b71
add img to home tooltip
hermosillajelmy Nov 16, 2022
ad52555
fixes Footer logo CSS conflicting with Home logos
davelandry Nov 23, 2022
e8f1b43
strips P tags from comparison search placeholder
davelandry Nov 23, 2022
3216f0e
fixes selectors
davelandry Nov 23, 2022
6764af4
Merge pull request #1018 from DataUSA/bug/selectors
hermosillajelmy Nov 24, 2022
cce8aa4
bumps version number
davelandry Dec 1, 2022
f0f90d6
add opeid in customAttributes
hermosillajelmy Apr 6, 2023
c7fcc5f
fix logic
hermosillajelmy Apr 10, 2023
85e4fc0
hides legend tooltip tbody in global d3plus config
davelandry Apr 13, 2023
dfab8af
updates house and senate wiki candidates
davelandry Apr 13, 2023
55690bb
add ids and opeid of similar universities
hermosillajelmy May 2, 2023
d79e98b
changes according to PR comments
hermosillajelmy May 2, 2023
3e56b8b
fixes similarOpeidID spelling error
davelandry May 3, 2023
b3bf465
adds crossorigin to google font links
davelandry Jun 15, 2023
47f62ae
adds BEA and BLS crosswalks to customAttributes
davelandry Jun 15, 2023
fc7e2f9
add bea ids for industry 11-21
hermosillajelmy Jun 19, 2023
cf09bf1
adds pumsLatestYear to naics and soc customAttributes
davelandry Jun 23, 2023
bf036c8
fixes breadrcrumbs and new latestYear vars
davelandry Jul 3, 2023
74d351f
bumps version number for xenotime release
davelandry Jul 14, 2023
e155404
Merge branch 'main' into staging
davelandry Jul 14, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 29 additions & 2 deletions api/customAttributes.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
const axios = require("axios");
const colors = require("../static/data/colors.json");
const iocodes = require("../static/data/pums_naics_to_iocode.json");
const blsInds = require("../static/data/pums_bls_industry_crosswalk.json");
const blsOccs = require("../static/data/pums_bls_occupation_crosswalk.json");

const loadJSON = require("../utils/loadJSON");
const universitySimilar = loadJSON("/static/data/similar_universities_with_dist.json");

const colorMapping = Object.keys(colors)
.reduce((obj, k) => {
Expand Down Expand Up @@ -30,15 +36,15 @@ const blsIndustryMap = [
module.exports = function(app) {

const {db} = app.settings;
const {blsMonthlyIndustries, urls} = app.settings.cache;
const {blsMonthlyIndustries, urls, opeid} = app.settings.cache;

app.post("/api/cms/customAttributes/:pid", async(req, res) => {

const {id, dimension, hierarchy} = req.body.variables;
const meta = await db.profile_meta.findOne({where: {dimension}}).catch(() => {});
const {slug} = meta;

const origin = `http${ req.connection.encrypted ? "s" : "" }://${ req.headers.host }`;
const origin = process.env.CANON_API;

const breadcrumbs = await axios.get(`${origin}/api/parents/${slug}/${id}`)
.then(resp => resp.data)
Expand Down Expand Up @@ -88,10 +94,31 @@ module.exports = function(app) {
retObj.blsMonthlyID = mapped ? mapped[1] : false;
retObj.blsMonthlyDimension = "Supersector";
}
const beaIds = iocodes[id];
retObj.beaL0 = beaIds && beaIds.L0 ? beaIds.L0 : false;
retObj.beaL1 = beaIds && beaIds.L1 ? beaIds.L1 : false;
retObj.blsIds = blsInds[id] || false;
retObj.pumsLatestYear = await axios.get(`${origin}/api/data?${hierarchy}=${id}&measures=Total%20Population&limit=1&order=Year&sort=desc`)
.then(resp => resp.data.data[0]["ID Year"])
.catch(() => 2020);
}
else if (dimension === "PUMS Occupation") {
retObj.blsIds = blsOccs[id] || false;
retObj.pumsLatestYear = await axios.get(`${origin}/api/data?${hierarchy}=${id}&measures=Total%20Population&limit=1&order=Year&sort=desc`)
.then(resp => resp.data.data[0]["ID Year"])
.catch(() => 2020);
}
else if (dimension === "CIP") {
retObj.stem = id.length === 6 ? stems.includes(id) ? "Stem Major" : false : "Contains Stem Majors"
}
else if (dimension === "University") {
const similarID = universitySimilar[id] ? universitySimilar[id].map(d => d.university) : [];
const similarOpeidID = similarID.map(d => opeid[d]).filter(Boolean).join(",");

retObj.opeid = opeid && opeid[id]? opeid[id] : false;
retObj.similarID = similarID.join(",");
retObj.similarOpeidId = similarOpeidID;
}

return res.json(retObj);

Expand Down
1 change: 1 addition & 0 deletions app/d3plus.js
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,7 @@ export default {
},
legendPosition: "bottom",
legendTooltip: {
tbody: [],
title(d) {
return findTooltipTitle(d, this)
}
Expand Down
4 changes: 2 additions & 2 deletions app/helmet.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ const desc = "The most comprehensive visualization of U.S. public data. Data USA
export default {
link: [
{rel: "icon", href: "/images/favicon.ico?v=3"},
{rel: "preconnect", href: "https://fonts.gstatic.com/", crossorigin: ""},
{rel: "stylesheet", href: "https://fonts.googleapis.com/css?family=Lato:300|Palanquin:300,400,500,600,700|Source+Sans+Pro:300,400|Pathway+Gothic+One"}
{rel: "preconnect", href: "https://fonts.gstatic.com/", crossorigin: "anonymous"},
{rel: "stylesheet", href: "https://fonts.googleapis.com/css?family=Lato:300|Palanquin:300,400,500,600,700|Source+Sans+Pro:300,400|Pathway+Gothic+One", crossorigin: "anonymous"}
],
meta: [
{charset: "utf-8"},
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "datausa-site",
"version": "3.2.1",
"version": "3.2.2",
"description": "The most comprehensive visualization of U.S. public data",
"main": "src/index.js",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion scripts/candidateImage.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ async function printProgress() {

/** */
function getFileName(member) {
const {key} = member;
const key = member.key || member["Candidate ID"];
return path.join(process.cwd(), `static/images/candidates/${cube}/${key}.jpg`);
}

Expand Down
35 changes: 28 additions & 7 deletions scripts/wikiCandidates.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,29 @@ if (!level || !urls[level]) {
shell.exit(1);
}

// Internal list of HTML entities for escaping.
const entities = {
"&": "&",
"&lt;": "<",
"&gt;": ">",
"&quot;": "\"",
"&#x27;": "'",
"&#x60;": "`",
"&nbsp;": ""
};

const source = `(?:${ Object.keys(entities).join("|") })`;
const testRegexp = RegExp(source);
const replaceRegexp = RegExp(source, "g");

/**
* Converts html tags to spaces, then removes redundant spaces
*/
function stripHTML(n) {
const s = String(n).replace(/<[^>]+>/g, " ").replace(/\s+/g, " ").trim();
return testRegexp.test(s) ? s.replace(replaceRegexp, match => entities[match]) : s;
}

/** */
async function run() {

Expand All @@ -36,25 +59,23 @@ async function run() {
.querySelectorAll("th")
.reduce((arr, d) => {
const cols = d.rawAttrs.includes("colspan") ? +d.rawAttrs.match(/colspan="([0-9])"/)[1] : 1;
const text = d.querySelector("span").innerHTML
.replace(/\<br[\s\=\"\'A-z0-9]{1,}\/\>/g, " ");
const text = stripHTML(d.querySelector("span").innerHTML).replace(/\s\[[0-9].*\]/g, "");
for (let i = 0; i < cols; i++) arr.push(text);
return arr;
}, []);

let colOffset = 0;
const candidates = table.querySelectorAll("tr")
.slice(1)
// .slice(1, 2)
// .slice(7, 12)
.reduce((arr, row, ii) => {
const obj = {};
// console.log(row);
row.childNodes
.filter(d => d.nodeType !== 3)
.forEach((column, i) => {
const header = headers[i + colOffset]
.replace(/<br[^>]*>/g, " ")
.replace(/\<.*$/g, "");
const header = headers[i + colOffset];
let data = column;
while (data.querySelector(".cx-segment") || data.querySelector(".cx-link")) {
data = data.querySelector(".cx-segment") || data.querySelector(".cx-link");
Expand All @@ -76,8 +97,8 @@ async function run() {
obj.Image = `https:${data.querySelector("img").getAttribute("src")}`;
}
}
else if (header === "Term up") {
obj[header] = data.innerHTML.slice(0, 4);
else if (header === "Class") {
obj["Term up"] = data.innerHTML.slice(0, 4);
}
else if (!["Born", "Education", "Prior experience", "Occupation(s)", "Previous office(s)", "Previous elective office(s)", "Residence"].includes(header)) {
obj[header] = data.innerHTML
Expand Down
3 changes: 2 additions & 1 deletion static/data/pums_naics_to_iocode.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,5 +307,6 @@
"92M1": {"L1": "GFGN", "L0": "G"},
"92M2": {"L1": "GFGN", "L0": "G"},
"92MP": {"L1": "GFGN", "L0": "G"},
"9211MP": {"L1": "GSLG", "L0": "G"}
"9211MP": {"L1": "GSLG", "L0": "G"},
"11-21": {"L1": null, "L0": "11,21"}
}
Loading