Skip to content

Commit

Permalink
Merge branch 'master' into tkd-fix-Signing
Browse files Browse the repository at this point in the history
  • Loading branch information
tkdsym2 committed Nov 8, 2018
2 parents 0f23701 + 8bdea27 commit 159c163
Show file tree
Hide file tree
Showing 113 changed files with 2,495 additions and 2,677 deletions.
Binary file modified build/icon.icns
Binary file not shown.
Binary file modified build/icon.ico
Binary file not shown.
Binary file modified build/icons/512x512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2,631 changes: 1,127 additions & 1,504 deletions package-lock.json

Large diffs are not rendered by default.

14 changes: 9 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "fabnavi-app",
"version": "0.5.5",
"version": "0.6.0",
"description": "fabnavi app",
"repository": {
"type": "git",
Expand Down Expand Up @@ -32,14 +32,14 @@
],
"license": "ISC",
"devDependencies": {
"babel-core": "^6.25.0",
"babel-core": "^6.26.3",
"babel-eslint": "^7.2.3",
"babel-jest": "^23.6.0",
"babel-loader": "^7.1.0",
"babel-plugin-styled-components": "^1.5.1",
"babel-plugin-transform-export-extensions": "^6.22.0",
"babel-plugin-transform-object-rest-spread": "^6.23.0",
"babel-preset-env": "^1.6.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.23.0",
"babel-preset-stage-2": "^6.24.1",
"css-loader": "^0.28.4",
Expand All @@ -56,7 +56,7 @@
"jest": "^21.2.1",
"jest-cli": "^23.6.0",
"jest-styled-components": "^6.2.0",
"node-sass": "^4.5.3",
"node-sass": "^4.9.4",
"npm-run-all": "^4.0.2",
"react-test-renderer": "^16.0.0",
"redux-mock-store": "^1.5.3",
Expand All @@ -71,20 +71,24 @@
"axios": "^0.16.1",
"babel-polyfill": "^6.23.0",
"debug": "^2.6.8",
"electron-dl": "^1.12.0",
"electron-is-dev": "^0.2.0",
"electron-log": "^2.2.9",
"electron-updater": "^2.18.2",
"history": "^4.6.3",
"jszip": "^3.1.5",
"jszip-utils": "0.0.2",
"keymirror": "^0.1.1",
"prop-types": "^15.5.10",
"qs": "^6.5.0",
"react": "^16.0.0",
"react-color": "^2.13.8",
"react-color": "^2.14.1",
"react-dom": "^16.0.0",
"react-modal": "^3.1.7",
"react-redux": "^5.0.5",
"react-router-dom": "^4.1.1",
"react-router-redux": "5.0.0-alpha.6",
"react-sortable-hoc": "^0.8.3",
"redux": "^3.7.0",
"redux-actions": "^2.0.3",
"redux-observable": "^0.14.1",
Expand Down
71 changes: 47 additions & 24 deletions src/main/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
const{ app, BrowserWindow, globalShortcut, Menu, dialog } = require('electron');
const{ app, BrowserWindow, Menu, dialog, ipcMain } = require('electron');
const{ autoUpdater } = require('electron-updater');
const isDev = require('electron-is-dev');
const log = require('electron-log');
const{ download } = require('electron-dl');

app.commandLine.appendSwitch('remote-debugging-port', 9223);

Expand Down Expand Up @@ -54,8 +55,14 @@ app.on('will-quit', () => {

app.on('ready', () => {
mainWindow = new BrowserWindow({
frame: true,
x: 0,
y: 0,
width: 1920,
height: 1080,
frame: false,
show: true,
kiosk: isDev ? false : true,
'fullscreen': isDev ? false : true,
webPreferences: {
webSecurity: false
}
Expand All @@ -66,7 +73,7 @@ app.on('ready', () => {
// points to `index.html` in production
const url = isDev ? `http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}` : `file://${__dirname}/index.html`

mainWindow.maximize();
if(!isDev) mainWindow.maximize();
mainWindow.loadURL(url);

if(isDev) {
Expand All @@ -75,44 +82,55 @@ app.on('ready', () => {
loadDevtool(loadDevtool.REDUX_DEVTOOLS);
}

globalShortcut.register('CommandOrControl+R', () => {
if(mainWindow) {
mainWindow.loadURL(url);
}
});

const template = [
{
label: 'fabnavi',
submenu: [
{
label: 'Restart',
click: () => mainWindow.reload(),
label: 'About fabnavi',
click: () => dialog.showMessageBox(mainWindow, {
title: 'fabnavi',
type: 'info',
message: 'fabnavi',
detail: `\nVersion: ${app.getVersion()}\nElectron: ${process.versions.electron}\nRenderer: ${process.versions.chrome}\nNode: ${process.versions.node}\nArchitecture: ${process.platform + ' ' + process.arch}`,
buttons: ['OK'],
noLink: true
})
},
{
type: 'separator',
},
{
label: 'Reload',
accelerator: 'CommandOrControl+R',
click: () => mainWindow.loadURL(url),
},
{
label: mainWindow.isKiosk() ? 'Quit Kiosk Mode' : 'Start Kiosk Mode',
accelerator: 'Shift+CommandOrControl+K',
click: () => mainWindow.setKiosk(!mainWindow.isKiosk()),
},
{
type: 'separator',
},
{
label: 'DevTools',
accelerator: 'Alt+CmdOrCtrl+J',
click: () => mainWindow.webContents.openDevTools({ mode: 'detach' }),
},
{
label: 'Quit App',
accelerator: 'Command+Q',
click: () => app.quit(),
label: 'Restart fabnavi',
accelerator: 'Shift+CommandOrControl+R',
click: () => mainWindow.reload(),
},
{
type: 'separator',
},
{
label: 'About',
click: () => dialog.showMessageBox(mainWindow, {
title: 'fabnavi',
type: 'info',
message: 'fabnavi',
detail: `\nVersion: ${app.getVersion()}\nElectron: ${process.versions.electron}\nRenderer: ${process.versions.chrome}\nNode: ${process.versions.node}\nArchitecture: ${process.platform + ' ' + process.arch}`,
buttons: ['OK'],
noLink: true
})
},
label: 'Quit',
accelerator: 'Command+Q',
click: () => app.quit(),
}
],
}, {
label: 'Edit',
Expand Down Expand Up @@ -156,6 +174,11 @@ app.on('ready', () => {
app.on('activate', () => {
mainWindow.show();
});

ipcMain.on('download', (event, data) => {
download(BrowserWindow.getFocusedWindow(), data.url, data.properties)
.then(dl => window.webContents.send('download complete', dl.getSavePath()));
})
});

app.on('ready', () => {
Expand Down
15 changes: 0 additions & 15 deletions src/renderer/actions/KeyActionCreator.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,25 +127,10 @@ export function handleKeyDown(store) {
break;
}
}
} else if(route.pathname.split('/')[1] === 'detail') {
switch(event.keyCode) {
case 27:
exitDetail(store, payload);
break;
default:
break;
}
}
};
}

function exitDetail(store, action) {
action.type = 'EXIT_DETAIL';
action.payload = 'manager';
store.dispatch(action);
store.dispatch(push('/'));
}

function togglePlaying(store, action) {
action.type = 'TOGGLE_PLAYING'
store.dispatch(action);
Expand Down
27 changes: 27 additions & 0 deletions src/renderer/components/Caption.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import PropTypes from 'prop-types';
import { secondsToHHMMSS } from '../utils/playerUtils';

import {
StyledCaption,
MetaData,
Text
} from '../stylesheets/application/ProjectShow/Caption';

export default function Caption({ caption, contentType, figureIndex, isLast }) {
return (
<StyledCaption isLast={isLast}>
<MetaData>
{contentType}#{figureIndex + 1}: {secondsToHHMMSS(caption.start_sec)}
</MetaData>
<Text>{caption.text}</Text>
</StyledCaption>
);
}

Caption.propTypes = {
caption: PropTypes.object,
contentType: PropTypes.string,
figureIndex: PropTypes.number,
isLast: PropTypes.bool
};
97 changes: 97 additions & 0 deletions src/renderer/components/CaptionList.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
const{ ipcRenderer } = require('electron');
import React from 'react';
import PropTypes from 'prop-types';
import JSZip from 'jszip';
import JSZipUtils from 'jszip-utils';

import { assetsPath } from '../utils/assetsUtils'
import { getVttUrl } from '../utils/playerUtils'

import Caption from './Caption'

import {
StyledCaptionList,
StyledList,
StyledDownloadButton,
} from '../stylesheets/application/ProjectShow/CaptionList';

import {
StyledHead
} from '../stylesheets/application/ProjectShow/StyledProjectDetail';


const downloadIcon = `${assetsPath}/images/download.svg`;

const downloadFile = async (zip, url, index) => {
return new Promise((resolve, reject) => {
JSZipUtils.getBinaryContent(url, (error, data) => {
if(error) reject(error);
zip.file(`${index}.vtt`, data, { binary: true });
resolve(data);
})
})
};

const downloadFiles = async (zip, vttList) => {
return Promise.all(vttList.map((vtt) => downloadFile(zip, vtt.url, vtt.index)));
};

const createVttList = (figures) => {
return figures.map((figure, index) => (
{
url: getVttUrl(figure.captions, 'captions'),
index: index + 1
}
));
};

const createZipURL = async (figures) => {
const vttList = createVttList(figures);
const zip = new JSZip();
await downloadFiles(zip, vttList);
const blob = await zip.generateAsync({ type: 'blob' });
return URL.createObjectURL(blob);
}


export default function CaptionList({ figures, contentType }) {
return (
<StyledCaptionList>
<StyledHead>
Captions
<StyledDownloadButton src={downloadIcon} onClick={async () => {
const url = await createZipURL(figures);
ipcRenderer.send('download', {
url: url,
properties: { saveAs: true }
})
}} />
</StyledHead>
<StyledList>
{
figures.map((figure, figureIndex) => (
{
entities: figure.captions.sort((a, b) => (a.start_sec - b.start_sec)),
figureIndex
}
)).map((captions) => {
return captions.entities.map((caption, index) => (
<Caption
caption={caption}
figureIndex={captions.figureIndex}
isLast={(index === captions.entities.length - 1)}
contentType={contentType}
key={index}
/>
))
})
}
</StyledList>
</StyledCaptionList>
);
}

CaptionList.propTypes = {
figures: PropTypes.array,
contentType: PropTypes.string
};
12 changes: 8 additions & 4 deletions src/renderer/components/DeleteModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import {
StyledProjectName,
InterfaceFrame
} from '../stylesheets/application/ProjectIndex/StyledDeleteModal';
import { Button } from '../stylesheets/application/interface/StyledButton';
import { DeleteButton, Button } from '../stylesheets/application/interface/StyledButton';
import { assetsPath } from '../utils/assetsUtils';

const debug = Debug('fabnavi:js:DeleteModal');

Expand Down Expand Up @@ -46,7 +47,10 @@ class DeleteModal extends React.Component {

render() {
const project = this.props.targetProject;
const thumb = project.content[0].figure.file.thumb.url;
const thumb =
project.content.length === 0 ?
`${assetsPath}/images/no_thumbnail.png` :
project.content[0].figure.file.thumb.url;
return (
<ReactModal
isOpen={this.props.showDeleteConfirmation}
Expand All @@ -60,13 +64,13 @@ class DeleteModal extends React.Component {
{project.name}」を削除しますか?
</StyledProjectName>
<InterfaceFrame>
<Button
<DeleteButton
onClick={() => {
this.onDeleteProject(project.id);
}}
>
Delete
</Button>
</DeleteButton>
<Button cancel onClick={this.closeConfirmation}>
Cancel
</Button>
Expand Down
10 changes: 4 additions & 6 deletions src/renderer/components/Footer.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import Debug from 'debug';

import { FooterBorder, FooterStyle } from '../stylesheets/application/Footer';
import { FooterStyle } from '../stylesheets/application/Footer';

const debug = Debug('fabnavi:jsx:Footer');

Expand All @@ -12,11 +12,9 @@ export default class Footer extends React.Component {

render() {
return (
<div>
<FooterStyle>
<small>&copy; fabnavi</small>
</FooterStyle>
</div>
<FooterStyle>
<small>&copy; fabnavi</small>
</FooterStyle>
);
}
}
Loading

0 comments on commit 159c163

Please sign in to comment.