large chunk of work towards a nicer build system
- plugins are now parsed for @@..@@ replacements - main script and plugins have separate .meta.js files created - less web server load for update checks - build script has variables for resource URL, update URL, etc, substituted via @@..@@ into main script and all plugins
This commit is contained in:
parent
6984510ac9
commit
4ce0da5056
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
iitc-debug.user.js
|
||||
push-live
|
||||
mobile/IngressIntelTC/bin
|
||||
build
|
||||
|
98
build.py
98
build.py
@ -4,6 +4,9 @@ import glob
|
||||
import time
|
||||
import re
|
||||
import io
|
||||
import os
|
||||
import shutil
|
||||
|
||||
|
||||
def readfile(fn):
|
||||
with io.open(fn, 'Ur', encoding='utf8') as f:
|
||||
@ -17,20 +20,93 @@ def loaderRaw(var):
|
||||
fn = var.group(1)
|
||||
return readfile(fn)
|
||||
|
||||
def loadCode(ignore):
|
||||
return '\n\n'.join(map(readfile, glob.glob('code/*')))
|
||||
|
||||
c = '\n\n'.join(map(readfile, glob.glob('code/*')))
|
||||
n = time.strftime('%Y-%m-%d-%H%M%S')
|
||||
m = readfile('main.js')
|
||||
|
||||
m = m.split('@@INJECTHERE@@')
|
||||
m.insert(1, c)
|
||||
m = '\n\n'.join(m)
|
||||
def extractUserScriptMeta(var):
|
||||
m = re.search ( r"//[ \t]*==UserScript==\n.*?//[ \t]*==/UserScript==\n", var, re.MULTILINE|re.DOTALL )
|
||||
return m.group(0)
|
||||
|
||||
m = m.replace('@@BUILDDATE@@', n)
|
||||
m = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, m)
|
||||
m = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, m)
|
||||
|
||||
with io.open('iitc-debug.user.js', 'w', encoding='utf8') as f:
|
||||
f.write(m)
|
||||
# set up vars used for replacements
|
||||
|
||||
|
||||
utcTime = time.gmtime()
|
||||
buildDate = time.strftime('%Y-%m-%d-%H%M%S',utcTime)
|
||||
dateTimeVersion = time.strftime('%Y%m%d.%H%M%S',utcTime)
|
||||
|
||||
# TODO: some kind of settings files for these
|
||||
resourceUrlBase = 'http://iitc.jonatkins.com/dist'
|
||||
distUrlBase = 'http://iitc.jonatkins.com/dist'
|
||||
buildName = 'jonatkins'
|
||||
|
||||
|
||||
|
||||
def doReplacements(script,updateUrl,downloadUrl):
|
||||
|
||||
script = re.sub('@@INJECTCODE@@',loadCode,script)
|
||||
|
||||
script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script)
|
||||
script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script)
|
||||
|
||||
script = script.replace('@@BUILDDATE@@', buildDate)
|
||||
script = script.replace('@@DATETIMEVERSION@@', dateTimeVersion)
|
||||
script = script.replace('@@RESOURCEURLBASE@@', resourceUrlBase)
|
||||
script = script.replace('@@BUILDNAME@@', buildName)
|
||||
|
||||
script = script.replace('@@UPDATEURL@@', updateUrl)
|
||||
script = script.replace('@@DOWNLOADURL@@', downloadUrl)
|
||||
|
||||
return script
|
||||
|
||||
|
||||
def saveScriptAndMeta(script,fn,metafn):
|
||||
with io.open(fn, 'w', encoding='utf8') as f:
|
||||
f.write(script)
|
||||
|
||||
with io.open(metafn, 'w', encoding='utf8') as f:
|
||||
meta = extractUserScriptMeta(script)
|
||||
f.write(meta)
|
||||
|
||||
|
||||
outDir = 'build/jonatkins-dist'
|
||||
|
||||
|
||||
# create the build output
|
||||
|
||||
# first, delete any existing build
|
||||
if os.path.exists(outDir):
|
||||
shutil.rmtree(outDir)
|
||||
|
||||
# copy the 'dist' folder - this creates the target directory (and any missing parent dirs)
|
||||
# FIXME? replace with manual copy, and any .css and .js files are parsed for replacement tokens?
|
||||
shutil.copytree('dist', outDir)
|
||||
|
||||
|
||||
|
||||
# load main.js, parse, and create main total-conversion.user.js
|
||||
main = readfile('main.js')
|
||||
|
||||
downloadUrl = distUrlBase + '/total-conversion.user.js'
|
||||
updateUrl = distUrlBase + '/total-conversion.meta.js'
|
||||
main = doReplacements(main,downloadUrl=downloadUrl,updateUrl=updateUrl)
|
||||
|
||||
saveScriptAndMeta(main, os.path.join(outDir,'total-conversion.user.js'), os.path.join(outDir,'total-conversion.meta.js'))
|
||||
|
||||
|
||||
# for each plugin, load, parse, and save output
|
||||
os.mkdir(os.path.join(outDir,'plugins'))
|
||||
|
||||
for fn in glob.glob("plugins/*.user.js"):
|
||||
script = readfile(fn)
|
||||
|
||||
downloadUrl = distUrlBase + '/' + fn.replace("\\","/")
|
||||
updateUrl = downloadUrl.replace('.user.js', '.meta.js')
|
||||
script = doReplacements(script, downloadUrl=downloadUrl, updateUrl=updateUrl)
|
||||
|
||||
metafn = fn.replace('.user.js', '.meta.js')
|
||||
saveScriptAndMeta(script, os.path.join(outDir,fn), os.path.join(outDir,metafn))
|
||||
|
||||
|
||||
# vim: ai si ts=4 sw=4 sts=4 et
|
||||
|
@ -321,7 +321,7 @@ function boot() {
|
||||
window.runOnSmartphonesBeforeBoot();
|
||||
|
||||
// overwrite default Leaflet Marker icon to be a neutral color
|
||||
var base = 'http://iitc.jonatkins.com/dist/images';
|
||||
var base = '@@RESOURCEURLBASE@@/images';
|
||||
L.Icon.Default.imagePath = base;
|
||||
|
||||
window.iconEnl = L.Icon.Default.extend({options: { iconUrl: base + '/marker-green.png' } });
|
||||
|
2
external/leaflet.css
vendored
2
external/leaflet.css
vendored
@ -285,7 +285,7 @@
|
||||
border-radius: 8px;
|
||||
}
|
||||
.leaflet-control-layers-toggle {
|
||||
background-image: url(http://iitc.jonatkins.com/dist/images/layers.png);
|
||||
background-image: url(@@RESOURCEURLBASE@@/images/layers.png);
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
}
|
||||
|
12
main.js
12
main.js
@ -1,11 +1,11 @@
|
||||
// ==UserScript==
|
||||
// @id ingress-intel-total-conversion@jonatkins
|
||||
// @name intel map total conversion
|
||||
// @version 0.9.0-@@BUILDDATE@@-jonatkins
|
||||
// @name IITC: Ingress intel map total conversion
|
||||
// @version 0.9.1.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/total-conversion-build.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/total-conversion-build.user.js
|
||||
// @description total conversion for the ingress intel map. (jonatkins branch)
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Total conversion for the ingress intel map. [@@BUILDNAME@@-@@BUILDDATE@@]
|
||||
// @include http://www.ingress.com/intel*
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @match http://www.ingress.com/intel*
|
||||
@ -236,7 +236,7 @@ window.resonators = {};
|
||||
if(typeof window.plugin !== 'function') window.plugin = function() {};
|
||||
|
||||
|
||||
@@INJECTHERE@@
|
||||
@@INJECTCODE@@
|
||||
|
||||
|
||||
} // end of wrapper
|
||||
|
@ -1,11 +1,11 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-ap-list@xelio
|
||||
// @name iitc: AP List
|
||||
// @version 0.4.1
|
||||
// @name IITC plugin: AP List
|
||||
// @version 0.4.1.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/ap-list.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/plugins/ap-list.user.js
|
||||
// @description List top 10 portals by AP of either faction. Other functions and controls please refer to the Userguide. (https://github.com/breunigs/ingress-intel-total-conversion/wiki/Userguide-%28Main-Vanilla-IITC%29#wiki-pluginsAPListUserGuide)
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description List top 10 portals by AP of either faction. Other functions and controls please refer to the Userguide.
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
// @match https://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-compute-ap-stats@Hollow011
|
||||
// @name iitc: Compute AP statistics
|
||||
// @version 0.3.1
|
||||
// @name IITC plugin: Compute AP statistics
|
||||
// @version 0.3.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/compute-ap-stats.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/plugins/compute-ap-stats.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Tries to determine overal AP stats for the current zoom
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-draw-tools@breunigs
|
||||
// @name iitc: draw tools
|
||||
// @version 0.2.3
|
||||
// @name IITC plugin: draw tools
|
||||
// @version 0.2.3.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/draw-tools.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/draw-tools.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Allows you to draw things into the current map so you may plan your next move
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-guess-player-levels@breunigs
|
||||
// @name iitc: guess player level
|
||||
// @version 0.3.1
|
||||
// @name IITC plugin: guess player level
|
||||
// @version 0.3.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/guess-player-levels.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/guess-player-levels.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Tries to determine player levels from the data available in the current view
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,9 +1,9 @@
|
||||
// ==UserScript==
|
||||
// @id max-links@boombuler
|
||||
// @name iitc: Max-Links-Plugin
|
||||
// @version 0.2.1
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/max-links.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/max-links.user.js
|
||||
// @name IITC plugin: Max Links
|
||||
// @version 0.2.1.@@DATETIMEVERSION@@
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Calculates how to link the portals to create the maximum number of fields.
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-player-tracker@breunigs
|
||||
// @name iitc: player tracker
|
||||
// @version 0.7.2
|
||||
// @name IITC Plugin: player tracker
|
||||
// @version 0.7.2.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/player-tracker.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/player-tracker.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description draws trails for the path a user went onto the map. Only draws the last hour. Does not request chat data on its own, even if that would be useful.
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-render-limit-increase@jonatkins
|
||||
// @name iitc: render limit increase
|
||||
// @version 0.2
|
||||
// @name IITC plugin: render limit increase
|
||||
// @version 0.2.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/render-limit-increase.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/render-limit-increase.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Increase the render limits, so less likely to be hit in higher density areas
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-reso-energy-pct-in-portal-detail@xelio
|
||||
// @name iitc: reso energy pct in portal detail
|
||||
// @version 0.1.2
|
||||
// @name IITC plugin: reso energy pct in portal detail
|
||||
// @version 0.1.2.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/reso-energy-pct-in-portal-detail.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/reso-energy-pct-in-portal-detail.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Show resonator energy percentage on resonator energy bar in portal detail panel.
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-resonator-display-zoom-level-decrease@xelio
|
||||
// @name iitc: resonator display zoom level decrease
|
||||
// @version 1.0.2
|
||||
// @name IITC plugin: resonator display zoom level decrease
|
||||
// @version 1.0.2.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/resonator-display-zoom-level-decrease.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/resonator-display-zoom-level-decrease.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Resonator start display earlier
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-scale-bar@breunigs
|
||||
// @name iitc: scale bar
|
||||
// @version 0.1.1
|
||||
// @name IITC plugin: scale bar
|
||||
// @version 0.1.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/scale-bar.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/scale-bar.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description shows scale bar on the map
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-scoreboard@vita10gy
|
||||
// @name iitc: show a localized scoreboard.
|
||||
// @version 0.1.4
|
||||
// @name IITC plugin: show a localized scoreboard.
|
||||
// @version 0.1.4.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/scoreboard.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/scoreboard.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description A localized scoreboard.
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-show-address@vita10gy
|
||||
// @name iitc: show portal address in sidebar
|
||||
// @version 0.2.2
|
||||
// @name IITC plugin: show portal address in sidebar
|
||||
// @version 0.2.2.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/show-address.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/show-address.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Portal address will show in the sidebar.
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
@ -1,10 +1,10 @@
|
||||
// ==UserScript==
|
||||
// @id iitc-plugin-show-portal-weakness@vita10gy
|
||||
// @name iitc: show portal weakness
|
||||
// @version 0.6.1
|
||||
// @name IITC plugin: show portal weakness
|
||||
// @version 0.6.1.@@DATETIMEVERSION@@
|
||||
// @namespace https://github.com/jonatkins/ingress-intel-total-conversion
|
||||
// @updateURL http://iitc.jonatkins.com/dist/plugins/show-portal-weakness.user.js
|
||||
// @downloadURL http://iitc.jonatkins.com/dist/plugins/show-portal-weakness.user.js
|
||||
// @updateURL @@UPDATEURL@@
|
||||
// @downloadURL @@DOWNLOADURL@@
|
||||
// @description Uses the fill color of the portals to denote if the portal is weak (Needs recharging, missing a resonator, needs shields) Red, needs energy and shields. Orange, only needs energy (either recharge or resonators). Yellow, only needs shields.
|
||||
// @include https://www.ingress.com/intel*
|
||||
// @include http://www.ingress.com/intel*
|
||||
|
Loading…
x
Reference in New Issue
Block a user