diff --git a/examples/blog-examples-from-docusaurus/2016-03-11-blog-post.md b/examples/basics/blog-examples-from-docusaurus/2016-03-11-blog-post.md similarity index 98% rename from examples/blog-examples-from-docusaurus/2016-03-11-blog-post.md rename to examples/basics/blog-examples-from-docusaurus/2016-03-11-blog-post.md index eb9597895c..cf2ba29606 100755 --- a/examples/blog-examples-from-docusaurus/2016-03-11-blog-post.md +++ b/examples/basics/blog-examples-from-docusaurus/2016-03-11-blog-post.md @@ -2,7 +2,7 @@ title: Blog Title author: Blog Author authorURL: http://twitter.com/ -authorFBID: 0 +authorFBID: 100002976521003 --- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus elementum massa eget nulla aliquet sagittis. Proin odio tortor, vulputate ut odio in, ultrices ultricies augue. Cras ornare ultrices lorem malesuada iaculis. Etiam sit amet libero tempor, pulvinar mauris sed, sollicitudin sapien. @@ -15,4 +15,4 @@ Nulla facilisi. Maecenas sodales nec purus eget posuere. Sed sapien quam, pretiu Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin venenatis lectus dui, vel ultrices ante bibendum hendrerit. Aenean egestas feugiat dui id hendrerit. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Curabitur in tellus laoreet, eleifend nunc id, viverra leo. Proin vulputate non dolor vel vulputate. Curabitur pretium lobortis felis, sit amet finibus lorem suscipit ut. Sed non mollis risus. Duis sagittis, mi in euismod tincidunt, nunc mauris vestibulum urna, at euismod est elit quis erat. Phasellus accumsan vitae neque eu placerat. In elementum arcu nec tellus imperdiet, eget maximus nulla sodales. Curabitur eu sapien eget nisl sodales fermentum. -Phasellus pulvinar ex id commodo imperdiet. Praesent odio nibh, sollicitudin sit amet faucibus id, placerat at metus. Donec vitae eros vitae tortor hendrerit finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque vitae purus dolor. Duis suscipit ac nulla et finibus. Phasellus ac sem sed dui dictum gravida. Phasellus eleifend vestibulum facilisis. Integer pharetra nec enim vitae mattis. Duis auctor, lectus quis condimentum bibendum, nunc dolor aliquam massa, id bibendum orci velit quis magna. Ut volutpat nulla nunc, sed interdum magna condimentum non. Sed urna metus, scelerisque vitae consectetur a, feugiat quis magna. Donec dignissim ornare nisl, eget tempor risus malesuada quis. \ No newline at end of file +Phasellus pulvinar ex id commodo imperdiet. Praesent odio nibh, sollicitudin sit amet faucibus id, placerat at metus. Donec vitae eros vitae tortor hendrerit finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque vitae purus dolor. Duis suscipit ac nulla et finibus. Phasellus ac sem sed dui dictum gravida. Phasellus eleifend vestibulum facilisis. Integer pharetra nec enim vitae mattis. Duis auctor, lectus quis condimentum bibendum, nunc dolor aliquam massa, id bibendum orci velit quis magna. Ut volutpat nulla nunc, sed interdum magna condimentum non. Sed urna metus, scelerisque vitae consectetur a, feugiat quis magna. Donec dignissim ornare nisl, eget tempor risus malesuada quis. diff --git a/examples/blog-examples-from-docusaurus/2017-04-10-blog-post-two.md b/examples/basics/blog-examples-from-docusaurus/2017-04-10-blog-post-two.md similarity index 98% rename from examples/blog-examples-from-docusaurus/2017-04-10-blog-post-two.md rename to examples/basics/blog-examples-from-docusaurus/2017-04-10-blog-post-two.md index 35aeaece6d..3ab4637bd5 100644 --- a/examples/blog-examples-from-docusaurus/2017-04-10-blog-post-two.md +++ b/examples/basics/blog-examples-from-docusaurus/2017-04-10-blog-post-two.md @@ -2,7 +2,7 @@ title: New Blog Post author: Blog Author authorURL: http://twitter.com/ -authorFBID: 0 +authorFBID: 100002976521003 --- Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque elementum dignissim ultricies. Fusce rhoncus ipsum tempor eros aliquam consequat. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus elementum massa eget nulla aliquet sagittis. Proin odio tortor, vulputate ut odio in, ultrices ultricies augue. Cras ornare ultrices lorem malesuada iaculis. Etiam sit amet libero tempor, pulvinar mauris sed, sollicitudin sapien. @@ -15,4 +15,4 @@ Nulla facilisi. Maecenas sodales nec purus eget posuere. Sed sapien quam, pretiu Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Proin venenatis lectus dui, vel ultrices ante bibendum hendrerit. Aenean egestas feugiat dui id hendrerit. Orci varius natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Curabitur in tellus laoreet, eleifend nunc id, viverra leo. Proin vulputate non dolor vel vulputate. Curabitur pretium lobortis felis, sit amet finibus lorem suscipit ut. Sed non mollis risus. Duis sagittis, mi in euismod tincidunt, nunc mauris vestibulum urna, at euismod est elit quis erat. Phasellus accumsan vitae neque eu placerat. In elementum arcu nec tellus imperdiet, eget maximus nulla sodales. Curabitur eu sapien eget nisl sodales fermentum. -Phasellus pulvinar ex id commodo imperdiet. Praesent odio nibh, sollicitudin sit amet faucibus id, placerat at metus. Donec vitae eros vitae tortor hendrerit finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque vitae purus dolor. Duis suscipit ac nulla et finibus. Phasellus ac sem sed dui dictum gravida. Phasellus eleifend vestibulum facilisis. Integer pharetra nec enim vitae mattis. Duis auctor, lectus quis condimentum bibendum, nunc dolor aliquam massa, id bibendum orci velit quis magna. Ut volutpat nulla nunc, sed interdum magna condimentum non. Sed urna metus, scelerisque vitae consectetur a, feugiat quis magna. Donec dignissim ornare nisl, eget tempor risus malesuada quis. \ No newline at end of file +Phasellus pulvinar ex id commodo imperdiet. Praesent odio nibh, sollicitudin sit amet faucibus id, placerat at metus. Donec vitae eros vitae tortor hendrerit finibus. Interdum et malesuada fames ac ante ipsum primis in faucibus. Quisque vitae purus dolor. Duis suscipit ac nulla et finibus. Phasellus ac sem sed dui dictum gravida. Phasellus eleifend vestibulum facilisis. Integer pharetra nec enim vitae mattis. Duis auctor, lectus quis condimentum bibendum, nunc dolor aliquam massa, id bibendum orci velit quis magna. Ut volutpat nulla nunc, sed interdum magna condimentum non. Sed urna metus, scelerisque vitae consectetur a, feugiat quis magna. Donec dignissim ornare nisl, eget tempor risus malesuada quis. diff --git a/examples/core/Footer.js b/examples/basics/core/Footer.js similarity index 100% rename from examples/core/Footer.js rename to examples/basics/core/Footer.js diff --git a/examples/docs-examples-from-docusaurus/en/doc1.md b/examples/basics/docs-examples-from-docusaurus/doc1.md similarity index 100% rename from examples/docs-examples-from-docusaurus/en/doc1.md rename to examples/basics/docs-examples-from-docusaurus/doc1.md diff --git a/examples/docs-examples-from-docusaurus/en/doc2.md b/examples/basics/docs-examples-from-docusaurus/doc2.md similarity index 100% rename from examples/docs-examples-from-docusaurus/en/doc2.md rename to examples/basics/docs-examples-from-docusaurus/doc2.md diff --git a/examples/docs-examples-from-docusaurus/en/doc3.md b/examples/basics/docs-examples-from-docusaurus/doc3.md similarity index 100% rename from examples/docs-examples-from-docusaurus/en/doc3.md rename to examples/basics/docs-examples-from-docusaurus/doc3.md diff --git a/examples/docs-examples-from-docusaurus/en/exampledoc4.md b/examples/basics/docs-examples-from-docusaurus/exampledoc4.md similarity index 100% rename from examples/docs-examples-from-docusaurus/en/exampledoc4.md rename to examples/basics/docs-examples-from-docusaurus/exampledoc4.md diff --git a/examples/docs-examples-from-docusaurus/en/exampledoc5.md b/examples/basics/docs-examples-from-docusaurus/exampledoc5.md similarity index 100% rename from examples/docs-examples-from-docusaurus/en/exampledoc5.md rename to examples/basics/docs-examples-from-docusaurus/exampledoc5.md diff --git a/examples/pages/en/help.js b/examples/basics/pages/en/help.js similarity index 97% rename from examples/pages/en/help.js rename to examples/basics/pages/en/help.js index 002c46f78c..0782693e6e 100755 --- a/examples/pages/en/help.js +++ b/examples/basics/pages/en/help.js @@ -16,6 +16,7 @@ const GridBlock = CompLibrary.GridBlock; const siteConfig = require(process.cwd() + "/siteConfig.js"); class Help extends React.Component { + render() { const supportLinks = [ { @@ -49,8 +50,4 @@ class Help extends React.Component { } } -Help.defaultProps = { - language: "en" -}; - module.exports = Help; diff --git a/examples/pages/en/index.js b/examples/basics/pages/en/index.js similarity index 92% rename from examples/pages/en/index.js rename to examples/basics/pages/en/index.js index 59461769f7..c4aacd7893 100755 --- a/examples/pages/en/index.js +++ b/examples/basics/pages/en/index.js @@ -44,7 +44,9 @@ class HomeSplash extends React.Component {

