Commit 5e93be9a authored by Mihkel Putrinš's avatar Mihkel Putrinš

Merge branch 'master' into test

# Conflicts:
#	code/app.js
#	code/panu.js
parents 1f84ed4d 86d1afb0
...@@ -18,7 +18,11 @@ var pjson_path = path.join(__dirname, '..', 'package.json') ...@@ -18,7 +18,11 @@ var pjson_path = path.join(__dirname, '..', 'package.json')
var pjson = require(pjson_path) var pjson = require(pjson_path)
if (IS_DEV) { if (IS_DEV) {
pjson.build++ pjson.build++
<<<<<<< HEAD
fs.writeFileSync(pjson_path, JSON.stringify(pjson, null, 4)) fs.writeFileSync(pjson_path, JSON.stringify(pjson, null, 4))
=======
fs.writeFileSync(pjson_path, JSON.stringify(pjson, null, 2))
>>>>>>> master
} }
console.log('----==== ' + pjson.name + ' v.' + pjson.version + ' (build ' + (pjson.build) + ') ====----') console.log('----==== ' + pjson.name + ' v.' + pjson.version + ' (build ' + (pjson.build) + ') ====----')
...@@ -56,10 +60,10 @@ app.on('ready', function() { ...@@ -56,10 +60,10 @@ app.on('ready', function() {
mainWindow = new BrowserWindow({ width: 900, height: 600, show: true, "web-preferences": web_preferences }) mainWindow = new BrowserWindow({ width: 900, height: 600, show: true, "web-preferences": web_preferences })
mainWindow.setTitle('Panustaja') mainWindow.setTitle('Panustaja')
mainWindow.center() mainWindow.center()
var view_path = path.join(app.getAppPath(), 'code', 'main.html') var view_path = path.join(app.getAppPath(), 'code', 'panu_view.html')
mainWindow.webContents.loadUrl('file://' + view_path) mainWindow.webContents.loadUrl('file://' + view_path)
if (IS_DEV) {
mainWindow.webContents.openDevTools(true) mainWindow.webContents.openDevTools(true)
if (IS_DEV) {
} }
windows['authWindow'].close() windows['authWindow'].close()
delete windows['authWindow'] delete windows['authWindow']
...@@ -82,14 +86,14 @@ ipc.on('setTitle', function(event, message) { ...@@ -82,14 +86,14 @@ ipc.on('setTitle', function(event, message) {
}) })
var user_data = false var user_data = false
console.log('user_data: ' + JSON.stringify(user_data, null, 4)) // console.log('user_data: ' + JSON.stringify(user_data, null, 4))
ipc.on('setUser', function(event, data) { ipc.on('setUser', function(event, data) {
user_data = data user_data = data
console.log('setUser: ' + JSON.stringify(user_data, null, 4)) // console.log('setUser: ' + JSON.stringify(user_data, null, 4))
}) })
ipc.on('getUser', function(event, msg) { ipc.on('getUser', function(event, msg) {
event.returnValue = user_data event.returnValue = user_data
console.log('getUser: ' + JSON.stringify(user_data, null, 4)) // console.log('getUser: ' + JSON.stringify(user_data, null, 4))
}) })
app.on('window-all-closed', function() { app.on('window-all-closed', function() {
......
doctype html
html
head
meta(charset='utf-8')
link(rel='stylesheet', type='text/css', href='./style.css')
link(rel='icon' type='image/png', href='/favicon-96x96.png' sizes='96x96')
link(rel='shortcut icon', href='/favicon.ico')
body
h1#userName() Tere
div#selectLocal(hidden)
p#selectLocalMessage Palun vali fail(id) ja/või kataloog(id), mida soovid üles laadida.
button#selectLocalButton(onclick='selectLocal()') Vali
div#resourceName(hidden='')
p#resourceNameMessage Muuda ressursi nimi sobivaks.
input#resourceNameInput(type='text' placeholder='Ressursi nimi' style='width:100%;')
div#loading(hidden='')
h3 Loen failisüsteemist ...
div#resourceStats(hidden='')
ul#resourceStatsList
li#resourceDirectories
li#resourceFiles
ul#mimeStats
div#uploadResource(hidden='')
p#uploadResourceMessage Ressurss on üleslaadimiseks valmis.
button#uploadResourceButton(onclick='uploadResource()') Panusta!
div#uploading(hidden='')
span= 'Kataloogid: '
span#uploadedResources 0
span /
span#uploadTotalResources 0
div#resourceProgressbarOuter
div#resourceProgressbarInner
div#fileProgressbarInner
span= 'Failid: '
span#uploadedSize 0
span /
span#uploadTotalSize 0
//- div#fileProgressbarOuter
pre#status
div#thankYou(hidden='') Aitäh!
script(src='./main.js')
...@@ -3,10 +3,7 @@ var fs = require('fs') ...@@ -3,10 +3,7 @@ var fs = require('fs')
var op = require('object-path') var op = require('object-path')
var path = require('path') var path = require('path')
var async = require('async') var async = require('async')
var mime = require('mime')
var mmm = require('mmmagic')
var Magic = mmm.Magic
var magic = new Magic(mmm.MAGIC_MIME_TYPE | mmm.MAGIC_MIME_ENCODING)
var remote = require('remote') var remote = require('remote')
var app = remote.require('app') var app = remote.require('app')
...@@ -25,6 +22,10 @@ var user_data = {} ...@@ -25,6 +22,10 @@ var user_data = {}
var data = ipc.sendSync('getUser', null) var data = ipc.sendSync('getUser', null)
var initialize = function initialize() { var initialize = function initialize() {
<<<<<<< HEAD:code/main.js
=======
// console.log('user_data: ' + data)
>>>>>>> master:code/panu.js
if (!data) { if (!data) {
data = JSON.parse(clipboard.readText()) data = JSON.parse(clipboard.readText())
clipboard.clear() clipboard.clear()
...@@ -104,6 +105,7 @@ var resourceLoaded = function resourceLoaded() { ...@@ -104,6 +105,7 @@ var resourceLoaded = function resourceLoaded() {
} }
var renderResource = function renderResource() { var renderResource = function renderResource() {
console.log(JSON.stringify(op.get(resource_stats, 'mime'), null, 2))
document.getElementById('resourceStats').removeAttribute('hidden') document.getElementById('resourceStats').removeAttribute('hidden')
document.getElementById('resourceDirectories').innerHTML = '' document.getElementById('resourceDirectories').innerHTML = ''
document.getElementById('resourceFiles').innerHTML = '' document.getElementById('resourceFiles').innerHTML = ''
...@@ -129,21 +131,15 @@ var recurseLocal = function recurseLocal(parent_resource, paths, loadedCB) { ...@@ -129,21 +131,15 @@ var recurseLocal = function recurseLocal(parent_resource, paths, loadedCB) {
return callback() return callback()
} }
if (stats.isFile()) { if (stats.isFile()) {
magic.detectFile(_path, function(err, result) { var mimetype = mime.lookup(_path)
if (err) { // console.log(mimetype)
return callback() resource_stats.files.count++
} resource_stats.files.size += stats.size
resource_stats.files.count++ op.push(parent_resource, 'files', _path)
resource_stats.files.size += stats.size var charset = ''
op.push(parent_resource, 'files', _path) op.set(resource_stats, ['mime', mimetype, 'count'], op.get(resource_stats, ['mime', mimetype, 'count'], 0) + 1)
var mime = result.split(';')[0] op.set(resource_stats, ['mime', mimetype, 'size'], op.get(resource_stats, ['mime', mimetype, 'size'], 0) + stats.size)
var charset = result.split(';')[1].split('=')[1] callback()
op.set(resource_stats, ['mime', mime, 'count'], op.get(resource_stats, ['mime', mime, 'count'], 0) + 1)
op.set(resource_stats, ['mime', mime, 'size'], op.get(resource_stats, ['mime', mime, 'size'], 0) + stats.size)
op.set(resource_stats, ['mime', mime, 'charsets', charset, 'count'], op.get(resource_stats, ['mime', mime, 'charsets', charset, 'count'], 0) + 1)
op.set(resource_stats, ['mime', mime, 'charsets', charset, 'size'], op.get(resource_stats, ['mime', mime, 'charsets', charset, 'size'], 0) + stats.size)
callback()
})
} else if (stats.isDirectory()) { } else if (stats.isDirectory()) {
resource_stats.directories.count++ resource_stats.directories.count++
var directory = {name: _path} var directory = {name: _path}
...@@ -164,6 +160,7 @@ var recurseLocal = function recurseLocal(parent_resource, paths, loadedCB) { ...@@ -164,6 +160,7 @@ var recurseLocal = function recurseLocal(parent_resource, paths, loadedCB) {
if( err ) { if( err ) {
console.log('A file failed to process', err) console.log('A file failed to process', err)
} else { } else {
// console.log(JSON.stringify(op.get(resource_stats, 'mime'), null, 2))
loadedCB() loadedCB()
} }
}) })
......
...@@ -3,10 +3,15 @@ ...@@ -3,10 +3,15 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<link rel="stylesheet" type="text/css" href="./style.css"> <link rel="stylesheet" type="text/css" href="./style.css">
<link rel="icon" type="image/png" href="/favicon-96x96.png" sizes="96x96"> <link rel="icon" type="image/png" href="/images/murakas.ico" sizes="96x96">
<link rel="shortcut icon" href="/favicon.ico"> <link rel="shortcut icon" href="/images/murakas.ico">
</head> </head>
<body> <body>
<div id="murakas">
<img src="../images/murakas/png/96x96.png">
<br/>
Panustaja
</div>
<h1 id="userName">Tere</h1> <h1 id="userName">Tere</h1>
<div id="selectLocal" hidden> <div id="selectLocal" hidden>
<p id="selectLocalMessage">Palun vali fail(id) ja/või kataloog(id), mida soovid üles laadida.</p> <p id="selectLocalMessage">Palun vali fail(id) ja/või kataloog(id), mida soovid üles laadida.</p>
...@@ -45,6 +50,6 @@ ...@@ -45,6 +50,6 @@
<a id="resource_entu_link">siin</a> <a id="resource_entu_link">siin</a>
</div> </div>
</div> </div>
<script src="./main.js"></script> <script src="./panu.js"></script>
</body> </body>
</html> </html>
...@@ -26,3 +26,28 @@ ...@@ -26,3 +26,28 @@
background-color: #0065CA; background-color: #0065CA;
/*border: 0px solid green;*/ /*border: 0px solid green;*/
} }
#murakas {
text-align: center;
font: caption;
margin: 0px;
position: fixed;
top: 1em;
right: 1em;
}
body
{
font: caption;
color: WindowText;
background-color: Window;
/*border: 2px solid ActiveBorder;*/
}
h1
{
font: caption;
color: WindowText;
}
/*leave 2 pixels of space between a focus outline and the element that has the focus or is active*/
:focus,:active { outline-offset: 2px }
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
"name": "Panustaja", "name": "Panustaja",
"description": "Ressursikataloogi upitamiseks keeleressurside Entu repositooriumisse.", "description": "Ressursikataloogi upitamiseks keeleressurside Entu repositooriumisse.",
"version": "1.0.1-d", "version": "1.0.1-d",
"build": 96, "build": 99,
"main": "./code/app.js", "main": "./code/app.js",
"license": "CC-SA", "license": "CC-SA",
"private": true, "private": true,
...@@ -13,7 +13,7 @@ ...@@ -13,7 +13,7 @@
"dependencies": { "dependencies": {
"async": "^1.5.0", "async": "^1.5.0",
"electron-jade": "^1.3.0", "electron-jade": "^1.3.0",
"mmmagic": "^0.4.1", "mime": "^1.3.4",
"object-path": "^0.9.2", "object-path": "^0.9.2",
"request": "^2.65.0" "request": "^2.65.0"
}, },
......
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