Skip to content

Commit fee78b9

Browse files
author
Pietro Passarelli - News Labs
committedMay 21, 2019
reorged project
1 parent cee22ef commit fee78b9

22 files changed

+3807
-1
lines changed
 

‎.eslintrc

+59
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
{
2+
"parser": "babel-eslint",
3+
"plugins": [
4+
"react"
5+
],
6+
"extends": [
7+
"plugin:react/recommended"
8+
],
9+
"env": {
10+
"browser": true,
11+
"jest": true
12+
},
13+
"rules": {
14+
"no-unused-expressions": "error",
15+
"no-trailing-spaces": "error",
16+
"no-nested-ternary": "error",
17+
"space-infix-ops": "error",
18+
"indent": ["warn", 2],
19+
"arrow-spacing": ["error", { "before": true, "after": true }],
20+
"space-in-parens": [ 0, "never" ],
21+
"template-curly-spacing": [ 2, "always" ],
22+
"array-bracket-spacing": [ 2, "always" ],
23+
"object-curly-spacing": [ 2, "always" ],
24+
"computed-property-spacing": [ 2, "never" ],
25+
"no-multiple-empty-lines": [ 2, { "max": 1, "maxEOF": 0, "maxBOF": 0 } ],
26+
"quotes": [ 1, "single", "avoid-escape" ],
27+
"no-use-before-define": [ 2, { "functions": false } ],
28+
"semi": [1, "always"],
29+
"prefer-const": 1,
30+
"react/prefer-es6-class": 0,
31+
"react/jsx-filename-extension": 0,
32+
"react/jsx-curly-spacing": [ 2, "always" ],
33+
"react/jsx-indent": [ 2, 2 ],
34+
"react/prop-types": [ 1 ],
35+
"react/no-array-index-key": [ 1 ],
36+
"class-methods-use-this": [ 1 ],
37+
"no-console": 0,
38+
"no-undef": [ 1 ],
39+
"no-case-declarations": [ 1 ],
40+
"no-return-assign": [ 1 ],
41+
"no-param-reassign": [ 1 ],
42+
"no-shadow": [ 1 ],
43+
"camelcase": [ 1 ],
44+
"no-underscore-dangle" : [0, "always"],
45+
"keyword-spacing": ["error", { "before": true, "after": true }],
46+
"newline-before-return": "error",
47+
"space-before-blocks": "error",
48+
"no-unused-vars": "error",
49+
"no-multi-spaces": "warn",
50+
"comma-spacing": ["error", { "before": false, "after": true }],
51+
"prefer-destructuring": ["error", {
52+
"VariableDeclarator": {
53+
"array": false,
54+
"object": false
55+
}
56+
}]
57+
}
58+
}
59+

‎.github/ISSUE_TEMPLATE/bug_report.md