{siteConfig.title} - {siteConfig.tagline} + + {siteConfig.tagline} +

@@ -52,14 +54,20 @@ class HomeSplash extends React.Component {
diff --git a/examples/pages/en/users.js b/examples/basics/pages/en/users.js similarity index 97% rename from examples/pages/en/users.js rename to examples/basics/pages/en/users.js index e5d9f16b42..0daa73e49e 100644 --- a/examples/pages/en/users.js +++ b/examples/basics/pages/en/users.js @@ -49,8 +49,4 @@ class Users extends React.Component { } } -Users.defaultProps = { - language: "en" -}; - module.exports = Users; diff --git a/examples/sidebar.json b/examples/basics/sidebars.json similarity index 100% rename from examples/sidebar.json rename to examples/basics/sidebars.json diff --git a/examples/basics/siteConfig.js b/examples/basics/siteConfig.js new file mode 100644 index 0000000000..accc9e4abf --- /dev/null +++ b/examples/basics/siteConfig.js @@ -0,0 +1,46 @@ +/** + * 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. + */ + +/* List of projects/orgs using your project for the users page */ +const users = [ + { + caption: "User1", + image: "/test-site/img/docusaurus.svg", + infoLink: "https://www.example.com", + pinned: true + } +]; + +const siteConfig = { + title: "Test Site" /* title for your website */, + tagline: "A website for testing", + url: "https://deltice.github.io" /* your github url */, + baseUrl: "/test-site/" /* base url for your project */, + projectName: "test-site", + headerLinks: [ + { doc: "doc1", label: "Docs" }, + { doc: "doc4", label: "API" }, + { page: "help", label: "Help" }, + { blog: true, label: "Blog" } + ], + users, + /* path to images for header/footer */ + headerIcon: "img/docusaurus.svg", + footerIcon: "img/docusaurus.svg", + favicon: "img/favicon.png", + /* colors for website */ + colors: { + primaryColor: "#2E8555", + secondaryColor: "#205C3B", + prismColor: + "rgba(46, 133, 85, 0.03)" /* primaryColor in rgba form, with 0.03 alpha */ + } +}; + +module.exports = siteConfig; diff --git a/examples/static/img/docusaurus.svg b/examples/basics/static/img/docusaurus.svg similarity index 100% rename from examples/static/img/docusaurus.svg rename to examples/basics/static/img/docusaurus.svg diff --git a/examples/static/img/favicon.png b/examples/basics/static/img/favicon.png similarity index 100% rename from examples/static/img/favicon.png rename to examples/basics/static/img/favicon.png diff --git a/examples/static/img/favicon/favicon.ico b/examples/basics/static/img/favicon/favicon.ico similarity index 100% rename from examples/static/img/favicon/favicon.ico rename to examples/basics/static/img/favicon/favicon.ico diff --git a/examples/static/img/oss_logo.png b/examples/basics/static/img/oss_logo.png similarity index 100% rename from examples/static/img/oss_logo.png rename to examples/basics/static/img/oss_logo.png diff --git a/examples/siteConfig.js b/examples/siteConfig.js deleted file mode 100644 index 48e7d132c0..0000000000 --- a/examples/siteConfig.js +++ /dev/null @@ -1,74 +0,0 @@ -/** - * 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. - */ - -/* List of projects/orgs using your project for the users page */ -const users = [ - { - caption: "User1", - image: "/test-site/img/docusaurus.svg", - infoLink: "https://www.example.com", - pinned: true - } -]; - -const siteConfig = { - title: "Test Site" /* title for your website */, - url: "https://deltice.github.io" /* your github url */, - baseUrl: "/test-site/" /* base url for your project */, - projectName: "test-site", - repo: "deltice/test-site" /* repo for your project */, - users, - /* base url for editing docs, usage example: editUrl + 'en/doc1.md' */ - editUrl: "https://github.com/deltice/test-site/edit/master/docs/", - /* header links for links on this site, 'LANGUAGE' will be replaced by whatever - language the page is for, ex: 'en' */ - headerLinksInternal: [ - { - section: "docs", - href: "/test-site/docs/LANGUAGE/doc1.html", - text: "Docs" - }, - { section: "api", href: "/test-site/docs/LANGUAGE/doc4.html", text: "API" }, - { section: "help", href: "/test-site/LANGUAGE/help.html", text: "Help" }, - { section: "blog", href: "/test-site/blog", text: "Blog" } - ], - /* header links for links outside the site */ - headerLinksExternal: [ - { - section: "github", - href: "https://github.com/deltice/test-site", - text: "GitHub" - } - ], - /* path to images for header/footer */ - headerIcon: "img/docusaurus.svg", - disableHeaderTitle: false /* disable title text in header (only show headerIcon) */, - footerIcon: "img/docusaurus.svg", - favicon: "img/favicon.png", - /* colors for website */ - colors: { - primaryColor: "#2E8555", - secondaryColor: "#205C3B", - prismColor: - "rgba(46, 133, 85, 0.03)" /* primaryColor in rgba form, with 0.03 alpha */ - }, - tagline: "My Tagline", - recruitingLink: - "https://crowdin.com/project/test-site" /* translation site "help translate" link */, - /* remove this section to disable search bar */ - algolia: { - apiKey: - "0f9f28b9ab9efae89810921a351753b5" /* use your search-only api key */, - indexName: "github" - } - /* remove this to disable google analytics tracking */ - /* gaTrackingId: "" */ -}; - -module.exports = siteConfig; diff --git a/examples-translations/crowdin.yaml b/examples/translations/crowdin.yaml similarity index 93% rename from examples-translations/crowdin.yaml rename to examples/translations/crowdin.yaml index e3bd756a7d..13fe725384 100644 --- a/examples-translations/crowdin.yaml +++ b/examples/translations/crowdin.yaml @@ -6,7 +6,7 @@ preserve_hierarchy: true files: - source: '/docs/en/*.md' - translation: '/docs/%locale%/%original_file_name%' + translation: '/website/translated_docs/%locale%/%original_file_name%' languages_mapping: &anchor locale: 'af': 'af' diff --git a/examples-translations/languages.js b/examples/translations/languages.js similarity index 100% rename from examples-translations/languages.js rename to examples/translations/languages.js diff --git a/examples-translations/pages/en/help-with-translations.js b/examples/translations/pages/en/help-with-translations.js similarity index 100% rename from examples-translations/pages/en/help-with-translations.js rename to examples/translations/pages/en/help-with-translations.js diff --git a/examples/versions/pages/en/versions.js b/examples/versions/pages/en/versions.js new file mode 100644 index 0000000000..aad9ef92d7 --- /dev/null +++ b/examples/versions/pages/en/versions.js @@ -0,0 +1,92 @@ +const React = require("react"); + +const CompLibrary = require("../../core/CompLibrary"); +const Container = CompLibrary.Container; +const GridBlock = CompLibrary.GridBlock; + +const CWD = process.cwd(); + +const siteConfig = require(CWD + "/siteConfig.js"); +const versions = require(CWD + "/versions.json"); + +class Versions extends React.Component { + render() { + const latestVersion = versions[0]; + return ( +
+ +
+
+

{siteConfig.title + " Versions"}

+
+

New versions of this project are released every so often.

+ +

Current version (Stable)

+ + + + + + + + +
+ {latestVersion} + + Documentation + + Release Notes +
+

+ This is the version that is configured automatically when you + first install this project. +

+
+

Pre-release versions

+ + + + + + + + +
master + Documentation + + Release Notes +
+

Other text describing this section.

+
+

Past Versions

+ + + {versions.map( + version => + version !== latestVersion && + + + + + + )} + +
+ {version} + + Documentation + + Release Notes +
+

+ You can find past versions of this project{" "} + on GitHub . +

+
+
+
+ ); + } +} + +module.exports = Versions; diff --git a/lib/copy-examples.js b/lib/copy-examples.js index 88141ed8fd..8ca2282815 100755 --- a/lib/copy-examples.js +++ b/lib/copy-examples.js @@ -13,34 +13,176 @@ const CWD = process.cwd(); const fs = require("fs-extra"); const path = require("path"); const glob = require("glob"); +const chalk = require("chalk"); -let examplesFolder = "examples"; -if (process.argv.indexOf("translations") !== -1) { - examplesFolder = "examples-translations"; -} -const files = glob.sync(path.join(__dirname, "..", examplesFolder, "**")); -files.forEach(file => { - if (!fs.lstatSync(file).isDirectory()) { - let target = CWD; - if (file.includes("-examples")) { - target = path.join(CWD, ".."); - } - let fileName = file.substring( - file.indexOf(examplesFolder) + examplesFolder.length +let feature; + +const program = require("commander"); +program + .arguments("[feature]") + .action(feat => { + feature = feat; + }) + .parse(process.argv); + +const outerFolder = path.basename(path.dirname(CWD)); +if (feature === "translations") { + const folder = path.join(__dirname, "..", "examples", "translations"); + if (fs.existsSync(CWD + "/../crowdin.yaml")) { + console.log( + `${chalk.yellow("crowdin.yaml already exists")} in ${chalk.yellow( + outerFolder + "/" + )}. Rename or remove the file to regenerate an example version.\n` ); + } else { + fs.copySync(folder + "/crowdin.yaml", CWD + "/../crowdin.yaml"); + console.log( + `${chalk.green("Example crowdin.yaml file created")} in ${chalk.yellow( + outerFolder + "/" + )}.\n` + ); + } + let files = glob.sync(folder + "/**/*"); + files.forEach(file => { + if (fs.lstatSync(file).isDirectory()) { + return; + } + if (path.basename(file) === "crowdin.yaml") { + return; + } + const filePath = file.split(folder)[1]; try { - fs.copySync(file, path.join(target, fileName), { + fs.copySync(file, CWD + filePath, { overwrite: false, errorOnExist: true }); - console.log(fileName + " created in " + path.basename(target)); + console.log( + `${chalk.green( + "Example " + path.basename(filePath) + " file created" + )} in ${chalk.yellow( + "website" + filePath.split(path.basename(filePath))[0] + )}.\n` + ); } catch (e) { console.log( - fileName + - " already exists in " + - path.basename(target) + - ". Remove or rename the file to regenerate this example file." + `${chalk.yellow( + path.basename(filePath) + " already exists" + )} in ${chalk.yellow( + "website" + filePath.split(path.basename(filePath))[0] + )}. Rename or remove the file to regenerate an example version.\n` ); } + }); +} else if (feature === "versions") { + const folder = path.join(__dirname, "..", "examples", "versions"); + let files = glob.sync(folder + "/**/*"); + files.forEach(file => { + if (fs.lstatSync(file).isDirectory()) { + return; + } + const filePath = file.split(folder)[1]; + try { + fs.copySync(file, CWD + filePath, { + overwrite: false, + errorOnExist: true + }); + console.log( + `${chalk.green( + "Example " + path.basename(filePath) + " file created" + )} in ${chalk.yellow( + "website" + filePath.split(path.basename(filePath))[0] + )}.\n` + ); + } catch (e) { + console.log( + `${chalk.yellow( + path.basename(filePath) + " already exists" + )} in ${chalk.yellow( + "website" + filePath.split(path.basename(filePath))[0] + )}. Rename or remove the file to regenerate an example version.\n` + ); + } + }); +} else { + const folder = path.join(__dirname, "..", "examples", "basics"); + // copy docs examples + if (fs.existsSync(CWD + "/../docs-examples-from-docusaurus")) { + console.log( + `${chalk.yellow( + "Example docs already exist!" + )} Rename or remove ${chalk.yellow( + outerFolder + "/docs-examples-from-docusaurus" + )} to regenerate example docs.\n` + ); + } else { + fs.copySync( + folder + "/docs-examples-from-docusaurus", + CWD + "/../docs-examples-from-docusaurus" + ); + console.log( + `${chalk.green("Example docs created")} in ${chalk.yellow( + outerFolder + "/docs-examples-from-docusaurus" + )}! Rename the folder to ${chalk.yellow( + outerFolder + "/docs" + )} to see the example docs on your site.\n` + ); } -}); + // copy blog examples + if (fs.existsSync(CWD + "/blog-examples-from-docusaurus")) { + console.log( + `${chalk.yellow( + "Example blog posts already exist!" + )} Rename or remove ${chalk.yellow( + outerFolder + "/website/blog-examples-from-docusaurus" + )} to regenerate example blog posts.\n` + ); + } else { + fs.copySync( + path.join(folder, "blog-examples-from-docusaurus"), + path.join(CWD, "blog-examples-from-docusaurus") + ); + console.log( + `${chalk.green("Example blog posts created")} in ${chalk.yellow( + outerFolder + "/website/blog-examples-from-docusaurus" + )}! Rename the folder to ${chalk.yellow( + outerFolder + "/website/blog" + )} to see the example blog posts on your site.\n` + ); + } + // copy other files + let files = glob.sync(folder + "/**/*"); + files.forEach(file => { + if (fs.lstatSync(file).isDirectory()) { + return; + } + const containingFolder = path.basename(path.dirname(file)); + if ( + containingFolder === "blog-examples-from-docusaurus" || + containingFolder === "docs-examples-from-docusaurus" + ) { + return; + } + const filePath = file.split(folder)[1]; + try { + fs.copySync(file, CWD + filePath, { + overwrite: false, + errorOnExist: true + }); + console.log( + `${chalk.green( + "Example " + path.basename(filePath) + " file created" + )} in ${chalk.yellow( + "website" + filePath.split(path.basename(filePath))[0] + )}.\n` + ); + } catch (e) { + console.log( + `${chalk.yellow( + path.basename(filePath) + " already exists" + )} in ${chalk.yellow( + "website" + filePath.split(path.basename(filePath))[0] + )}. Rename or remove the file to regenerate an example version.\n` + ); + } + }); +} diff --git a/package.json b/package.json index 4fb48e9e29..906b8cfd24 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "babel-register": "^6.24.1", "babel-traverse": "^6.25.0", "babylon": "^6.17.4", + "chalk": "^2.1.0", "classnames": "^2.2.5", "commander": "^2.11.0", "diff": "^3.3.0",