Skip to content
This repository has been archived by the owner on Nov 17, 2021. It is now read-only.

Commit

Permalink
fix(Demo): Generate examples standalone
Browse files Browse the repository at this point in the history
To avoid conflicts and confusion when example HTML has existing themes CSS and JS
  • Loading branch information
nokome committed Feb 12, 2020
1 parent bf12a60 commit a2eb9f1
Show file tree
Hide file tree
Showing 9 changed files with 9,444 additions and 9,675 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"postinstall": "npm run build:selectors",
"semantic-release": "semantic-release",
"test": "npm run test:build && npm run test:run",
"test:build": "parcel build ./src/examples/article-kitchen-sink.html -d test/build --public-url .",
"test:build": "parcel build ./src/index.html ./src/examples/*.html -d test/build --public-url .",
"test:run": "SAUCE_API_HOST=eu-central-1.saucelabs.com wdio",
"watch": "parcel watch ./src/**/*.css ./src/**/*.ts"
},
Expand Down
2 changes: 1 addition & 1 deletion src/demo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const exampleSet = async (example: string): Promise<void> => {

// Load the HTML content
const req = new XMLHttpRequest()
req.open('GET', `./${examples[example]}`, false)
req.open('GET', examples[example], false)
req.send(null)
const html = req.responseText

Expand Down
4 changes: 2 additions & 2 deletions src/demo/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ header {

.github {
img {
margin-left: 1rem;
margin: 0 0.5rem;
height: 24px;
width: 24px;
color: #777;
opacity: 0.4;
}
}
}
Expand Down
8,003 changes: 3,961 additions & 4,042 deletions src/examples/article-antibodies.html

Large diffs are not rendered by default.

10,171 changes: 5,028 additions & 5,143 deletions src/examples/article-drosophila.html

Large diffs are not rendered by default.

917 changes: 442 additions & 475 deletions src/examples/article-kitchen-sink.html

Large diffs are not rendered by default.

12 changes: 4 additions & 8 deletions src/examples/generate.sh
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
#!/bin/sh

# Generate article-kitchen-sink.html
npx encoda convert article-kitchen-sink.json article-kitchen-sink.html
npx encoda convert article-kitchen-sink.json article-kitchen-sink.html --standalone=false

# Generate article-drosophila.html
npx encoda convert https://elifesciences.org/articles/49574v2 article-drosophila.html
npx encoda convert https://elifesciences.org/articles/49574v2 article-drosophila.html --standalone=false

# Generate article-antibodies.html
npx encoda convert 'https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1007207' article-antibodies.html
npx encoda convert 'https://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1007207' article-antibodies.html --standalone=false

# Generate article-rmarkdown.html
# Temporarily excluded becuase, with removal of `coerce()` call from `xmd` codec
# the metadata is causing this to fail.
# curl -o rmarkdown.nb.html https://raw.githubusercontent.com/stencila/examples/master/rmarkdown/rmarkdown.nb.html
# npx encoda convert rmarkdown.nb.html --from rnb article-rmarkdown.html
# npx encoda convert rmarkdown.nb.html --from rnb article-rmarkdown.html --standalone=false
# rm rmarkdown.nb.html

# Replace unpkg Thema packages with local versions for development. Swapping out JavaScript files for TypeScript
perl -pi -w -e 's/https:\/\/unpkg.com\/\@stencila\/thema\@1\/dist\/(.+\/index)\.js/\.\.\/$1\.ts/g;' *.html
perl -pi -w -e 's/https:\/\/unpkg.com\/\@stencila\/thema\@1\/dist/\.\./g;' *.html
6 changes: 3 additions & 3 deletions src/examples/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export const examples: { [key: string]: string } = {
'article-kitchen-sink': '/examples/article-kitchen-sink.html',
'article-antibodies': '/examples/article-antibodies.html',
'article-drosophila': '/examples/article-drosophila.html'
'article-kitchen-sink': 'examples/article-kitchen-sink.html',
'article-antibodies': 'examples/article-antibodies.html',
'article-drosophila': 'examples/article-drosophila.html'
}
2 changes: 2 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@
class="theme"
rel="stylesheet"
href="./themes/stencila/styles.css"
disabled
/>
<link
id="skeleton"
class="theme"
rel="stylesheet"
href="./themes/skeleton/styles.css"
disabled
/>
</head>
<body>
Expand Down

0 comments on commit a2eb9f1

Please sign in to comment.