Skip to content

Commit

Permalink
fix(WebSite): Use Hexo to build the github.io web site
Browse files Browse the repository at this point in the history
  • Loading branch information
jourdain committed Mar 2, 2016
1 parent 44939b4 commit dc09a4a
Show file tree
Hide file tree
Showing 72 changed files with 2,385 additions and 25 deletions.
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@
.npmrc
npm-debug.log
node_modules
documentation/www
documentation/_tmp
7 changes: 7 additions & 0 deletions documentation/www/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
.idea/
node_modules/
*.log
db.json
public/
.deploy*/
37 changes: 37 additions & 0 deletions documentation/www/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# ParaViewWeb developer Website

The website for ParaViewWeb can be found at [kitware/paraviewweb](https://github.com/kitware/paraviewweb) repository.

## Getting started

Install dependencies:

``` bash
$ git clone https://github.com/kitware/paravieweb.git
$ cd documentation/www
```

Generate:

``` bash
$ npm run build
```

Run server:

``` bash
$ npm run server
```

## Contributors

- English - [tommy351](https://github.com/tommy351)
- 正體中文 - [tommy351](https://github.com/tommy351)
- 简体中文 - [pinggod](https://github.com/pinggod), [Xuanwo](https://github.com/Xuanwo)

## License

[CC BY 4.0](http://creativecommons.org/licenses/by/4.0/)

[tommy351]: https://github.com/tommy351
[pinggod]: https://github.com/pinggod
22 changes: 22 additions & 0 deletions documentation/www/_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
title: ParaViewWeb
description: "ParaViewWeb is a Web framework which allow to bring the power of ParaView and VTK into the Web."
subtitle: "Small framework for bringing scientific visualization to the Web"
author: Kitware Inc.
language: en
timezone: UTC
url: https://kitware.github.io/paraviewweb
root: /paraviewweb/
permalink: news/:year/:month/:day/:title/
archive_dir: news
code_dir: downloads/code
new_post_name: :year-:month-:day-:title.md # File name of new posts
post_asset_folder: true
highlight:
enable: true
line_number: false
per_page: 0

theme: navy

google_analytics:
github: kitware/paraviewweb
72 changes: 72 additions & 0 deletions documentation/www/gulpfile.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
'use strict';

var gulp = require('gulp');
var $ = require('gulp-load-plugins')();
var cssnano = require('cssnano');

var dirs = {
public: 'public',
screenshots: 'public/build/screenshots'
};

gulp.task('useref', ['screenshot'], function(){
var assets = $.useref.assets({
searchPath: 'public'
});

return gulp.src('public/**/*.html')
// .pipe(assets)
.pipe($.uniqueFiles())
.pipe($.if('*.css', $.postcss([
cssnano()
])))
.pipe($.if('*.js', $.uglify()))
.pipe($.rev())
.pipe(assets.restore())
// .pipe($.useref())
// .pipe($.revReplace({
// prefix: '/'
// }))
.pipe(gulp.dest('public'));
});

gulp.task('screenshot:rev', function(){
return gulp.src('public/applications/screenshots/*.png')
.pipe($.rev())
.pipe(gulp.dest(dirs.screenshots))
.pipe($.rev.manifest())
.pipe(gulp.dest(dirs.screenshots));
});

gulp.task('screenshot:resize', ['screenshot:rev'], function(){
return gulp.src(dirs.screenshots + '/*.png')
.pipe($.responsive({
'*.png': [
{
width: 400,
progressive: true
},
{
progressive: true,
rename: {
suffix: '@2x'
}
}
]
}))
.pipe(gulp.dest(dirs.screenshots));
});

gulp.task('screenshot:revreplace', ['screenshot:rev'], function(){
return gulp.src([dirs.screenshots + '/rev-manifest.json', 'public/applications/index.html'])
.pipe($.revCollector({
replaceReved: true,
dirReplacements: {
'/applications/screenshots': '/build/screenshots'
}
}))
.pipe(gulp.dest('public/applications'));
});

gulp.task('screenshot', ['screenshot:rev', 'screenshot:resize', 'screenshot:revreplace']);
gulp.task('default', ['useref', 'screenshot']);
41 changes: 41 additions & 0 deletions documentation/www/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"name": "paraviewweb-site",
"version": "0.0.0",
"private": true,
"hexo": {
"version": "3.2.0"
},
"scripts": {
"build": "hexo generate && gulp",
"server": "hexo server",
"doc": "npm run build && npm run server"
},
"dependencies": {
"cheerio": "^0.20.0",
"hexo": "^3.2.0",
"hexo-deployer-git": "^0.1.0",
"hexo-generator-archive": "^0.1.4",
"hexo-generator-feed": "^1.1.0",
"hexo-generator-sitemap": "^1.1.2",
"hexo-renderer-jade": "^0.3.0",
"hexo-renderer-marked": "^0.2.10",
"hexo-renderer-stylus": "^0.3.1",
"hexo-server": "^0.2.0",
"lodash": "^4.5.1",
"lunr": "^0.6.0"
},
"devDependencies": {
"cssnano": "^3.5.2",
"gulp": "^3.9.1",
"gulp-if": "^2.0.0",
"gulp-load-plugins": "^1.2.0",
"gulp-postcss": "^6.1.0",
"gulp-responsive": "^2.1.0",
"gulp-rev": "^6.0.1",
"gulp-rev-collector": "^1.0.2",
"gulp-rev-replace": "^0.4.3",
"gulp-uglify": "^1.5.3",
"gulp-unique-files": "^0.1.2",
"gulp-useref": "^2.1.0"
}
}
2 changes: 2 additions & 0 deletions documentation/www/scaffolds/page.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: {{ title }}
---
2 changes: 2 additions & 0 deletions documentation/www/scaffolds/post.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
title: {{ title }}
---
155 changes: 155 additions & 0 deletions documentation/www/scripts/helpers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,155 @@
'use strict';

var pathFn = require('path');
var _ = require('lodash');
var url = require('url');
var cheerio = require('cheerio');
var lunr = require('lunr');

var localizedPath = ['docs', 'api'];

function startsWith(str, start){
return str.substring(0, start.length) === start;
}

hexo.extend.helper.register('page_nav', function(){
var type = this.page.canonical_path.split('/')[0];
var sidebar = this.site.data.sidebar[type];
var path = pathFn.basename(this.path);
var list = {};
var prefix = 'sidebar.' + type + '.';

for (var i in sidebar){
for (var j in sidebar[i]){
list[sidebar[i][j]] = j;
}
}

var keys = Object.keys(list);
var index = keys.indexOf(path);
var result = '';

if (index > 0){
result += '<a href="' + keys[index - 1] + '" class="article-footer-prev" title="' + this.__(prefix + list[keys[index - 1]]) + '">' +
'<i class="fa fa-chevron-left"></i><span>' + this.__('page.prev') + '</span></a>';
}

if (index < keys.length - 1){
result += '<a href="' + keys[index + 1] + '" class="article-footer-next" title="' + this.__(prefix + list[keys[index + 1]]) + '">' +
'<span>' + this.__('page.next') + '</span><i class="fa fa-chevron-right"></i></a>';
}

return result;
});

hexo.extend.helper.register('doc_sidebar', function(className){
var type = this.page.canonical_path.split('/')[0];
var sidebar = this.site.data.sidebar[type];
var path = pathFn.basename(this.path);
var result = '';
var self = this;
var prefix = 'sidebar.' + type + '.';

_.each(sidebar, function(menu, title){
result += '<strong class="' + className + '-title">' + self.__(prefix + title) + '</strong>';

_.each(menu, function(link, text){
var itemClass = className + '-link';
if (link === path) itemClass += ' current';

result += '<a href="' + link + '" class="' + itemClass + '">' + self.__(prefix + text) + '</a>';
})
});

return result;
});

hexo.extend.helper.register('header_menu', function(className){
var menu = this.site.data.menu;
var result = '';
var self = this;
var lang = this.page.lang;
var isEnglish = lang === 'en';

_.each(menu, function(path, title){
if (!isEnglish && ~localizedPath.indexOf(title)) path = lang + path;

result += '<a href="' + self.url_for(path) + '" class="' + className + '-link">' + self.__('menu.' + title) + '</a>';
});

return result;
});

hexo.extend.helper.register('canonical_url', function(lang){
var path = this.page.canonical_path;
if (lang && lang !== 'en') path = lang + '/' + path;

return this.config.url + '/' + path;
});

hexo.extend.helper.register('url_for_lang', function(path){
var lang = this.page.lang;
var url = this.url_for(path);

if (lang !== 'en' && url[0] === '/') url = '/' + lang + url;

return url;
});

hexo.extend.helper.register('raw_link', function(path){
return 'https://github.com/hexojs/site/edit/master/source/' + path;
});

hexo.extend.helper.register('page_anchor', function(str){
var $ = cheerio.load(str, {decodeEntities: false});
var headings = $('h1, h2, h3, h4, h5, h6');

if (!headings.length) return str;

headings.each(function(){
var id = $(this).attr('id');

$(this)
.addClass('article-heading')
.append('<a class="article-anchor" href="#' + id + '" aria-hidden="true"></a>');
});

return $.html();
});

hexo.extend.helper.register('lunr_index', function(data){
var index = lunr(function(){
this.field('name', {boost: 10});
this.field('tags', {boost: 50});
this.field('description');
this.ref('id');
});

_.sortBy(data, 'name').forEach(function(item, i){
index.add(_.assign({id: i}, item));
});

return JSON.stringify(index.toJSON());
});

hexo.extend.helper.register('canonical_path_for_nav', function(){
var path = this.page.canonical_path;

if (startsWith(path, 'docs/') || startsWith(path, 'api/')){
return path;
} else {
return '';
}
});

hexo.extend.helper.register('lang_name', function(lang){
var data = this.site.data.languages[lang];
return data.name || data;
});

hexo.extend.helper.register('disqus_lang', function(){
var lang = this.page.lang;
var data = this.site.data.languages[lang];

return data.disqus_lang || lang;
});
17 changes: 17 additions & 0 deletions documentation/www/scripts/tags.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict';

hexo.extend.tag.register('note', function(args, content){
var className = args.shift();
var header = '';
var result = '';

if (args.length){
header += '<strong class="note-title">' + args.join(' ') + '</strong>';
}

result += '<blockquote class="note ' + className + '">' + header;
result += hexo.render.renderSync({text: content, engine: 'markdown'});
result += '</blockquote>';

return result;
}, true);
1 change: 1 addition & 0 deletions documentation/www/source/CNAME
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
kitware.github.io
12 changes: 12 additions & 0 deletions documentation/www/source/_data/applications.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
- name: Visualizer
description: A full feature ParaView like application in the web.
link: https://github.com/kitware/visualizer
preview: https://github.com/kitware/visualizer
tags:
- ParaView
- name: ArcticViewer
description: Artifact Web viewer
link: https://github.com/kitware/arctic-viewer
preview: http://kitware.github.io/arctic-viewer/
tags:
- ParaView
1 change: 1 addition & 0 deletions documentation/www/source/_data/languages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
en: English
4 changes: 4 additions & 0 deletions documentation/www/source/_data/menu.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
docs: /docs/
api: /api/
news: /news/
applications: /applications/
Loading

0 comments on commit dc09a4a

Please sign in to comment.