Skip to content

Commit

Permalink
Merge pull request #46 from aMarcireau/state
Browse files Browse the repository at this point in the history
State
  • Loading branch information
Alexandre Marcireau authored Jan 3, 2018
2 parents f4bf665 + eb8188e commit 6d1ebef
Show file tree
Hide file tree
Showing 23 changed files with 1,093 additions and 217 deletions.
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ Origami is an open-source research tool focused on graphical representations of

## Download

| [<img src="linux.png" width="50px"/>](https://github.com/aMarcireau/origami/releases/download/v0.8.1/Origami-linux-x64.zip) | [<img src="macOs.png" width="50px"/>](https://github.com/aMarcireau/origami/releases/download/v0.8.1/Origami-darwin-x64.zip) | [<img src="windows.png" width="50px"/>](https://github.com/aMarcireau/origami/releases/download/v0.8.1/Origami-win32-x64.zip) |
| [<img src="linux.png" width="50px"/>](https://github.com/aMarcireau/origami/releases/download/v0.9.0/Origami-linux-x64.zip) | [<img src="macOs.png" width="50px"/>](https://github.com/aMarcireau/origami/releases/download/v0.9.0/Origami-darwin-x64.zip) | [<img src="windows.png" width="50px"/>](https://github.com/aMarcireau/origami/releases/download/v0.9.0/Origami-win32-x64.zip) |
| ------------------------------------ | ------------------------------------ | ---------------------------------------|
| [Download for Linux](https://github.com/aMarcireau/origami/releases/download/v0.8.1/Origami-linux-x64.zip) | [Download for macOS](https://github.com/aMarcireau/origami/releases/download/v0.8.1/Origami-darwin-x64.zip) | [Download for Windows](https://github.com/aMarcireau/origami/releases/download/v0.8.1/Origami-win32-x64.zip) |
| [Download for Linux](https://github.com/aMarcireau/origami/releases/download/v0.9.0/Origami-linux-x64.zip) | [Download for macOS](https://github.com/aMarcireau/origami/releases/download/v0.9.0/Origami-darwin-x64.zip) | [Download for Windows](https://github.com/aMarcireau/origami/releases/download/v0.9.0/Origami-win32-x64.zip) |

Visit the [Releases](https://github.com/aMarcireau/origami/releases) page to download Origami for other platforms.

Expand Down Expand Up @@ -42,7 +42,7 @@ Origami can load several DOIs at once from a [JSON](https://www.json.org) format
Origami saves and load collections in [JSON](https://www.json.org) format. The generated files have the following structure:
```yaml
{
"appVersion": "0.8.1", # the version of the app used to generate this save
"appVersion": "0.9.0", # the version of the app used to generate this save
"display": 0, # the current display's index (0 for graph, 1 for list)
"knownDois": [ # list of DOIs clicked at least once (used to highlight new publications)
"10.1109/tpami.2016.2574707"
Expand Down Expand Up @@ -105,7 +105,6 @@ Origami saves and load collections in [JSON](https://www.json.org) format. The g
"xOffset": 0, # the current graph positions' x coordinate, float
"yOffset": 0, # the current graph positions' y coordinate, float
"sticky": false # false means that the 'sticky' box is unchecked

},
"publications": [ # list of known publications
[ # each publication is a two-elements list containg a string and an object
Expand Down
15 changes: 10 additions & 5 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"dependencies": {
"ajv": "5.3.0",
"ajv": "5.5.0",
"archiver": "2.1.0",
"babel-core": "6.26.0",
"babel-loader": "7.1.2",
Expand All @@ -15,6 +15,7 @@
"html-webpack-inline-source-plugin": "0.0.9",
"html-webpack-plugin": "2.30.1",
"htmlparser2": "3.9.2",
"deep-equal": "1.0.1",
"radium": "0.19.6",
"react": "16.0.0",
"react-dom": "16.0.0",
Expand All @@ -27,8 +28,8 @@
"webpack-merge": "4.1.1"
},
"scripts": {
"start": "webpack --progress --colors --watch --config webpack.dev.js",
"build": "webpack --progress --colors --config webpack.prod.js",
"release": "node release.js"
"start": "node node_modules/webpack/bin/webpack.js --progress --colors --watch --config scripts/webpack.dev.js",
"build": "node node_modules/webpack/bin/webpack.js --progress --colors --config scripts/webpack.prod.js",
"release": "node scripts/release.js"
}
}
File renamed without changes.
38 changes: 19 additions & 19 deletions release.js → scripts/release.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
const fs = require('fs');
const path = require('path');
const request = require('request');
const readline = require('readline');
const stream = require('stream');
const fs = require('fs');
const archiver = require('archiver');
const zlib = require('zlib');
const urlTemplate = require('url-template');
const recursive = require(`${__dirname}/recursive`);
const path = require('path');

function isSmallerThan(firstVersion, secondVersion) {
if (firstVersion.major !== secondVersion.major) {
Expand All @@ -28,7 +28,7 @@ function areEqual(firstVersion, secondVersion) {

const semver = /^v([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)(?:-([0-9A-Za-z-\.]+)$|$)/;

const versionAsString = JSON.parse(fs.readFileSync(`${__dirname}/source/package.json`)).version;
const versionAsString = JSON.parse(fs.readFileSync(`${path.dirname(__dirname)}/source/package.json`)).version;
const semverMatch = semver.exec(`v${versionAsString}`);
if (!semverMatch) {
console.error('The version number does not have the expected format');
Expand All @@ -44,7 +44,7 @@ const version = {
// check the links' version in README.md
if (version.identifier == null) {
const simpleSemver = /([1-9]\d*|0)\.([1-9]\d*|0)\.([1-9]\d*|0)/g;
const readme = fs.readFileSync(`${__dirname}/README.md`).toString('utf8');
const readme = fs.readFileSync(`${path.dirname(__dirname)}/README.md`).toString('utf8');
for (;;) {
const simpleSemverMatch = simpleSemver.exec(readme);
if (simpleSemverMatch == null) {
Expand Down Expand Up @@ -130,20 +130,20 @@ usernameInterface.question('username: ', username => {
process.exit(1);
}
try {
fs.mkdirSync(`${__dirname}/build/archives`);
fs.mkdirSync(`${path.dirname(__dirname)}/build/archives`);
} catch (error) {}
let directoriesLeft = 0;
for (const directoryToZip of fs.readdirSync(`${__dirname}/build`)) {
if (fs.lstatSync(`${__dirname}/build/${directoryToZip}`).isDirectory()) {
for (const directoryToZip of fs.readdirSync(`${path.dirname(__dirname)}/build`)) {
if (fs.lstatSync(`${path.dirname(__dirname)}/build/${directoryToZip}`).isDirectory()) {
const matchedConfiguration = /^Origami-([^-]+)-([^-]+)$/.exec(directoryToZip);
if (matchedConfiguration != null) {
++directoriesLeft;
const output = fs.createWriteStream(`${__dirname}/build/archives/${directoryToZip}.zip`);
const output = fs.createWriteStream(`${path.dirname(__dirname)}/build/archives/${directoryToZip}.zip`);
output.on('close', () => {
console.log(`Created '${__dirname}/build/archives/${directoryToZip}.zip'`);
fs.readFile(`${__dirname}/build/archives/${directoryToZip}.zip`, (error, archive) => {
console.log(`Created '${path.dirname(__dirname)}/build/archives/${directoryToZip}.zip'`);
fs.readFile(`${path.dirname(__dirname)}/build/archives/${directoryToZip}.zip`, (error, archive) => {
if (error) {
console.error(`${__dirname}/build/archives/${directoryToZip}.zip`, error);
console.error(`${path.dirname(__dirname)}/build/archives/${directoryToZip}.zip`, error);
process.exit(1);
}
request.post({
Expand Down Expand Up @@ -338,17 +338,17 @@ usernameInterface.question('username: ', username => {

// resolve Framework symlinks manually before zipping
try {
recursive.rmSync(`${__dirname}/build/archives/${directoryToZip}`);
fs.mkdirSync(`${__dirname}/build/archives`);
recursive.rmSync(`${path.dirname(__dirname)}/build/archives/${directoryToZip}`);
fs.mkdirSync(`${path.dirname(__dirname)}/build/archives`);
} catch (error) {}
try {
fs.mkdirSync(`${__dirname}/build/archives/${directoryToZip}`);
fs.mkdirSync(`${path.dirname(__dirname)}/build/archives/${directoryToZip}`);
} catch (error) {}
recursive.copyFileSync(
`${__dirname}/build/${directoryToZip}/Origami.app`,
`${__dirname}/build/archives/${directoryToZip}/Origami.app`
`${path.dirname(__dirname)}/build/${directoryToZip}/Origami.app`,
`${path.dirname(__dirname)}/build/archives/${directoryToZip}/Origami.app`
);
const frameworks = `${__dirname}/build/archives/${directoryToZip}/Origami.app/Contents/Frameworks`;
const frameworks = `${path.dirname(__dirname)}/build/archives/${directoryToZip}/Origami.app/Contents/Frameworks`;
for (const frameworkFile of fs.readdirSync(frameworks)) {
if (path.extname(frameworkFile) === '.framework') {
const framework = `${frameworks}/${frameworkFile}`;
Expand All @@ -362,10 +362,10 @@ usernameInterface.question('username: ', username => {
}
}

archive.directory(`${__dirname}/build/archives/${directoryToZip}/Origami.app`, 'Origami.app');
archive.directory(`${path.dirname(__dirname)}/build/archives/${directoryToZip}/Origami.app`, 'Origami.app');
archive.finalize();
} else {
archive.directory(`${__dirname}/build/${directoryToZip}`, 'Origami');
archive.directory(`${path.dirname(__dirname)}/build/${directoryToZip}`, 'Origami');
archive.finalize();
}
}
Expand Down
77 changes: 77 additions & 0 deletions scripts/webpack.common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
const fs = require('fs');
const path = require('path');
const webpack = require('webpack');
const child_process = require('child_process');
const packager = require('electron-packager');
const recursive = require(`${__dirname}/recursive`);

module.exports = {

/// package uses electron-packager to convert the output of webpack to actual apps.
package: (production, callback) => {
console.log('\nCopying the package assets');
try {
fs.mkdirSync(`${path.dirname(path.dirname(__dirname))}/build/origami`);
} catch (error) {}
fs.copyFileSync(`${path.dirname(__dirname)}/source/package.json`, `${path.dirname(__dirname)}/build/origami/package.json`);
fs.writeFileSync(`${path.dirname(__dirname)}/build/origami/main.js`, `process.env.ORIGAMI_ENV = '${production ? 'production' : 'development'}';\n`);
fs.appendFileSync(`${path.dirname(__dirname)}/build/origami/main.js`, fs.readFileSync(`${path.dirname(__dirname)}/source/main.js`));
fs.copyFileSync(`${path.dirname(__dirname)}/themes/default.json`, `${path.dirname(__dirname)}/build/origami/colors.json`);
try {
fs.mkdirSync(`${path.dirname(__dirname)}/build/origami/fonts`);
} catch (error) {}
recursive.copyFileSync(`${path.dirname(__dirname)}/fonts`, `${path.dirname(__dirname)}/build/origami/fonts`);
fs.copyFileSync(`${path.dirname(__dirname)}/icons/origami.png`, `${path.dirname(__dirname)}/build/origami/origami.png`);
fs.copyFileSync(`${path.dirname(__dirname)}/build/index.html`, `${path.dirname(__dirname)}/build/origami/index.html`);
child_process.execSync('npm install', {cwd: `${path.dirname(__dirname)}/build/origami`}, {stdio: 'inherit'});
packager({
dir: `${path.dirname(__dirname)}/build/origami`,
all: production,
out: `${path.dirname(__dirname)}/build`,
overwrite: true,
icon: `${path.dirname(__dirname)}/icons/origami`,
download: {
cache: `${path.dirname(__dirname)}/build/cache`,
},
}, (error, appPaths) => {
if (error) {
console.error(error);
} else {
console.log(appPaths.map(appPath => `Created ${appPath}`).join('\n'));
}
callback();
});
},

/// configuration defines common webpack parameters for dev and prod.
configuration: {
target: 'electron-renderer',
entry: `${path.dirname(__dirname)}/source/app.js`,
output: {
path: `${path.dirname(__dirname)}/build`,
filename: 'index.js',
},
module: {
loaders: [
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/,
query: {
presets: [
['env', {targets: {electron: '1.7.6'}}],
'react',
],
plugins: [
'babel-plugin-transform-class-properties',
'babel-plugin-transform-object-rest-spread',
],
},
},
],
},
resolve: {
modules: [`${path.dirname(__dirname)}/node_modules`],
},
},
};
10 changes: 4 additions & 6 deletions webpack.dev.js → scripts/webpack.dev.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const fs = require('fs');
const path = require('path');
const merge = require('webpack-merge');
const common = require('./webpack.common');
const common = require(`${__dirname}/webpack.common`);
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');

Expand All @@ -15,16 +15,14 @@ module.exports = merge(common.configuration, {
callback();
} else {
this.packaged = true;
common.package(false, () => {
callback();
});
common.package(false, callback);
}
});
callback();
});
},
new HtmlWebpackPlugin({
template: './source/index.ejs',
template: `${path.dirname(__dirname)}/source/index.ejs`,
inlineSource: '\.js$',
inject: true
}),
Expand Down
10 changes: 6 additions & 4 deletions webpack.prod.js → scripts/webpack.prod.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
const path = require('path');
const webpack = require('webpack');
const merge = require('webpack-merge');
const common = require('./webpack.common');
const common = require(`${__dirname}/webpack.common`);
const HtmlWebpackPlugin = require('html-webpack-plugin');
const HtmlWebpackInlineSourcePlugin = require('html-webpack-inline-source-plugin');

module.exports = merge(common.configuration, {
plugins: [
function() {
this.plugin('before-run', (compiler, callback) => {
compiler.plugin('done', () => {
common.package(true);
compiler.plugin('after-emit', (compilation, callback) => {
common.package(true, callback);
});

callback();
});
},
new webpack.DefinePlugin({
'process.env.NODE_ENV': JSON.stringify('production'),
}),
new HtmlWebpackPlugin({
template: './source/index.ejs',
template: `${path.dirname(__dirname)}/source/index.ejs`,
inlineSource: '\.js$',
inject: true,
minify: {
Expand Down
9 changes: 9 additions & 0 deletions source/actions/managePublication.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
REMOVE_PUBLICATION,
UPDATE_PUBLICATION,
UPDATE_ALL_PUBLICATIONS,
SET_PUBLICATION_TAG,
} from '../constants/actionTypes'

export function addPublicationToCollection(doi, timestamp) {
Expand Down Expand Up @@ -47,3 +48,11 @@ export function updateAllPublications(timestamp) {
timestamp,
};
}

export function setPublicationTag(doi, tag) {
return {
type: SET_PUBLICATION_TAG,
doi,
tag,
};
}
Loading

0 comments on commit 6d1ebef

Please sign in to comment.