Commit 7f9ff620 authored by Thierry BUGEAT's avatar Thierry BUGEAT

#63 First desktop version commit.

parent 29112794
const electron = require('electron')
// Module to control application life.
const app = electron.app
// Module to create native browser window.
const BrowserWindow = electron.BrowserWindow
// 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
function createWindow () {
const {Menu} = require('electron')
const template = [
{
label: 'View',
submenu: [
{
label: 'Reload',
accelerator: 'CmdOrCtrl+R',
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.reload()
}
},{
label: 'Toggle Developer Tools',
accelerator: process.platform === 'darwin' ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click (item, focusedWindow) {
if (focusedWindow) focusedWindow.webContents.toggleDevTools()
}
}
]
},{
role: 'window',
submenu: [
{role: 'minimize'},
{role: 'close'},
{type: 'separator'},
{role: 'togglefullscreen'}
]
},{
role: 'help',
submenu: [
{
label: 'Website',
click () { require('electron').shell.openExternal('http://thierry.bugeat.com/myFeeds') }
},{
label: 'Git repository',
click () { require('electron').shell.openExternal('https://framagit.org/thierry-bugeat/myFeeds') }
},{
label: 'Changelog',
click () { require('electron').shell.openExternal('https://framagit.org/thierry-bugeat/myFeeds/blob/master/CHANGELOG') }
},{
type: 'separator'
},{
label: 'About',
click () {
const {BrowserWindow} = require('electron')
let win = new BrowserWindow({width: 350, height: 300, frame: false})
win.on('closed', () => {win = null})
win.loadURL(`file://${__dirname}/electron/about.html`)
win.setMenu(null);
win.show();
}
}
]
}
]
const menu = Menu.buildFromTemplate(template)
Menu.setApplicationMenu(menu)
// Create the browser window.
mainWindow = new BrowserWindow({width: 350, height: 650, icon: __dirname+'/www/img/icon-60.png'})
// and load the index.html of the app.
mainWindow.loadURL(`file://${__dirname}/www/index.html`)
// Open the DevTools.
//mainWindow.webContents.openDevTools()
// Emitted when the window is closed.
mainWindow.on('closed', function () {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null
})
}
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', createWindow)
// Quit when all windows are closed.
app.on('window-all-closed', function () {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', function () {
// On OS X it's common to re-create a window in the app when the
// dock icon is clicked and there are no other windows open.
if (mainWindow === null) {
createWindow()
}
})
// In this file you can include the rest of your app's specific main process
// code. You can also put them in separate files and require them here.
<style>
*{
margin: 0px;
padding: 0px;
}
html{
font-family: system, -apple-system, '.SFNSText-Regular', 'SF UI Text', 'Lucida Grande', 'Segoe UI', Ubuntu, Cantarell, sans-serif;
color: #FFFFFF;
background-color: #F97C17;
color: #2C393B;
background-color: #F4F4F4;
text-align: center;
}
h2 {font-size: 40px;}
img{ padding:1rem; }
#close {
color: #00AACC;
position: absolute;
bottom: 20px;
left: 50%;
transform: translateX(-50%);
font-size: 12px;
text-decoration: none;
cursor: pointer;
}
</style>
<body>
<h2>myFeeds</h2>
<img src="../www/img/icon-128.png" />
<p>Version 1.5.0 - Thierry BUGEAT</p>
<a id="close" href="javascript:window.close();">Close this window</button>
</body>
......@@ -6,7 +6,9 @@
background-color: var(--fxos-ivory);
}
#browser > iframe {
#browser > iframe,
#browser > webview
{
background-color: var(--fxos-ivory);
border: 0px solid red;
box-sizing: border-box;
......
......@@ -12,6 +12,7 @@ var _srcDocCss = [
' margin: 0; ',
' padding: 0; ',
' font-family: "FiraSans"; ',
' font-family: FiraSans, HelveticaNeue-Light, HelveticaNeue, Helvetica, Arial, sans-serif; ',
'} ',
' ',
'@font-face { ',
......@@ -40,4 +41,4 @@ var _srcDocCss = [
'.entry-enclosure {background-color: #EAEAE7; padding-bottom: 14rem; position: relative; height: 0; overflow: hidden; display: block;}',
'.entry-enclosure img {position: absolute; top: 50%; width:100%; left: 50%; transform: translate(-50%, -50%); border-bottom: 0.1rem solid #2C393B;',
'</style> '
].join('');
].trim().join('');
.developper-menu {
display: none;
}
#login-view-container{
/* will-change: transform; GPU acceleration */
position:absolute;
display: block;
width:100%;
max-width: 480px;
height:100%;
/*margin:0px auto;*/
/*position: fixed;*/
top:0%;
left:100%;
z-index:10;
box-sizing: border-box;
}
#login-view-container:before {
position:inherit;
content: " ";
width: 100%;
height: 100%;
/*box-shadow: 0 0 22px #777;*/
}
#login-view {
background-color: var(--fxos-ivory);
border: 0px solid red;
box-sizing: border-box;
width: 100%;
height: calc(100% - 9.5rem) !important;
overflow-x:hidden;
overflow-y:auto;
padding: 0;
}
#login-view > h2 {
color: var(--fxos-grey);
overflow: auto;
list-style: none outside none;
margin: 0;
overflow: hidden;
padding: var(--my-spacing);
font-size:1.6rem;
font-weight:normal;
}
#login-view h3 {
font-size:1.6rem;
font-weight:normal;
overflow: auto;
list-style: none outside none;
margin: 0;
overflow: hidden;
padding: 0;
}
#login-view span{
height: 4rem;
line-height:4rem;
display: inline-block;
color: #858585;
vertical-align:middle;
margin-right: var(--my-spacing);
}
#login-view webview {
height: 100%;
}
......@@ -51,6 +51,7 @@
<link href="css/feeds-list.css" type="text/css" rel="stylesheet">
<link href="css/find-feeds.css" type="text/css" rel="stylesheet">
<link href="css/settings.css" type="text/css" rel="stylesheet">
<link href="css/login-desktop.css" type="text/css" rel="stylesheet">
<link href="css/style.css" type="text/css" rel="stylesheet">
<link href="css/entries-list.css" type="text/css" rel="stylesheet">
<link href="css/switches.css" type="text/css" rel="stylesheet">
......@@ -233,11 +234,37 @@
</div>
<!-- ============================== -->
<!-- Desktop version (Login screen) -->
<!-- ============================== -->
<div role="region" data-type="sidebar" id="login-view-container">
<section role="myHeader">
<header class="mySystemHeader">
<h1 data-l10n-id="my-online-account">my Online Account</h1>
</header>
</section>
<div id="login-view" class="scrollable scroll"></div>
<section role="myFooter" class="">
<header>
<button id="loginClose" class="_startAnimation_"><span data-icon="close"></span></button>
</header>
</section>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/index.js"></script>
</body>
<!-- Libs -->
<script type="text/javascript" src="js/libs/myCore.js"></script>
<!-- Inline CSS -->
<script type="text/javascript" src="css/inline.css.js"></script>
......@@ -248,10 +275,6 @@
<link rel="resource" type="application/l10n" href="js/locales/locales.ini" />
<script type="text/javascript" src="js/locales/locales.js"></script>
<!-- Libs -->
<script type="text/javascript" src="js/libs/myCore.js"></script>
<!-- classes -->
<script type="text/javascript" src="js/classes/MyFeeds.class.js"></script>
......
......@@ -108,6 +108,7 @@
}
var liveValues = {
"platform": (typeof process != 'undefined' && process.platform) || (typeof cordova != 'undefined' && cordova.platformId) || "",
"timestamps": {
"min": -1, // Timestamp value beyond which an entry can't be displayed (Too old). Set by function "_setTimestamps()"
"max": -1 // End of current day (23:59:59). Set by function "_setTimestamps()"
......@@ -1857,9 +1858,7 @@
share.setAttribute("_mySha256_link", sortedEntries[entryId]['_mySha256_link']);
share.setAttribute("_mySha256_title", sortedEntries[entryId]['_mySha256_title']);
if (url != "" ) {
ui.echo("browser", '<iframe src="' + url + '" sandbox="allow-same-origin allow-scripts" mozbrowser remote></iframe>', "");
} else {
if (url == "") {
var _entry = sortedEntries[entryId];
var _srcDoc = "";
var _regex = new RegExp('\'', 'g');
......@@ -1891,7 +1890,20 @@
_srcDoc = _srcDoc + '<div class="entrie-visit-website"><a href="' + _entry.link + '"><my data-l10n-id="entry-visit-website">' + document.webL10n.get('entry-visit-website') + '</my></a></div>';
_srcDoc = _srcDoc + '</div>';
ui.echo("browser", '<iframe srcdoc=\'' + _srcDoc + '\' sandbox="allow-same-origin allow-scripts" mozbrowser remote></iframe>', "");
}
if (url != "") {
if (liveValues.platform === "linux") {
ui.echo("browser", '<webview id="electronView" src="' + url + '" ></webview>', "");
} else {
ui.echo("browser", '<iframe src="' + url + '" sandbox="allow-same-origin allow-scripts" mozbrowser remote></iframe>', "");
}
} else {
if (liveValues.platform === "linux") {
ui.echo("browser", '<webview id="electronView" src=\'data:text/html;charset=utf-8,' + _srcDoc + '\'></webview>', "");
} else {
ui.echo("browser", '<iframe srcdoc=\'' + _srcDoc + '\' sandbox="allow-same-origin allow-scripts" mozbrowser remote></iframe>', "");
}
}
document.getElementById("browser").style.cssText = "display: block;";
......
/**
* Copyright 2015 Thierry BUGEAT
* Copyright 2015, 2016 Thierry BUGEAT
*
* This file is part of myFeeds.
*
......@@ -105,17 +105,37 @@ AolReader.prototype.login = function() {
_url = 'http://' + params.settings.proxy.host + '/proxy/aolreader/example.php';
}*/
var _inAppBrowser = window.open(_url, '_blank', 'location=yes');
_inAppBrowser.addEventListener('loadstart', function(event) {
//_MyFeeds.log(event);
if (event.url.match(/^http:\/\/localhost/)) {
if (event.url.match(/code=([^&]+)/)) {
_inAppBrowser.close();
_AolReader._loginCallback(event.url);
// Electron (Desktop version)
// Cordova (FXOS, Android, Browser)
if (liveValues.platform === "linux") {
ui.echo("login-view", '<webview id="aolreaderElectronView" src="' + _url + '" ></webview>');
ui._vibrate(); ui._translate(dom['screens']['login'], 'left');
var _webView = document.getElementById("aolreaderElectronView");
_webView.addEventListener("dom-ready", function(event) {
if (event.target.src.match(/^http:\/\/localhost/)) {
if (event.target.src.match(/code=([^&]+)/)) {
loginClose.click();
ui.echo("login-view", '');
_AolReader._loginCallback(event.target.src);
}
}
}
});
});
} else {
var _inAppBrowser = window.open(_url, '_blank', 'location=yes');
_inAppBrowser.addEventListener('loadstart', function(event) {
if (event.url.match(/^http:\/\/localhost/)) {
if (event.url.match(/code=([^&]+)/)) {
_inAppBrowser.close();
_AolReader._loginCallback(event.url);
}
}
});
}
return false;
};
......
......@@ -135,18 +135,37 @@ Feedly.prototype.login = function() {
_urlParams = '&url=' + encodeURIComponent(_Feedly.feedly.host + '/v3/auth/auth?client_id=' + encodeURIComponent(_Feedly.feedly.client_id) + '&redirect_uri=' + encodeURIComponent('http://localhost') + '&response_type=code' + '&scope=' + encodeURIComponent('https://cloud.feedly.com/subscriptions'));
_url = 'http://' + params.settings.proxy.host + '/proxy/?' + _urlParams;
}*/
var _inAppBrowser = window.open(_url, '_blank', 'location=yes');
_inAppBrowser.addEventListener('loadstart', function(event) {
//_MyFeeds.log(event);
if (event.url.match(/^http:\/\/localhost/)) {
if (event.url.match(/code=([^&]+)/)) {
_inAppBrowser.close();
_Feedly._loginCallback(event.url);
// Electron (Desktop version)
// Cordova (FXOS, Android, Browser)
if (liveValues.platform === "linux") {
ui.echo("login-view", '<webview id="feedlyElectronView" src="' + _url + '" ></webview>');
ui._vibrate(); ui._translate(dom['screens']['login'], 'left');
var _webView = document.getElementById("feedlyElectronView");
_webView.addEventListener("dom-ready", function(event) {
if (event.target.src.match(/^http:\/\/localhost/)) {
if (event.target.src.match(/code=([^&]+)/)) {
loginClose.click();
ui.echo("login-view", '');
_Feedly._loginCallback(event.target.src);
}
}
}
});
});
} else {
var _inAppBrowser = window.open(_url, '_blank', 'location=yes');
_inAppBrowser.addEventListener('loadstart', function(event) {
if (event.url.match(/^http:\/\/localhost/)) {
if (event.url.match(/code=([^&]+)/)) {
_inAppBrowser.close();
_Feedly._loginCallback(event.url);
}
}
});
}
return false;
};
......
......@@ -49,10 +49,12 @@ var dom = {
},
"settings": document.getElementById('settings-container'),
"feeds": document.getElementById('feeds-list-container'),
"find": document.getElementById('find-feeds-container')
"find": document.getElementById('find-feeds-container'),
"login": document.getElementById('login-view-container')
}
};
var search = document.getElementById("search");
var loginClose = document.getElementById("loginClose");
var settingsOpen = document.getElementById("settingsOpen");
var settingsClose = document.getElementById("settingsClose");
var find_feeds = document.getElementById("find-feeds");
......@@ -759,6 +761,7 @@ closeFeedsList.onclick = function(event) {ui._vibrate(); ui._scrollTo(0);}
settingsOpen.onclick = function(event) {ui._vibrate(); ui._translate(dom['screens']['settings'], 'left');}
settingsClose.onclick = function(event) {ui._vibrate(); ui._translate(dom['screens']['settings'], 'right');}
loginClose.onclick = function(event) {ui._vibrate(); ui._translate(dom['screens']['login'], 'right');}
/* --- Events Search --- */
......
/**
* Copyright 2015 Thierry BUGEAT
* Copyright 2015, 2016 Thierry BUGEAT
*
* This file is part of myFeeds.
*
......@@ -38,6 +38,13 @@ Array.prototype.last = function() {
return this[i];
}
Array.prototype.trim = function() {
for (var i = 0; i < this.length; i++) {
this[i] = this[i].trim();
}
return this;
}
String.prototype.htmlentities = function() {
return String(this).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/"/g, '&quot;');
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment