Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Front end design & cleanup #14

Merged
merged 6 commits into from
Dec 11, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
site/public/build
4 changes: 4 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"parser": "babel-eslint",
"extends": "standard"
}
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
all: all_dists index

all_dists: go-ipfs ipfs-app
all_dists: go-ipfs

ipfs-app:
echo "** making $@ **"
Expand Down
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# distributions
# IPFS distributions

Script to build the dist.ipfs.io pages.
> Source for building https://dist.ipfs.io

## How this repo works

Expand Down Expand Up @@ -78,5 +78,3 @@ This project uses a makefile + scripts to build all the things.
make
```
should do everything.


5 changes: 5 additions & 0 deletions gulpfile.babel.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const gulp = require('gulp')

require('require-dir')('tasks')

gulp.task('default', ['lint'])
40 changes: 32 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,36 @@
"name": "dist.ipfs.io",
"version": "1.0.0",
"description": "Script to build the dist.ipfs.io pages.",
"main": "gen-index.js",
"dependencies": {
"nunjucks": "^1.3.4",
"marked": "^0.3.5",
"nunjucks-markdown": "^1.1.0"
"main": "gulpfile.babel.js",
"dependencies": {},
"devDependencies": {
"babel-core": "^6.1.2",
"babel-eslint": "^4.1.3",
"babel-jscs": "^2.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-remove-console": "^6.0.14",
"babel-polyfill": "^6.0.14",
"babel-preset-es2015": "^6.0.15",
"bootstrap": "^4.0.0-alpha.2",
"browser-sync": "^2.10.0",
"eslint": "^1.8.0",
"eslint-config-standard": "^4.4.0",
"eslint-plugin-standard": "^1.3.1",
"gulp": "^3.9.0",
"gulp-batch": "^1.0.5",
"gulp-eslint": "^1.1.1",
"gulp-load-plugins": "^1.1.0",
"gulp-watch": "^4.3.5",
"harp": "^0.20.0",
"jquery": "^2.1.4",
"pre-commit": "^1.1.2",
"require-dir": "^0.3.0",
"tether": "^1.1.1",
"webpack": "^1.12.2",
"webpack-stream": "^2.3.0"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"lint": "gulp lint"
},
"repository": {
"type": "git",
Expand All @@ -24,5 +45,8 @@
"bugs": {
"url": "https://github.com/ipfs/distributions/issues"
},
"homepage": "https://github.com/ipfs/distributions#readme"
"homepage": "https://github.com/ipfs/distributions#readme",
"pre-commit": [
"lint"
]
}
7 changes: 3 additions & 4 deletions gen-index.js → scripts/gen-index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var fs = require('fs')
var marked = require('marked')
var nunjucks = require('nunjucks')
var njmd = require('nunjucks-markdown')
Expand All @@ -7,14 +6,14 @@ var njx = nunjucks.configure('.')
njmd.register(njx, marked)

var spec = {
template: "tmpl/index.html",
data: { dists: {} },
template: 'tmpl/index.html',
data: { dists: {} }
}

var goipfsPath = './releases/go-ipfs/v0.3.7/dist.json'
spec.data.dists['go-ipfs'] = require(goipfsPath)

njx.render(spec.template, spec.data, function(err, res) {
njx.render(spec.template, spec.data, function (err, res) {
if (err) throw err
process.stdout.write(res)
process.exit(0)
Expand Down
28 changes: 14 additions & 14 deletions mkdist.js → scripts/mkdist.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ var fs = require('fs')

module.exports = mkdist

function mkdist(opts, cb) {
if (!opts) throw new Error("no options given")
if (!opts.dist) throw new Error("no dist given")
if (!opts.dist.id) throw new Error("no dist.id given")
if (!opts.dist.version) throw new Error("no dist.version given")
if (!opts.path) throw new Error("no path given")
if (!opts.platforms) throw new Error("no platforms given")
function mkdist (opts, cb) {
if (!opts) throw new Error('no options given')
if (!opts.dist) throw new Error('no dist given')
if (!opts.dist.id) throw new Error('no dist.id given')
if (!opts.dist.version) throw new Error('no dist.version given')
if (!opts.path) throw new Error('no path given')
if (!opts.platforms) throw new Error('no platforms given')
if (!cb) cb = noopcb

var dist = opts.dist
Expand All @@ -30,7 +30,7 @@ function mkdist(opts, cb) {
icon: 'apple',
archs: [{
name: 'Universal',
link: f,
link: f
}]
})
}
Expand All @@ -57,19 +57,19 @@ function mkdist(opts, cb) {
})
}

function writeDist(path, dist) {
function writeDist (path, dist) {
fs.writeFileSync(path, JSON.stringify(dist, null, ' '))
console.log('wrote', path)
}

function addOSBinaries(dir, src, dst) {
function addOSBinaries (dir, src, dst) {
for (var osi in src.oses) {
var os = src.oses[osi]
var p = {
id: os.id,
name: os.name,
icon: os.icon,
archs: [],
archs: []
}

for (var a in src.archs) {
Expand All @@ -81,7 +81,7 @@ function addOSBinaries(dir, src, dst) {
p.archs.push({
id: arch.id,
name: arch.name,
link: f,
link: f
})
}

Expand All @@ -92,7 +92,7 @@ function addOSBinaries(dir, src, dst) {
return dst
}

function findFile(dir, pattern) {
function findFile (dir, pattern) {
for (var e in dir) {
if (dir[e].match(pattern)) {
return dir[e]
Expand All @@ -101,6 +101,6 @@ function findFile(dir, pattern) {
return null
}

function noopcb(err) {
function noopcb (err) {
if (err) throw err
}
24 changes: 24 additions & 0 deletions site/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log

# Runtime data
pids
*.pid
*.seed

# node-waf configuration
.lock-wscript

# HARP BUILD FOLDER
www

# BABELJS BUILDS
public/build

www

# Dependency directory
node_modules

npm-debug.log
18 changes: 18 additions & 0 deletions site/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# IPFS Distributions


## Development

Harpjs setup with

* Live reload using browser-sync
* JavaScript
* bundeling using webpack
* transpiling using babel
* Linting using eslint
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these required? why can't we keep these out? it makes it daunting to modify websites when suddenly you have to know a ton more tools and know how to debug them when something goes wrong.

there's a lot to be said for simplicity and reducing cognitive complexity to the user.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are a couple of major points why I think we need them

  • Manage dependencies using npm
  • Consistency with other browser based modules like js-ipf-api
  • Make my life easier when working on the code (livereload is really a must for web dev for me)

The only thing that might not be needed is harpjs, though it was just a lot faster for me to use something working like that, than implementing all the tooling manually.

For me this is a lot simpler and more straight forward setup, especially while working with it than it was before. Also this enables me to add things like proper minification and asset bundeling which we need to have to ship this.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok sounds good. let's ship it



```bash
$ gulp
$ open localhost:3000
```
28 changes: 28 additions & 0 deletions site/config/webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
var webpack = require('webpack')

module.exports = {
entry: ['babel-polyfill', './public/_js/script.js'],
output: {
path: __dirname,
filename: './public/build/script.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
query: {
cacheDirectory: true,
presets: ['es2015']
}
}
]
},
plugins: [
new webpack.NoErrorsPlugin()
],
stats: {
colors: true
},
devtool: 'source-map'
}
34 changes: 34 additions & 0 deletions site/config/webpack.production.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
var webpack = require('webpack')

module.exports = {
entry: ['babel-polyfill', './public/_js/script.js'],
output: {
path: __dirname,
filename: './public/build/script.js'
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel',
exclude: /node_modules/,
query: {
cacheDirectory: true,
presets: ['es2015'],
plugins: ['transform-remove-console']
}
}
]
},
plugins: [
new webpack.optimize.UglifyJsPlugin({
compressor: {
warnings: false
}
}),
new webpack.NoErrorsPlugin()
],
stats: {
colors: true
}
}
8 changes: 8 additions & 0 deletions site/harp.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"globals": {
"meta" :{
"title" : "IPFS Distributions",
"desc" : "Distributions of IPFS"
}
}
}
45 changes: 45 additions & 0 deletions site/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
{
"name": "ipfs-distributions",
"version": "1.0.0",
"description": "IPFS Distributions page",
"main": "app.js",
"scripts": {
"dev": "webpack --progress --colors --watch",
"prod": "NODE_ENV=production webpack -p --config webpack.production.config.js",
"lint": "gulp lint"
},
"pre-commit": [
"lint"
],
"repository": {
"type": "git",
"url": "https://github.com/ipfs/distributions.git"
},
"author": "Friedel Ziegelmayer <dignifiedquire@gmail.com>",
"license": "MIT",
"bugs": {
"url": "https://github.com/ipfs/distributions/issues"
},
"homepage": "https://dist.ipfs.io",
"devDependencies": {
"babel-core": "^6.1.2",
"babel-eslint": "^4.1.3",
"babel-jscs": "^2.0.0",
"babel-loader": "^6.0.0",
"babel-plugin-transform-remove-console": "^6.0.14",
"babel-polyfill": "^6.0.14",
"babel-preset-es2015": "^6.0.15",
"browser-sync": "^2.10.0",
"eslint": "^1.8.0",
"eslint-config-standard": "^4.4.0",
"eslint-plugin-standard": "^1.3.1",
"gulp": "^3.9.0",
"gulp-batch": "^1.0.5",
"gulp-eslint": "^1.1.1",
"gulp-load-plugins": "^1.1.0",
"gulp-watch": "^4.3.5",
"harp": "^0.20.0",
"pre-commit": "^1.1.2",
"webpack": "^1.12.2"
}
}
2 changes: 2 additions & 0 deletions site/public/404.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
h1 404
h3 Whoops. Looks like what you're looking for can't be found.
10 changes: 10 additions & 0 deletions site/public/_js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const $ = window.jQuery = require('jquery')
window.Tether = require('tether')
require('bootstrap')

const init = () => {
// LETS DO THIS!
console.log('hello world')
}

$(init)
17 changes: 17 additions & 0 deletions site/public/_layout.jade
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
doctype
html(lang='en')
head
meta(charset='utf-8')
meta(http-equiv='X-UA-Compatible' content='IE=edge')/
title= meta.title
meta(name='viewport' content='width=device-width, initial-scale=1, shrink-to-fit=no')
meta(name='description' content='#{meta.desc}')
link(rel='stylesheet' href='css/style.css')
link(
href='https://fonts.googleapis.com/css?family=Fira+Sans:500,300,400,400italic'
rel='stylesheet'
type='text/css'
)
body
!= yield
script(src='build/script.js')
Loading