diff --git a/LICENSE b/LICENSE new file mode 100644 index 000000000000..774c15f3297b --- /dev/null +++ b/LICENSE @@ -0,0 +1,30 @@ +BSD License + +For Docusaurus software + +Copyright (c) 2017-present, Facebook, Inc. All rights reserved. + +Redistribution and use in source and binary forms, with or without modification, +are permitted provided that the following conditions are met: + + * Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + + * Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + + * Neither the name Facebook nor the names of its contributors may be used to + endorse or promote products derived from this software without specific + prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR +ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON +ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/PATENTS b/PATENTS new file mode 100644 index 000000000000..d4602119b86a --- /dev/null +++ b/PATENTS @@ -0,0 +1,33 @@ +Additional Grant of Patent Rights Version 2 + +"Software" means the Docusaurus software contributed by Facebook, Inc. + +Facebook, Inc. ("Facebook") hereby grants to each recipient of the Software +("you") a perpetual, worldwide, royalty-free, non-exclusive, irrevocable +(subject to the termination provision below) license under any Necessary +Claims, to make, have made, use, sell, offer to sell, import, and otherwise +transfer the Software. For avoidance of doubt, no license is granted under +Facebook’s rights in any patent claims that are infringed by (i) modifications +to the Software made by you or any third party or (ii) the Software in +combination with any software or other technology. + +The license granted hereunder will terminate, automatically and without notice, +if you (or any of your subsidiaries, corporate affiliates or agents) initiate +directly or indirectly, or take a direct financial interest in, any Patent +Assertion: (i) against Facebook or any of its subsidiaries or corporate +affiliates, (ii) against any party if such Patent Assertion arises in whole or +in part from any software, technology, product or service of Facebook or any of +its subsidiaries or corporate affiliates, or (iii) against any party relating +to the Software. Notwithstanding the foregoing, if Facebook or any of its +subsidiaries or corporate affiliates files a lawsuit alleging patent +infringement against you in the first instance, and you respond by filing a +patent infringement counterclaim in that lawsuit against that party that is +unrelated to the Software, the license granted hereunder will not terminate +under section (i) of this paragraph due to such counterclaim. + +A "Necessary Claim" is a claim of a patent owned by Facebook that is +necessarily infringed by the Software standing alone. + +A "Patent Assertion" is any lawsuit or other action alleging direct, indirect, +or contributory infringement or inducement to infringe any patent, including a +cross-claim or counterclaim. diff --git a/examples/core/Footer.js b/examples/core/Footer.js index 1a2a4d944577..958e44161941 100644 --- a/examples/core/Footer.js +++ b/examples/core/Footer.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require("react"); const githubButton = ( diff --git a/examples/languages.js b/examples/languages.js index 38f07528690b..da8b56a10d18 100644 --- a/examples/languages.js +++ b/examples/languages.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const languages = [ { enabled: false, diff --git a/examples/pages/en/help.js b/examples/pages/en/help.js index fe9ee0129726..6c3ce1cedccf 100755 --- a/examples/pages/en/help.js +++ b/examples/pages/en/help.js @@ -1,3 +1,11 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ const React = require("react"); const CompLibrary = require("../../core/CompLibrary.js"); diff --git a/examples/pages/en/index.js b/examples/pages/en/index.js index f4124ce9417a..b4dcd6998e8b 100755 --- a/examples/pages/en/index.js +++ b/examples/pages/en/index.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require("react"); const CompLibrary = require("../../core/CompLibrary.js"); diff --git a/examples/pages/en/users.js b/examples/pages/en/users.js index f3ec586b4697..e189ab4e4d19 100644 --- a/examples/pages/en/users.js +++ b/examples/pages/en/users.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require("react"); const CompLibrary = require("../../core/CompLibrary.js"); diff --git a/examples/siteConfig.js b/examples/siteConfig.js index 52375822f815..23ab4a9cbecd 100644 --- a/examples/siteConfig.js +++ b/examples/siteConfig.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const fs = require("fs"); /* List of projects/orgs using your project for the users page */ diff --git a/lib/build-files.js b/lib/build-files.js index 9545023f067d..0b4a6235957b 100644 --- a/lib/build-files.js +++ b/lib/build-files.js @@ -1,5 +1,14 @@ #!/usr/bin/env node +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + require('babel-register') ({ ignore: false, "presets": ["react"] diff --git a/lib/copy-examples.js b/lib/copy-examples.js index 3273626632a2..ba54b1265760 100644 --- a/lib/copy-examples.js +++ b/lib/copy-examples.js @@ -1,6 +1,15 @@ #!/usr/bin/env node +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const CWD = process.cwd(); const fs = require('fs-extra'); -fs.copySync(__dirname + '/../examples/', CWD, {overwrite: false}); \ No newline at end of file +fs.copySync(__dirname + '/../examples/', CWD, {overwrite: false}); diff --git a/lib/core/BlogPageLayout.js b/lib/core/BlogPageLayout.js index ac34b022caff..0a180c38a5b2 100644 --- a/lib/core/BlogPageLayout.js +++ b/lib/core/BlogPageLayout.js @@ -1,4 +1,13 @@ -const BlogPost = require('./BlogPost.js'); +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + const BlogPost = require('./BlogPost.js'); const BlogSidebar = require('./BlogSidebar.js'); const Container = require('./Container.js'); const MetadataBlog = require('./MetadataBlog.js'); @@ -54,4 +63,4 @@ const BlogPageLayout = React.createClass({ }, }); -module.exports = BlogPageLayout; \ No newline at end of file +module.exports = BlogPageLayout; diff --git a/lib/core/BlogPost.js b/lib/core/BlogPost.js index 7a11b8cd3879..c4df3e7440ae 100644 --- a/lib/core/BlogPost.js +++ b/lib/core/BlogPost.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const Marked = require('./Marked.js'); const React = require('react'); @@ -95,4 +104,4 @@ class BlogPost extends React.Component { } } -module.exports = BlogPost; \ No newline at end of file +module.exports = BlogPost; diff --git a/lib/core/BlogPostLayout.js b/lib/core/BlogPostLayout.js index 3086d0f95106..04c0f2d9f966 100644 --- a/lib/core/BlogPostLayout.js +++ b/lib/core/BlogPostLayout.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require('react'); const BlogPost = require('./BlogPost.js'); const BlogSidebar = require('./BlogSidebar.js'); @@ -34,4 +43,4 @@ class BlogPostLayout extends React.Component { } } -module.exports = BlogPostLayout; \ No newline at end of file +module.exports = BlogPostLayout; diff --git a/lib/core/BlogSidebar.js b/lib/core/BlogSidebar.js index fa477135e53d..bec1e6571792 100644 --- a/lib/core/BlogSidebar.js +++ b/lib/core/BlogSidebar.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require('react'); const Container = require('./Container.js'); const SideNav = require('./nav/SideNav.js'); @@ -29,4 +38,4 @@ class BlogSidebar extends React.Component { } } -module.exports = BlogSidebar; \ No newline at end of file +module.exports = BlogSidebar; diff --git a/lib/core/CompLibrary.js b/lib/core/CompLibrary.js index e016e234b851..3f019d75493e 100644 --- a/lib/core/CompLibrary.js +++ b/lib/core/CompLibrary.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const Marked = require('./Marked.js'); const Container = require('./Container.js'); const GridBlock = require('./GridBlock.js'); @@ -6,4 +15,4 @@ module.exports = { Marked: Marked, Container: Container, GridBlock: GridBlock -} \ No newline at end of file +} diff --git a/lib/core/Container.js b/lib/core/Container.js index fc559b179d4b..34fcada0918f 100644 --- a/lib/core/Container.js +++ b/lib/core/Container.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require('react'); const classNames = require('classnames'); @@ -35,4 +44,4 @@ Container.defaultProps = { wrapper: true, }; -module.exports = Container; \ No newline at end of file +module.exports = Container; diff --git a/lib/core/Doc.js b/lib/core/Doc.js index 20656f3e9769..4ba4d5954ec0 100644 --- a/lib/core/Doc.js +++ b/lib/core/Doc.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require('react'); const Marked = require('./Marked.js'); @@ -31,4 +40,4 @@ class Doc extends React.Component { } } -module.exports = Doc; \ No newline at end of file +module.exports = Doc; diff --git a/lib/core/DocsLayout.js b/lib/core/DocsLayout.js index 29d6ac3aa38e..089d1234809c 100644 --- a/lib/core/DocsLayout.js +++ b/lib/core/DocsLayout.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require('react'); const Container = require('./Container.js'); const Doc = require('./Doc.js'); diff --git a/lib/core/DocsSidebar.js b/lib/core/DocsSidebar.js index 849f423ee0ce..ac85f3bdefff 100644 --- a/lib/core/DocsSidebar.js +++ b/lib/core/DocsSidebar.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const Metadata = require('./metadata.js'); const React = require('react'); const Container = require('./Container.js'); diff --git a/lib/core/Footer.js b/lib/core/Footer.js index 67fa05cc8040..972fd46fe12e 100644 --- a/lib/core/Footer.js +++ b/lib/core/Footer.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require('react'); const githubButton = ( @@ -43,7 +52,7 @@ class Footer extends React.Component { > Guides (or other categories) - - {this.props.config.algolia && + {this.props.config.algolia &&
  • diff --git a/lib/core/nav/SideNav.js b/lib/core/nav/SideNav.js index d1eba8566329..7ffa3c006619 100644 --- a/lib/core/nav/SideNav.js +++ b/lib/core/nav/SideNav.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const React = require('react'); const classNames = require('classnames'); @@ -47,17 +56,17 @@ class SideNav extends React.Component { } getLocalizedCategoryString(category) { let categoryString = - siteConfig[this.props.language] ? - siteConfig[this.props.language]['localized-strings'][category] || category + siteConfig[this.props.language] ? + siteConfig[this.props.language]['localized-strings'][category] || category : category; return categoryString; } getLocalizedString(metadata) { let localizedString = - siteConfig[this.props.language] ? + siteConfig[this.props.language] ? siteConfig[this.props.language]['localized-strings'][metadata.localized_id] || metadata.title : metadata.title; - + return localizedString; } getLink(metadata) { diff --git a/lib/core/toSlug.js b/lib/core/toSlug.js index 578696603833..e4f816b04b24 100644 --- a/lib/core/toSlug.js +++ b/lib/core/toSlug.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + module.exports = string => { // var accents = "àáäâèéëêìíïîòóöôùúüûñç"; const accents = '\u00e0\u00e1\u00e4\u00e2\u00e8' diff --git a/lib/core/unindent.js b/lib/core/unindent.js index b53f7a32c63c..8c05b267a26e 100644 --- a/lib/core/unindent.js +++ b/lib/core/unindent.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + // Remove the indentation introduced by JSX function unindent(code) { const lines = code.split('\n'); diff --git a/lib/publish-gh-pages.js b/lib/publish-gh-pages.js index fc0284a9ccbc..e3de7212cf8c 100644 --- a/lib/publish-gh-pages.js +++ b/lib/publish-gh-pages.js @@ -1,5 +1,14 @@ #!/usr/bin/env node +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const shell = require('shelljs'); const GIT_USER = process.env.GIT_USER; @@ -60,4 +69,3 @@ if (shell.exec('git push origin gh-pages').code !== 0) { shell.echo(`Website is live at: https://${CIRCLE_PROJECT_USERNAME}.github.io/${CIRCLE_PROJECT_REPONAME}/`); shell.exit(0); } - diff --git a/lib/server/generate.js b/lib/server/generate.js index e056a6df0d26..35ddbbaaf2b4 100644 --- a/lib/server/generate.js +++ b/lib/server/generate.js @@ -1,4 +1,13 @@ -function execute() { +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + function execute() { const translation = require('./translation.js'); translation(); @@ -72,7 +81,7 @@ function execute() { layouts[layout] = true; readCategories(layout); } - } + } const DocsLayout = require('../core/DocsLayout.js'); @@ -108,7 +117,7 @@ function execute() { /* replace any links to markdown files to their website html links */ Object.keys(mdToHtml).forEach(function(key, index) { rawContent = rawContent.replace(new RegExp(key,'g'), mdToHtml[key]); - }); + }); const docComp = {rawContent}; const str = renderToStaticMarkup(docComp); @@ -185,18 +194,18 @@ function execute() { } else if (!fs.lstatSync(file).isDirectory()) { mkdirp.sync(targetFile.replace(new RegExp('/[^/]*$'), '')); - fs.copySync(file, targetFile); + fs.copySync(file, targetFile); } }); /* copy all static files from user */ files = glob.sync(CWD + '/static/**'); files.forEach(file => { - if (file.match(/\.css$/)) { + if (file.match(/\.css$/)) { const mainCss = __dirname + '/../../build' + '/' + siteConfig.projectName + '/' + 'css/main.css'; let cssContent = fs.readFileSync(file); cssContent = fs.readFileSync(mainCss) + '\n' + cssContent; - + cssContent = cssContent.toString().replace(new RegExp('{primaryColor}', 'g'), siteConfig.colors.primaryColor); cssContent = cssContent.replace(new RegExp('{secondaryColor}', 'g'), siteConfig.colors.secondaryColor); cssContent = cssContent.replace(new RegExp('{prismColor}', 'g'), siteConfig.colors.prismColor); @@ -237,7 +246,7 @@ function execute() { writeFileAndCreateFolder(targetFile, str); fs.removeSync(tempFile); - } + } else if (!fs.lstatSync(file).isDirectory()) { let parts = file.split('pages'); let targetFile = __dirname + '/../../build' + '/' + siteConfig.projectName + '/' + parts[1]; diff --git a/lib/server/readCategories.js b/lib/server/readCategories.js index 6ad2fa36ed70..3d5b9d6bceb7 100644 --- a/lib/server/readCategories.js +++ b/lib/server/readCategories.js @@ -1,4 +1,13 @@ -const CWD = process.cwd(); +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + const CWD = process.cwd(); const Metadata = require('../core/metadata.js'); const fs = require('fs'); @@ -84,8 +93,8 @@ function readCategories(layout) { fs.writeFileSync( __dirname + '/../core/' + layout + 'Categories.js', '/**\n' + - ' * @generated\n' + - ' */\n' + + ' * @generated\n' + + ' */\n' + 'module.exports = ' + JSON.stringify(allCategories, null, 2) + ';' diff --git a/lib/server/readMetadata.js b/lib/server/readMetadata.js index e63fa6af2935..bd0bf5be82dc 100644 --- a/lib/server/readMetadata.js +++ b/lib/server/readMetadata.js @@ -1,4 +1,13 @@ -const CWD = process.cwd(); +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + const CWD = process.cwd(); const path = require('path'); const fs = require('fs'); @@ -94,7 +103,7 @@ function generateDocsMetadata() { const metadatas = []; - const files = glob.sync(CWD + '/../docs/**'); + const files = glob.sync(CWD + '/../docs/**'); files.forEach(file => { let language = 'en'; const match = regexSubFolder.exec(file); @@ -154,13 +163,13 @@ function generateBlogMetadata() { metadata.id = metadata.title; metadatas.push(metadata); }); - + fs.writeFileSync( __dirname + '/../core/MetadataBlog.js', '/**\n' + ' * @generated\n' + ' */\n' + - 'module.exports = ' + + 'module.exports = ' + JSON.stringify(metadatas, null, 2) + ';' ); diff --git a/lib/server/server.js b/lib/server/server.js index 4f4bbfb0309b..cc8acac1fd56 100644 --- a/lib/server/server.js +++ b/lib/server/server.js @@ -1,4 +1,13 @@ -function execute () { +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + + function execute () { const translation = require('./translation.js'); translation(); const CWD = process.cwd(); @@ -70,7 +79,7 @@ function execute () { Metadata = require('../core/metadata.js'); purgeCache('./readCategories.js'); readCategories = require('./readCategories.js'); - + let layouts = {}; for (let i = 0; i < Metadata.length; i++) { let layout = Metadata[i].layout; @@ -136,7 +145,7 @@ function execute () { const metadata = result.metadata; const language = metadata.language; let rawContent = result.rawContent; - + /* generate table of contents if appropriate */ if (rawContent && rawContent.indexOf(TABLE_OF_CONTENTS_TOKEN) !== -1) { rawContent = insertTableOfContents(rawContent); @@ -145,7 +154,7 @@ function execute () { /* replace any links to markdown files to their website html links */ Object.keys(mdToHtml).forEach(function(key, index) { rawContent = rawContent.replace(new RegExp(key,'g'), mdToHtml[key]); - }); + }); purgeCache('../core/DocsLayout.js'); const DocsLayout = require('../core/DocsLayout.js'); @@ -158,7 +167,7 @@ function execute () { purgeCache(CWD + '/siteConfig.js'); siteConfig = require(CWD + '/siteConfig.js'); - + if (fs.existsSync(__dirname + '../core/MetadataBlog.js')) { purgeCache('../core/MetadataBlog.js'); fs.removeSync(__dirname + '../core/MetadataBlog.js') @@ -185,7 +194,7 @@ function execute () { let path = (page > 0 ? 'page' + (page + 1) : '') + '/index.html'; blogPages[path] = str; } - + let parts = req.path.toString().split('blog/'); // send corresponding blog page if appropriate if (parts[1] === 'index.html') { @@ -193,7 +202,7 @@ function execute () { } else if (parts[1].endsWith('/index.html')) { res.send(blogPages[parts[1]]); - } + } else if (parts[1].match(/page([0-9]+)/)) { if (parts[1].endsWith('/')) { res.send(blogPages[parts[1] + 'index.html']); @@ -206,7 +215,7 @@ function execute () { let file = parts[1]; file = file.replace(/\.html$/, '.md'); file = file.replace(new RegExp('/', 'g'), '-'); - file = CWD + '/../blog/' + file; + file = CWD + '/../blog/' + file; const result = readMetadata.extractMetadata(fs.readFileSync(file, {encoding: 'utf8'})); const rawContent = result.rawContent; @@ -229,7 +238,7 @@ function execute () { /* handle all other main pages */ app.get('*.html', (req, res) => { purgeCache(CWD + '/siteConfig.js'); - siteConfig = require(CWD + '/siteConfig.js'); + siteConfig = require(CWD + '/siteConfig.js'); console.log(req.path); @@ -262,7 +271,7 @@ function execute () { } if (fs.existsSync(userFile) || fs.existsSync(userFile=userFile.replace(path.basename(userFile), 'en/' + path.basename(userFile)))) { - + /* copy into docusaurus so require paths work */ let parts = userFile.split('pages/'); let tempFile = __dirname + '/../pages/' + parts[1]; @@ -281,7 +290,7 @@ function execute () { res.send(str); } - + else { console.log(req.path); res.send('No file found'); @@ -305,11 +314,11 @@ function execute () { res.send(cssContent); }); - + /* serve static content first from user folder then from docusaurus */ app.use(siteConfig.baseUrl, express.static(CWD + '/static')); app.use(siteConfig.baseUrl, express.static(__dirname + '/../static')); - + app.get(/\/[^\.]*\/?$/, (req, res) => { if (req.path.toString().endsWith('/')) { request.get('http://localhost:3000' + req.path + 'index.html', (err, response, body) => { @@ -322,7 +331,7 @@ function execute () { if (!err) { res.send(body); } - }); + }); } }); diff --git a/lib/server/translation.js b/lib/server/translation.js index 411059a8325b..9ea86eecb4b8 100644 --- a/lib/server/translation.js +++ b/lib/server/translation.js @@ -1,3 +1,12 @@ +/** + * Copyright (c) 20__-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + const CWD = process.cwd(); const fs = require('fs-extra'); const glob = require('glob'); @@ -61,7 +70,7 @@ function injectContent() { const language = match[1]; languages.push(language); } - }); + }); let injectedContent = ''; languages.filter(language => language != 'en').forEach(language => { diff --git a/lib/start-server.js b/lib/start-server.js index b6781c52a4cb..0a91ae59f0b2 100644 --- a/lib/start-server.js +++ b/lib/start-server.js @@ -1,9 +1,18 @@ #!/usr/bin/env node +/** + * Copyright (c) 2017-present, Facebook, Inc. + * All rights reserved. + * + * This source code is licensed under the BSD-style license found in the + * LICENSE file in the root directory of this source tree. An additional grant + * of patent rights can be found in the PATENTS file in the same directory. + */ + require('babel-register') ({ ignore: false, "presets": ["react"] }); const server = require('./server/server.js'); -server(); \ No newline at end of file +server();