Add ATTRIBUTION.md to About IITC pop up
This commit is contained in:
parent
bec7ae8c95
commit
ae8200d7be
30
build.py
30
build.py
@ -8,6 +8,10 @@ import base64
|
||||
import sys
|
||||
import os
|
||||
import shutil
|
||||
import json
|
||||
import urllib2
|
||||
import shelve
|
||||
import hashlib
|
||||
|
||||
|
||||
# load settings file
|
||||
@ -66,6 +70,31 @@ def loaderRaw(var):
|
||||
fn = var.group(1)
|
||||
return readfile(fn)
|
||||
|
||||
def loaderGFM(var):
|
||||
fn = var.group(1)
|
||||
db = shelve.open('build/GFM.dat')
|
||||
if db.has_key('files'):
|
||||
files = db['files']
|
||||
else:
|
||||
files = {}
|
||||
file = readfile(fn)
|
||||
filemd5 = hashlib.md5(file).hexdigest()
|
||||
# check if file has already been parsed by the github api
|
||||
if fn in files and filemd5 in files[fn]:
|
||||
# use the stored copy if nothing has changed to avoid hiting the api more then the 60/hour when not signed in
|
||||
return files[fn][filemd5]
|
||||
else:
|
||||
url = 'https://api.github.com/markdown'
|
||||
payload = {'text': readfile(fn), 'mode': 'gfm', 'context': 'jonatkins/ingress-intel-total-conversion'}
|
||||
req = urllib2.Request(url)
|
||||
req.add_header('Content-Type', 'application/json')
|
||||
gfm = urllib2.urlopen(req, json.dumps(payload)).read().replace('\n', '').replace('\'', '\\\'')
|
||||
files[fn] = {}
|
||||
files[fn][filemd5] = gfm
|
||||
db['files'] = files
|
||||
db.close()
|
||||
return gfm
|
||||
|
||||
def loaderImage(var):
|
||||
fn = var.group(1)
|
||||
return 'data:image/png;base64,{0}'.format(base64.encodestring(open(fn, 'rb').read()).decode('utf8').replace('\n', ''))
|
||||
@ -86,6 +115,7 @@ def doReplacements(script,updateUrl,downloadUrl):
|
||||
|
||||
script = re.sub('@@INCLUDERAW:([0-9a-zA-Z_./-]+)@@', loaderRaw, script)
|
||||
script = re.sub('@@INCLUDESTRING:([0-9a-zA-Z_./-]+)@@', loaderString, script)
|
||||
script = re.sub('@@INCLUDEGFM:([0-9a-zA-Z_./-]+)@@', loaderGFM, script)
|
||||
script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script)
|
||||
|
||||
script = script.replace('@@BUILDDATE@@', buildDate)
|
||||
|
@ -1,7 +1,8 @@
|
||||
// UTILS + MISC ///////////////////////////////////////////////////////
|
||||
|
||||
window.aboutIITC = function(){
|
||||
var v = '@@BUILDNAME@@-@@BUILDDATE@@'
|
||||
var v = '@@BUILDNAME@@-@@BUILDDATE@@';
|
||||
var attrib = '@@INCLUDEGFM:ATTRIBUTION.md@@';
|
||||
var a = ''
|
||||
+ ' <div><b>About IITC</b></div> '
|
||||
+ ' <div>Ingress Intel Total Conversion</div> '
|
||||
@ -20,8 +21,11 @@ window.aboutIITC = function(){
|
||||
+ ' MapQuest OSM tiles Courtesy of <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png">'
|
||||
+ ' </div>'
|
||||
+ ' <hr>'
|
||||
+ ' <div>Version: ' + v + '</div>';
|
||||
alert(a);
|
||||
+ ' <div>Version: ' + v + '</div>'
|
||||
+ ' <hr>'
|
||||
+ ' <div>' + attrib + '</div>';
|
||||
alert(a, true, function() {$('.ui-dialog').removeClass('ui-dialog-aboutIITC');});
|
||||
$('.ui-dialog').addClass('ui-dialog-aboutIITC');
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user