diff --git a/ATTRIBUTION.md b/ATTRIBUTION.md index 4f9035599..77512fcb1 100644 --- a/ATTRIBUTION.md +++ b/ATTRIBUTION.md @@ -1,6 +1,10 @@ This project is [licensed](https://github.com/IITC-CE/ingress-intel-total-conversion/blob/master/LICENSE) under the permissive [ISC license](https://www.isc.org/licenses/). Parts imported from other projects remain under their respective licenses: +### Vue.js-related components: +- [**Vue.js**](https://vuejs.org/) © Yuxi (Evan) You: [[MIT](https://github.com/vuejs/vue/blob/dev/LICENSE)] +- [**http-vue-loader**](https://github.com/FranckFreiburger/http-vue-loader) © Franck Freiburger: [[MIT](https://github.com/FranckFreiburger/http-vue-loader/blob/master/LICENSE)] + ### jQuery-related components: - [**jQuery**](https://jquery.com/) © [_JS Foundation_](https://js.foundation/): [[MIT](https://jquery.org/license/)] - [**jQuery UI**](https://jqueryui.com/) © [_JS Foundation_](https://js.foundation/): [[MIT](https://jquery.org/license/)] diff --git a/build_plugin.py b/build_plugin.py index 3e9a582c7..51eb3a1bc 100755 --- a/build_plugin.py +++ b/build_plugin.py @@ -136,7 +136,7 @@ def expand_template(match, path=None): return """// *** included: {filename} *** {content} -""".format(filename=filename, content=readtext(fullname)) +""".format(filename=filename, content=recursive_expand_template(readtext(fullname), path)) elif kw == 'include_string': return quote % multi_line(readtext(fullname)) elif kw == 'include_img': @@ -146,6 +146,10 @@ def expand_template(match, path=None): css = re.sub(pattern, partial(imgrepl, path=fullname.parent), readtext(fullname)) return quote % multi_line(css) +def recursive_expand_template(script, path=None): + template = r"'@(\w+)(?::([\w./-]+))?@'" # to find '@keyword[:path]@' patterns + repl = partial(expand_template, path=path) + return re.sub(template, repl, script) def process_file(source, out_dir, dist_path=None, deps_list=None): """Generate .user.js (and optionally .meta.js) from given source file. @@ -167,12 +171,10 @@ def process_file(source, out_dir, dist_path=None, deps_list=None): path = source.parent # used as root for all (relative) paths script = re.sub(r"'@bundle_code@';", partial(bundle_code, path=path), script) wrapper = get_module(settings.plugin_wrapper) - template = r"'@(\w+)(?::([\w./-]+))?@'" # to find '@keyword[:path]@' patterns - repl = partial(expand_template, path=path) data = [ meta, - re.sub(template, repl, wrapper.start), - re.sub(template, repl, script), + recursive_expand_template(wrapper.start, path), + recursive_expand_template(script, path), wrapper.setup, wrapper.end, ] diff --git a/core/code/boot.js b/core/code/boot.js index c576302a4..6ef831bbf 100644 --- a/core/code/boot.js +++ b/core/code/boot.js @@ -274,7 +274,7 @@ window.setupMap = function() { window.layerChooser = new L.Control.Layers(baseLayers, addLayers); - // Remove the hidden layer after layerChooser built, to avoid messing up ordering of layers + // Remove the hidden layer after layerChooser built, to avoid messing up ordering of layers $.each(hiddenLayer, function(ind, layer){ map.removeLayer(layer); @@ -850,7 +850,12 @@ try { '@include_raw:external/jquery-ui-1.12.1.min.js@'; '@include_raw:external/taphold.js@'; '@include_raw:external/jquery.qrcode.min.js@'; - + + '@include_raw:external/vue.js@'; + '@include_raw:external/httpVueLoader.js@'; + + '@include_raw:components/main.vue.js@'; + } catch (e) { log.error("External's js loading failed"); throw e; diff --git a/core/code/smartphone.js b/core/code/smartphone.js index b6f5ca536..4a1ceeca9 100644 --- a/core/code/smartphone.js +++ b/core/code/smartphone.js @@ -26,6 +26,7 @@ window.runOnSmartphonesBeforeBoot = function() { style.type = 'text/css'; style.appendChild(document.createTextNode('@include_string:smartphone.css@')); document.head.appendChild(style); + document.querySelector('body').classList.add('smartphone') // don’t need many of those window.setupStyles = function() { diff --git a/core/components/chat.vue b/core/components/chat.vue new file mode 100644 index 000000000..52156eb5d --- /dev/null +++ b/core/components/chat.vue @@ -0,0 +1,41 @@ + + + \ No newline at end of file diff --git a/core/components/main.vue.js b/core/components/main.vue.js new file mode 100644 index 000000000..0de7976d5 --- /dev/null +++ b/core/components/main.vue.js @@ -0,0 +1,14 @@ +window.vm = {}; + +Vue.component("updatestatus", httpVueLoader(`'@include_raw:components/updatestatus.vue@'`)); +Vue.component("chat", httpVueLoader(`'@include_raw:components/chat.vue@'`)); +Vue.component("toolbox", httpVueLoader(`'@include_raw:components/toolbox.vue@'`)); +Vue.component("sidebar", httpVueLoader(`'@include_raw:components/sidebar.vue@'`)); + +let app = new Vue({ + el: '#app', + mounted() { + vm.main = this; + } +}) + diff --git a/core/components/sidebar.vue b/core/components/sidebar.vue new file mode 100644 index 000000000..8a0a6f959 --- /dev/null +++ b/core/components/sidebar.vue @@ -0,0 +1,62 @@ + + + \ No newline at end of file diff --git a/core/components/toolbox.vue b/core/components/toolbox.vue new file mode 100644 index 000000000..75afb1253 --- /dev/null +++ b/core/components/toolbox.vue @@ -0,0 +1,59 @@ + + + + + \ No newline at end of file diff --git a/core/components/updatestatus.vue b/core/components/updatestatus.vue new file mode 100644 index 000000000..c64e3fc5d --- /dev/null +++ b/core/components/updatestatus.vue @@ -0,0 +1,11 @@ + + + \ No newline at end of file diff --git a/core/external/httpVueLoader.js b/core/external/httpVueLoader.js new file mode 100644 index 000000000..423dee6a4 --- /dev/null +++ b/core/external/httpVueLoader.js @@ -0,0 +1,463 @@ +(function umd(root,factory){ + if(typeof module==='object' && typeof exports === 'object' ) + module.exports=factory() + else if(typeof define==='function' && define.amd) + define([],factory) + else + root.httpVueLoader=factory() +})(this,function factory() { + 'use strict'; + + var scopeIndex = 0; + + StyleContext.prototype = { + + withBase: function(callback) { + + var tmpBaseElt; + if ( this.component.baseURI ) { + + // firefox and chrome need the to be set while inserting or modifying