Skip to content

Commit

Permalink
Improved add-to-site.js help
Browse files Browse the repository at this point in the history
  • Loading branch information
ihh committed Mar 7, 2017
1 parent 5ceab16 commit 0772cdc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ To set up the web client as a [static site](https://en.wikipedia.org/wiki/Static
- hand-edit the [index.html](https://github.com/evoldoers/wtfgenes/blob/master/web/index.html) file in the static site directory to include any additional text you want to include
- move the static site directory to someplace your webserver can see (it's OK to rename it)

The `create-site.js` and `add-to-site.js` scripts should be self-documenting (use the `-h` option to show a brief help message).

Since the web client consists of web-browsable files and does not need to execute any code on a server,
you can serve it up from any static web hosting service; for example, [Amazon S3](https://aws.amazon.com/s3/) or [GitHub pages](https://pages.github.com/).

Expand Down
17 changes: 10 additions & 7 deletions bin/add-to-site.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,14 @@ function inputError (err, showHelp) {
opt.argv.length || inputError ("Please specify a directory", true)
opt.argv.length === 1 || inputError ("Too many arguments", true)

opt.options.obo || inputError ("Please specify an OBO file")
opt.options.gaf || inputError ("Please specify a GAF file")
var dir = opt.argv[0]
var datasetsPath = "datasets.json"
function dirPath (filename) { return dir + "/" + filename }

fs.existsSync(dirPath(datasetsPath)) || inputError ("Can't find " + dirPath(datasetsPath))

opt.options.obo || inputError ("Please specify an OBO file", true)
opt.options.gaf || inputError ("Please specify a GAF file", true)

fs.existsSync(opt.options.obo) || inputError ("OBO file not found")
fs.existsSync(opt.options.gaf) || inputError ("GAF file not found")
Expand All @@ -50,24 +56,21 @@ var examples
if (opt.options.example || opt.options.ids) {
var exampleName = opt.options.example || []
var exampleIds = opt.options.ids || []
exampleName.length === exampleIds.length || inputError ("Please supply as many example gene-set names as example gene-sets")
exampleName.length === exampleIds.length || inputError ("Please supply as many example gene-set names as example gene-sets", true)
examples = exampleName.map (function (name, n) { return { name: name, genes: exampleIds[n].split(" ") } })
}

var dir = opt.argv[0]
function dirPath (filename) { return dir + "/" + filename }
function readJson (filename) {
var path = dirPath(filename)
fs.existsSync (path) || inputError ("Can't find " + path)
return JSON.parse (fs.readFileSync(path).toString())
}

function writeJson (filename, json) {
fs.writeFileSync (dirPath(filename), JSON.stringify (json))
}

var datasetsPath = "datasets.json"
var datasets = readJson (datasetsPath)

var oboText = fs.readFileSync(opt.options.obo).toString()
var gafText = fs.readFileSync(opt.options.gaf).toString()

Expand Down

0 comments on commit 0772cdc

Please sign in to comment.