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

get up to date #3

Merged
merged 22 commits into from
May 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
83b71a4
Shift markdown parsing into helper function
jameshadfield Apr 28, 2020
4a4408c
Add allowed SVG tags + attrs
jameshadfield Apr 28, 2020
663fc36
color value was in quotes, was bad syntax. tested by making it #3f3 b…
rleir Apr 30, 2020
16e98ab
change color to fix integration test
rleir Apr 30, 2020
4a7bb02
do frequency dates like tree
eharkins May 1, 2020
5f5ce75
compute frequency ticks dynamically as in tree
eharkins May 1, 2020
67b591a
forgot to remove unused prop
eharkins May 1, 2020
bb15498
remove added blank line
eharkins May 1, 2020
5903ab5
standardize calculateMajorGridSeperationFor*
eharkins May 4, 2020
b3bbaac
Fix rename of grid step
eharkins May 4, 2020
4391487
update docstrings
jameshadfield May 5, 2020
478f981
Merge pull request #1096 from nextstrain/frequency-date
jameshadfield May 5, 2020
90d91e9
Increase allowed bundlesizes
jameshadfield May 5, 2020
9e5147a
Added arabic to locales
anouarh Apr 26, 2020
39479ad
Add Arabic sidebar, modified French sidebar
anouarh May 3, 2020
c975de3
modify fr sidebar
anouarh May 3, 2020
599c0b8
Add ar translations, edited fr translations
anouarh May 4, 2020
e1dc2b1
Merge pull request #1107 from nextstrain/arabic-translation
jameshadfield May 5, 2020
37aece4
Merge pull request #1087 from nextstrain/svg-in-md
jameshadfield May 5, 2020
138fb33
removed unwanted text color attribute
rleir May 6, 2020
5679742
Merge pull request #1094 from rleir/invalid_css_color
jameshadfield May 6, 2020
2356920
version bump to 2.15.0 for release
jameshadfield May 6, 2020
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
title: Changelog
---

## version 2.15.0 - 2020/05/06


## version 2.14.0 - 2020/04/24


Expand Down
4 changes: 2 additions & 2 deletions bundlesize.config.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@
"files": [
{
"path": "./dist/auspice.bundle.js",
"maxSize": "180 kB"
"maxSize": "200 kB"
},
{
"path": "./dist/auspice.chunk.*.bundle.js",
"maxSize": "110 kB"
"maxSize": "120 kB"
}
]
}
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auspice",
"version": "2.14.0",
"version": "2.15.0",
"description": "Web app for visualizing pathogen evolution",
"author": "James Hadfield, Trevor Bedford and Richard Neher",
"license": "AGPL-3.0-only",
Expand Down
3 changes: 2 additions & 1 deletion src/components/controls/language.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ class Language extends React.Component {
{value: "pt", label: "Português"},
{value: "fr", label: "Français"},
{value: "tr", label: "Türkçe"},
{value: "ja", label: "日本語"}
{value: "ja", label: "日本語"},
{value: "ar", label: "العربية"}
];
return languages;
}
Expand Down
32 changes: 2 additions & 30 deletions src/components/framework/footer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import React from "react";
import { connect } from "react-redux";
import marked from "marked";
import dompurify from "dompurify";
import styled from 'styled-components';
import { withTranslation } from "react-i18next";
import { FaDownload } from "react-icons/fa";
Expand All @@ -13,6 +11,7 @@ import { version } from "../../version";
import { publications } from "../download/downloadModal";
import { isValueValid } from "../../util/globals";
import hardCodedFooters from "./footer-descriptions";
import { parseMarkdown } from "../../util/parseMarkdown";

