Skip to content

Commit

Permalink
Added an injection step into translationPre.js that will only require…
Browse files Browse the repository at this point in the history
… available translation files (jestjs#3475)

Refactored how generate works to now call translatePre.js, translate.js, and convert.js

Fixed folder delete race condition

Add website building scripts to prettier

Fix prettier warnings

Fixes page next/prev routing, updates website pages in prettier

Localize page's browser title

Debugging fs failure

Change how it writes file to disk to create folder if missing
  • Loading branch information
ericnakagawa authored May 5, 2017
1 parent 2e1e1f1 commit 6f4a001
Show file tree
Hide file tree
Showing 19 changed files with 456 additions and 370 deletions.
66 changes: 33 additions & 33 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -25,39 +25,39 @@
/website/i18n/*
!/website/i18n/en.json

/website/af
/website/ar
/website/ca
/website/cs
/website/da
/website/de
/website/el
/website/es-ES
/website/fa-IR
/website/fi
/website/fr
/website/he
/website/hu
/website/id-ID
/website/it
/website/ja
/website/ko
/website/mr-IN
/website/nl
/website/no-NO
/website/pl
/website/pt-BR
/website/pt-PT
/website/ro
/website/ru
/website/sk-SK
/website/sr
/website/sv-SE
/website/tr
/website/uk
/website/vi
/website/zh-Hans
/website/zh-Hant
/website/src/jest/af
/website/src/jest/ar
/website/src/jest/ca
/website/src/jest/cs
/website/src/jest/da
/website/src/jest/de
/website/src/jest/el
/website/src/jest/es-ES
/website/src/jest/fa-IR
/website/src/jest/fi
/website/src/jest/fr
/website/src/jest/he
/website/src/jest/hu
/website/src/jest/id-ID
/website/src/jest/it
/website/src/jest/ja
/website/src/jest/ko
/website/src/jest/mr-IN
/website/src/jest/nl
/website/src/jest/no-NO
/website/src/jest/pl
/website/src/jest/pt-BR
/website/src/jest/pt-PT
/website/src/jest/ro
/website/src/jest/ru
/website/src/jest/sk-SK
/website/src/jest/sr
/website/src/jest/sv-SE
/website/src/jest/tr
/website/src/jest/uk
/website/src/jest/vi
/website/src/jest/zh-Hans
/website/src/jest/zh-Hant

/docs/*
!/docs/en
Expand Down
2 changes: 1 addition & 1 deletion docs/en/TestingFrameworks.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ id: testing-frameworks
title: Testing other frameworks
layout: docs
category: Guides
permalink: docs/testing-frameworks.html
permalink: docs/en/testing-frameworks.html
previous: migration-guide
next: troubleshooting
---
Expand Down
8 changes: 7 additions & 1 deletion scripts/prettier.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,13 @@ const config = {
options: {
'trailing-comma': 'es5',
},
patterns: ['examples/**/', 'scripts/**/', 'integration_tests/**/'],
patterns: [
'examples/**/',
'scripts/**/',
'integration_tests/**/',
'website/server/*',
'website/layout/*',
],
},
};

