Skip to content

Commit

Permalink
[Improve] download links improvements (#337)
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfboys authored Mar 13, 2024
1 parent d6a9dd5 commit 060948e
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 36 deletions.
13 changes: 4 additions & 9 deletions src/pages/download/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,8 @@ export default function () {
const isBrowser = useIsBrowser();
const language = isBrowser && location.pathname.indexOf('/zh-CN/') === 0 ? 'zh-CN' : 'en';
const dataSource = config?.[language];
let latest = downloadDataSource[0];
downloadDataSource.forEach((item) => {
if (item.date > latest.date) {
latest = item;
}
})
const lastRelease = [latest]
const lastRelease = [downloadDataSource[0]];
const archived = downloadDataSource.slice(1, downloadDataSource.length)
return (
<Layout>
<div className="block download_page" style={{ padding: "10px 0 30px" }}>
Expand Down Expand Up @@ -44,7 +39,7 @@ export default function () {
</ul>
</div>
<h3 className="fs-4 mb-4 fw-bold">{dataSource.latestVersion}</h3>
<ReleaseTable dataSource={lastRelease}>
<ReleaseTable dataSource={lastRelease} latest={true}>
</ReleaseTable>
<h3 className="fs-4 mb-4 fw-bold">{dataSource.archived}</h3>
<div className="custom-info-block">
Expand All @@ -56,7 +51,7 @@ export default function () {
<li>{dataSource.note}</li>
</ul>
</div>
<ReleaseTable dataSource={downloadDataSource}>
<ReleaseTable dataSource={archived} latest={false}>
</ReleaseTable>
<h4>License</h4>
<p>
Expand Down
80 changes: 53 additions & 27 deletions src/pages/download/table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,29 +4,55 @@ import config from './languages.json'

export default function (props) {
const tableData = props.dataSource || []
const latest = props.latest || false
const isBrowser = useIsBrowser();
const language = isBrowser && location.pathname.indexOf('/zh-CN/') === 0 ? 'zh-CN' : 'en'
const dataSource = config?.[language];

function getSourceLink(version, suffix) {
return 'https://www.apache.org/dyn/closer.lua/incubator/streampark/'
.concat(version)
.concat('/apache-streampark-')
.concat(version)
.concat('-incubating-src.tar.gz')
.concat(suffix)
}
function getSourceLink(version) {
const prefix = latest
? 'https://www.apache.org/dyn/closer.lua/incubator/streampark/'
: 'https://archive.apache.org/dist/incubator/streampark/';

function getBinaryLink(scala, version, suffix) {
return 'https://www.apache.org/dyn/closer.lua/incubator/streampark/'
.concat(version)
.concat('/apache-streampark_')
.concat(scala)
.concat('-')
.concat(version)
.concat('-incubating-bin.tar.gz')
.concat(suffix)
}
return prefix
.concat(version)
.concat('/apache-streampark-')
.concat(version)
.concat('-incubating-src.tar.gz')
}

function getSourceSigs(version, suffix) {
return 'https://downloads.apache.org/incubator/streampark/'
.concat(version)
.concat('/apache-streampark-')
.concat(version)
.concat('-incubating-src.tar.gz')
.concat(suffix)
}

function getBinaryLink(scala, version) {
const prefix = latest
? 'https://www.apache.org/dyn/closer.lua/incubator/streampark/'
: 'https://archive.apache.org/dist/incubator/streampark/';
return prefix
.concat(version)
.concat('/apache-streampark_')
.concat(scala)
.concat('-')
.concat(version)
.concat('-incubating-bin.tar.gz')
}

function getBinarySigs(scala, version, suffix) {
return 'https://downloads.apache.org/incubator/streampark/'
.concat(version)
.concat('/apache-streampark_')
.concat(scala)
.concat('-')
.concat(version)
.concat('-incubating-bin.tar.gz')
.concat(suffix)
}

return (
<table className="table-ui mb-4">
Expand All @@ -46,36 +72,36 @@ export default function (props) {
<td className='text-center'> {release.version} </td>
<td className='text-center'> {release.date} </td>
<td className='text-center'>
<a href={getSourceLink(release.version, '')} target="_blank">source</a>
<a href={getSourceLink(release.version)} target="_blank">source</a>
<span> ( </span>
<a href={getSourceLink(release.version, '.sha512')} target="_blank">sha512</a>
<a href={getSourceSigs(release.version, '.sha512')} target="_blank">sha512</a>
<span> | </span>
<a href={getSourceLink(release.version, '.asc')} target="_blank">signature</a>
<a href={getSourceSigs(release.version, '.asc')} target="_blank">signature</a>
<span> ) </span>
</td>
<td className='text-center'>
<a href={getBinaryLink('2.12', release.version, '')} target="_blank">
<a href={getBinaryLink('2.12', release.version)} target="_blank">
{'apache-streampark_2.12-' + release.version + '-incubating-bin.tar.gz'}
</a>
<span> ( </span>
<a href={getBinaryLink('2.12', release.version, '.asc')} target="_blank">
<a href={getBinarySigs( '2.12', release.version, '.asc')} target="_blank">
Sign
</a>
<span> | </span>
<a href={getBinaryLink('2.12', release.version, '.sha512')} target="_blank">
<a href={getBinarySigs('2.12', release.version, '.sha512')} target="_blank">
SHA512
</a>
<span> ) </span>
<br/>
<a href={getBinaryLink('2.11', release.version, '')} target="_blank">
<a href={getBinaryLink('2.11', release.version)} target="_blank">
{'apache-streampark_2.11-' + release.version + '-incubating-bin.tar.gz'}
</a>
<span> ( </span>
<a href={getBinaryLink('2.11', release.version, '.asc')} target="_blank">
<a href={getBinarySigs('2.11', release.version, '.asc')} target="_blank">
Sign
</a>
<span> | </span>
<a href={getBinaryLink('2.11', release.version, '.sha512')} target="_blank">
<a href={getBinarySigs('2.11', release.version, '.sha512')} target="_blank">
SHA512
</a>
<span> ) </span>
Expand Down

0 comments on commit 060948e

Please sign in to comment.