+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: Bug report
3+
about: Create a report to help us improve
4+
title: ''
5+
labels: bug
6+
assignees: pietrop
7+
8+
---
9+
10+
**Describe the bug**
11+
A clear and concise description of what the bug is.
12+
13+
**To Reproduce**
14+
Steps to reproduce the behavior:
15+
1. Go to '...'
16+
2. Click on '....'
17+
3. Scroll down to '....'
18+
4. See error
19+
20+
**Expected behavior**
21+
A clear and concise description of what you expected to happen.
22+
23+
**Screenshots**
24+
If applicable, add screenshots to help explain your problem.
25+
26+
**Desktop (please complete the following information):**
27+
- OS: [e.g. iOS]
28+
- Browser [e.g. chrome, safari]
29+
- Version [e.g. 22]
30+
31+
**Smartphone (please complete the following information):**
32+
- Device: [e.g. iPhone6]
33+
- OS: [e.g. iOS8.1]
34+
- Browser [e.g. stock browser, safari]
35+
- Version [e.g. 22]
36+
37+
**Additional context**
38+
Add any other context about the problem here.
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
---
2+
name: Feature request
3+
about: Suggest an idea for this project
4+
title: ''
5+
labels: enhancement
6+
assignees: pietrop
7+
8+
---
9+
10+
**Is your feature request related to a problem? Please describe.**
11+
<!-- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
12+
13+
**Describe the solution you'd like**
14+
<!-- A clear and concise description of what you want to happen. -->
15+
16+
**Describe alternatives you've considered**
17+
<!-- A clear and concise description of any alternative solutions or features you've considered. -->
18+
19+
**Additional context**
20+
<!-- Add any other context or screenshots about the feature request here. -->
21+
22+
<!--
23+
## User Story / Context
24+
|As a ...|I want ...|So that ...|
25+
|-|-|-|
26+
|<Who>|<What>|<Why>|
27+
28+
## Acceptance Criteria
29+
- <Criteria to satisfy the PR Issue>
30+
31+
## Definitions of Done
32+
- [ ] Runs locally
33+
- [ ] Runs remotely
34+
- [ ] Test passes
35+
- [ ] Demonstrated
36+
- [ ] Deployed to Cosmos on Test and Live
37+
- [ ] Documentation
38+
- [ ] Developer Documentation - [repo's README|<link>]
39+
- [ ] Stakeholder Documentation - [Confluence|<link>]
40+
- [ ] Operational Documentation - [Runbook|<link>]
41+
- [ ] Peer reviewed by:
42+
-->

‎.github/ISSUE_TEMPLATE/question.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
name: Question
3+
about: Ask a question about this project
4+
title: ''
5+
labels: question
6+
assignees: pietrop
7+
8+
---
9+
10+
<!-- _where applicable, please provide context and use case around your question._ -->

‎.github/PULL_REQUEST_TEMPLATE.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
**Is your Pull Request request related to another [issue](https://github.com/bbc/react-transcript-editor/issues) in this repository ?**
2+
<!-- _If so please link to other issues and PRs as appropriate_ -->
3+
4+
**Describe what the PR does**
5+
<!-- _A clear and concise description of what the PR does. Feel free to use bulletpoints and checkboxes if needed [...]_ -->
6+
7+
8+
**State whether the PR is ready for review or whether it needs extra work**
9+
<!-- _If you are still working on it and just setting it up for later review, or if it's ready to be reviewed for merging_ -->
10+
11+
**Additional context**
12+
<!-- Add any other context or screenshots about the PR. -->
13+
14+
15+
<!--
16+
## User Story / Context
17+
|As a ...|I want ...|So that ...|
18+
|-|-|-|
19+
|<Who>|<What>|<Why>|
20+
21+
## Acceptance Criteria
22+
- <Criteria to satisfy the PR Issue>
23+
24+
## Definitions of Done
25+
- [ ] Runs locally
26+
- [ ] Runs remotely
27+
- [ ] Test passes
28+
- [ ] Demonstrated
29+
- [ ] Deployed to Cosmos on Test and Live
30+
- [ ] Documentation
31+
- [ ] Developer Documentation - [repo's README|<link>]
32+
- [ ] Stakeholder Documentation - [Confluence|<link>]
33+
- [ ] Operational Documentation - [Runbook|<link>]
34+
- [ ] Peer reviewed by:
35+
-->

‎.gitignore

+76
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,79 @@ typings/
5959

6060
# next.js build output
6161
.next
62+
63+
64+
# .gitignore, files to ignore when pushing to github
65+
66+
dist/
67+
68+
# app.js in electron folder is generated with browserify using the npm comands.
69+
electron/app.js
70+
71+
#ignore all video files
72+
*.wmv
73+
*.mpg
74+
*.mpeg
75+
*.mp4
76+
*.mov
77+
*.flv
78+
*.avi
79+
*.ogv
80+
*.ogg
81+
*.webm
82+
83+
#ignore audio file
84+
*.wav
85+
*.mp3
86+
87+
#ingore subtitles files
88+
*.srt
89+
*.sbv
90+
91+
92+
# Logs
93+
logs
94+
*.log
95+
96+
# Runtime data
97+
pids
98+
*.pid
99+
*.seed
100+
101+
102+
# app ready for distribution
103+
dist
104+
105+
build/
106+
107+
# Dependency directory
108+
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
109+
node_modules
110+
111+
112+
.idea
113+
Notes
114+
115+
notes.md
116+
117+
.env
118+
119+
# mac file system
120+
.DS_Store
121+
122+
# used for packaging Adobe CEP extension, before packaging and signing, exclude to avoid conflice
123+
adobe-panel-build/
124+
125+
# self signed certificate needed for Adobe CEP Panel
126+
ccextensionsmac/certificate.p12
127+
128+
# including ZXPSignCmd comand
129+
# ccextensionsmac/ZXPSignCmd
130+
131+
# Packaged app for Adobe CEP Panel Exchange site submission or distribution.
132+
dist/com.autoedit2.it.zxp
133+
134+
135+
# dotenv ENV var
136+
.env
137+

‎.nvmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lts/dubnium

‎.travis.yml

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Travis CI configuration to run automated test when pushing to github
2+
language: node_js
3+
node_js:
4+
- "10"
5+
6+
install:
7+
- node --version
8+
- npm i -g npm@5
9+
- npm --version
10+
# - npm install
11+
12+
script:
13+
# TODO: some make command?
14+
# - npm run test:ci
15+
# TODO: could also run lit

‎CODE_OF_CONDUCT.md

+63
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Code of Conduct
2+
3+
We are committed to providing a friendly, safe and welcoming environment for all, regardless of gender, sexual orientation, disability, ethnicity, religion, or similar personal characteristic.
4+
5+
We’ve written this code of conduct not because we expect bad behaviour from our community—which, in our experience, is overwhelmingly kind and civil—but because we believe a clear code of conduct is one necessary part of building a respectful community space.
6+
7+
We are committed to providing a welcoming and inspiring community for all and expect our code of conduct to be honored. Anyone who violates this code of conduct may be banned from the community.
8+
9+
Please be kind and courteous. There's no need to be mean or rude. Respect that people have differences of opinion and that every design or implementation choice carries a trade-off and numerous costs. There is seldom a right answer, merely an optimal answer given a set of values and circumstances.
10+
11+
12+
## Our open community strives to:
13+
14+
**Be friendly and patient**.
15+
16+
**Be considerate**: Your work will be used by other people, and you in turn will depend on the work of others. Any decision you take will affect users and colleagues, and you should take those consequences into account when making decisions. Remember that we’re a world-wide community, so you might not be communicating in someone else’s primary language.
17+
18+
**Be respectful**: Not all of us will agree all the time, but disagreement is no excuse for poor behaviour and poor manners. We might all experience some frustration now and then, but we cannot allow that frustration to impact others. It’s important to remember that a community where people feel uncomfortable or threatened is not a productive one.
19+
20+
**Be careful in the words that we choose**: we are a community of professionals, and we conduct ourselves professionally. Be kind to others. Do not insult or put down other participants. Harassment and other exclusionary behaviour aren’t acceptable.
21+
22+
**Try to understand why we disagree**: Disagreements, both social and technical, happen all the time. It is important that we resolve disagreements and differing views constructively. Remember that we’re different. The strength of our community comes from its diversity, people from a wide range of backgrounds. Different people have different perspectives on issues. Being unable to understand why someone holds a viewpoint doesn’t mean that they’re wrong. Don’t forget that it is human to err and blaming each other doesn’t get us anywhere. Instead, focus on helping to resolve issues and learning from mistakes.
23+
24+
**What goes around comes a round**. We believe in open source, and are excited by what happens when people add value to each others work in a collaborative way.
25+
26+
**Take care of each other**. Alert a member of the project team if you notice a dangerous situation, someone in distress, or violations of this code of conduct, even if they seem inconsequential.
27+
28+
If any participants engages in harassing behaviour, the project team may take any lawful action we deem appropriate, including but not limited to warning the offender or asking the offender to leave the project.
29+
30+
31+
## Diversity Statement
32+
33+
We encourage everyone to participate and are committed to building a community for all. Although we will fail at times, we seek to treat everyone both as fairly and equally as possible. Whenever a participant has made a mistake, we expect them to take responsibility for it. If someone has been harmed or offended, it is our responsibility to listen carefully and respectfully, and do our best to right the wrong.
34+
35+
## Reporting Issues
36+
37+
If you experience or witness unacceptable behaviour—or have any other concerns—please report it by contacting us via **${TBC}**<!-- TODO: we need to add an email for contact eg at textAV we had - textav@bbcnewslabs.co.uk. --> All reports will be handled with discretion. In your report please include:
38+
39+
- Your contact information.
40+
- Names (real, nicknames, or pseudonyms) of any individuals involved. If there are additional witnesses, please include them as well. Your account of what occurred, and if you believe the incident is ongoing. If there is a publicly available record (e.g. a mailing list archive or a public slack channel), please include a link.
41+
- Any additional information that may be helpful.
42+
43+
After filing a report, a representative will contact you personally, review the incident, follow up with any additional questions, and make a decision as to how to respond. If the person who is harassing you is part of the response team, they will recuse themselves from handling your incident. If the complaint originates from a member of the response team, it will be handled by a different member of the response team. We will respect confidentiality requests for the purpose of protecting victims of abuse.
44+
45+
## Feedback
46+
We welcome your feedback on this and every other aspect of this project and we thank you for working with us to make it a safe, enjoyable, and friendly experience for everyone who participates.
47+
48+
## Attribution & Acknowledgements
49+
50+
We all stand on the shoulders of giants across many open source communities. We’d like to thank the communities and projects that established code of conducts and diversity statements as our inspiration:
51+
52+
- [textAV](https://sites.google.com/view/textav/conduct-london-18)
53+
- [SRCCON](https://srccon.org/conduct/)
54+
- [Django](https://www.djangoproject.com/conduct/reporting/)
55+
- [Python](https://www.python.org/community/diversity/)
56+
- [Ubuntu](https://www.ubuntu.com/community/code-of-conduct)
57+
- [Contributor Covenant](https://www.contributor-covenant.org/)
58+
- [Geek Feminism](https://geekfeminism.org/about/code-of-conduct/)
59+
- [Citizen Code of Conduct](http://citizencodeofconduct.org/)
60+
- [Gulp](https://github.com/gulpjs/gulp/blob/master/CONTRIBUTING.md)
61+
- [Open code of Conduct](https://todogroup.org/opencodeofconduct/)
62+
- ["Why You Want a Code of Conduct & How We Made One"](http://incisive.nu/2014/codes-of-conduct/)
63+
- [Facebook Open Source Code of Conduct](https://code.fb.com/codeofconduct/)

‎CONTRIBUTING.md

+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# CONTRIBUTING - Draft
2+
3+
This project has a [Code of Conduct](./CODE_OF_CONDUCT.md) that we expect all of our contributors to abide by, please check it out before contributing.
4+
5+
## Contributor license agreement
6+
By submitting code as an individual or as an entity you agree that your code is licensed the same as the [Digital Paper Edit](./LICENCE.md).
7+
8+
## Pull requests and branching
9+
10+
1. [Feel free to start by raising an issue](https://github.com/bbc/digital-paper-edit-electron/issues/new?template=feature_request.md) so that others can be aware of areas where there is active development, and if needed we can synchronies the effort.
11+
12+
2. [Fork the repo](https://help.github.com/articles/fork-a-repo/)
13+
14+
3. Before working on a feature **always** create a new branch first. Createa a branch with a meaningful name.
15+
4. Branches should be short lived - consider doing multiple PR breaking down functionalities as opposed to one big change.
16+
5. If you've added code that should be tested, add tests, if you need help with automated testing, feel free to raise an [issue](https://github.com/bbc/digital-paper-edit-electron/issues/new?template=feature_request.md).
17+
6. Ensure the test suite passes.
18+
7. Make sure your code lints.
19+
8. If you've changed APIs, consider [updating the documentation](https://github.com/bbc/digital-paper-edit-electron#documentation) and QA Testing docs.
20+
9. Once the work is complete push the branch up on to GitHub for review. Make sure your branch is up to date with `master` before making a pull request. eg use [`git merge origin/master`](https://git-scm.com/docs/git-merge) or [rebase](https://git-scm.com/book/en/v2/Git-Branching-Rebasing)
21+
10. Once a branch has been merged into `master`, delete it.
22+
23+
`master` is rarely committed to directly unless the change is quite trivial or a code review is unnecessary (code formatting or documentation updates for example).
24+
25+
## Code Quality
26+
- Aim for solutions that are easy to explain and reason around so that others can contribute to it.
27+
- Use meaningfull descriptive variables and function names. eg avoid using `x`,`y`,`z` as variable names.
28+
- Keep lines short
29+
- Keep functions small and avoid [side effects](https://en.wikipedia.org/wiki/Side_effect_(computer_science)) when possible.
30+
- etc..
31+
32+
See [this blog post for more on this](https://medium.com/mindorks/how-to-write-clean-code-lessons-learnt-from-the-clean-code-robert-c-martin-9ffc7aef870c)
33+
34+
## Contributing checklist
35+
36+
- [ ] Fork the repository
37+
- [ ] Create a branch with a meaningful name
38+
- [ ] Add automated tests where appropriate
39+
- [ ] Ensure test suite passes (`npm run test`)
40+
- [ ] Make sure your code lints. (`npm run lint`)
41+
- [ ] consider re-factoring for code quality and readability
42+
- [ ] Update documentation and QA docs where appropriate - [see updating the documentation](https://github.com/bbc/digital-paper-edit-electron#documentation)
43+
- [ ] Setup your PR for review
44+
45+
<!--
46+
Good example of contribution guideline
47+
48+
https://reactjs.org/docs/how-to-contribute.html
49+
50+
another example - with more tech details
51+
52+
https://github.com/facebook/create-react-app/blob/master/CONTRIBUTING.md
53+
54+
https://github.com/facebookresearch/wav2letter/blob/master/CONTRIBUTING.md
55+
56+
https://github.com/hiddentao/fast-levenshtein/blob/master/CONTRIBUTING.md
57+
-->

‎LICENSE

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
MIT License
22

3-
Copyright (c) 2019 BBC
3+
Pietro Passarelli CC0 BBC 2019
44

55
Permission is hereby granted, free of charge, to any person obtaining a copy
66
of this software and associated documentation files (the "Software"), to deal

‎README.md

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
2+
# Digital Paper Edit - Electron
3+
Electron Cross Platform Desktop app
4+
5+
---> _Work in progress_ <--
6+
7+
<!-- _One liner + link to confluence page_
8+
_Screenshot of UI - optional_ -->
9+
10+
11+
[See here for overall project architecture info](https://github.com/bbc/digital-paper-edit-client#project-architecture)
12+
13+
## Setup
14+
<!-- _stack - optional_
15+
_How to build and run the code/app_ -->
16+
17+
```
18+
git clone git@github.com:bbc/digital-paper-edit-electron.git
19+
```
20+
21+
```
22+
cd digital-paper-edit-electron
23+
```
24+
25+
Optional step to setup [nvm](https://github.com/nvm-sh/nvm) to use node version 10, otherwise just use node version 10
26+
```
27+
nvm use || nvm install`
28+
```
29+
30+
in root of project
31+
```
32+
npm install
33+
```
34+
35+
## Usage
36+
37+
```
38+
npm start
39+
```
40+
41+
42+
## System Architecture
43+
<!-- _High level overview of system architecture_ -->
44+
45+
Electron Cross platform desktop app
46+
47+
## Development env
48+
<!-- _How to run the development environment_
49+
50+
_Coding style convention ref optional, eg which linter to use_
51+
52+
_Linting, github pre-push hook - optional_ -->
53+
54+
- [ ] npm > `6.1.0`
55+
- [ ] node v 10 - [lts/dubnium](https://scotch.io/tutorials/whats-new-in-node-10-dubnium)
56+
- [ ] see [`.eslintrc`](./.eslintrc) in the various packages for linting rules
57+
58+
Node version is set in node version manager [`.nvmrc`](https://github.com/creationix/nvm#nvmrc)
59+
60+
## Build
61+
<!-- _How to run build_ -->
62+
63+
<!--
64+
TODO: needs to pull in React front end from npm.
65+
eg how it was done in Makefile before
66+
67+
build-electron: build-react
68+
@echo "Electron build"
69+
# does areact-build
70+
# clears build folder inside of electron
71+
rm -rf ./packages/electron/build
72+
rm -rf ./packages/electron/dist
73+
# then copies the react build folder into electron folder
74+
cp -a ./packages/client/build ./packages/electron/build
75+
# build/package electron for mac, wind and linux
76+
cd ./packages/electron && npm run build:mwl
77+
78+
and then run
79+
80+
```
81+
npm run build:mwl
82+
```
83+
-->
84+
85+
_TBC_
86+
87+
## Tests
88+
<!-- _How to carry out tests_ -->
89+
90+
_TBC_
91+
92+
## Deployment
93+
<!-- _How to deploy the code/app into test/staging/production_ -->
94+
95+
_TBC_
96+
97+
<!-- Probably through Travis or Circle CI -->

‎assets/background.png

20.3 KB
Loading

‎assets/icon.icns

953 KB
Binary file not shown.

‎assets/icon.ico

66.7 KB
Binary file not shown.

‎assets/test.png

23.9 KB
Loading

‎db/db.js

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// https://www.npmjs.com/package/electron-sqlite3
2+
// const sqlite3 = require('sqlite3').verbose();
3+
// const db = new sqlite3.Database(':memory:');
4+
// const db = new sqlite3.Database('./development.sqlite3');
5+
6+
7+
// db.serialize(function() {
8+
// db.run("CREATE TABLE lorem (info TEXT)");
9+
10+
// var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
11+
// for (var i = 0; i < 10; i++) {
12+
// stmt.run("Ipsum " + i);
13+
// }
14+
// stmt.finalize();
15+
16+
// db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
17+
// console.log(row.id + ": " + row.info);
18+
// });
19+
// });
20+
21+
// db.close();
22+
23+
const DB = {};
24+
25+
DB.getProjects = ()=>{
26+
new Promise((resolve, reject) => {
27+
resolve({projects:[{
28+
id: 1,
29+
title: 'Project title TEST',
30+
description: 'Project one description'
31+
}]});
32+
reject(false);
33+
});
34+
35+
}
36+
37+
DB.test =()=> {
38+
console.log('db');
39+
}
40+
41+
// export default DB;
42+
module.exports = DB;

‎db/development.sqlite3

8 KB
Binary file not shown.

‎db/graphql-api.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
3+
function graphQL(query) {
4+
// // if in browser mode, call graphQL API
5+
if(true){
6+
return fetch('http://localhost:4000/graphql', {
7+
method: 'POST',
8+
headers: { 'Content-Type': 'application/json' },
9+
body: JSON.stringify({ query: '{ hello }' }),
10+
})
11+
.then(res => res.json())
12+
.then(res => console.log(res.data));
13+
// if in electron then call
14+
}else{
15+
graphql(schema, query, root).then((response) => {
16+
// graphql(schema, query).then((response) => {
17+
console.log(response);
18+
});
19+
}
20+
}

‎electron-starter.js

+202
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,202 @@
1+
const electron = require("electron");
2+
// Module to control application life.
3+
const app = electron.app;
4+
const Menu = electron.Menu;
5+
const shell = electron.shell;
6+
// Module to create native browser window.
7+
const BrowserWindow = electron.BrowserWindow;
8+
9+
const path = require("path");
10+
const url = require("url");
11+
12+
// TODO: figure out auto updater
13+
// require("update-electron-app")({
14+
// repo: "kitze/react-electron-example",
15+
// updateInterval: "1 hour"
16+
// });
17+
18+
// Keep a global reference of the window object, if you don't, the window will
19+
// be closed automatically when the JavaScript object is garbage collected.
20+
let mainWindow;
21+
22+
function createWindow() {
23+
// Create the browser window.
24+
mainWindow = new BrowserWindow({
25+
width: 1000,
26+
height: 670,
27+
minWidth: 1000,
28+
minHeight: 670,
29+
titleBarStyle: 'show',
30+
webPreferences: {
31+
webSecurity: false
32+
}
33+
});
34+
35+
console.log(__dirname);
36+
if (process.env.NODE_ENV === "development") {
37+
// and load the index.html of the app.
38+
mainWindow.loadURL("http://localhost:3000");
39+
// Open the DevTools.
40+
mainWindow.webContents.openDevTools();
41+
}
42+
// Once we package this in electron we no longer
43+
// have access to process.env.NODE_ENV to set it to production
44+
// so we need to recur to putting the production mode
45+
// into the else for now.
46+
else{
47+
mainWindow.loadURL(
48+
url.format({
49+
pathname: path.join(__dirname, "./build/index.html"),
50+
protocol: "file:",
51+
slashes: true
52+
})
53+
);
54+
}
55+
56+
// https://github.com/electron/electron/issues/1095
57+
mainWindow.dataPath = app.getPath("userData");
58+
59+
// MENU
60+
// TODO: menu could be refactored as separate file?
61+
// Create the Application's main menu
62+
var template = [
63+
{
64+
label: "Application",
65+
submenu: [
66+
{
67+
label: "About Application",
68+
selector: "orderFrontStandardAboutPanel:"
69+
},
70+
{ type: "separator" },
71+
{
72+
label: "Quit",
73+
accelerator: "Command+Q",
74+
click: function() {
75+
app.quit();
76+
}
77+
}
78+
]
79+
},
80+
{
81+
label: "Edit",
82+
submenu: [
83+
{ label: "Undo", accelerator: "CmdOrCtrl+Z", selector: "undo:" },
84+
{ label: "Redo", accelerator: "Shift+CmdOrCtrl+Z", selector: "redo:" },
85+
{ type: "separator" },
86+
{ label: "Cut", accelerator: "CmdOrCtrl+X", selector: "cut:" },
87+
{ label: "Copy", accelerator: "CmdOrCtrl+C", selector: "copy:" },
88+
{ label: "Paste", accelerator: "CmdOrCtrl+V", selector: "paste:" },
89+
{ role: "pasteandmatchstyle" },
90+
{ role: "delete" },
91+
{
92+
label: "Select All",
93+
accelerator: "CmdOrCtrl+A",
94+
selector: "selectAll:"
95+
},
96+
{ type: "separator" },
97+
{
98+
label: "Speech",
99+
submenu: [
100+
{ role: "startspeaking", accelerator: "CmdOrCtrl+E" }, //perhaps add keyboard shortcut?
101+
{ role: "stopspeaking", accelerator: "CmdOrCtrl+Shift+E" } //perhaps add keyboard shortcut?
102+
]
103+
}
104+
]
105+
},
106+
{
107+
label: "View",
108+
submenu: [
109+
{ role: "reload" },
110+
{ role: "forcereload" },
111+
{ role: "toggledevtools", accelerator: "CmdOrCtrl+Alt+I" },
112+
{ type: "separator" },
113+
{ role: "resetzoom" },
114+
{ role: "zoomin" },
115+
{ role: "zoomout" },
116+
{ type: "separator" },
117+
{ role: "togglefullscreen" }
118+
]
119+
},
120+
{
121+
role: "window",
122+
submenu: [{ role: "minimize" }, { role: "close" }]
123+
},
124+
{
125+
role: "help",
126+
submenu: [
127+
// {
128+
// label: "Project Page",
129+
// click() {
130+
// require("electron").shell.openExternal("https://autoEdit.io");
131+
// }
132+
// },
133+
// {
134+
// label: "User Manual",
135+
// click() {
136+
// require("electron").shell.openExternal(
137+
// "https://pietropassarelli.gitbooks.io/autoedit2-user-manual/content/"
138+
// );
139+
// }
140+
// },
141+
// {
142+
// label: "Advanced - Developer Console",
143+
// click() {
144+
// win.webContents.toggleDevTools();
145+
// }
146+
// }
147+
]
148+
}
149+
];
150+
151+
Menu.setApplicationMenu(Menu.buildFromTemplate(template));
152+
153+
// Emitted when the window is closed.
154+
mainWindow.on("closed", function() {
155+
// Dereference the window object, usually you would store windows
156+
// in an array if your app supports multi windows, this is the time
157+
// when you should delete the corresponding element.
158+
mainWindow = null;
159+
});
160+
}
161+
162+
// This method will be called when Electron has finished
163+
// initialization and is ready to create browser windows.
164+
// Some APIs can only be used after this event occurs.
165+
app.on("ready", createWindow);
166+
167+
// Quit when all windows are closed.
168+
app.on("window-all-closed", function() {
169+
// On OS X it is common for applications and their menu bar
170+
// to stay active until the user quits explicitly with Cmd + Q
171+
if (process.platform !== "darwin") {
172+
app.quit();
173+
}
174+
});
175+
176+
app.on("activate", function() {
177+
// On OS X it's common to re-create a window in the app when the
178+
// dock icon is clicked and there are no other windows open.
179+
if (mainWindow === null) {
180+
createWindow();
181+
}
182+
});
183+
184+
// https://electron.atom.io/docs/api/app/#event-open-file-macos
185+
//not working ?
186+
app.on("open-file", (event, path) => {
187+
console.log('open-file: ',path);
188+
event.preventDefault();
189+
// shell.openExternal(url);
190+
});
191+
192+
// https://electronjs.org/docs/api/app#appsetbadgecountcount-linux-macos
193+
// app.setBadgeCount(3)
194+
195+
//not working ?
196+
app.on("open-url", (event, url) => {
197+
console.log('open-url: ',url);
198+
// On macOS it is common for applications and their menu bar
199+
// to stay active until the user quits explicitly with Cmd + Q
200+
event.preventDefault();
201+
shell.openExternal(url);
202+
});

‎package-lock.json

+2,980
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎package.json

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
{
2+
"name": "electron-tmp",
3+
"version": "1.0.0",
4+
"description": "",
5+
"main": "electron-starter.js",
6+
"scripts": {
7+
"test": "echo \"Error: no test specified\" && exit 1",
8+
"start": "cross-env NODE_ENV=development electron .",
9+
"build:mwl": "cross-env NODE_ENV=production electron-builder -m"
10+
},
11+
"license": "MIT",
12+
"author": "Pietro Passarelli CC0 BBC 2019",
13+
"contributors": [
14+
""
15+
],
16+
"devDependencies": {
17+
"cross-env": "^5.2.0",
18+
"electron": "^4.0.8",
19+
"electron-builder": "^20.38.5"
20+
},
21+
"build": {
22+
"appId": "org.autoEdit2.autoEdit2-electron",
23+
"asar": false,
24+
"directories": {
25+
"buildResources": "assets"
26+
},
27+
"files": [
28+
"**/*",
29+
"build/**",
30+
"!config/",
31+
"!assets/",
32+
"!spec/",
33+
"!project_page/",
34+
"!vendor/",
35+
"!docs/",
36+
"!dist/",
37+
"!icons/",
38+
"node_modules/**/*",
39+
"node_modules/ffmpeg-static-electron/bin/${os}/${arch}/ffmpeg",
40+
"node_modules/ffmpeg-static-electron/index.js",
41+
"node_modules/ffmpeg-static-electron/package.json",
42+
"node_modules/ffprobe-static-electron/bin/${os}/${arch}/ffmpeg",
43+
"node_modules/ffprobe-static-electron/index.js",
44+
"node_modules/ffprobe-static-electron/package.json"
45+
],
46+
"copyright": "2019 BBC - Pietro Passarelli",
47+
"mac": {
48+
"category": "public.app-category.productivity",
49+
"files": [
50+
"!node_modules/ffmpeg-static-electron/bin/win${/*}",
51+
"!node_modules/ffmpeg-static-electron/bin/linux${/*}",
52+
"!node_modules/ffprobe-static-electron/bin/win${/*}",
53+
"!node_modules/ffprobe-static-electron/bin/linux${/*}"
54+
],
55+
"target": [
56+
{
57+
"target": "zip",
58+
"arch": [
59+
"x64"
60+
]
61+
}
62+
]
63+
}
64+
},
65+
"dependencies": {
66+
"graphql": "^14.2.1",
67+
"sqlite3": "^4.0.6"
68+
}
69+
}

0 commit comments

Comments
 (0)
Please sign in to comment.