Skip to content

Commit

Permalink
build(website): remove download page
Browse files Browse the repository at this point in the history
redirect to github release page
  • Loading branch information
lengyanyu258 committed Apr 14, 2020
1 parent 47dd298 commit ceca694
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 154 deletions.
62 changes: 10 additions & 52 deletions build-website.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,14 @@ const footerTemplate = fs.readFileSync('templates/_footer.mustache', encoding)
const homepageTemplate = fs.readFileSync('templates/homepage.mustache', encoding)
const examplesTemplate = fs.readFileSync('templates/examples.mustache', encoding)
const docsTemplate = fs.readFileSync('templates/docs.mustache', encoding)
const downloadTemplate = fs.readFileSync('templates/download.mustache', encoding)

const latestChessboardJS = fs.readFileSync('src/xiangqiboard.js', encoding)
const latestChessboardCSS = fs.readFileSync('src/xiangqiboard.css', encoding)
const latestJQueryMinJS = fs.readFileSync('node_modules/jquery/dist/jquery.min.js', encoding)
const latestNormalizeCSS = fs.readFileSync('node_modules/normalize.css/normalize.css', encoding)

const packageFiles = ['./CHANGELOG.md', 'LICENSE.md', 'package.json', 'README.md']

// grab the examples
const examplesArr = kidif('examples/*.example')
const examplesObj = examplesArr.reduce(function (examplesObj, example) {
Expand Down Expand Up @@ -95,7 +96,7 @@ function renderCSS (css) {
}

function writeSrcFiles () {
const releasePath = './docs/releases/' + VERSION
const releasePath = './docs/releases/xiangqiboardjs-' + VERSION
const jsReleasePath = releasePath + '/js/xiangqiboard-' + VERSION + '.js'
const jsReleaseMinPath = jsReleasePath.replace(/js$/g, 'min.js')
const cssReleasePath = releasePath + '/css/xiangqiboard-' + VERSION + '.css'
Expand All @@ -112,6 +113,11 @@ function writeSrcFiles () {
const cssInput = renderCSS(latestChessboardCSS)
const cssOutput = csso.minify(cssInput)

// sync to release
if (!fs.existsSync(releasePath + '/js')) fs.mkdirSync(releasePath + '/js', { recursive: true })
if (!fs.existsSync(releasePath + '/css')) fs.mkdirSync(releasePath + '/css', { recursive: true })
// if (!fs.existsSync(releasePath + '/img')) fs.mkdirSync(releasePath + '/img', { recursive: true })
packageFiles.forEach(file => {fs.writeFileSync(releasePath + '/' + file, fs.readFileSync(file, encoding), encoding)})
// .js, .css
fs.writeFileSync(jsReleasePath, jsInput, encoding)
fs.writeFileSync(cssReleasePath, cssInput, encoding)
Expand All @@ -121,8 +127,8 @@ function writeSrcFiles () {
// sync to website
fs.writeFileSync('docs/js/jquery.min.js', latestJQueryMinJS, encoding)
fs.writeFileSync('docs/css/normalize.min.css', csso.minify(latestNormalizeCSS).css, encoding)
fs.writeFileSync('docs/js/xiangqiboard.min.js', fs.readFileSync(jsReleaseMinPath, encoding), encoding)
fs.writeFileSync('docs/css/xiangqiboard.min.css', fs.readFileSync(cssReleaseMinPath, encoding), encoding)
fs.writeFileSync('src/xiangqiboard.min.js', fs.readFileSync(jsReleaseMinPath, encoding), encoding)
fs.writeFileSync('src/xiangqiboard.min.css', fs.readFileSync(cssReleaseMinPath, encoding), encoding)
}

function writeHomepage () {
Expand Down Expand Up @@ -182,31 +188,11 @@ function writeDocsPage () {
fs.writeFileSync('docs/docs.html', html, encoding)
}

const downloadsRowsHTML = releases.reduce(function (html, itm) {
if (isString(itm)) return html
return html + buildDownloadsRowHTML(itm)
}, '')

function writeDownloadPage () {
const headHTML = mustache.render(headTemplate, { pageTitle: 'Download' })
const headerHTML = mustache.render(headerTemplate, { downloadActive: true })

const html = mustache.render(downloadTemplate, {
head: headHTML,
header: headerHTML,
mostRecentVersion: buildMostRecentVersionHTML('Download'),
downloadsRows: downloadsRowsHTML,
footer: footerTemplate
})
fs.writeFileSync('docs/download.html', html, encoding)
}

function writeWebsite () {
writeSrcFiles()
writeHomepage()
writeExamplesPage()
writeDocsPage()
writeDownloadPage()
}

writeWebsite()
Expand Down Expand Up @@ -439,34 +425,6 @@ function buildMostRecentVersionHTML (page) {
return html
}

function buildDownloadsRowHTML (release) {
if (release.released === false) return ''

let html = '<div class="section release">'

// version and date
html += '<h4>v' + release.version + ' <small>released on ' + release.date + '</small></h4>'

// files
html += '<ul>'
release.files.forEach(function (file) {
html += `<li><a href="releases/${release.version}/${file.name}">${file.name}</a> <small>${file.size}</small></li>`
})
html += '</ul>'

// changes
html += '<h6>Changes:</h6>'
html += '<ul class="disc">'
release.changes.forEach(function (change) {
html += '<li>' + change + '</li>'
})
html += '</ul>'

html += '</div>'

return html
}

function isString (s) {
return typeof s === 'string'
}
5 changes: 3 additions & 2 deletions docs/docs.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<!--<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">-->
<link rel="stylesheet" href="css/website.css" />
<link rel="stylesheet" href="css/xiangqiboard.min.css" />
<link rel="stylesheet" href="../src/xiangqiboard.min.css" />
</head>

<body>
Expand All @@ -21,7 +21,8 @@
<a href="index.html">Home</a>
<a href="examples.html">Examples</a>
<a class="active" href="docs.html">Docs</a>
<a href="download.html">Download</a>
<a
href="https://github.com/lengyanyu258/xiangqiboardjs/releases" target="_blank">Download</a>
</div>
</div>
</header>
Expand Down
58 changes: 0 additions & 58 deletions docs/download.html

This file was deleted.

7 changes: 4 additions & 3 deletions docs/examples.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<!--<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">-->
<link rel="stylesheet" href="css/website.css" />
<link rel="stylesheet" href="css/xiangqiboard.min.css" />
<link rel="stylesheet" href="../src/xiangqiboard.min.css" />
</head>

<body>
Expand All @@ -21,7 +21,8 @@
<a href="index.html">Home</a>
<a class="active" href="examples.html">Examples</a>
<a href="docs.html">Docs</a>
<a href="download.html">Download</a>
<a
href="https://github.com/lengyanyu258/xiangqiboardjs/releases" target="_blank">Download</a>
</div>
</div>
</header>
Expand Down Expand Up @@ -1109,7 +1110,7 @@
</script>
<script src="js/jquery.min.js"></script>
<script src="js/prettify.min.js"></script>
<script src="js/xiangqiboard.min.js"></script>
<script src="../src/xiangqiboard.min.js"></script>
<script src="js/xiangqi-0.3.1-dev.min.js"></script>
<script src="js/examples.js"></script>
</body>
Expand Down
9 changes: 5 additions & 4 deletions docs/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<!--<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">-->
<link rel="stylesheet" href="css/website.css" />
<link rel="stylesheet" href="css/xiangqiboard.min.css" />
<link rel="stylesheet" href="../src/xiangqiboard.min.css" />
</head>

<body class="homepage">
Expand All @@ -18,7 +18,7 @@
<img src="img/logo.png" alt="Red King"/>
<h1>xiangqiboard.js</h1>
<h3>The easiest way to embed a xiangqi/chinese chess board on your site.</h3>
<a href="releases/0.2.0/xiangqiboardjs-0.2.0.zip">Download v0.2.0</a>
<a href="releases/0.3.0/xiangqiboardjs-0.3.0.zip">Download v0.3.0</a>
</div>
</div>

Expand All @@ -27,7 +27,8 @@ <h3>The easiest way to embed a xiangqi/chinese chess board on your site.</h3>
<a href="#start"><span class="piece">&#9823;</span> Getting Started</a>
<a href="examples.html"><span class="piece">&#9819;</span> Examples</a>
<a href="docs.html"><span class="piece">&#9820;</span> Documentation</a>
<a href="download.html"><span class="piece">&#9822;</span> Download</a>
<a href="https://github.com/lengyanyu258/xiangqiboardjs/releases" target="_blank">
<span class="piece">&#9822;</span> Download</a>
</div>
</nav>

Expand Down Expand Up @@ -86,7 +87,7 @@ <h4>JavaScript</h4>

<script src="js/jquery.min.js"></script>
<script src="js/prettify.min.js"></script>
<script src="js/xiangqiboard.min.js"></script>
<script src="../src/xiangqiboard.min.js"></script>
<script>
(function () {
function isTouchDevice () {
Expand Down
4 changes: 2 additions & 2 deletions docs/css/xiangqiboard.min.css → src/xiangqiboard.min.css
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/*!
* xiangqiboard.js 0.2.0
* xiangqiboard.js 0.3.0
*
* Copyright 2013 Chris Oakman
* Copyright 2018 @lengyanyu258
* Released under the MIT license
* https://github.com/lengyanyu258/xiangqiboardjs/blob/master/LICENSE
*
* Date: 14 Apr 2019
* Date: 14 Apr 2020
*/
.clearfix-5f3b5{clear:both}.board-1ef78{border:2px solid #404040;box-sizing:content-box}.square-2b8ce{float:left;position:relative;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.highlight1-e13fc,.highlight2-e0a03{box-shadow:inset 0 0 3px 3px #ff0}.notation-8c7a2{cursor:default;font-family:"Helvetica Neue",Helvetica,Arial,sans-serif;font-size:14px;position:absolute}.alpha-f4ef2{bottom:1px;right:40%}.numeric-fe76e{top:40%;left:1px}
2 changes: 1 addition & 1 deletion docs/js/xiangqiboard.min.js → src/xiangqiboard.min.js

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

2 changes: 1 addition & 1 deletion templates/_head.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@
<link rel="shortcut icon" href="img/favicon.ico" type="image/x-icon" />
<!--<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Open+Sans:300,400,600|Roboto+Mono">-->
<link rel="stylesheet" href="css/website.css" />
<link rel="stylesheet" href="css/xiangqiboard.min.css" />
<link rel="stylesheet" href="../src/xiangqiboard.min.css" />
</head>
3 changes: 2 additions & 1 deletion templates/_header.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
<a href="index.html">Home</a>
<a {{#examplesActive}}class="active"{{/examplesActive}} href="examples.html">Examples</a>
<a {{#docsActive}}class="active"{{/docsActive}} href="docs.html">Docs</a>
<a {{#downloadActive}}class="active"{{/downloadActive}} href="download.html">Download</a>
<a {{#downloadActive}}class="active"{{/downloadActive}}
href="https://github.com/lengyanyu258/xiangqiboardjs/releases" target="_blank">Download</a>
</div>
</div>
</header>
27 changes: 0 additions & 27 deletions templates/download.mustache

This file was deleted.

2 changes: 1 addition & 1 deletion templates/examples.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
</script>
<script src="js/jquery.min.js"></script>
<script src="js/prettify.min.js"></script>
<script src="js/xiangqiboard.min.js"></script>
<script src="../src/xiangqiboard.min.js"></script>
<script src="js/xiangqi-0.3.1-dev.min.js"></script>
<script src="js/examples.js"></script>
</body>
Expand Down
5 changes: 3 additions & 2 deletions templates/homepage.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
<a href="#start"><span class="piece">&#9823;</span> Getting Started</a>
<a href="examples.html"><span class="piece">&#9819;</span> Examples</a>
<a href="docs.html"><span class="piece">&#9820;</span> Documentation</a>
<a href="download.html"><span class="piece">&#9822;</span> Download</a>
<a href="https://github.com/lengyanyu258/xiangqiboardjs/releases" target="_blank">
<span class="piece">&#9822;</span> Download</a>
</div>
</nav>

Expand Down Expand Up @@ -61,7 +62,7 @@

<script src="js/jquery.min.js"></script>
<script src="js/prettify.min.js"></script>
<script src="js/xiangqiboard.min.js"></script>
<script src="../src/xiangqiboard.min.js"></script>
<script>
(function () {
function isTouchDevice () {
Expand Down

0 comments on commit ceca694

Please sign in to comment.