Add ATTRIBUTION.md to About IITC pop up

This commit is contained in:
Kevin 2013-04-16 20:18:21 -07:00
parent bec7ae8c95
commit ae8200d7be
3 changed files with 42 additions and 3 deletions

View File

@ -8,6 +8,10 @@ import base64
import sys import sys
import os import os
import shutil import shutil
import json
import urllib2
import shelve
import hashlib
# load settings file # load settings file
@ -66,6 +70,31 @@ def loaderRaw(var):
fn = var.group(1) fn = var.group(1)
return readfile(fn) 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): def loaderImage(var):
fn = var.group(1) fn = var.group(1)
return 'data:image/png;base64,{0}'.format(base64.encodestring(open(fn, 'rb').read()).decode('utf8').replace('\n', '')) 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('@@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('@@INCLUDEGFM:([0-9a-zA-Z_./-]+)@@', loaderGFM, script)
script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script) script = re.sub('@@INCLUDEIMAGE:([0-9a-zA-Z_./-]+)@@', loaderImage, script)
script = script.replace('@@BUILDDATE@@', buildDate) script = script.replace('@@BUILDDATE@@', buildDate)

View File

@ -1,7 +1,8 @@
// UTILS + MISC /////////////////////////////////////////////////////// // UTILS + MISC ///////////////////////////////////////////////////////
window.aboutIITC = function(){ window.aboutIITC = function(){
var v = '@@BUILDNAME@@-@@BUILDDATE@@' var v = '@@BUILDNAME@@-@@BUILDDATE@@';
var attrib = '@@INCLUDEGFM:ATTRIBUTION.md@@';
var a = '' var a = ''
+ ' <div><b>About IITC</b></div> ' + ' <div><b>About IITC</b></div> '
+ ' <div>Ingress Intel Total Conversion</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">' + ' 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>' + ' </div>'
+ ' <hr>' + ' <hr>'
+ ' <div>Version: ' + v + '</div>'; + ' <div>Version: ' + v + '</div>'
alert(a); + ' <hr>'
+ ' <div>' + attrib + '</div>';
alert(a, true, function() {$('.ui-dialog').removeClass('ui-dialog-aboutIITC');});
$('.ui-dialog').addClass('ui-dialog-aboutIITC');
} }

View File

@ -762,6 +762,11 @@ h3 {
text-decoration: underline; text-decoration: underline;
} }
.ui-dialog-aboutIITC {
max-width: 600px !important;
width: 600px !important;
}
td { td {
padding: 0; padding: 0;
vertical-align: top; vertical-align: top;