Compare commits

...

17 Commits

Author SHA1 Message Date
ertherod
b6a4c1b1ee
Update README.md
Changing an error on the URL for cloning the repository
2019-04-06 08:39:37 +02:00
0ec6cf80db Ready to inject CSS in app 2019-02-11 20:12:17 +01:00
250a4544ab Updated project structure 2019-02-11 19:07:16 +01:00
cb3867584f Added some shorcuts 2019-02-11 19:03:47 +01:00
64f82bf087 Changed icon 2019-02-11 18:54:12 +01:00
5567ea7501 Can enable incognito mode 2019-02-11 18:47:09 +01:00
e01f521192 Can enable dark mode 2019-02-11 18:43:03 +01:00
33b8e4e2b6 Begin to create custom application menu 2019-02-11 18:38:00 +01:00
24643f0867 Updated project structure 2019-02-11 18:25:22 +01:00
484813ff4d Updated project 2019-02-11 18:13:40 +01:00
ee02924124 Updated dependencies 2019-02-11 18:13:23 +01:00
fd006da615 Updated license 2019-02-11 18:13:12 +01:00
Pierre HUBERT
594b07360f Updated packages 2018-09-27 15:29:20 +02:00
Pierre HUBERT
60119b81e4 Added package-lock.json 2018-09-27 15:15:23 +02:00
Pierre HUBERT
6d06b71b78 Added gitignore 2018-09-27 15:14:27 +02:00
Pierre HUBERT
e86d694861 Updated electron 2018-09-27 15:14:04 +02:00
ertherod
5ac9adefd4 Add version 0.2.0 2018-09-26 20:08:35 +02:00
12 changed files with 1476 additions and 30 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
node_modules/*

14
Config.js Normal file
View File

@ -0,0 +1,14 @@
/**
* Project configuration
*/
const Config = {
/**
* URL to access to Comunic
*/
access_url: 'https://comunic.io'
}
module.exports = Config;

View File

@ -1,6 +1,6 @@
MIT License
Copyright (c) 2018 Pierre Hubert
Copyright (c) 2018 The Comunic Project
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -3,7 +3,7 @@
## Using for dev
Please make sure you have installed npm on your computer.
git clone https://github.com/pierre42100/ComunicDesktop
git clone https://github.com/pierre42100/ComunicDesktop.git
npm i --save electron
npm install
electron index.js

5
app.css Normal file
View File

@ -0,0 +1,5 @@
/**
* Comunic WebApp custom stylesheet
*
* @author Comunic authors
*/

BIN
icon.png

Binary file not shown.

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 8.4 KiB

View File