Expand Down
11 changes: 8 additions & 3 deletions website/core/JestIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@ const JestIndex = React.createClass({
</Container>
<div
className="productShowcaseSection paddingBottom"
style={{textAlign: 'center'}}
>
style={{textAlign: 'center'}}>
<h2>{siteConfig[language].featureCallout.title}</h2>
<Marked>
{siteConfig[language].featureCallout.content}
Expand Down Expand Up @@ -149,7 +148,13 @@ const JestIndex = React.createClass({
<a className="hash-link" href="#watch" />
<div className="blockElement imageAlignSide twoByGridBlock">
<div className="video">
<iframe width="560" height="315" src="https://www.youtube.com/embed/HAuXJVI_bUs?rel=0" frameborder="0" allowfullscreen></iframe>
<iframe
width="560"
height="315"
src="https://www.youtube.com/embed/HAuXJVI_bUs?rel=0"
frameBorder="0"
allowFullScreen
/>
</div>
<div className="blockContent">
<h2>{siteConfig[language].belowFold.watch.title}</h2>
Expand Down
6 changes: 4 additions & 2 deletions website/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,13 +96,15 @@
"tutorial-react": "Testing React Apps",
"tutorial-react-native": "Testing React Native Apps",
"using-matchers": "Using Matchers",
"webpack": "Using With Webpack"
"webpack": "Using With Webpack",
"previous": "Previous",
"next": "Continue Reading"
},
"promo": {
"get": "Get Started",
"learn": "Learn More",
"try": "Try Out Jest",
"watch": "Watch Talks",
"watch": "Watch Talks"
},
"repo": "facebook/jest",
"support": {
Expand Down
2 changes: 1 addition & 1 deletion website/languages.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const languages = [
tag: 'el',
},
{
enabled: false,
enabled: true,
name: 'Español',
tag: 'es-ES',
},
Expand Down
23 changes: 10 additions & 13 deletions website/layout/BlogPageLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* @jsx React.DOM
*/

/* eslint-disable max-len */
/* eslint-disable max-len */

const BlogPost = require('BlogPost');
const BlogSidebar = require('BlogSidebar');
Expand All @@ -27,16 +27,10 @@ const BlogPageLayout = React.createClass({
const perPage = this.props.metadata.perPage;
const page = this.props.metadata.page;
return (
<Site
section="blog"
title="Blog"
language="en"
>
<Site section="blog" title="Blog" language="en">
<div className="docMainWrapper wrapper">
<BlogSidebar language={this.props.language} />
<Container
className="mainContainer documentContainer postContainer blogContainer"
>
<Container className="mainContainer documentContainer postContainer blogContainer">
<div className="posts">
{MetadataBlog.files
.slice(page * perPage, (page + 1) * perPage)
Expand All @@ -49,13 +43,16 @@ const BlogPageLayout = React.createClass({
key={post.path + post.title}
/>
);
})
}
})}
<div className="docs-prevnext">
{page > 0 &&
<a className="docs-prev" href={this.getPageURL(page - 1)}>&larr; Prev</a>}
<a className="docs-prev" href={this.getPageURL(page - 1)}>
← Prev
</a>}
{MetadataBlog.files.length > (page + 1) * perPage &&
<a className="docs-next" href={this.getPageURL(page + 1)}>Next &rarr;</a>}
<a className="docs-next" href={this.getPageURL(page + 1)}>
Next →
</a>}
</div>
</div>
</Container>
Expand Down
3 changes: 2 additions & 1 deletion website/layout/BlogPostLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ const BlogPostLayout = React.createClass({
url={'blog/' + this.props.metadata.path}
title={this.props.metadata.title}
language={'en'}
description={this.props.children.trim().split('\n')[0]}>
description={this.props.children.trim().split('\n')[0]}
>
<div className="docMainWrapper wrapper">
<BlogSidebar language={'en'} current={this.props.metadata} />
<Container className="mainContainer documentContainer postContainer blogContainer">
Expand Down
53 changes: 40 additions & 13 deletions website/layout/DocsLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @providesModule DocsLayout
* @jsx React.DOM
*/
/* eslint-disable max-len */
/* eslint-disable max-len */

const React = require('React');
const Site = require('Site');
Expand All @@ -14,38 +14,65 @@ const siteConfig = require('../siteConfig.js');

const DocsLayout = React.createClass({
render() {

const metadata = this.props.metadata;
const content = this.props.children;
return (
<Site
className="sideNavVisible"
section="docs"
title={metadata.title}
title={
siteConfig[this.props.metadata.language]['localized-strings'][
this.props.metadata.localized_id
]
}
description={content.trim().split('\n')[0]}
language={metadata.language}
>
>
<div className="docMainWrapper wrapper">
<DocsSidebar metadata={metadata} />
<Container className="mainContainer">
<Doc content={content}
<Doc
content={content}
source={metadata.source}
title={siteConfig[this.props.metadata.language]['localized-strings'][this.props.metadata.localized_id]}
title={
siteConfig[this.props.metadata.language]['localized-strings'][
this.props.metadata.localized_id
]
}
language={metadata.language}
/>
<div className="docs-prevnext">
{metadata.previous && <a className="docs-prev button" href={stripLang(metadata.previous) + '.html#content'}>&larr; Previous</a>}
{metadata.next && <a className="docs-next button" href={stripLang(metadata.next) + '.html#content'}>Continue Reading &rarr;</a>}
{metadata.previous_id &&
<a
className="docs-prev button"
href={metadata.previous_id + '.html#content'}
>
{' '}
{
siteConfig[this.props.metadata.language][
'localized-strings'
]['previous']
}
</a>}
{metadata.next_id &&
<a
className="docs-next button"
href={metadata.next_id + '.html#content'}
>
{
siteConfig[this.props.metadata.language][
'localized-strings'
]['next']
}
{' '}
</a>}
</div>
</Container>
</div>
</Site>
);
},
});

function stripLang(s) {
return s.replace(/^[a-z]{2}-/, '');
}

module.exports = DocsLayout;
2 changes: 1 addition & 1 deletion website/layout/PageLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @providesModule PageLayout
* @jsx React.DOM
*/
/* eslint-disable max-len */
/* eslint-disable max-len */

const React = require('React');
const Site = require('Site');
Expand Down
28 changes: 15 additions & 13 deletions website/layout/RedirectLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @providesModule RedirectLayout
* @jsx React.DOM
*/
/* eslint-disable max-len */
/* eslint-disable max-len */

const React = require('React');

Expand All @@ -12,18 +12,20 @@ class RedirectLayout extends React.Component {

return (
<html>
<head>
<meta charSet="utf-8" />
<link rel="canonical" href={ destinationUrl } />
<meta httpEquiv="refresh" content={'0; url=' + destinationUrl} />
<title>Redirecting...</title>
</head>
<body>
<h1>Redirecting...</h1>
<a href={ destinationUrl }>Click here if you are not redirected.</a>
<script dangerouslySetInnerHTML={{__html: 'location=' + destinationUrl}} />
</body>
</html>
<head>
<meta charSet="utf-8" />
<link rel="canonical" href={destinationUrl} />
<meta httpEquiv="refresh" content={'0; url=' + destinationUrl} />
<title>Redirecting...</title>
</head>
<body>
<h1>Redirecting...</h1>
<a href={destinationUrl}>Click here if you are not redirected.</a>
<script
dangerouslySetInnerHTML={{__html: 'location=' + destinationUrl}}
/>
</body>
</html>
);
}
}
Expand Down
20 changes: 15 additions & 5 deletions website/layout/ReferenceLayout.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* @providesModule ReferenceLayout
* @jsx React.DOM
*/
/* eslint-disable max-len */
/* eslint-disable max-len */

const React = require('React');
const Site = require('Site');
Expand All @@ -21,12 +21,22 @@ const ReferenceLayout = React.createClass({
title={metadata.title}
description={content.trim().split('\n')[0]}
language={metadata.language}
>
>
<div className="docMainWrapper wrapper">
<DocsSidebar language={this.props.language} metadata={metadata} title="API" root="/jest/docs/api.html" layout="reference" />
<DocsSidebar
language={this.props.language}
metadata={metadata}
title="API"
root="/jest/docs/api.html"
layout="reference"
/>
<Container className="mainContainer referenceContainer">
<Doc content={content} source={metadata.source} language={metadata.language}
title={metadata.title} />
<Doc
content={content}
source={metadata.source}
language={metadata.language}
title={metadata.title}
/>
</Container>
</div>
</Site>
Expand Down
Loading

0 comments on commit 6f4a001

Please sign in to comment.