Merge pull request #46 from Fragger/master-base64-icons

Add in base64 image encoding to build system and move images over to use it
This commit is contained in:
Jon Atkins 2013-03-23 12:38:24 -07:00
commit 0f04cc24a6
3 changed files with 33 additions and 3 deletions

View File

@ -4,6 +4,7 @@ import glob
import time import time
import re import re
import io import io
import base64
import sys import sys
import os import os
import shutil import shutil
@ -65,6 +66,10 @@ def loaderRaw(var):
fn = var.group(1) fn = var.group(1)
return readfile(fn) return readfile(fn)
def loaderImage(var):
fn = var.group(1)
return 'data:image/png;base64,{0}'.format(str(base64.encodestring(open(fn, 'rb').read())).replace('\n', ''))
def loadCode(ignore): def loadCode(ignore):
return '\n\n'.join(map(readfile, glob.glob('code/*'))) return '\n\n'.join(map(readfile, glob.glob('code/*')))
@ -81,6 +86,7 @@ def doReplacements(script,updateUrl,downloadUrl):
script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script) script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script)
script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script) script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script)
script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script)
script = script.replace('@@BUILDDATE@@', buildDate) script = script.replace('@@BUILDDATE@@', buildDate)
script = script.replace('@@DATETIMEVERSION@@', dateTimeVersion) script = script.replace('@@DATETIMEVERSION@@', dateTimeVersion)

View File

@ -324,8 +324,32 @@ function boot() {
var base = '@@RESOURCEURLBASE@@/images'; var base = '@@RESOURCEURLBASE@@/images';
L.Icon.Default.imagePath = base; L.Icon.Default.imagePath = base;
window.iconEnl = L.Icon.Default.extend({options: { iconUrl: base + '/marker-green.png' } }); var iconEnlImage = '@@INCLUDEIMAGE:images/marker-green.png@@';
window.iconRes = L.Icon.Default.extend({options: { iconUrl: base + '/marker-blue.png' } }); var iconEnlRetImage = '@@INCLUDEIMAGE:images/marker-green_2x.png@@';
var iconResImage = '@@INCLUDEIMAGE:images/marker-blue.png@@';
var iconResRetImage = '@@INCLUDEIMAGE:images/marker-blue_2x.png@@';
var iconShadowImage = '@@INCLUDEIMAGE:images/marker-shadow.png@@';
window.iconEnl = L.Icon.extend({options: {
iconUrl: iconEnlImage,
iconRetinaUrl: iconEnlRetImage,
shadowUrl: iconShadowImage,
shadowRetinaUrl: iconShadowImage,
iconSize: new L.Point(25, 41),
iconAnchor: new L.Point(12, 41),
popupAnchor: new L.Point(1, -34),
shadowSize: new L.Point(41, 41)
}});
window.iconRes = L.Icon.extend({options: {
iconUrl: iconResImage,
iconRetinaUrl: iconResRetImage,
shadowUrl: iconShadowImage,
shadowRetinaUrl: iconShadowImage,
iconSize: new L.Point(25, 41),
iconAnchor: new L.Point(12, 41),
popupAnchor: new L.Point(1, -34),
shadowSize: new L.Point(41, 41)
}});
window.setupTaphold(); window.setupTaphold();
window.setupStyles(); window.setupStyles();

View File

@ -285,7 +285,7 @@
border-radius: 8px; border-radius: 8px;
} }
.leaflet-control-layers-toggle { .leaflet-control-layers-toggle {
background-image: url(@@RESOURCEURLBASE@@/images/layers.png); background-image: url(@@INCLUDEIMAGE:images/layers.png@@);
width: 36px; width: 36px;
height: 36px; height: 36px;
} }