Repository: incubator-apex-site Updated Branches: refs/heads/master 670efbcf7 -> 7e2788684
APEX-261 #resolve Project: http://git-wip-us.apache.org/repos/asf/incubator-apex-site/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-apex-site/commit/7e278868 Tree: http://git-wip-us.apache.org/repos/asf/incubator-apex-site/tree/7e278868 Diff: http://git-wip-us.apache.org/repos/asf/incubator-apex-site/diff/7e278868 Branch: refs/heads/master Commit: 7e2788684f50a6ba0ca83628d46e90f29b5eb044 Parents: 670efbc Author: Andy Perlitch <[email protected]> Authored: Thu Nov 12 14:18:56 2015 -0800 Committer: Andy Perlitch <[email protected]> Committed: Thu Nov 12 14:18:56 2015 -0800 ---------------------------------------------------------------------- README.md | 22 +++++ gulpfile.js | 156 ++++++++++++++++++++++++++++++++++- navigation.js | 24 ------ navigation.json | 19 +++++ package.json | 6 +- releases.json | 14 ++++ src/less/header.less | 12 +++ src/md/third-party-downloads.md | 7 ++ src/pages/downloads.html | 62 ++++++++++++++ src/partials/header.handlebars | 3 +- 10 files changed, 297 insertions(+), 28 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/README.md ---------------------------------------------------------------------- diff --git a/README.md b/README.md index 0c2e9fc..bc9fece 100644 --- a/README.md +++ b/README.md @@ -95,3 +95,25 @@ To test changes: One way to improve this process is to run `./node_modules/.bin/gulp watch`. This will start a process that watches for changes to source files and updates the `/content` folder accordingly. This way you make your change and refresh the page to see the effect immediately. + + +Updating Downloads Page +----------------------- + +The downloads page uses the content of `./releases.json` to populate the tables found there. +Care has been taken to automatically generate this releases.json file. To do so, run: + +```bash +./node_modules/.bin/gulp fetch-releases +git add releases.json +git commit -m 'updated releases' +``` + +This will do the following things: + +1. Parses out the release versions available via the [ASF dist pages](https://dist.apache.org/repos/dist/release/incubator/apex). +2. Queries Github for these found release tags to find the date they were published to github +3. Writes to releases.json with release information. + + +Once you have committed the changes to `releases.json`, follow the steps to contributing steps to publish the site to go live. http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/gulpfile.js ---------------------------------------------------------------------- diff --git a/gulpfile.js b/gulpfile.js index 3a3c47b..aed7406 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,6 +6,11 @@ var marked = require('gulp-marked'); var handlebars = require('gulp-compile-handlebars'); var less = require('gulp-less'); var path = require('path'); +var request = require('request'); +var jsdom = require('jsdom'); +var fs = require('fs'); +var async = require('async'); +var _ = require('lodash'); // Constants var TEMP_PARTIAL_LOCATION = './.tmp/partials/'; @@ -32,12 +37,18 @@ gulp.task('html', ['md2html'], function() { // Get partials from src and temp partials locations. // Temp partials are rendered md files var options = { - batch: ['./src/partials', TEMP_PARTIAL_LOCATION] + batch: ['./src/partials', TEMP_PARTIAL_LOCATION], + helpers: { + releaseDate: function(timestamp) { + var d = new Date(timestamp); + return [d.getFullYear(), d.getMonth() + 1, d.getDate()].join('-'); + } + } }; // Render the files in pages gulp.src('./src/pages/*.html') - .pipe(handlebars({ nav: require('./navigation') }, options)) + .pipe(handlebars({ nav: require('./navigation.json'), releases: require('./releases.json') }, options)) .pipe(gulp.dest(BUILD_LOCATION)) .on('error', function(err) { console.warn(err); @@ -74,6 +85,147 @@ gulp.task('copy:images', function() { // Default task is to build the site gulp.task('default', ['less', 'html', 'copy:js', 'copy:images']); +// Creates releases.json file. +// +// 1. Requests page that lists release versions (https://dist.apache.org/repos/dist/release/incubator/apex[/malhar]) +// 2. Queries Github for release tags to find the date they were published to github +// 3. Writes to releases.json with release information. +// +gulp.task('fetch-versions', function(taskCb) { + + // The base location for release listings + var distUrl = 'https://dist.apache.org/repos/dist/'; + + // The release "targets", in this case meaning apex-core and apex-malhar + var targets = [ + // NOTE: Once apex leaves incubation, this object should be changed to exclude "incubator" + { key: 'core.src', path: 'release/incubator/apex', repo: 'incubator-apex-core' }, + { key: 'malhar.src', path: 'release/incubator/apex/malhar', repo: 'incubator-apex-malhar' } + ]; + + // For each target, get the releases + async.map(targets, function(target, cb) { + + // Request the page that lists the release versions, + // e.g. https://dist.apache.org/repos/dist/release/incubator/apex + request(distUrl + target.path, function(err, response) { + + // Abort for error + if (err) { + return cb(err); + } + + // Parse out the link names which are the + // available versions + jsdom.env( + response.body, + function (err, window) { + + // Query the DOM for all links in the list + var releaseLinks = window.document.querySelectorAll('ul li a'); + + // Convert this NodeList to an array + releaseLinks = Array.prototype.slice.call(releaseLinks) + + // Filter out non-version-looking links + .filter(function(el) { + var text = el.innerHTML.trim(); + return ['..', 'KEYS', 'malhar', 'malhar/'].indexOf(text) === -1; + }); + + // Create array of releases from this filtered NodeList + var releases = releaseLinks.map(function(el) { + return { + // Trim the href attribute of leading "v" and trailing slash + version: el.href.trim().replace(/^v/, '').replace(/\/$/, ''), + // Add repo for use in async.each call below + repo: target.repo + }; + }); + + // Get the date for each release via the github API + async.each(releases, function(release, eachCb) { + + // Get the tags for the repo + request({ + url: 'https://api.github.com/repos/apache/' + release.repo + '/tags', + json: true, + headers: { 'User-Agent': 'apache' } // Github asks that the user agent is the GH org or username + }, function(err, response) { + + // Abort if tags not found or something happened with github API + if (err) { + return eachCb(err); + } + + // Find the tag object corresponding to this release + var ghTag = _.find(response.body, function(t) { + return t.name.replace(/^v/, '') === release.version; + }); + + // Get info about the commit that the tag points to + request({ + url: ghTag.commit.url, // Github API address + json: true, + headers: { 'User-Agent': 'apache' } + }, function(err, response) { + + // Abort if the commit could not be found + if (err) { + return eachCb(err); + } + + // Set the date from the this information + release.date = Date.parse(response.body.commit.author.date); + + // We're all done + eachCb(); + + }); + + }); + + }, function(err) { // callback for async.each(releases, ...) + + // Abort if error occurred somewhere + if (err) { + return cb(err); + } + + // Sort the releases by the date + releases.sort(function(a, b) { + return b.date - a.date; + }); + + // Return with a new target object with releases. + // Note that this is the cb from the async.map call above + cb(null, _.extend({}, target, { releases: releases }) ); + + }); + + } // end jsdom.env callback + ); // end jsdom.env + + }); // end request to the listing of this target + + + }, function(err, targetsWithVersions) { // this is the async.map(targets) callback + + // This will be written to releases.json + var fileContents = {}; + + // Use the "key" to set core.src and malhar.src, etc. + targetsWithVersions.forEach(function(trg) { + _.set(fileContents, trg.key, trg.releases); + }); + + // Write the file to releases.json + fs.writeFile('./releases.json', JSON.stringify(fileContents, 0, 2), taskCb); + + }); + +}); + // Watch for changes gulp.task('watch', function() { gulp.watch('./src/less/*.less', ['less']); http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/navigation.js ---------------------------------------------------------------------- diff --git a/navigation.js b/navigation.js deleted file mode 100644 index 23ef750..0000000 --- a/navigation.js +++ /dev/null @@ -1,24 +0,0 @@ -'use strict'; - -/** - * This array generates the top navigation - */ - -exports = module.exports = [ - { id: 'index', label: 'Home', href: '/' }, - { id: 'community', label: 'Community', href: '/community.html' }, - { id: 'docs', label: 'Docs', href: '/docs.html' }, - { id: 'source', label: 'Source', items: [ - { label: 'Apex Core (ASF)', href: 'https://git-wip-us.apache.org/repos/asf?p=incubator-apex-core.git' }, - { label: 'Apex Core (Github Mirror)', href: 'https://github.com/apache/incubator-apex-core' }, - { label: 'Apex Malhar (ASF)', href: 'https://git-wip-us.apache.org/repos/asf?p=incubator-apex-malhar.git' }, - { label: 'Apex Malhar (Github Mirror)', href: 'https://github.com/apache/incubator-apex-malhar' } - ] }, - { id: 'apache', label: 'Apache', items: [ - { label: 'Status Page', href: 'http://incubator.apache.org/projects/apex.html' }, - { label: 'Apache Foundation', href: 'http://www.apache.org/foundation/how-it-works.html' }, - { label: 'Apache License', href: 'http://www.apache.org/licenses/' }, - { label: 'Sponsorship', href: 'http://www.apache.org/foundation/sponsorship.html' }, - { label: 'Thanks', href: 'http://www.apache.org/foundation/thanks.html' } - ]} -]; \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/navigation.json ---------------------------------------------------------------------- diff --git a/navigation.json b/navigation.json new file mode 100644 index 0000000..6ce8b6d --- /dev/null +++ b/navigation.json @@ -0,0 +1,19 @@ +[ + { "id": "index", "label": "Home", "href": "/" }, + { "id": "community", "label": "Community", "href": "/community.html" }, + { "id": "docs", "label": "Docs", "href": "/docs.html" }, + { "id": "source", "label": "Source", "items": [ + { "label": "Apex Core (ASF)", "href": "https://git-wip-us.apache.org/repos/asf?p=incubator-apex-core.git" }, + { "label": "Apex Core (Github Mirror)", "href": "https://github.com/apache/incubator-apex-core" }, + { "label": "Apex Malhar (ASF)", "href": "https://git-wip-us.apache.org/repos/asf?p=incubator-apex-malhar.git" }, + { "label": "Apex Malhar (Github Mirror)", "href": "https://github.com/apache/incubator-apex-malhar" } + ] }, + { "id": "apache", "label": "Apache", "items": [ + { "label": "Status Page", "href": "http://incubator.apache.org/projects/apex.html" }, + { "label": "Apache Foundation", "href": "http://www.apache.org/foundation/how-it-works.html" }, + { "label": "Apache License", "href": "http://www.apache.org/licenses/" }, + { "label": "Sponsorship", "href": "http://www.apache.org/foundation/sponsorship.html" }, + { "label": "Thanks", "href": "http://www.apache.org/foundation/thanks.html" } + ]}, + { "id": "download", "label": "Download", "href": "/downloads.html", "classes": "btn btn-success" } +] \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/package.json ---------------------------------------------------------------------- diff --git a/package.json b/package.json index 26da00f..bf02e99 100644 --- a/package.json +++ b/package.json @@ -21,12 +21,16 @@ "author": "Andy Perlitch <[email protected]>", "license": "Apache-2.0", "dependencies": { + "async": "^1.5.0", "bower": "^1.5.2", "gulp": "^3.9.0", "gulp-compile-handlebars": "^0.5.0", "gulp-less": "^3.0.3", "gulp-marked": "^1.0.0", "handlebars": "^4.0.2", - "highlight.js": "^8.9.1" + "highlight.js": "^8.9.1", + "jsdom": "^7.0.2", + "lodash": "^3.10.1", + "request": "^2.65.0" } } http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/releases.json ---------------------------------------------------------------------- diff --git a/releases.json b/releases.json new file mode 100644 index 0000000..1a4751a --- /dev/null +++ b/releases.json @@ -0,0 +1,14 @@ +{ + "core": { + "src": [ + { + "version": "3.2.0-incubating", + "date": 1445639866000, + "repo": "incubator-apex-core" + } + ] + }, + "malhar": { + "src": [] + } +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/src/less/header.less ---------------------------------------------------------------------- diff --git a/src/less/header.less b/src/less/header.less index 13f1722..1a7e265 100644 --- a/src/less/header.less +++ b/src/less/header.less @@ -8,6 +8,18 @@ &:hover { background: lighten(@brand-primary, 25%); } + &.btn { + padding-bottom: 7px; + padding-top: 7px; + margin-top: 8px; + margin-left: 5px; + margin-right: 5px; + &.btn-success { + &:hover { + background-color: darken(@brand-success, 10%); + } + } + } } .navbar-brand { font-family: @headings-font-family; http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/src/md/third-party-downloads.md ---------------------------------------------------------------------- diff --git a/src/md/third-party-downloads.md b/src/md/third-party-downloads.md new file mode 100644 index 0000000..47c0ecc --- /dev/null +++ b/src/md/third-party-downloads.md @@ -0,0 +1,7 @@ +## Third-Party Downloads + +This is a list of 3rd party binary packages based on Apache Apex. The Apache Apex project does not endorse or maintain any 3rd party binary packages. + +- [DataTorrent RTS](https://www.datatorrent.com/download/) is a binary build of Apache Apex created by [DataTorrent](https://datatorrent.com). + +If you would like to provide your own edition of Apache Apex here, please send email to [[email protected]](mailto:[email protected]). \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/src/pages/downloads.html ---------------------------------------------------------------------- diff --git a/src/pages/downloads.html b/src/pages/downloads.html new file mode 100644 index 0000000..8c58112 --- /dev/null +++ b/src/pages/downloads.html @@ -0,0 +1,62 @@ +{{> header}} + +<div class="container"> + + <h1>Downloads</h1> + + <!-- APEX CORE SOURCE RELEASES TABLE --> + {{#if releases.core.src.length}} + <h2>Apex Source Releases</h2> + <table class="table table-bordered table-striped"> + <thead> + <tr> + <th scope="col">Version</th> + <th scope="col">Date</th> + <th scope="col">Source (zip)</th> + <th scope="col">Source (tarball)</th> + </tr> + </thead> + <tbody> + {{#each releases.core.src as |version vIndex|}} + <tr> + <td> + {{ version.version }} + {{#if @first}} + (latest) + {{/if}} + </td> + <td> + {{releaseDate version.date}} + </td> + <td> + <a href="http://www.apache.org/dyn/closer.lua/incubator/apex/v{{ version.version }}/apex-{{ version.version }}-source-release.zip">apex-{{ version.version }}-source-release.zip</a><br> + <small> + ( + <a href="https://dist.apache.org/repos/dist/release/incubator/apex/v{{ version.version }}/apex-{{ version.version }}-source-release.zip.asc">pgp</a>, + <a href="https://dist.apache.org/repos/dist/release/incubator/apex/v{{ version.version }}/apex-{{ version.version }}-source-release.zip.md5">md5</a>, + <a href="https://dist.apache.org/repos/dist/release/incubator/apex/v{{ version.version }}/apex-{{ version.version }}-source-release.zip.sha">sha1</a> + ) + </small> + </td> + <td> + <a href="http://www.apache.org/dyn/closer.lua/incubator/apex/v{{ version.version }}/apex-{{ version.version }}-source-release.tar.gz">apex-{{ version.version }}-source-release.tar.gz</a><br> + <small> + ( + <a href="https://dist.apache.org/repos/dist/release/incubator/apex/v{{ version.version }}/apex-{{ version.version }}-source-release.tar.gz.asc">pgp</a>, + <a href="https://dist.apache.org/repos/dist/release/incubator/apex/v{{ version.version }}/apex-{{ version.version }}-source-release.tar.gz.md5">md5</a>, + <a href="https://dist.apache.org/repos/dist/release/incubator/apex/v{{ version.version }}/apex-{{ version.version }}-source-release.tar.gz.sha">sha1</a> + ) + </small> + </td> + </tr> + {{/each}} + </tbody> + </table> + {{/if}} + + + {{> third-party-downloads}} + +</div> + +{{> footer}} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/incubator-apex-site/blob/7e278868/src/partials/header.handlebars ---------------------------------------------------------------------- diff --git a/src/partials/header.handlebars b/src/partials/header.handlebars index 50e1526..f4eb8a3 100644 --- a/src/partials/header.handlebars +++ b/src/partials/header.handlebars @@ -47,10 +47,11 @@ </li> {{else}} <li class="nav-item"> - <a class="nav-link" href="{{href}}">{{label}}</a> + <a class="nav-link {{classes}}" href="{{href}}">{{label}}</a> </li> {{/if}} {{/each}} </ul> + </div> </nav> \ No newline at end of file
