Skip to content

Commit

Permalink
REST API to grab about information #32
Browse files Browse the repository at this point in the history
  • Loading branch information
lpsandaruwan committed Feb 5, 2017
1 parent 02f0164 commit ab2cd9b
Show file tree
Hide file tree
Showing 6 changed files with 199 additions and 17 deletions.
50 changes: 50 additions & 0 deletions app/about.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>About</title>
</head>

<style>

.app-logo {
height: 80px;
}

</style>

<script src="node_modules/jquery/dist/jquery.min.js" type="text/javascript"></script>
<script src="node_modules/angular/angular.min.js" type="text/javascript"></script>

<script>

var aboutModule = angular.module("aboutModule", []);

aboutModule.controller("aboutController", function ($http, $scope) {
$scope.abtData = undefined;

$http.get("http://127.0.0.1:5000/settings/about")
.then(function onSuccess(response) {
$scope.abtData = response.data;
})
.catch(function onError(response) {

})
});

</script>

<body ng-app="aboutModule" ng-controller="aboutController">

<img class="app-logo" src="images/fontman.png">
<h3>Fontman Desktop</h3>
<h4>Version {{abtData.version}} {{abtData.platform}}</h4>

<p>Fontman Desktop is a cross-platform desktop font package manager which brings latest and greatest Libre, open source fonts to your desktop.</p>
<p>Fontman is a free software project and welcomes bug reports, suggestions, contributions and code contributions. See FAQ for more information.</p>
<p>This software is licensed under GNU GPL version 3 and the source code is hosted on Github. See the LICENSE for more information.</p>

<h5>© Copyright {{abtData.year}} Fontman Project Authors.</h5>

</body>
</html>
2 changes: 2 additions & 0 deletions app/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -98,5 +98,7 @@
<script src="ng-modules/fontsModule.js" type="text/javascript"></script>
<script src="ng-modules/typecasesModule.js" type="text/javascript"></script>

<script src="renderer.js" type="text/javascript"></script>

</body>
</html>
89 changes: 73 additions & 16 deletions app/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,26 @@ const app = electron.app;
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow;

const path = require('path');
const url = require('url');

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;


// build app native menus
const {Menu} = require('electron');

const ipc = require('electron').ipcRenderer;

// native menu template
const nativeMenus = [
{
label: 'Fonts',
submenu: [
{
label: 'Check for updates'
label: 'Check for updates',
click () {openCheckFontsUpdate();}
}
]

Expand All @@ -36,22 +45,27 @@ const nativeMenus = [
label: 'Settings'
},
{
label: 'About'
label: 'About',
click () {openAbout();}
},
{
label: 'Help',
submenu: [
{
label: 'Help'
label: 'Help',
click () { require('electron').shell.openExternal('http://fontman.io/help') }
},
{
label: 'Interface guide'
label: 'Interface guide',
click () { require('electron').shell.openExternal('http://fontman.io/help#desktop-interface') }
},
{
label: 'Report a bug'
label: 'Report a bug',
click () { require('electron').shell.openExternal('http://github.com/fontman/fontman-desktop/issues/new') }
},
{
label: 'Ask a question'
label: 'Ask a question',
click () { require('electron').shell.openExternal('http://github.com/fontman/fontman-desktop/issues/new') }
},
{
label: 'Updates from @fontmanApp'
Expand All @@ -64,16 +78,59 @@ const menu = Menu.buildFromTemplate(nativeMenus);
Menu.setApplicationMenu(menu);


// Module to control tray application.
const Tray = electron.Tray;
// font updates window
var checkFontsUpdates = null;

const path = require('path');
const url = require('url');
function openCheckFontsUpdate() {
if (checkFontsUpdates) {
checkFontsUpdates.focus();
return;
}

checkFontsUpdates = new BrowserWindow({
height: 400,
resizable: false,
width: 400,
title: "Check for font updates",
minimizable: true,
fullscreenable: false
});

checkFontsUpdates.loadURL('file://' + __dirname + '/views/font_updates.html');
checkFontsUpdates.setMenu(null);

checkFontsUpdates.on('closed', function () {
checkFontsUpdates = null;
});
}


// about window
var about = null;

function openAbout() {
if (about) {
about.focus();
return;
}

about = new BrowserWindow({
height: 500,
resizable: false,
width: 600,
title: "About",
minimizable: false,
fullscreenable: false
});

about.loadURL('file://' + __dirname + '/about.html');
about.setMenu(null);

about.on('closed', function () {
about = null;
});
}

// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
let mainWindow;
let appIcon = null;

function createWindow () {

Expand All @@ -88,7 +145,7 @@ function createWindow () {
}));

// remove default main menu
//mainWindow.setMenu(null);
// mainWindow.setMenu('js/menu.js');

// Open the DevTools.
mainWindow.webContents.openDevTools();
Expand Down
63 changes: 63 additions & 0 deletions app/menu/menu.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/**
* Created by lpsandaruwan on 2/5/17.
*/

// build app native menus
const {Menu} = require('electron');
const ipc = require('electron').ipcRenderer;

// native menu template
const nativeMenus = [
{
label: 'Fonts',
submenu: [
{
label: 'Check for updates'
}
]

},
{
label: 'Account',
submenu: [
{
label: 'Register'
},
{
label: "Sign In"
}
]
},
{
label: 'Settings'
},
{
label: 'About'
},
{
label: 'Help',
submenu: [
{
label: 'Help',
click () { require('electron').shell.openExternal('http://fontman.io/help') }
},
{
label: 'Interface guide',
click () { require('electron').shell.openExternal('http://fontman.io/help#desktop-interface') }
},
{
label: 'Report a bug',
click () { require('electron').shell.openExternal('http://github.com/fontman/fontman-desktop/issues/new') }
},
{
label: 'Ask a question',
click () { require('electron').shell.openExternal('http://github.com/fontman/fontman-desktop/issues/new') }
},
{
label: 'Updates from @fontmanApp'
}
]
}
];

const menu = Menu.buildFromTemplate(nativeMenus);
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,6 @@
"textangular": "^1.5.16"
},
"devDependencies": {
"electron": "^1.4.1"
"electron": "^1.4.15"
}
}
10 changes: 10 additions & 0 deletions app/views/font_updates.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Check for fonts updates</title>
</head>
<body>

</body>
</html>

0 comments on commit ab2cd9b

Please sign in to comment.