@ -1,28 +1,14 @@
const electron = require('electron');
const app = electron.app;
const BrowserWindow = electron.BrowserWindow;
/**
* Application main script
*
* @author The Comunic Authors
*/
let mainWindow
const {app} = require('electron');
function createWindow() {
mainWindow = new BrowserWindow({
icon:'resources/app/icon.png',
webPreferences: {
nodeIntegration: false,
preload: './preload.js'
}
});
mainWindow.setIco
mainWindow.loadURL('https://beta.communiquons.org/');
mainWindow.on('closed', () =>{
mainWindow = null;
});
}
app.on('window-all-closed', () =>{
if(process.platform !== 'darwin'){
app.quit();
}
const MainWindow = require("./modules/MainWindow");
console.log("Starting...");
app.on('ready', () => {
MainWindow.show();
});
app.on('ready', createWindow);

136
modules/ApplicationMenu.js Normal file
View File

@ -0,0 +1,136 @@
/**
* Application menu
*
* @author Comunic Authors
*/
const {app, Menu} = require('electron');
/**
* Get application menu
*
* @param {BrowserWindow} window
* @return {Menu} Application menu
*/
module.exports.Get = function(window){
/**
* Execute javascript quickly
*/
let js = function(code) {window.webContents.executeJavaScript(code)};
return Menu.buildFromTemplate([
//File menu
{
label: "File",
submenu: [
//Close app
{
label: "Quit",
click: () => {
app.quit();
}
}
]
},
//Shorcuts menu
{
label: "Shorcuts",
submenu: [
//Latest posts
{
label: "Latest posts",
click: () => {
js("openPage('latest');");
}
},
//User page
{
label: "Your page",
click: () => {
js("openPage('user/' + userID());");
}
},
//Conversations
{
label: "Conversations",
click: () => {
js("openPage('conversations');");
}
},
//Groups
{
label: "Groups",
click: () => {
js("openPage('groups');");
}
}
]
},
//Settings menu
{
label: "Settings",
submenu: [
//Dark mode
{
label: "Toggle dark mode",
click: () => {
js("ComunicWeb.components.darkTheme.setEnabled(!ComunicWeb.components.darkTheme.isEnabled());");
}
},
//Incognito mode
{
label: "Enable incognito mode",
sublabel: "F6",
click: () => {
js("ComunicWeb.components.incognito.ui.confirmEnable();");
}
},
//Account settings
{
label: "Account settings",
click: () => {
js("openPage('settings');");
}
}
]
},
//Advanced menu
{
label: "Advanced",
submenu: [
//Dev tools
{
label: "Toggle developer tools",
click: () => {
window.webContents.toggleDevTools();
}
}
]
}
])
}

79
modules/MainWindow.js Normal file
View File

@ -0,0 +1,79 @@
/**
* Main Window script
*
* @author The Comunic authors
*/
const electron = require('electron');
const BrowserWindow = electron.BrowserWindow;
const {Menu, Tray} = require('electron');
const Config = require("../Config");
const TrayMenu = require("./TrayMenu");
const ApplicationMenu = require("./ApplicationMenu");
const fs = require("fs");
let mainWindow;
let tray = null;
let page_finished_loading = false;
/**
* Show main window
*/
exports.show = function(){
//Create and show main window
mainWindow = new BrowserWindow({
icon:'icon.png',
webPreferences: {
nodeIntegration: false
},
//show: false
});
//mainWindow.maximize();
//set the url which must be open
mainWindow.loadURL(Config.access_url);
mainWindow.on('closed', () =>{
//To close the window
mainWindow = null;
});
//Create tray
tray = new Tray('./icon.png');
tray.setToolTip('Comunic');
tray.setContextMenu(TrayMenu);
console.log("Started successfully");
//Set application menu
Menu.setApplicationMenu(ApplicationMenu.Get(mainWindow));
mainWindow.once('ready-to-show', () => {
mainWindow.show();
});
mainWindow.webContents.on('did-finish-load', function() {
page_finished_loading = true;
//Inject CSS
fs.readFile("./app.css", (err, data) => {
//Check for errors
if(err){
console.error("Error while loading ./app.css: " + err);
return;
}
let style = data.toString();
mainWindow.webContents.executeJavaScript("let style = document.createElement('style');" +
"style.innerHTML = decodeURIComponent(\""+encodeURIComponent(style)+"\");" +
"document.head.appendChild(style);");
});
});
}

14
modules/TrayMenu.js Normal file
View File

@ -0,0 +1,14 @@
/**
* Tray menu
*
* @author Comunic Authors
*/
const {app, Menu} = require('electron');
module.exports = Menu.buildFromTemplate([{
label : 'Close',
click: () => {
app.quit();
console.log("Closed");
}
}]);

1210
package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,15 +1,16 @@
{
"name": "communic-desktop",
"version": "0.1.0",
"version": "0.2.0",
"description": "A client-desktop for communiquons.org",
"main": "index.js",
"scripts": {
"test": "electron ."
"test": "electron .",
"run": "electron index.js"
},
"author": "Team dev communic",
"license": "GPL-3.0",
"dependencies": {},
"devDependencies": {
"electron": "^2.0.0"
"electron": "^3.1.3"
}
}