diff --git a/libresapi/src/libresapi.pro b/libresapi/src/libresapi.pro index bcbf542ab..f1f387e4a 100644 --- a/libresapi/src/libresapi.pro +++ b/libresapi/src/libresapi.pro @@ -13,13 +13,23 @@ CONFIG += libmicrohttpd INCLUDEPATH += ../../libretroshare/src unix { - webui_files.path = "$${DATA_DIR}/webui" - webui_files.files = webfiles/* - INSTALLS += webui_files + + webui_files.path = "$${DATA_DIR}/webui" + webui_files.files = webui-src/public-gen/app.js + webui_files.files += webui-src/public-gen/app.css + webui_files.files += webui-src/public-gen/index.html + INSTALLS += webui_files webui_img_files.path = "$${DATA_DIR}/webui/img" webui_img_files.files = ../../retroshare-gui/src/gui/images/logo/logo_splash.png INSTALLS += webui_img_files + + create_webfiles.commands = sh $$_PRO_FILE_PWD_/webui-src/make-src/build.sh $$_PRO_FILE_PWD_/webui-src + QMAKE_EXTRA_TARGETS += create_webfiles + PRE_TARGETDEPS += create_webfiles + + system($$create_webfiles.commands) + } win32{ diff --git a/libresapi/src/webui-src/.gitignore b/libresapi/src/webui-src/.gitignore index cff629a7a..9688f9995 100644 --- a/libresapi/src/webui-src/.gitignore +++ b/libresapi/src/webui-src/.gitignore @@ -1,2 +1,3 @@ node_modules/* public/* +public-gen/* diff --git a/libresapi/src/webui-src/README.md b/libresapi/src/webui-src/README.md index 3d2748d6c..bab6fdc79 100644 --- a/libresapi/src/webui-src/README.md +++ b/libresapi/src/webui-src/README.md @@ -56,3 +56,4 @@ need 4 master [X] unsubscribe lobby [X] unread chat message counter in menu [X] list chat-lobby participants +[ ] creating app.js on build (no need for npm on regulary build) diff --git a/libresapi/src/webui-src/app/menudef.js b/libresapi/src/webui-src/app/menudef.js index da41fb616..7181a986f 100644 --- a/libresapi/src/webui-src/app/menudef.js +++ b/libresapi/src/webui-src/app/menudef.js @@ -1,4 +1,4 @@ -rs=require("retroshare"); +var rs=require("retroshare"); module.exports = { nodes: [ { name: "home", diff --git a/libresapi/src/webui-src/make-src/build.sh b/libresapi/src/webui-src/make-src/build.sh new file mode 100755 index 000000000..70ef86d76 --- /dev/null +++ b/libresapi/src/webui-src/make-src/build.sh @@ -0,0 +1,40 @@ +#!/usr/bin/sh +echo $1 +if [ "$1" == "" ];then + publicdest=../public-gen + src=.. +else + publicdest=$1/public-gen + src=$1 +fi +echo $publicdest + +if [ -d "$publicdest" ]; then + echo remove $publicdest + rm $publicdest -R +fi +echo mkdir $publicdest +mkdir $publicdest + +echo copy template.js ... +cp $src/make-src/template.js $publicdest/app.js + +for filename in $src/app/*.js; do + fname=$(basename "$filename") + fname="${fname%.*}" + echo adding $fname ... + echo require.register\(\"$fname\", function\(exports, require, module\) { >> $publicdest/app.js + cat $filename >> $publicdest/app.js + echo >> $publicdest/app.js + echo }\)\; >> $publicdest/app.js +done + +echo building app.css +cat $src/app/green-black.scss >> $publicdest/app.css +cat $src/make-src/main.css >> $publicdest/app.css +cat $src/make-src/chat.css >> $publicdest/app.css + +echo copy index.html +cp $src/app/assets/index.html $publicdest/index.html + +echo build.sh complete diff --git a/libresapi/src/webui-src/make-src/chat.css b/libresapi/src/webui-src/make-src/chat.css new file mode 100644 index 000000000..e76d764c3 --- /dev/null +++ b/libresapi/src/webui-src/make-src/chat.css @@ -0,0 +1,72 @@ +.chat { + padding: 15px; } + .chat.container { + height: 100%; + padding: 0px; + position: relative; + box-sizing: border-box; } + .chat.header { + position: absolute; + top: 0px; + left: 0px; + right: 0px; + height: 50px; + background-color: black; + border-bottom: solid 1px gray; + box-sizing: border-box; } + .chat.left { + position: absolute; + top: 50px; + bottom: 0px; + left: 0px; + width: 200px; + box-sizing: border-box; + background-color: black; } + .chat.right { + position: absolute; + top: 50px; + right: 0px; + bottom: 0px; + width: 200px; + box-sizing: border-box; } + .chat.middle { + position: absolute; + top: 0px; + margin-top: 50px; + left: 200px; + right: 200px; + box-sizing: border-box; + padding: 0px; + height: 100%; + overflow-y: scroll; } + .chat.bottom { + position: absolute; + bottom: 0px; + right: 200px; + left: 200px; + padding: 5px; } + .chat.msg { + padding: 0px; } + .chat.msg.container { + position: relative; + border-bottom: solid 1px lightgray; + padding: 10px; + height: unset; } + .chat.msg.from { + position: absolute; + width: 100px; + top: 10px; + left: 0px; + color: white; + text-align: right; } + .chat.msg.when { + float: right; + color: lightgray; + margin-bottom: 10px; } + .chat.msg.text { + padding-left: 100px; + top: 0px; + left: 100px; + white-space: pre-wrap; + height: initial; } + diff --git a/libresapi/src/webui-src/make-src/main.css b/libresapi/src/webui-src/make-src/main.css new file mode 100644 index 000000000..539963e7e --- /dev/null +++ b/libresapi/src/webui-src/make-src/main.css @@ -0,0 +1,2 @@ +html, body, #main { + height: 100%; } diff --git a/libresapi/src/webui-src/make-src/template.js b/libresapi/src/webui-src/make-src/template.js new file mode 100644 index 000000000..e0f04f75d --- /dev/null +++ b/libresapi/src/webui-src/make-src/template.js @@ -0,0 +1,112 @@ +(function() { + 'use strict'; + + var globals = typeof window === 'undefined' ? global : window; + if (typeof globals.require === 'function') return; + + var modules = {}; + var cache = {}; + var aliases = {}; + var has = ({}).hasOwnProperty; + + var endsWith = function(str, suffix) { + return str.indexOf(suffix, str.length - suffix.length) !== -1; + }; + + var _cmp = 'components/'; + var unalias = function(alias, loaderPath) { + var start = 0; + if (loaderPath) { + if (loaderPath.indexOf(_cmp) === 0) { + start = _cmp.length; + } + if (loaderPath.indexOf('/', start) > 0) { + loaderPath = loaderPath.substring(start, loaderPath.indexOf('/', start)); + } + } + var result = aliases[alias + '/index.js'] || aliases[loaderPath + '/deps/' + alias + '/index.js']; + if (result) { + return _cmp + result.substring(0, result.length - '.js'.length); + } + return alias; + }; + + var _reg = /^\.\.?(\/|$)/; + var expand = function(root, name) { + var results = [], part; + var parts = (_reg.test(name) ? root + '/' + name : name).split('/'); + for (var i = 0, length = parts.length; i < length; i++) { + part = parts[i]; + if (part === '..') { + results.pop(); + } else if (part !== '.' && part !== '') { + results.push(part); + } + } + return results.join('/'); + }; + + var dirname = function(path) { + return path.split('/').slice(0, -1).join('/'); + }; + + var localRequire = function(path) { + return function expanded(name) { + var absolute = expand(dirname(path), name); + return globals.require(absolute, path); + }; + }; + + var initModule = function(name, definition) { + var module = {id: name, exports: {}}; + cache[name] = module; + definition(module.exports, localRequire(name), module); + return module.exports; + }; + + var require = function(name, loaderPath) { + var path = expand(name, '.'); + if (loaderPath == null) loaderPath = '/'; + path = unalias(name, loaderPath); + + if (has.call(cache, path)) return cache[path].exports; + if (has.call(modules, path)) return initModule(path, modules[path]); + + var dirIndex = expand(path, './index'); + if (has.call(cache, dirIndex)) return cache[dirIndex].exports; + if (has.call(modules, dirIndex)) return initModule(dirIndex, modules[dirIndex]); + + throw new Error('Cannot find module "' + name + '" from '+ '"' + loaderPath + '"'); + }; + + require.alias = function(from, to) { + aliases[to] = from; + }; + + require.register = require.define = function(bundle, fn) { + if (typeof bundle === 'object') { + for (var key in bundle) { + if (has.call(bundle, key)) { + modules[key] = bundle[key]; + } + } + } else { + modules[bundle] = fn; + } + }; + + require.list = function() { + var result = []; + for (var item in modules) { + if (has.call(modules, item)) { + result.push(item); + } + } + return result; + }; + + require.brunch = true; + require._cache = cache; + globals.require = require; +})(); +