diff --git a/.gitignore b/.gitignore index 2f78cf5..7587a46 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,9 @@ *.pyc +*.pyo +static/stubs* +scratch/* + +#ignore the pictures and font files +tools/*.png +tools/*.ttf diff --git a/app.yaml b/app.yaml index c177daf..a655c2f 100644 --- a/app.yaml +++ b/app.yaml @@ -1,5 +1,5 @@ -application: codeabbey-banners -version: 1 +application: code-abbey-banner +version: 4 runtime: python27 api_version: 1 threadsafe: yes @@ -13,3 +13,9 @@ libraries: version: "2.6" - name: markupsafe version: "0.15" +- name: PIL + version: "1.1.7" + +skip_files: +- ^(.*/)?\.git.*$ +- ^(.*/)?.*pyc$ \ No newline at end of file diff --git a/flags/ad.gif b/flags/ad.gif new file mode 100644 index 0000000..57b4997 Binary files /dev/null and b/flags/ad.gif differ diff --git a/flags/ae.gif b/flags/ae.gif new file mode 100644 index 0000000..78d15b6 Binary files /dev/null and b/flags/ae.gif differ diff --git a/flags/af.gif b/flags/af.gif new file mode 100644 index 0000000..9889408 Binary files /dev/null and b/flags/af.gif differ diff --git a/flags/ag.gif b/flags/ag.gif new file mode 100644 index 0000000..48f8e7b Binary files /dev/null and b/flags/ag.gif differ diff --git a/flags/ai.gif b/flags/ai.gif new file mode 100644 index 0000000..1cbc579 Binary files /dev/null and b/flags/ai.gif differ diff --git a/flags/al.gif b/flags/al.gif new file mode 100644 index 0000000..c44fe0a Binary files /dev/null and b/flags/al.gif differ diff --git a/flags/am.gif b/flags/am.gif new file mode 100644 index 0000000..2915e30 Binary files /dev/null and b/flags/am.gif differ diff --git a/flags/an.gif b/flags/an.gif new file mode 100644 index 0000000..cb570c6 Binary files /dev/null and b/flags/an.gif differ diff --git a/flags/ao.gif b/flags/ao.gif new file mode 100644 index 0000000..8c854fa Binary files /dev/null and b/flags/ao.gif differ diff --git a/flags/ar.gif b/flags/ar.gif new file mode 100644 index 0000000..a9f71f7 Binary files /dev/null and b/flags/ar.gif differ diff --git a/flags/as.gif b/flags/as.gif new file mode 100644 index 0000000..d776ec2 Binary files /dev/null and b/flags/as.gif differ diff --git a/flags/at.gif b/flags/at.gif new file mode 100644 index 0000000..87e1217 Binary files /dev/null and b/flags/at.gif differ diff --git a/flags/au.gif b/flags/au.gif new file mode 100644 index 0000000..5269c6a Binary files /dev/null and b/flags/au.gif differ diff --git a/flags/aw.gif b/flags/aw.gif new file mode 100644 index 0000000..27fdb4d Binary files /dev/null and b/flags/aw.gif differ diff --git a/flags/ax.gif b/flags/ax.gif new file mode 100644 index 0000000..0ceb684 Binary files /dev/null and b/flags/ax.gif differ diff --git a/flags/az.gif b/flags/az.gif new file mode 100644 index 0000000..d771618 Binary files /dev/null and b/flags/az.gif differ diff --git a/flags/ba.gif b/flags/ba.gif new file mode 100644 index 0000000..9bf5f0a Binary files /dev/null and b/flags/ba.gif differ diff --git a/flags/bb.gif b/flags/bb.gif new file mode 100644 index 0000000..b7d08e5 Binary files /dev/null and b/flags/bb.gif differ diff --git a/flags/bd.gif b/flags/bd.gif new file mode 100644 index 0000000..0fd27ec Binary files /dev/null and b/flags/bd.gif differ diff --git a/flags/be.gif b/flags/be.gif new file mode 100644 index 0000000..ae09bfb Binary files /dev/null and b/flags/be.gif differ diff --git a/flags/bf.gif b/flags/bf.gif new file mode 100644 index 0000000..9d6772c Binary files /dev/null and b/flags/bf.gif differ diff --git a/flags/bg.gif b/flags/bg.gif new file mode 100644 index 0000000..11cf8ff Binary files /dev/null and b/flags/bg.gif differ diff --git a/flags/bh.gif b/flags/bh.gif new file mode 100644 index 0000000..56aa72b Binary files /dev/null and b/flags/bh.gif differ diff --git a/flags/bi.gif b/flags/bi.gif new file mode 100644 index 0000000..6e2cbe1 Binary files /dev/null and b/flags/bi.gif differ diff --git a/flags/bj.gif b/flags/bj.gif new file mode 100644 index 0000000..e676116 Binary files /dev/null and b/flags/bj.gif differ diff --git a/flags/bm.gif b/flags/bm.gif new file mode 100644 index 0000000..9feb87b Binary files /dev/null and b/flags/bm.gif differ diff --git a/flags/bn.gif b/flags/bn.gif new file mode 100644 index 0000000..b7b6b0f Binary files /dev/null and b/flags/bn.gif differ diff --git a/flags/bo.gif b/flags/bo.gif new file mode 100644 index 0000000..4844f85 Binary files /dev/null and b/flags/bo.gif differ diff --git a/flags/br.gif b/flags/br.gif new file mode 100644 index 0000000..8c86616 Binary files /dev/null and b/flags/br.gif differ diff --git a/flags/bs.gif b/flags/bs.gif new file mode 100644 index 0000000..c0a741e Binary files /dev/null and b/flags/bs.gif differ diff --git a/flags/bt.gif b/flags/bt.gif new file mode 100644 index 0000000..abe2f3c Binary files /dev/null and b/flags/bt.gif differ diff --git a/flags/bv.gif b/flags/bv.gif new file mode 100644 index 0000000..6202d1f Binary files /dev/null and b/flags/bv.gif differ diff --git a/flags/bw.gif b/flags/bw.gif new file mode 100644 index 0000000..986ab63 Binary files /dev/null and b/flags/bw.gif differ diff --git a/flags/by.gif b/flags/by.gif new file mode 100644 index 0000000..43ffcd4 Binary files /dev/null and b/flags/by.gif differ diff --git a/flags/bz.gif b/flags/bz.gif new file mode 100644 index 0000000..791737f Binary files /dev/null and b/flags/bz.gif differ diff --git a/flags/ca.gif b/flags/ca.gif new file mode 100644 index 0000000..457d966 Binary files /dev/null and b/flags/ca.gif differ diff --git a/flags/cc.gif b/flags/cc.gif new file mode 100644 index 0000000..3f78327 Binary files /dev/null and b/flags/cc.gif differ diff --git a/flags/cd.gif b/flags/cd.gif new file mode 100644 index 0000000..1df717a Binary files /dev/null and b/flags/cd.gif differ diff --git a/flags/cf.gif b/flags/cf.gif new file mode 100644 index 0000000..35787ca Binary files /dev/null and b/flags/cf.gif differ diff --git a/flags/cg.gif b/flags/cg.gif new file mode 100644 index 0000000..e0a62a5 Binary files /dev/null and b/flags/cg.gif differ diff --git a/flags/ch.gif b/flags/ch.gif new file mode 100644 index 0000000..d5c0e5b Binary files /dev/null and b/flags/ch.gif differ diff --git a/flags/ci.gif b/flags/ci.gif new file mode 100644 index 0000000..844120a Binary files /dev/null and b/flags/ci.gif differ diff --git a/flags/ck.gif b/flags/ck.gif new file mode 100644 index 0000000..2edb739 Binary files /dev/null and b/flags/ck.gif differ diff --git a/flags/cl.gif b/flags/cl.gif new file mode 100644 index 0000000..cbc370e Binary files /dev/null and b/flags/cl.gif differ diff --git a/flags/cm.gif b/flags/cm.gif new file mode 100644 index 0000000..1fb102b Binary files /dev/null and b/flags/cm.gif differ diff --git a/flags/cn.gif b/flags/cn.gif new file mode 100644 index 0000000..b052530 Binary files /dev/null and b/flags/cn.gif differ diff --git a/flags/co.gif b/flags/co.gif new file mode 100644 index 0000000..d0e15ca Binary files /dev/null and b/flags/co.gif differ diff --git a/flags/cr.gif b/flags/cr.gif new file mode 100644 index 0000000..0728dd6 Binary files /dev/null and b/flags/cr.gif differ diff --git a/flags/cu.gif b/flags/cu.gif new file mode 100644 index 0000000..291255c Binary files /dev/null and b/flags/cu.gif differ diff --git a/flags/cv.gif b/flags/cv.gif new file mode 100644 index 0000000..43c6c6c Binary files /dev/null and b/flags/cv.gif differ diff --git a/flags/cx.gif b/flags/cx.gif new file mode 100644 index 0000000..a5b4308 Binary files /dev/null and b/flags/cx.gif differ diff --git a/flags/cy.gif b/flags/cy.gif new file mode 100644 index 0000000..35c661e Binary files /dev/null and b/flags/cy.gif differ diff --git a/flags/cz.gif b/flags/cz.gif new file mode 100644 index 0000000..0a605e5 Binary files /dev/null and b/flags/cz.gif differ diff --git a/flags/de.gif b/flags/de.gif new file mode 100644 index 0000000..75728dd Binary files /dev/null and b/flags/de.gif differ diff --git a/flags/dj.gif b/flags/dj.gif new file mode 100644 index 0000000..212406d Binary files /dev/null and b/flags/dj.gif differ diff --git a/flags/dk.gif b/flags/dk.gif new file mode 100644 index 0000000..03e75bd Binary files /dev/null and b/flags/dk.gif differ diff --git a/flags/dm.gif b/flags/dm.gif new file mode 100644 index 0000000..2f87f3c Binary files /dev/null and b/flags/dm.gif differ diff --git a/flags/do.gif b/flags/do.gif new file mode 100644 index 0000000..f7d0bad Binary files /dev/null and b/flags/do.gif differ diff --git a/flags/dz.gif b/flags/dz.gif new file mode 100644 index 0000000..ed580a7 Binary files /dev/null and b/flags/dz.gif differ diff --git a/flags/ec.gif b/flags/ec.gif new file mode 100644 index 0000000..9e41e0e Binary files /dev/null and b/flags/ec.gif differ diff --git a/flags/ee.gif b/flags/ee.gif new file mode 100644 index 0000000..9397a2d Binary files /dev/null and b/flags/ee.gif differ diff --git a/flags/eg.gif b/flags/eg.gif new file mode 100644 index 0000000..6857c7d Binary files /dev/null and b/flags/eg.gif differ diff --git a/flags/er.gif b/flags/er.gif new file mode 100644 index 0000000..3d4d612 Binary files /dev/null and b/flags/er.gif differ diff --git a/flags/es.gif b/flags/es.gif new file mode 100644 index 0000000..c27d65e Binary files /dev/null and b/flags/es.gif differ diff --git a/flags/et.gif b/flags/et.gif new file mode 100644 index 0000000..f77995d Binary files /dev/null and b/flags/et.gif differ diff --git a/flags/fi.gif b/flags/fi.gif new file mode 100644 index 0000000..8d3a191 Binary files /dev/null and b/flags/fi.gif differ diff --git a/flags/fj.gif b/flags/fj.gif new file mode 100644 index 0000000..486151c Binary files /dev/null and b/flags/fj.gif differ diff --git a/flags/fk.gif b/flags/fk.gif new file mode 100644 index 0000000..37b5ecf Binary files /dev/null and b/flags/fk.gif differ diff --git a/flags/fm.gif b/flags/fm.gif new file mode 100644 index 0000000..7f8723b Binary files /dev/null and b/flags/fm.gif differ diff --git a/flags/fo.gif b/flags/fo.gif new file mode 100644 index 0000000..4a90fc0 Binary files /dev/null and b/flags/fo.gif differ diff --git a/flags/fr.gif b/flags/fr.gif new file mode 100644 index 0000000..43d0b80 Binary files /dev/null and b/flags/fr.gif differ diff --git a/flags/ga.gif b/flags/ga.gif new file mode 100644 index 0000000..23fd5f0 Binary files /dev/null and b/flags/ga.gif differ diff --git a/flags/gb.gif b/flags/gb.gif new file mode 100644 index 0000000..3c6bce1 Binary files /dev/null and b/flags/gb.gif differ diff --git a/flags/gd.gif b/flags/gd.gif new file mode 100644 index 0000000..25ea312 Binary files /dev/null and b/flags/gd.gif differ diff --git a/flags/ge.gif b/flags/ge.gif new file mode 100644 index 0000000..faa7f12 Binary files /dev/null and b/flags/ge.gif differ diff --git a/flags/gf.gif b/flags/gf.gif new file mode 100644 index 0000000..43d0b80 Binary files /dev/null and b/flags/gf.gif differ diff --git a/flags/gh.gif b/flags/gh.gif new file mode 100644 index 0000000..273fb7d Binary files /dev/null and b/flags/gh.gif differ diff --git a/flags/gi.gif b/flags/gi.gif new file mode 100644 index 0000000..7b1984b Binary files /dev/null and b/flags/gi.gif differ diff --git a/flags/gl.gif b/flags/gl.gif new file mode 100644 index 0000000..ef445be Binary files /dev/null and b/flags/gl.gif differ diff --git a/flags/gm.gif b/flags/gm.gif new file mode 100644 index 0000000..6847c5a Binary files /dev/null and b/flags/gm.gif differ diff --git a/flags/gn.gif b/flags/gn.gif new file mode 100644 index 0000000..a982ac6 Binary files /dev/null and b/flags/gn.gif differ diff --git a/flags/gp.gif b/flags/gp.gif new file mode 100644 index 0000000..31166db Binary files /dev/null and b/flags/gp.gif differ diff --git a/flags/gq.gif b/flags/gq.gif new file mode 100644 index 0000000..8b4e0cc Binary files /dev/null and b/flags/gq.gif differ diff --git a/flags/gr.gif b/flags/gr.gif new file mode 100644 index 0000000..b4c8c04 Binary files /dev/null and b/flags/gr.gif differ diff --git a/flags/gs.gif b/flags/gs.gif new file mode 100644 index 0000000..ccc96ec Binary files /dev/null and b/flags/gs.gif differ diff --git a/flags/gt.gif b/flags/gt.gif new file mode 100644 index 0000000..7e94d1d Binary files /dev/null and b/flags/gt.gif differ diff --git a/flags/gu.gif b/flags/gu.gif new file mode 100644 index 0000000..eafef68 Binary files /dev/null and b/flags/gu.gif differ diff --git a/flags/gw.gif b/flags/gw.gif new file mode 100644 index 0000000..55f7571 Binary files /dev/null and b/flags/gw.gif differ diff --git a/flags/gy.gif b/flags/gy.gif new file mode 100644 index 0000000..1cb4cd7 Binary files /dev/null and b/flags/gy.gif differ diff --git a/flags/hk.gif b/flags/hk.gif new file mode 100644 index 0000000..798af96 Binary files /dev/null and b/flags/hk.gif differ diff --git a/flags/hm.gif b/flags/hm.gif new file mode 100644 index 0000000..5269c6a Binary files /dev/null and b/flags/hm.gif differ diff --git a/flags/hn.gif b/flags/hn.gif new file mode 100644 index 0000000..6c4ffe8 Binary files /dev/null and b/flags/hn.gif differ diff --git a/flags/hr.gif b/flags/hr.gif new file mode 100644 index 0000000..557c660 Binary files /dev/null and b/flags/hr.gif differ diff --git a/flags/ht.gif b/flags/ht.gif new file mode 100644 index 0000000..059604a Binary files /dev/null and b/flags/ht.gif differ diff --git a/flags/hu.gif b/flags/hu.gif new file mode 100644 index 0000000..6142d86 Binary files /dev/null and b/flags/hu.gif differ diff --git a/flags/id.gif b/flags/id.gif new file mode 100644 index 0000000..865161b Binary files /dev/null and b/flags/id.gif differ diff --git a/flags/ie.gif b/flags/ie.gif new file mode 100644 index 0000000..506ad28 Binary files /dev/null and b/flags/ie.gif differ diff --git a/flags/il.gif b/flags/il.gif new file mode 100644 index 0000000..c8483ae Binary files /dev/null and b/flags/il.gif differ diff --git a/flags/in.gif b/flags/in.gif new file mode 100644 index 0000000..1cd8027 Binary files /dev/null and b/flags/in.gif differ diff --git a/flags/io.gif b/flags/io.gif new file mode 100644 index 0000000..de7e7ab Binary files /dev/null and b/flags/io.gif differ diff --git a/flags/iq.gif b/flags/iq.gif new file mode 100644 index 0000000..c34fe3c Binary files /dev/null and b/flags/iq.gif differ diff --git a/flags/ir.gif b/flags/ir.gif new file mode 100644 index 0000000..156040f Binary files /dev/null and b/flags/ir.gif differ diff --git a/flags/is.gif b/flags/is.gif new file mode 100644 index 0000000..b42502d Binary files /dev/null and b/flags/is.gif differ diff --git a/flags/it.gif b/flags/it.gif new file mode 100644 index 0000000..d79e90e Binary files /dev/null and b/flags/it.gif differ diff --git a/flags/jm.gif b/flags/jm.gif new file mode 100644 index 0000000..0bed67c Binary files /dev/null and b/flags/jm.gif differ diff --git a/flags/jo.gif b/flags/jo.gif new file mode 100644 index 0000000..03daf8a Binary files /dev/null and b/flags/jo.gif differ diff --git a/flags/jp.gif b/flags/jp.gif new file mode 100644 index 0000000..444c1d0 Binary files /dev/null and b/flags/jp.gif differ diff --git a/flags/ke.gif b/flags/ke.gif new file mode 100644 index 0000000..c2b5d45 Binary files /dev/null and b/flags/ke.gif differ diff --git a/flags/kg.gif b/flags/kg.gif new file mode 100644 index 0000000..72a4d41 Binary files /dev/null and b/flags/kg.gif differ diff --git a/flags/kh.gif b/flags/kh.gif new file mode 100644 index 0000000..30a1831 Binary files /dev/null and b/flags/kh.gif differ diff --git a/flags/ki.gif b/flags/ki.gif new file mode 100644 index 0000000..4a0751a Binary files /dev/null and b/flags/ki.gif differ diff --git a/flags/km.gif b/flags/km.gif new file mode 100644 index 0000000..5859595 Binary files /dev/null and b/flags/km.gif differ diff --git a/flags/kn.gif b/flags/kn.gif new file mode 100644 index 0000000..bb9cc34 Binary files /dev/null and b/flags/kn.gif differ diff --git a/flags/kp.gif b/flags/kp.gif new file mode 100644 index 0000000..6e0ca09 Binary files /dev/null and b/flags/kp.gif differ diff --git a/flags/kr.gif b/flags/kr.gif new file mode 100644 index 0000000..1cddbe7 Binary files /dev/null and b/flags/kr.gif differ diff --git a/flags/kw.gif b/flags/kw.gif new file mode 100644 index 0000000..1efc734 Binary files /dev/null and b/flags/kw.gif differ diff --git a/flags/ky.gif b/flags/ky.gif new file mode 100644 index 0000000..d3d02ee Binary files /dev/null and b/flags/ky.gif differ diff --git a/flags/kz.gif b/flags/kz.gif new file mode 100644 index 0000000..24baebe Binary files /dev/null and b/flags/kz.gif differ diff --git a/flags/la.gif b/flags/la.gif new file mode 100644 index 0000000..d14cf4d Binary files /dev/null and b/flags/la.gif differ diff --git a/flags/lb.gif b/flags/lb.gif new file mode 100644 index 0000000..003d83a Binary files /dev/null and b/flags/lb.gif differ diff --git a/flags/lc.gif b/flags/lc.gif new file mode 100644 index 0000000..f5fe5bf Binary files /dev/null and b/flags/lc.gif differ diff --git a/flags/li.gif b/flags/li.gif new file mode 100644 index 0000000..713c58e Binary files /dev/null and b/flags/li.gif differ diff --git a/flags/lk.gif b/flags/lk.gif new file mode 100644 index 0000000..1b3ee7f Binary files /dev/null and b/flags/lk.gif differ diff --git a/flags/lr.gif b/flags/lr.gif new file mode 100644 index 0000000..435af9e Binary files /dev/null and b/flags/lr.gif differ diff --git a/flags/ls.gif b/flags/ls.gif new file mode 100644 index 0000000..427ae95 Binary files /dev/null and b/flags/ls.gif differ diff --git a/flags/lt.gif b/flags/lt.gif new file mode 100644 index 0000000..dee9c60 Binary files /dev/null and b/flags/lt.gif differ diff --git a/flags/lu.gif b/flags/lu.gif new file mode 100644 index 0000000..7d7293e Binary files /dev/null and b/flags/lu.gif differ diff --git a/flags/lv.gif b/flags/lv.gif new file mode 100644 index 0000000..17e71b7 Binary files /dev/null and b/flags/lv.gif differ diff --git a/flags/ly.gif b/flags/ly.gif new file mode 100644 index 0000000..a654c30 Binary files /dev/null and b/flags/ly.gif differ diff --git a/flags/ma.gif b/flags/ma.gif new file mode 100644 index 0000000..fc78411 Binary files /dev/null and b/flags/ma.gif differ diff --git a/flags/mc.gif b/flags/mc.gif new file mode 100644 index 0000000..02a7c8e Binary files /dev/null and b/flags/mc.gif differ diff --git a/flags/md.gif b/flags/md.gif new file mode 100644 index 0000000..e4b8a7e Binary files /dev/null and b/flags/md.gif differ diff --git a/flags/me.gif b/flags/me.gif new file mode 100644 index 0000000..a260453 Binary files /dev/null and b/flags/me.gif differ diff --git a/flags/mg.gif b/flags/mg.gif new file mode 100644 index 0000000..a91b577 Binary files /dev/null and b/flags/mg.gif differ diff --git a/flags/mh.gif b/flags/mh.gif new file mode 100644 index 0000000..92f5f48 Binary files /dev/null and b/flags/mh.gif differ diff --git a/flags/mk.gif b/flags/mk.gif new file mode 100644 index 0000000..7aeb831 Binary files /dev/null and b/flags/mk.gif differ diff --git a/flags/ml.gif b/flags/ml.gif new file mode 100644 index 0000000..53d6f49 Binary files /dev/null and b/flags/ml.gif differ diff --git a/flags/mm.gif b/flags/mm.gif new file mode 100644 index 0000000..9e0a275 Binary files /dev/null and b/flags/mm.gif differ diff --git a/flags/mn.gif b/flags/mn.gif new file mode 100644 index 0000000..dff8ea5 Binary files /dev/null and b/flags/mn.gif differ diff --git a/flags/mo.gif b/flags/mo.gif new file mode 100644 index 0000000..66cf5b4 Binary files /dev/null and b/flags/mo.gif differ diff --git a/flags/mp.gif b/flags/mp.gif new file mode 100644 index 0000000..73b7147 Binary files /dev/null and b/flags/mp.gif differ diff --git a/flags/mq.gif b/flags/mq.gif new file mode 100644 index 0000000..570bc5d Binary files /dev/null and b/flags/mq.gif differ diff --git a/flags/mr.gif b/flags/mr.gif new file mode 100644 index 0000000..f52fcf0 Binary files /dev/null and b/flags/mr.gif differ diff --git a/flags/ms.gif b/flags/ms.gif new file mode 100644 index 0000000..5e5a67a Binary files /dev/null and b/flags/ms.gif differ diff --git a/flags/mt.gif b/flags/mt.gif new file mode 100644 index 0000000..45c709f Binary files /dev/null and b/flags/mt.gif differ diff --git a/flags/mu.gif b/flags/mu.gif new file mode 100644 index 0000000..081ab45 Binary files /dev/null and b/flags/mu.gif differ diff --git a/flags/mv.gif b/flags/mv.gif new file mode 100644 index 0000000..46b6387 Binary files /dev/null and b/flags/mv.gif differ diff --git a/flags/mw.gif b/flags/mw.gif new file mode 100644 index 0000000..ad045a0 Binary files /dev/null and b/flags/mw.gif differ diff --git a/flags/mx.gif b/flags/mx.gif new file mode 100644 index 0000000..ddc75d0 Binary files /dev/null and b/flags/mx.gif differ diff --git a/flags/my.gif b/flags/my.gif new file mode 100644 index 0000000..fc7d523 Binary files /dev/null and b/flags/my.gif differ diff --git a/flags/mz.gif b/flags/mz.gif new file mode 100644 index 0000000..7d63508 Binary files /dev/null and b/flags/mz.gif differ diff --git a/flags/na.gif b/flags/na.gif new file mode 100644 index 0000000..c0babe7 Binary files /dev/null and b/flags/na.gif differ diff --git a/flags/nc.gif b/flags/nc.gif new file mode 100644 index 0000000..b1e91b9 Binary files /dev/null and b/flags/nc.gif differ diff --git a/flags/ne.gif b/flags/ne.gif new file mode 100644 index 0000000..ff4eaf0 Binary files /dev/null and b/flags/ne.gif differ diff --git a/flags/nf.gif b/flags/nf.gif new file mode 100644 index 0000000..c83424c Binary files /dev/null and b/flags/nf.gif differ diff --git a/flags/ng.gif b/flags/ng.gif new file mode 100644 index 0000000..bdde7cb Binary files /dev/null and b/flags/ng.gif differ diff --git a/flags/ni.gif b/flags/ni.gif new file mode 100644 index 0000000..d05894d Binary files /dev/null and b/flags/ni.gif differ diff --git a/flags/nl.gif b/flags/nl.gif new file mode 100644 index 0000000..c1c8f46 Binary files /dev/null and b/flags/nl.gif differ diff --git a/flags/no.gif b/flags/no.gif new file mode 100644 index 0000000..6202d1f Binary files /dev/null and b/flags/no.gif differ diff --git a/flags/np.gif b/flags/np.gif new file mode 100644 index 0000000..1096893 Binary files /dev/null and b/flags/np.gif differ diff --git a/flags/nr.gif b/flags/nr.gif new file mode 100644 index 0000000..2e4c0c5 Binary files /dev/null and b/flags/nr.gif differ diff --git a/flags/nu.gif b/flags/nu.gif new file mode 100644 index 0000000..618210a Binary files /dev/null and b/flags/nu.gif differ diff --git a/flags/nz.gif b/flags/nz.gif new file mode 100644 index 0000000..028a5dc Binary files /dev/null and b/flags/nz.gif differ diff --git a/flags/om.gif b/flags/om.gif new file mode 100644 index 0000000..2b8c775 Binary files /dev/null and b/flags/om.gif differ diff --git a/flags/pa.gif b/flags/pa.gif new file mode 100644 index 0000000..d518b2f Binary files /dev/null and b/flags/pa.gif differ diff --git a/flags/pe.gif b/flags/pe.gif new file mode 100644 index 0000000..3bc7639 Binary files /dev/null and b/flags/pe.gif differ diff --git a/flags/pf.gif b/flags/pf.gif new file mode 100644 index 0000000..849297a Binary files /dev/null and b/flags/pf.gif differ diff --git a/flags/pg.gif b/flags/pg.gif new file mode 100644 index 0000000..2d20b07 Binary files /dev/null and b/flags/pg.gif differ diff --git a/flags/ph.gif b/flags/ph.gif new file mode 100644 index 0000000..12b380a Binary files /dev/null and b/flags/ph.gif differ diff --git a/flags/pk.gif b/flags/pk.gif new file mode 100644 index 0000000..f3f62c2 Binary files /dev/null and b/flags/pk.gif differ diff --git a/flags/pl.gif b/flags/pl.gif new file mode 100644 index 0000000..bf10646 Binary files /dev/null and b/flags/pl.gif differ diff --git a/flags/pm.gif b/flags/pm.gif new file mode 100644 index 0000000..99bf6fd Binary files /dev/null and b/flags/pm.gif differ diff --git a/flags/pn.gif b/flags/pn.gif new file mode 100644 index 0000000..4bc86a1 Binary files /dev/null and b/flags/pn.gif differ diff --git a/flags/pr.gif b/flags/pr.gif new file mode 100644 index 0000000..6d5d589 Binary files /dev/null and b/flags/pr.gif differ diff --git a/flags/pt.gif b/flags/pt.gif new file mode 100644 index 0000000..e735f74 Binary files /dev/null and b/flags/pt.gif differ diff --git a/flags/pw.gif b/flags/pw.gif new file mode 100644 index 0000000..5854510 Binary files /dev/null and b/flags/pw.gif differ diff --git a/flags/py.gif b/flags/py.gif new file mode 100644 index 0000000..f2e66af Binary files /dev/null and b/flags/py.gif differ diff --git a/flags/qa.gif b/flags/qa.gif new file mode 100644 index 0000000..2e843ff Binary files /dev/null and b/flags/qa.gif differ diff --git a/flags/re.gif b/flags/re.gif new file mode 100644 index 0000000..43d0b80 Binary files /dev/null and b/flags/re.gif differ diff --git a/flags/ro.gif b/flags/ro.gif new file mode 100644 index 0000000..f5d5f12 Binary files /dev/null and b/flags/ro.gif differ diff --git a/flags/rs.gif b/flags/rs.gif new file mode 100644 index 0000000..3bd1fb2 Binary files /dev/null and b/flags/rs.gif differ diff --git a/flags/ru.gif b/flags/ru.gif new file mode 100644 index 0000000..b525c46 Binary files /dev/null and b/flags/ru.gif differ diff --git a/flags/rw.gif b/flags/rw.gif new file mode 100644 index 0000000..0d095f7 Binary files /dev/null and b/flags/rw.gif differ diff --git a/flags/sa.gif b/flags/sa.gif new file mode 100644 index 0000000..179961b Binary files /dev/null and b/flags/sa.gif differ diff --git a/flags/sb.gif b/flags/sb.gif new file mode 100644 index 0000000..8f5ff83 Binary files /dev/null and b/flags/sb.gif differ diff --git a/flags/sc.gif b/flags/sc.gif new file mode 100644 index 0000000..31b4767 Binary files /dev/null and b/flags/sc.gif differ diff --git a/flags/sd.gif b/flags/sd.gif new file mode 100644 index 0000000..53ae214 Binary files /dev/null and b/flags/sd.gif differ diff --git a/flags/se.gif b/flags/se.gif new file mode 100644 index 0000000..80f6285 Binary files /dev/null and b/flags/se.gif differ diff --git a/flags/sg.gif b/flags/sg.gif new file mode 100644 index 0000000..5663d39 Binary files /dev/null and b/flags/sg.gif differ diff --git a/flags/sh.gif b/flags/sh.gif new file mode 100644 index 0000000..dcc7f3b Binary files /dev/null and b/flags/sh.gif differ diff --git a/flags/si.gif b/flags/si.gif new file mode 100644 index 0000000..23852b5 Binary files /dev/null and b/flags/si.gif differ diff --git a/flags/sj.gif b/flags/sj.gif new file mode 100644 index 0000000..6202d1f Binary files /dev/null and b/flags/sj.gif differ diff --git a/flags/sk.gif b/flags/sk.gif new file mode 100644 index 0000000..1b3f22b Binary files /dev/null and b/flags/sk.gif differ diff --git a/flags/sl.gif b/flags/sl.gif new file mode 100644 index 0000000..f0f3492 Binary files /dev/null and b/flags/sl.gif differ diff --git a/flags/sm.gif b/flags/sm.gif new file mode 100644 index 0000000..04d98de Binary files /dev/null and b/flags/sm.gif differ diff --git a/flags/sn.gif b/flags/sn.gif new file mode 100644 index 0000000..6dac870 Binary files /dev/null and b/flags/sn.gif differ diff --git a/flags/so.gif b/flags/so.gif new file mode 100644 index 0000000..f196169 Binary files /dev/null and b/flags/so.gif differ diff --git a/flags/sr.gif b/flags/sr.gif new file mode 100644 index 0000000..0f7499a Binary files /dev/null and b/flags/sr.gif differ diff --git a/flags/st.gif b/flags/st.gif new file mode 100644 index 0000000..4f1e6e0 Binary files /dev/null and b/flags/st.gif differ diff --git a/flags/sv.gif b/flags/sv.gif new file mode 100644 index 0000000..2d7b159 Binary files /dev/null and b/flags/sv.gif differ diff --git a/flags/sy.gif b/flags/sy.gif new file mode 100644 index 0000000..dc8bd50 Binary files /dev/null and b/flags/sy.gif differ diff --git a/flags/sz.gif b/flags/sz.gif new file mode 100644 index 0000000..f37aaf8 Binary files /dev/null and b/flags/sz.gif differ diff --git a/flags/tc.gif b/flags/tc.gif new file mode 100644 index 0000000..11a8c23 Binary files /dev/null and b/flags/tc.gif differ diff --git a/flags/td.gif b/flags/td.gif new file mode 100644 index 0000000..7aa8a10 Binary files /dev/null and b/flags/td.gif differ diff --git a/flags/tf.gif b/flags/tf.gif new file mode 100644 index 0000000..51a4325 Binary files /dev/null and b/flags/tf.gif differ diff --git a/flags/tg.gif b/flags/tg.gif new file mode 100644 index 0000000..ca6b4e7 Binary files /dev/null and b/flags/tg.gif differ diff --git a/flags/th.gif b/flags/th.gif new file mode 100644 index 0000000..0130792 Binary files /dev/null and b/flags/th.gif differ diff --git a/flags/tj.gif b/flags/tj.gif new file mode 100644 index 0000000..2fe38d4 Binary files /dev/null and b/flags/tj.gif differ diff --git a/flags/tk.gif b/flags/tk.gif new file mode 100644 index 0000000..3d3a727 Binary files /dev/null and b/flags/tk.gif differ diff --git a/flags/tl.gif b/flags/tl.gif new file mode 100644 index 0000000..df22d58 Binary files /dev/null and b/flags/tl.gif differ diff --git a/flags/tm.gif b/flags/tm.gif new file mode 100644 index 0000000..36d0994 Binary files /dev/null and b/flags/tm.gif differ diff --git a/flags/tn.gif b/flags/tn.gif new file mode 100644 index 0000000..917d428 Binary files /dev/null and b/flags/tn.gif differ diff --git a/flags/to.gif b/flags/to.gif new file mode 100644 index 0000000..d7ed4d1 Binary files /dev/null and b/flags/to.gif differ diff --git a/flags/tr.gif b/flags/tr.gif new file mode 100644 index 0000000..e407d55 Binary files /dev/null and b/flags/tr.gif differ diff --git a/flags/tt.gif b/flags/tt.gif new file mode 100644 index 0000000..47d3b80 Binary files /dev/null and b/flags/tt.gif differ diff --git a/flags/tv.gif b/flags/tv.gif new file mode 100644 index 0000000..3c33827 Binary files /dev/null and b/flags/tv.gif differ diff --git a/flags/tw.gif b/flags/tw.gif new file mode 100644 index 0000000..cacfd9b Binary files /dev/null and b/flags/tw.gif differ diff --git a/flags/tz.gif b/flags/tz.gif new file mode 100644 index 0000000..82b52ca Binary files /dev/null and b/flags/tz.gif differ diff --git a/flags/ua.gif b/flags/ua.gif new file mode 100644 index 0000000..5d6cd83 Binary files /dev/null and b/flags/ua.gif differ diff --git a/flags/ug.gif b/flags/ug.gif new file mode 100644 index 0000000..58b731a Binary files /dev/null and b/flags/ug.gif differ diff --git a/flags/um.gif b/flags/um.gif new file mode 100644 index 0000000..3b4c848 Binary files /dev/null and b/flags/um.gif differ diff --git a/flags/us.gif b/flags/us.gif new file mode 100644 index 0000000..8f198f7 Binary files /dev/null and b/flags/us.gif differ diff --git a/flags/uy.gif b/flags/uy.gif new file mode 100644 index 0000000..12848c7 Binary files /dev/null and b/flags/uy.gif differ diff --git a/flags/uz.gif b/flags/uz.gif new file mode 100644 index 0000000..dc9daec Binary files /dev/null and b/flags/uz.gif differ diff --git a/flags/va.gif b/flags/va.gif new file mode 100644 index 0000000..2bd7446 Binary files /dev/null and b/flags/va.gif differ diff --git a/flags/vc.gif b/flags/vc.gif new file mode 100644 index 0000000..4821381 Binary files /dev/null and b/flags/vc.gif differ diff --git a/flags/ve.gif b/flags/ve.gif new file mode 100644 index 0000000..19ce6c1 Binary files /dev/null and b/flags/ve.gif differ diff --git a/flags/vg.gif b/flags/vg.gif new file mode 100644 index 0000000..1fc0f96 Binary files /dev/null and b/flags/vg.gif differ diff --git a/flags/vi.gif b/flags/vi.gif new file mode 100644 index 0000000..66f9e74 Binary files /dev/null and b/flags/vi.gif differ diff --git a/flags/vn.gif b/flags/vn.gif new file mode 100644 index 0000000..f1e20c9 Binary files /dev/null and b/flags/vn.gif differ diff --git a/flags/vu.gif b/flags/vu.gif new file mode 100644 index 0000000..8a8b2b0 Binary files /dev/null and b/flags/vu.gif differ diff --git a/flags/wf.gif b/flags/wf.gif new file mode 100644 index 0000000..eaa954b Binary files /dev/null and b/flags/wf.gif differ diff --git a/flags/ws.gif b/flags/ws.gif new file mode 100644 index 0000000..a51f939 Binary files /dev/null and b/flags/ws.gif differ diff --git a/flags/ye.gif b/flags/ye.gif new file mode 100644 index 0000000..7b0183d Binary files /dev/null and b/flags/ye.gif differ diff --git a/flags/yt.gif b/flags/yt.gif new file mode 100644 index 0000000..a2267c0 Binary files /dev/null and b/flags/yt.gif differ diff --git a/flags/za.gif b/flags/za.gif new file mode 100644 index 0000000..ede5258 Binary files /dev/null and b/flags/za.gif differ diff --git a/flags/zm.gif b/flags/zm.gif new file mode 100644 index 0000000..b2851d2 Binary files /dev/null and b/flags/zm.gif differ diff --git a/flags/zw.gif b/flags/zw.gif new file mode 100644 index 0000000..02901f6 Binary files /dev/null and b/flags/zw.gif differ diff --git a/fonts/dejavu/DejaVuSans-Bold.ttf b/fonts/dejavu/DejaVuSans-Bold.ttf new file mode 100644 index 0000000..1f22f07 Binary files /dev/null and b/fonts/dejavu/DejaVuSans-Bold.ttf differ diff --git a/fonts/dejavu/DejaVuSans.ttf b/fonts/dejavu/DejaVuSans.ttf new file mode 100644 index 0000000..5267218 Binary files /dev/null and b/fonts/dejavu/DejaVuSans.ttf differ diff --git a/fonts/dejavu/DejaVuSerifCondensed-BoldItalic.ttf b/fonts/dejavu/DejaVuSerifCondensed-BoldItalic.ttf new file mode 100644 index 0000000..d657288 Binary files /dev/null and b/fonts/dejavu/DejaVuSerifCondensed-BoldItalic.ttf differ diff --git a/fonts/dejavu/LICENSE b/fonts/dejavu/LICENSE new file mode 100644 index 0000000..254e2cc --- /dev/null +++ b/fonts/dejavu/LICENSE @@ -0,0 +1,99 @@ +Fonts are (c) Bitstream (see below). DejaVu changes are in public domain. +Glyphs imported from Arev fonts are (c) Tavmjong Bah (see below) + +Bitstream Vera Fonts Copyright +------------------------------ + +Copyright (c) 2003 by Bitstream, Inc. All Rights Reserved. Bitstream Vera is +a trademark of Bitstream, Inc. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of the fonts accompanying this license ("Fonts") and associated +documentation files (the "Font Software"), to reproduce and distribute the +Font Software, including without limitation the rights to use, copy, merge, +publish, distribute, and/or sell copies of the Font Software, and to permit +persons to whom the Font Software is furnished to do so, subject to the +following conditions: + +The above copyright and trademark notices and this permission notice shall +be included in all copies of one or more of the Font Software typefaces. + +The Font Software may be modified, altered, or added to, and in particular +the designs of glyphs or characters in the Fonts may be modified and +additional glyphs or characters may be added to the Fonts, only if the fonts +are renamed to names not containing either the words "Bitstream" or the word +"Vera". + +This License becomes null and void to the extent applicable to Fonts or Font +Software that has been modified and is distributed under the "Bitstream +Vera" names. + +The Font Software may be sold as part of a larger software package but no +copy of one or more of the Font Software typefaces may be sold by itself. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS +OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF COPYRIGHT, PATENT, +TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL BITSTREAM OR THE GNOME +FOUNDATION BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, INCLUDING +ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, +WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF +THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM OTHER DEALINGS IN THE +FONT SOFTWARE. + +Except as contained in this notice, the names of Gnome, the Gnome +Foundation, and Bitstream Inc., shall not be used in advertising or +otherwise to promote the sale, use or other dealings in this Font Software +without prior written authorization from the Gnome Foundation or Bitstream +Inc., respectively. For further information, contact: fonts at gnome dot +org. + +Arev Fonts Copyright +------------------------------ + +Copyright (c) 2006 by Tavmjong Bah. All Rights Reserved. + +Permission is hereby granted, free of charge, to any person obtaining +a copy of the fonts accompanying this license ("Fonts") and +associated documentation files (the "Font Software"), to reproduce +and distribute the modifications to the Bitstream Vera Font Software, +including without limitation the rights to use, copy, merge, publish, +distribute, and/or sell copies of the Font Software, and to permit +persons to whom the Font Software is furnished to do so, subject to +the following conditions: + +The above copyright and trademark notices and this permission notice +shall be included in all copies of one or more of the Font Software +typefaces. + +The Font Software may be modified, altered, or added to, and in +particular the designs of glyphs or characters in the Fonts may be +modified and additional glyphs or characters may be added to the +Fonts, only if the fonts are renamed to names not containing either +the words "Tavmjong Bah" or the word "Arev". + +This License becomes null and void to the extent applicable to Fonts +or Font Software that has been modified and is distributed under the +"Tavmjong Bah Arev" names. + +The Font Software may be sold as part of a larger software package but +no copy of one or more of the Font Software typefaces may be sold by +itself. + +THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT +OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL +TAVMJONG BAH BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL +DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM +OTHER DEALINGS IN THE FONT SOFTWARE. + +Except as contained in this notice, the name of Tavmjong Bah shall not +be used in advertising or otherwise to promote the sale, use or other +dealings in this Font Software without prior written authorization +from Tavmjong Bah. For further information, contact: tavmjong @ free +. fr. + +$Id: LICENSE 2133 2007-11-28 02:46:28Z lechimp $ diff --git a/lib/UserBadge/__init__.py b/lib/UserBadge/__init__.py new file mode 100644 index 0000000..5b855bb --- /dev/null +++ b/lib/UserBadge/__init__.py @@ -0,0 +1,3 @@ +__version__ = '0.1' + +from _user_badge import UserBadge, RankCodeAbbey \ No newline at end of file diff --git a/lib/UserBadge/_user_badge.py b/lib/UserBadge/_user_badge.py new file mode 100644 index 0000000..d77edf1 --- /dev/null +++ b/lib/UserBadge/_user_badge.py @@ -0,0 +1,194 @@ +from PIL import Image, ImageDraw, ImageFont +import cStringIO +import StringIO +import urllib +import urllib2 +import json +import string + +from random import randint + +class RankCodeAbbey(object): + PEASANT = 0 + ACOLYTE = 1 + BELIEVER = 2 + FOLLOWER = 3 + PRIEST = 4 + FANATIC = 5 + DEACON = 6 + BISHOP = 7 + STARGAZER = 8 + THE_DOCTOR = 9 + FROST_ENCHANTER = 10 + CARDINAL = 11 + + +class UserBadge(object): + def __init__(self, x_size, y_size, rank = 'default'): + self.rank = rank + self.width = x_size + self.height = y_size + #store the colors + self.rank_rgb_color_dict = { RankCodeAbbey.PEASANT: (136, 136, 136), + RankCodeAbbey.ACOLYTE: (68, 255, 68), + RankCodeAbbey.BELIEVER: (0, 221, 221), + RankCodeAbbey.FOLLOWER: (68, 68, 255), + RankCodeAbbey.PRIEST: (221, 0, 221), + RankCodeAbbey.FANATIC: (221, 221, 0), + RankCodeAbbey.DEACON: (255, 153, 17), + RankCodeAbbey.BISHOP: (255, 68, 68), + RankCodeAbbey.STARGAZER: (68, 68, 255), + RankCodeAbbey.THE_DOCTOR: (255, 153, 17), + RankCodeAbbey.FROST_ENCHANTER: (0, 204, 238), + RankCodeAbbey.CARDINAL: (135, 0, 170), + 'default': (0, 0, 0) + } + + print rank + if RankCodeAbbey.PEASANT <= rank <= RankCodeAbbey.CARDINAL: + background_filename = 'static/rank' + str(rank) + '.png' + else: + background_filename = 'static/default.png' + + self.img = Image.open(background_filename) + self.draw = ImageDraw.Draw(self.img) + + #leave this stub in for now to create arbitrary size images + if rank == None: + self.img = Image.new("RGB", (x_size, y_size), '#FFFFFF') + self.draw = ImageDraw.Draw(self.img) + #set this to default for use by the other derived fields + self.rank = 'default' + + + self.padding = 5 + #configure square user image + self.tb_size = 50 + self.tb_x_offset = self.width - self.tb_size - self.padding + self.tb_y_offset = self.padding + + #configure size of flag + self.flag_width = 16 + self.flag_height = 11 + self.flag_spacing = 5 + + #configure size available for user name + self.name_x_offset = self.padding + self.username_allowed_width = self.width - self.name_x_offset - self.flag_spacing - self.flag_width - self.padding - self.tb_size - self.padding + self.username_baseline_offset = self.height * 0.35 + self.username_height = 35 + + + def AddUserName(self, name, rank = "default"): + #parameters to adjust name location and appearance + name_font_size = 14 + try: + name_font_color = self.rank_rgb_color_dict[self.rank] + except KeyError as e: + name_font_color = (0,0,0) + + #we are using this font just to test since it looks different + #than system font, so we can know when it is working + unicode_font = ImageFont.truetype("fonts/dejavu/DejaVuSerifCondensed-BoldItalic.ttf", name_font_size) + while True: + #dynamically determine the offset to have a relative placement in image + (predicted_width, predicted_height) = unicode_font.getsize(name) + if(predicted_width > self.username_allowed_width) and name_font_size > 12: + name_font_size -= 1 + unicode_font = ImageFont.truetype("fonts/dejavu/DejaVuSerifCondensed-BoldItalic.ttf", name_font_size) + else: + #check for case where we have to truncate + + while True: + if(predicted_width > self.username_allowed_width) and len(name) > 0: + (predicted_width, predicted_height) = unicode_font.getsize(name) + #truncate the string by one + name = name[:-1] + else: + break + self.username_width = predicted_width + self.username_height = predicted_height + break + + #compute the y offset to keep constant baseline position + self.name_y_offest = max([0, (self.username_baseline_offset - predicted_height)]) + + self.draw.text((self.name_x_offset, self.name_y_offest), name, font = unicode_font, fill = name_font_color) + + def AddCountryFlag(self, country): + iso_country_codes = set(['BD', 'BE', 'BF', 'BG', 'BA', 'BB', 'WF', 'BM', 'BN', 'BO', + 'BH', 'BI', 'BJ', 'BT', 'JM', 'BV', 'BW', 'WS', 'BR', 'BS', 'JE', 'BY', 'BZ', + 'RU', 'RW', 'RS', 'TL', 'RE', 'TM', 'TJ', 'RO', 'TK', 'GW', 'GU', 'GT', 'GS', + 'GR', 'GQ', 'GP', 'JP', 'GY', 'GG', 'GF', 'GE', 'GD', 'GB', 'GA', 'GN', 'GM', + 'GL', 'GI', 'GH', 'OM', 'TN', 'JO', 'TA', 'HR', 'HT', 'HU', 'HK', 'HN', 'HM', + 'VE', 'PR', 'PW', 'PT', 'KN', 'PY', 'AI', 'PA', 'PF', 'PG', 'PE', 'PK', 'PH', + 'PN', 'PL', 'PM', 'ZM', 'EE', 'EG', 'ZA', 'EC', 'IT', 'VN', 'SB', 'ET', 'SO', + 'ZW', 'KY', 'ES', 'ER', 'ME', 'MD', 'MG', 'MA', 'MC', 'UZ', 'MM', 'ML', 'MO', + 'MN', 'MH', 'MK', 'MU', 'MT', 'MW', 'MV', 'MQ', 'MP', 'MS', 'MR', 'IM', 'UG', + 'MY', 'MX', 'IL', 'FR', 'AW', 'SH', 'AX', 'SJ', 'FI', 'FJ', 'FK', 'FM', 'FO', + 'NI', 'NL', 'NO', 'NA', 'VU', 'NC', 'NE', 'NF', 'NG', 'NZ', 'NP', 'NR', 'NU', + 'CK', 'CI', 'CH', 'CO', 'CN', 'CM', 'CL', 'CC', 'CA', 'CG', 'CF', 'CD', 'CZ', + 'CY', 'CX', 'CR', 'CV', 'CU', 'SZ', 'SY', 'KG', 'KE', 'SR', 'KI', 'KH', 'SV', + 'KM', 'ST', 'SK', 'KR', 'SI', 'KP', 'KW', 'SN', 'SM', 'SL', 'SC', 'KZ', 'SA', + 'SG', 'SE', 'SD', 'DO', 'DM', 'DJ', 'DK', 'VG', 'DE', 'YE', 'DZ', 'US', 'UY', + 'YT', 'UM', 'LB', 'LC', 'LA', 'TV', 'TW', 'TT', 'TR', 'LK', 'LI', 'LV', 'TO', + 'LT', 'LU', 'LR', 'LS', 'TH', 'TF', 'TG', 'TD', 'TC', 'LY', 'VA', 'AC', 'VC', + 'AE', 'AD', 'AG', 'AF', 'IQ', 'VI', 'IS', 'IR', 'AM', 'AL', 'AO', 'AN', 'AQ', + 'AS', 'AR', 'AU', 'AT', 'IO', 'IN', 'TZ', 'AZ', 'IE', 'ID', 'UA', 'QA', 'MZ']) + if country in iso_country_codes: + self.flag_name = 'flags/' + country.lower() + '.gif' + + def AddNumSolved(self, num_solved = 0): + #error case num solved is ? + text = 'solved: ' + if num_solved > 0: + #hold field with to max of 4 chars + text += str(num_solved)[-4:] + + unicode_font = ImageFont.truetype("fonts/dejavu/DejaVuSans.ttf", 10) + solved_xo = self.padding + solved_yo = int(self.height * 0.45) + self.draw.text((solved_xo, solved_yo), text, font = unicode_font, fill = (32,32,32)) + + + def AddPosition(self, position): + #error case num solved is ? + text = 'rank: ' + if position > 0: + #switch to scientific notation if rank is large enough + if position > 999999: + if(position >= 1e100): + position = ">1e100" + else: + position = "{:.2e}".format(position) + #remove the positive exponent + position = string.replace(position, '+', '') + else: + position = str(position) + #hold field with to max of 4 chars + text += position[-10:] + + unicode_font = ImageFont.truetype("fonts/dejavu/DejaVuSans.ttf", 10) + solved_xo = self.padding + 65 + solved_yo = int(self.height * 0.45) + self.draw.text((solved_xo, solved_yo), text, font = unicode_font, fill = (32,32,32)) + + + + def RenderToBuffer(self): + #render all of variable position boxes here at once + self.flag_x_offset = int(self.name_x_offset + self.username_width + self.flag_spacing) + #Adjust this parameter to vary the spacing of the flag picture from baseline + FLAG_FUDGE_FACTOR = 0.3 + #self.draw.line((0, self.username_baseline_offset, self.width, self.username_baseline_offset), fill = (0,0,0)) + self.flag_y_offest = max([0, int(self.username_baseline_offset - int(self.username_height * FLAG_FUDGE_FACTOR)- self.flag_height)]) + + + flag_file = Image.open(self.flag_name) + (flag_x,flag_y) = flag_file.size + self.img.paste(flag_file, (self.flag_x_offset, self.flag_y_offest, self.flag_x_offset+flag_x , self.flag_y_offest+flag_y)) + + #create buffer for output + f = cStringIO.StringIO() + self.img.save(f, "PNG") + return f \ No newline at end of file diff --git a/main.py b/main.py index 9c800e7..eca10a9 100644 --- a/main.py +++ b/main.py @@ -4,13 +4,136 @@ import time from google.appengine.ext import db +import datetime +import StringIO +import random +import json + +from random import randint + +from UserBadge import UserBadge, RankCodeAbbey + app = flask.Flask(__name__) app.config['DEBUG'] = False @app.route('/') def index(): - return flask.render_template('index.html') + return flask.render_template('index.html') + +@app.route('/banner/') +def prepare_banner(username): + #github max user name is 39, and site only has max of 15 + MAX_USER_NAME_LEN = 40 + if len(username) > MAX_USER_NAME_LEN: + return "bad request", 400 + #TODO: More vaidation of username here + + #make a request to code abbey site + code_abbey_api = 'http://www.codeabbey.com/index/api_user/' + target_user = code_abbey_api + username + req = urllib2.Request(target_user) + try: + api_response = urllib2.urlopen(req) + except urllib2.HTTPError as e: + print e.code + return "User with given URL not found", 400 + except urllib2.URLError as e: + #we could not reach the server, so try again in a little bit + #TODO: choose a better error code to indicate try again + # or set a retry after header + return "try again", 500 + + if api_response.getcode() != 200: + return "service down", 205 + + if api_response.headers.getheader('content-type') == 'application/json': + data = json.load(api_response, encoding = 'utf-8') + if 'error' in data.keys(): + return data['error'], 400 + + #we nee the rank for the constructor to choose default image + try: + rank = int(data['rankNumber']) + except KeyError as e: + rank = None + + user_badge = UserBadge(200, 60, rank) + #dirty hack right now to test functioning + #user_badge = UserBadge(200, 60, 'default') + + try: + country = data['country'] + except KeyError as e: + #we do not add a country + pass + else: + user_badge.AddCountryFlag(country) + try: + badge_username = data['username'] + except KeyError as e: + #do not add a user name to the badge + pass + else: + user_badge.AddUserName(badge_username) + + try: + solved = int(data['solved']) + except KeyError as e: + user_badge.AddNumSolved(-1) + else: + user_badge.AddNumSolved(solved) + + try: + position = int(data['position']) + except KeyError as e: + user_badge.AddPosition(-1) + else: + user_badge.AddPosition(position) + + #at end prepare the file + f = user_badge.RenderToBuffer() + + response = flask.make_response(f.getvalue()) + response.headers['Content-Type'] = 'image/png' + return response + + else: + return "hello world" + + +@app.route("/simple.png") +def randgradient(): + img = Image.new("RGB", (300,300), "#FFFFFF") + draw = ImageDraw.Draw(img) + flag = Image.open('flags/us.gif') + + r,g,b = randint(0,255), randint(0,255), randint(0,255) + dr = (randint(0,255) - r)/300. + dg = (randint(0,255) - g)/300. + db = (randint(0,255) - b)/300. + for i in range(300): + r,g,b = r+dr, g+dg, b+db + draw.line((i,0,i,300), fill=(int(r),int(g),int(b))) + + + #paste in the country flag + (flag_x,flag_y) = flag.size + img.paste(flag, (20, 20, 20+flag_x , 20+flag_y)) + + f = cStringIO.StringIO() + img.save(f, "PNG") + + response = flask.make_response(f.getvalue()) + response.headers['Content-Type'] = 'image/png' + return response + +@app.route('/robots.txt', methods=['GET']) +def deny_all(): + response = flask.make_response(open('static/robots.txt').read()) + response.headers["Content-type"] = "text/plain" + return response @app.errorhandler(404) def page_not_found(e): - return 'Sorry, nothing at this URL.', 404 + return 'Sorry, nothing at this URL.', 404 + diff --git a/static/default.png b/static/default.png new file mode 100644 index 0000000..c51604c Binary files /dev/null and b/static/default.png differ diff --git a/static/rank0.png b/static/rank0.png new file mode 100644 index 0000000..4e12f44 Binary files /dev/null and b/static/rank0.png differ diff --git a/static/rank1.png b/static/rank1.png new file mode 100644 index 0000000..b9eb8c8 Binary files /dev/null and b/static/rank1.png differ diff --git a/static/rank10.png b/static/rank10.png new file mode 100644 index 0000000..1810737 Binary files /dev/null and b/static/rank10.png differ diff --git a/static/rank11.png b/static/rank11.png new file mode 100644 index 0000000..7ed92d9 Binary files /dev/null and b/static/rank11.png differ diff --git a/static/rank2.png b/static/rank2.png new file mode 100644 index 0000000..9e1fd9b Binary files /dev/null and b/static/rank2.png differ diff --git a/static/rank3.png b/static/rank3.png new file mode 100644 index 0000000..da5e784 Binary files /dev/null and b/static/rank3.png differ diff --git a/static/rank4.png b/static/rank4.png new file mode 100644 index 0000000..699e588 Binary files /dev/null and b/static/rank4.png differ diff --git a/static/rank5.png b/static/rank5.png new file mode 100644 index 0000000..ebf62ad Binary files /dev/null and b/static/rank5.png differ diff --git a/static/rank6.png b/static/rank6.png new file mode 100644 index 0000000..5cf4b3a Binary files /dev/null and b/static/rank6.png differ diff --git a/static/rank7.png b/static/rank7.png new file mode 100644 index 0000000..012d6f6 Binary files /dev/null and b/static/rank7.png differ diff --git a/static/rank8.png b/static/rank8.png new file mode 100644 index 0000000..689ac4a Binary files /dev/null and b/static/rank8.png differ diff --git a/static/rank9.png b/static/rank9.png new file mode 100644 index 0000000..95ec33f Binary files /dev/null and b/static/rank9.png differ diff --git a/static/robots.txt b/static/robots.txt new file mode 100644 index 0000000..1f53798 --- /dev/null +++ b/static/robots.txt @@ -0,0 +1,2 @@ +User-agent: * +Disallow: / diff --git a/static/stubs/acolyte.png b/static/stubs/acolyte.png new file mode 100644 index 0000000..c7d1f44 Binary files /dev/null and b/static/stubs/acolyte.png differ diff --git a/static/stubs/cardinal.png b/static/stubs/cardinal.png new file mode 100644 index 0000000..4853406 Binary files /dev/null and b/static/stubs/cardinal.png differ diff --git a/static/stubs/frost_enchanter.png b/static/stubs/frost_enchanter.png new file mode 100644 index 0000000..7b87c23 Binary files /dev/null and b/static/stubs/frost_enchanter.png differ diff --git a/tools/gen_defaults.py b/tools/gen_defaults.py new file mode 100644 index 0000000..06452fd --- /dev/null +++ b/tools/gen_defaults.py @@ -0,0 +1,110 @@ +from PIL import Image, ImageDraw, ImageFont +import cStringIO +import StringIO +import urllib +import urllib2 +import json +import sys +import string + +from UserBadge import * + + +rank_rgb_color_dict = { RankCodeAbbey.PEASANT: (136, 136, 136), + RankCodeAbbey.ACOLYTE: (68, 255, 68), + RankCodeAbbey.BELIEVER: (0, 221, 221), + RankCodeAbbey.FOLLOWER: (68, 68, 255), + RankCodeAbbey.PRIEST: (221, 0, 221), + RankCodeAbbey.FANATIC: (221, 221, 0), + RankCodeAbbey.DEACON: (255, 153, 17), + RankCodeAbbey.BISHOP: (255, 68, 68), + RankCodeAbbey.STARGAZER: (68, 68, 255), + RankCodeAbbey.THE_DOCTOR: (255, 153, 17), + RankCodeAbbey.FROST_ENCHANTER: (0, 204, 238), + RankCodeAbbey.CARDINAL: (135, 0, 170), + 'default': (0, 0, 0) + } + +ranks_to_enum_dict = {'peasant': RankCodeAbbey.PEASANT, + 'acolyte': RankCodeAbbey.ACOLYTE, + 'believer': RankCodeAbbey.BELIEVER, + 'follower': RankCodeAbbey.FOLLOWER, + 'priest': RankCodeAbbey.PRIEST, + 'fanatic': RankCodeAbbey.FANATIC, + 'deacon': RankCodeAbbey.DEACON, + 'bishop': RankCodeAbbey.BISHOP, + 'stargazer': RankCodeAbbey.STARGAZER, + 'the_doctor': RankCodeAbbey.THE_DOCTOR, + 'frost_enchanter': RankCodeAbbey.FROST_ENCHANTER, + 'cardinal': RankCodeAbbey.CARDINAL + } + + +def main(): + if(len(sys.argv) != 5): + print "usage {} ".format(sys.argv[0]) + sys.exit() + else: + rank = sys.argv[4].lower() + if rank not in ranks_to_enum_dict.keys(): + print "must enter valid rank" + sys.exit() + + rank_text = string.replace(rank, '_', ' ') + #switch rank to enum entry + rank = ranks_to_enum_dict[rank] + + font_size = 12 + unicode_font = ImageFont.truetype("DejaVuSans-Bold.ttf", font_size) + + font_allowable_width = 56 + font_allowable_height = 14 + + while True: + pr_w, pr_h = unicode_font.getsize(rank_text) + if pr_w > font_allowable_width: + font_size -= 1 + print font_size + unicode_font = ImageFont.truetype("DejaVuSans-Bold.ttf", font_size) + else: + break + + print "text size {} * {}".format(pr_w, pr_h) + font_color = rank_rgb_color_dict[rank] + + img = Image.open(sys.argv[1]) + draw = ImageDraw.Draw(img) + icon = Image.open(sys.argv[2]) + + img_width, img_height = img.size + if(img_width != 200) or (img_height != 60): + print "default image size must be 200*60" + sys.exit() + #change the size to fit within the limits of 56 by 56 + icon_height, icon_width = icon.size + print icon_height, icon_width + if icon_height != icon_width: + print "must choose a square image for icon image" + sys.exit() + target_size = 42 + if icon_width != target_size: + #we must resize the image + icon = icon.resize((target_size, target_size), Image.BICUBIC) + print icon.size + + centering_allowance = (font_allowable_width - target_size)/2 + border_width = 2 + icon_xo = img_width - border_width - centering_allowance - target_size + img.paste(icon, (icon_xo, 2, icon_xo+target_size, 2+target_size), icon) + + #compute text centering allowances + text_xo = img_width - font_allowable_width + (font_allowable_width - pr_w)/2 + text_yo = border_width + target_size + (font_allowable_height- pr_h)/2 + + draw.text((text_xo, text_yo), rank_text, font = unicode_font, fill = font_color) + + img.save(sys.argv[3], "PNG") + + +if __name__ == '__main__': + main() \ No newline at end of file