const dot = (
<span style={{marginLeft: 10, marginRight: 10}}>
Expand Down Expand Up @@ -138,36 +137,9 @@ export const getAcknowledgments = (metadata, dispatch) => {
* Jover. December 2019.
*/
if (metadata.description) {
dompurify.addHook("afterSanitizeAttributes", (node) => {
// Set external links to open in a new tab
if ('href' in node && location.hostname !== node.hostname) {
node.setAttribute('target', '_blank');
node.setAttribute('rel', 'noreferrer nofollow');
}
// Find nodes that contain images and add imageContainer class to update styling
const nodeContainsImg = ([...node.childNodes].filter((child) => child.localName === 'img')).length > 0;
if (nodeContainsImg) {
// For special case of image links, set imageContainer on outer parent
if (node.localName === 'a') {
node.parentNode.className += ' imageContainer';
} else {
node.className += ' imageContainer';
}
}
});

const sanitizer = dompurify.sanitize;
const sanitizerConfig = {
ALLOWED_TAGS: ['div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'em', 'strong', 'del', 'ol', 'ul', 'li', 'a', 'img', '#text', 'code', 'pre', 'hr'],
ALLOWED_ATTR: ['href', 'src', 'width', 'height', 'alt'],
KEEP_CONTENT: false,
ALLOW_DATA_ATTR: false
};

let cleanDescription;
try {
const rawDescription = marked(metadata.description);
cleanDescription = sanitizer(rawDescription, sanitizerConfig);
cleanDescription = parseMarkdown(metadata.description);
} catch (error) {
console.error(`Error parsing footer description: ${error}`);
cleanDescription = '<p>There was an error parsing the footer description.</p>';
Expand Down
20 changes: 16 additions & 4 deletions src/components/frequencies/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ import { axisBottom, axisLeft } from "d3-axis";
import { rgb } from "d3-color";
import { area } from "d3-shape";
import { format } from "d3-format";
import _range from "lodash/range";
import { dataFont } from "../../globalStyles";
import { unassigned_label } from "../../util/processFrequencies";
import { isColorByGenotype, decodeColorByGenotype } from "../../util/getGenotype";
import { numericToCalendar } from "../../util/dateHelpers";
import { createDisplayDate, calculateMajorGridSeperationForTime } from "../tree/phyloTree/grid";

/* C O N S T A N T S */
const opacity = 0.85;
Expand Down Expand Up @@ -52,11 +55,11 @@ const getOrderedCategories = (matrixCategories, colorScale) => {
return orderedCategories;
};

export const calcXScale = (chartGeom, pivots, ticks) => {
export const calcXScale = (chartGeom, pivots) => {
const x = scaleLinear()
.domain([pivots[0], pivots[pivots.length - 1]])
.range([chartGeom.spaceLeft, chartGeom.width - chartGeom.spaceRight]);
return {x, numTicksX: ticks.length};
return {x};
};

export const calcYScale = (chartGeom, maxY) => {
Expand All @@ -80,13 +83,22 @@ const removeProjectionInfo = (svg) => {
};

export const drawXAxis = (svg, chartGeom, scales) => {
const domain = scales.x.domain(),
range = scales.x.range();
const {majorStep} = calculateMajorGridSeperationForTime(
domain[1] - domain[0],
range[1] - range[0]
);
const customDate = (date) => createDisplayDate(majorStep, date);
removeXAxis(svg);
svg.append("g")
.attr("class", "x axis")
.attr("transform", `translate(0,${chartGeom.height - chartGeom.spaceBottom})`)
.style("font-family", dataFont)
.style("font-size", "12px")
.call(axisBottom(scales.x).ticks(scales.numTicksX, ".1f"));
.call(axisBottom(scales.x)
.tickValues(_range(domain[0], domain[1], majorStep))
.tickFormat(customDate));
};

export const drawYAxis = (svg, chartGeom, scales) => {
Expand Down Expand Up @@ -296,7 +308,7 @@ export const drawStream = (
.style("font-weight", 300)
.html(
`<p>${parseColorBy(colorBy, colorOptions)}: ${labels[i]}</p>
<p>${t("Time point")}: ${pivots[pivotIdx]}</p>
<p>${t("Time point")}: ${numericToCalendar(pivots[pivotIdx])}</p>
<p>${frequencyText}: ${freqVal}</p>`
);
}
Expand Down
3 changes: 1 addition & 2 deletions src/components/frequencies/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import "../../css/entropy.css";
return {
data: state.frequencies.data,
pivots: state.frequencies.pivots,
ticks: state.frequencies.ticks,
matrix: state.frequencies.matrix,
projection_pivot: state.frequencies.projection_pivot,
version: state.frequencies.version,
Expand All @@ -36,7 +35,7 @@ class Frequencies extends React.Component {
const data = processMatrix({...props});
newState.maxY = data.maxY;
newState.categories = data.categories;
const scalesX = calcXScale(chartGeom, props.pivots, props.ticks);
const scalesX = calcXScale(chartGeom, props.pivots);
const scalesY = calcYScale(chartGeom, data.maxY);
newState.scales = {...scalesX, ...scalesY};
drawXAxis(newState.svg, chartGeom, scalesX);
Expand Down
39 changes: 2 additions & 37 deletions src/components/narrative/MainDisplayMarkdown.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import React from "react";
import { connect } from "react-redux";
import marked from "marked";
import styled from 'styled-components';
import dompurify from "dompurify";
import { dataFont } from "../../globalStyles";

import { parseMarkdown } from "../../util/parseMarkdown";

/**
* The following code borrows heavily from the Footer
Expand Down Expand Up @@ -105,7 +103,7 @@ const Container = styled.div`
`;

const EXPERIMENTAL_MainDisplayMarkdown = ({narrativeBlock, width, mobile}) => {
const cleanHTML = mdToHtml(narrativeBlock.mainDisplayMarkdown);
const cleanHTML = parseMarkdown(narrativeBlock.mainDisplayMarkdown);
return (
<Container width={width} mobile={mobile}>
<div
Expand All @@ -120,36 +118,3 @@ const EXPERIMENTAL_MainDisplayMarkdown = ({narrativeBlock, width, mobile}) => {
export default connect((state) => ({
narrativeBlock: state.narrative.blocks[state.narrative.blockIdx]
}))(EXPERIMENTAL_MainDisplayMarkdown);

function mdToHtml(md) {
/* this is copy & pasted from `../framework/footer.js` and should be abstracted
into a function */
dompurify.addHook("afterSanitizeAttributes", (node) => {
// Set external links to open in a new tab
if ('href' in node && location.hostname !== node.hostname) {
node.setAttribute('target', '_blank');
node.setAttribute('rel', 'noreferrer nofollow');
}
// Find nodes that contain images and add imageContainer class to update styling
const nodeContainsImg = ([...node.childNodes].filter((child) => child.localName === 'img')).length > 0;
if (nodeContainsImg) {
// For special case of image links, set imageContainer on outer parent
if (node.localName === 'a') {
node.parentNode.className += ' imageContainer';
} else {
node.className += ' imageContainer';
}
}
});

const sanitizer = dompurify.sanitize;
const sanitizerConfig = {
ALLOWED_TAGS: ['div', 'h1', 'h2', 'h3', 'h4', 'h5', 'h6', 'p', 'em', 'strong', 'del', 'ol', 'ul', 'li', 'a', 'img', '#text', 'pre', 'hr', 'table', 'thead', 'tbody', 'th', 'tr', 'td'],
ALLOWED_ATTR: ['href', 'src', 'width', 'height', 'alt'],
KEEP_CONTENT: false,
ALLOW_DATA_ATTR: false
};
const rawDescription = marked(md);
const cleanDescription = sanitizer(rawDescription, sanitizerConfig);
return cleanDescription;
}
Loading