Skip to content
This repository has been archived by the owner on Jun 21, 2022. It is now read-only.

Commit

Permalink
Merge pull request #1126 from EB-Forks/refactor/use-mdn-data
Browse files Browse the repository at this point in the history
refactor(macros/CSS): Use `mdn‑data` as a node package
  • Loading branch information
escattone authored Jun 6, 2019
2 parents 3f1ab9f + 174ff0a commit fd3d002
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 71 deletions.
15 changes: 1 addition & 14 deletions macros/CSSAnimatedProperties.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,7 @@
// Read all CSSData and extract animated properties
var propertiesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/properties.json";
var atRulesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/at-rules.json";
var selectorsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/selectors.json";
var typesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/types.json";
var syntaxesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/syntaxes.json";
var unitsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/units.json";
var data = {
properties: await MDN.fetchJSONResource(propertiesUrl),
atRules: await MDN.fetchJSONResource(atRulesUrl),
selectors: await MDN.fetchJSONResource(selectorsUrl),
types: await MDN.fetchJSONResource(typesUrl),
syntaxes: await MDN.fetchJSONResource(syntaxesUrl),
units: await MDN.fetchJSONResource(unitsUrl)
};
var data = require('mdn-data/css');
var animatedProps = [];
// Go through all properties, and test if they are animated. If so, add them to
Expand Down
18 changes: 2 additions & 16 deletions macros/cssinfo.ejs → macros/CSSInfo.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,7 @@ let name = $0 || (slug ? slug.split("/").pop().toLowerCase() :
"preview-wiki-content");
let atRule = $1;
let propertiesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/properties.json";
let atRulesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/at-rules.json";
let selectorsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/selectors.json";
let typesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/types.json";
let syntaxesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/syntaxes.json";
let unitsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/units.json";
let localStringsUrl = "https://raw.githubusercontent.com/mdn/data/master/l10n/css.json";
let data = {
properties: await MDN.fetchJSONResource(propertiesUrl),
atRules: await MDN.fetchJSONResource(atRulesUrl),
selectors: await MDN.fetchJSONResource(selectorsUrl),
types: await MDN.fetchJSONResource(typesUrl),
syntaxes: await MDN.fetchJSONResource(syntaxesUrl),
units: await MDN.fetchJSONResource(unitsUrl)
};
var data = require('mdn-data/css');
let formattedError = "<span style=\"color:red;\">$1$</span>";
let commonLocalStrings = string.deserialize(await template("L10n:Common"));
let locale = env.locale;
Expand All @@ -37,7 +23,7 @@ let localWiki = wiki;
let currentPage = page;
let cssLocalStrings = string.deserialize(await template("L10n:CSS"));
let localStrings = await MDN.fetchJSONResource(localStringsUrl);
let localStrings = require('mdn-data/l10n/css');
/*
Creates a link to another API, e.g. a CSS property or SVG element
Expand Down
15 changes: 1 addition & 14 deletions macros/CSSRef.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,7 @@ if (slug) {
var htmlEscape = kuma.htmlEscape;
var rtlLocales = ['ar', 'he', 'fa'];
var propertiesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/properties.json";
var atRulesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/at-rules.json";
var selectorsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/selectors.json";
var typesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/types.json";
var syntaxesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/syntaxes.json";
var unitsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/units.json";
var data = {
properties: await MDN.fetchJSONResource(propertiesUrl),
atRules: await MDN.fetchJSONResource(atRulesUrl),
selectors: await MDN.fetchJSONResource(selectorsUrl),
types: await MDN.fetchJSONResource(typesUrl),
syntaxes: await MDN.fetchJSONResource(syntaxesUrl),
units: await MDN.fetchJSONResource(unitsUrl)
};
var data = require('mdn-data/css');
var commonl10n = string.deserialize(await template('L10n:Common'));
var cssl10n = string.deserialize(await template('L10n:CSS'));
Expand Down
16 changes: 3 additions & 13 deletions macros/csssyntax.ejs → macros/CSSSyntax.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,7 @@
$1 - @-rule - defaults to the @-rule within the URL
*/
let propertiesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/properties.json";
let atRulesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/at-rules.json";
let selectorsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/selectors.json";
let typesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/types.json";
let syntaxesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/syntaxes.json";
let unitsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/units.json";
const mdnDataCSS = require('mdn-data/css');
// List types for which we want to link to a description instead of
// including it in the formal syntax block
let s_named_color_link = mdn.localString({
Expand Down Expand Up @@ -43,13 +38,8 @@ let externallyDescribedTypesData = {
}
};
let data = {
properties: await MDN.fetchJSONResource(propertiesUrl),
atRules: await MDN.fetchJSONResource(atRulesUrl),
selectors: await MDN.fetchJSONResource(selectorsUrl),
types: await MDN.fetchJSONResource(typesUrl),
syntaxes: await MDN.fetchJSONResource(syntaxesUrl),
units: await MDN.fetchJSONResource(unitsUrl),
externallyDescribedTypes: externallyDescribedTypesData
...mdnDataCSS,
externallyDescribedTypes: externallyDescribedTypesData,
};
let slug = env.slug;
let locale = env.locale;
Expand Down
15 changes: 1 addition & 14 deletions macros/CSS_Ref.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,7 @@
defaults to ['standard'])
*/
var propertiesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/properties.json";
var atRulesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/at-rules.json";
var selectorsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/selectors.json";
var typesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/types.json";
var syntaxesUrl = "https://raw.githubusercontent.com/mdn/data/master/css/syntaxes.json";
var unitsUrl = "https://raw.githubusercontent.com/mdn/data/master/css/units.json";
var data = {
properties: await MDN.fetchJSONResource(propertiesUrl),
atRules: await MDN.fetchJSONResource(atRulesUrl),
selectors: await MDN.fetchJSONResource(selectorsUrl),
types: await MDN.fetchJSONResource(typesUrl),
syntaxes: await MDN.fetchJSONResource(syntaxesUrl),
units: await MDN.fetchJSONResource(unitsUrl)
};
var data = require('mdn-data/css');
var localStrings = string.deserialize(await template("L10n:Common"));
var types = ["properties", "selectors", "types", "syntaxes", "at-rules",
"descriptors", "units"];
Expand Down
5 changes: 5 additions & 0 deletions npm-shrinkwrap.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"express": "4.16",
"lru-cache": "5.1.1",
"mdn-browser-compat-data": "0.x",
"mdn-data": "2.x",
"morgan": "1.9.1",
"newrelic": "5.9.0",
"redis": "^2.8.0",
Expand Down

0 comments on commit fd3d002

Please sign in to comment.