diff --git a/.gitignore b/.gitignore index 8b75efd..168176b 100644 --- a/.gitignore +++ b/.gitignore @@ -14,4 +14,9 @@ firefox/package.json # Source build/ node_modules/ +assets/*.png +assets/*.gif npm-debug.log + +# VirtualEnv +env/ diff --git a/README.md b/README.md index 8817455..f11bc02 100644 --- a/README.md +++ b/README.md @@ -24,4 +24,4 @@ As you can tell, the quality of the code isnt perfect, or to a particular standa All the time the app has a version of `0.0.0`, the extensions are considered to be unstable and unlikely to work properly, if at all. ## Example ## -The sytax used is identical to what is used in the hipchat applications: wrapping the identifier in brackets `()`. For example, (yey) (allthethings) . +The sytax used is identical to what is used in the hipchat applications: wrapping the identifier in brackets `()`. For example, (yey) (allthethings) (boom) . diff --git a/assets/acceptable.png b/assets/acceptable.png deleted file mode 100644 index 5ff69ec..0000000 Binary files a/assets/acceptable.png and /dev/null differ diff --git a/assets/allthethings.png b/assets/allthethings.png deleted file mode 100644 index 6243a18..0000000 Binary files a/assets/allthethings.png and /dev/null differ diff --git a/assets/angrycat.png b/assets/angrycat.png deleted file mode 100644 index f6dbb8e..0000000 Binary files a/assets/angrycat.png and /dev/null differ diff --git a/assets/areyoukiddingme.png b/assets/areyoukiddingme.png deleted file mode 100644 index 172612c..0000000 Binary files a/assets/areyoukiddingme.png and /dev/null differ diff --git a/assets/argh.png b/assets/argh.png deleted file mode 100644 index 286927b..0000000 Binary files a/assets/argh.png and /dev/null differ diff --git a/assets/atom.png b/assets/atom.png deleted file mode 100644 index d17389d..0000000 Binary files a/assets/atom.png and /dev/null differ diff --git a/assets/awesome.png b/assets/awesome.png deleted file mode 100644 index fa671ef..0000000 Binary files a/assets/awesome.png and /dev/null differ diff --git a/assets/awthanks.png b/assets/awthanks.png deleted file mode 100644 index 3f9d0d4..0000000 Binary files a/assets/awthanks.png and /dev/null differ diff --git a/assets/aww.png b/assets/aww.png deleted file mode 100644 index 406faf5..0000000 Binary files a/assets/aww.png and /dev/null differ diff --git a/assets/awyeah.png b/assets/awyeah.png deleted file mode 100644 index 7e96e57..0000000 Binary files a/assets/awyeah.png and /dev/null differ diff --git a/assets/badass.png b/assets/badass.png deleted file mode 100644 index 03b6d86..0000000 Binary files a/assets/badass.png and /dev/null differ diff --git a/assets/beer.png b/assets/beer.png deleted file mode 100644 index d55f161..0000000 Binary files a/assets/beer.png and /dev/null differ diff --git a/assets/build-assets.py b/assets/build-assets.py index e13ca6c..72e3b91 100644 --- a/assets/build-assets.py +++ b/assets/build-assets.py @@ -1,23 +1,60 @@ -import json +import json, requests, os, base64 from glob import glob +from lxml import html +from collections import namedtuple -ASSETS_URL="https://raw.githubusercontent.com/RealOrangeOne/hipchat-emoticons-for-all/master/assets/" +ASSET_DIR = os.path.dirname(os.path.realpath(__file__)) +LOCAL_FILES = glob('assets/*.png') + glob('assets/*.gif') +Emoticon = namedtuple('Emoticon', ['ident', 'url']) +def get_filename(path): + return path.replace('assets/', '') def get_icon_name(path): return get_filename(path).replace('.png', '').replace('.gif', '') -def get_filename(path): - return path.replace('assets/', '') +print("Collecting Page Elements...") +page = requests.get("https://www.hipchat.com/emoticons") +html_tree = html.fromstring(page.text) +emoticon_paths = html_tree.xpath("//div[@class='emoticon-block']/img/@src") +emoticon_names = html_tree.xpath("//div[@class='emoticon-block']/div/text()") +emoticons = [] +for i in range(len(emoticon_names)-1): + emoticons.append(Emoticon(emoticon_names[i][1:-1], emoticon_paths[i])) + +print("Downloading offline emoticons...") +DOWNLOAD_FILES = [] +for emoticon in emoticons: + ext = 'gif' if emoticon.url.endswith('gif') else 'png' + path = ASSET_DIR + "/{0}.{1}".format(emoticon.ident, ext) + DOWNLOAD_FILES.append(path) + if os.path.isfile(path): + continue + with open(path, 'wb') as handle: + response = requests.get(emoticon.url, stream=True) + if not response.ok: + print("Something went wrong getting " + emoticon.ident) + continue + + for block in response.iter_content(1024): + handle.write(block) + + print ("{}/{} Files Downloaded\r".format(len(DOWNLOAD_FILES), len(emoticons)), end='' if len(DOWNLOAD_FILES) != len(emoticons) else '\n') + +for filename in LOCAL_FILES: + emoticons.append(Emoticon(get_icon_name(filename), filename)) -files = glob('assets/*.png') + glob('assets/*.gif') images = [] +print("Converting Files...") +for emoticon in emoticons: + ext = ext = 'gif' if emoticon.url.endswith('gif') else 'png' + path = ASSET_DIR + "/{0}.{1}".format(emoticon.ident, ext) + file = base64.b64encode(open(path, 'rb').read()).decode('utf-8').replace('\n', '') + data = "data:image/{0};base64,{1}".format(ext, file) + images.append({emoticon.ident: data}) -for filename in files: - images.append({get_icon_name(filename): ASSETS_URL + get_filename(filename)}) - - +print("Exporting JSON...") image_decoder = {"images":images} image_decoder_json = json.dumps(image_decoder, indent=2, sort_keys=True) @@ -30,3 +67,7 @@ js_file = js_file.replace("%image_decoder%", image_decoder_json) with open('build/global.js', 'w') as file: file.write(js_file) + +print("Deleting Temporary Files...") +for file in DOWNLOAD_FILES: + os.remove(file) diff --git a/assets/bullshirt.png b/assets/bullshirt.png deleted file mode 100644 index 520de64..0000000 Binary files a/assets/bullshirt.png and /dev/null differ diff --git a/assets/challengeaccepted.png b/assets/challengeaccepted.png deleted file mode 100644 index b23fdc3..0000000 Binary files a/assets/challengeaccepted.png and /dev/null differ diff --git a/assets/chompy.gif b/assets/chompy.gif deleted file mode 100644 index f979bc5..0000000 Binary files a/assets/chompy.gif and /dev/null differ diff --git a/assets/content.png b/assets/content.png deleted file mode 100644 index f3630e4..0000000 Binary files a/assets/content.png and /dev/null differ diff --git a/assets/doge.png b/assets/doge.png deleted file mode 100644 index 6ce3e4c..0000000 Binary files a/assets/doge.png and /dev/null differ diff --git a/assets/donotwant.gif b/assets/donotwant.gif deleted file mode 100644 index 552d0ca..0000000 Binary files a/assets/donotwant.gif and /dev/null differ diff --git a/assets/drool.png b/assets/drool.png deleted file mode 100644 index 7809759..0000000 Binary files a/assets/drool.png and /dev/null differ diff --git a/assets/evilburns.png b/assets/evilburns.png deleted file mode 100644 index 53ade86..0000000 Binary files a/assets/evilburns.png and /dev/null differ diff --git a/assets/facepalm.png b/assets/facepalm.png deleted file mode 100644 index eca7f0a..0000000 Binary files a/assets/facepalm.png and /dev/null differ diff --git a/assets/greenbeer.png b/assets/greenbeer.png deleted file mode 100644 index 321d1da..0000000 Binary files a/assets/greenbeer.png and /dev/null differ diff --git a/assets/herp.png b/assets/herp.png deleted file mode 100644 index 42f09fb..0000000 Binary files a/assets/herp.png and /dev/null differ diff --git a/assets/hubot.png b/assets/hubot.png deleted file mode 100644 index 1c1d78a..0000000 Binary files a/assets/hubot.png and /dev/null differ diff --git a/assets/iseewhatyoudidthere.png b/assets/iseewhatyoudidthere.png deleted file mode 100644 index b3b6b8a..0000000 Binary files a/assets/iseewhatyoudidthere.png and /dev/null differ diff --git a/assets/jackie.png b/assets/jackie.png deleted file mode 100644 index 6fe7924..0000000 Binary files a/assets/jackie.png and /dev/null differ diff --git a/assets/llama.png b/assets/llama.png deleted file mode 100644 index 6358097..0000000 Binary files a/assets/llama.png and /dev/null differ diff --git a/assets/lol.png b/assets/lol.png deleted file mode 100644 index 6041cfc..0000000 Binary files a/assets/lol.png and /dev/null differ diff --git a/assets/metal.png b/assets/metal.png deleted file mode 100644 index b751fb1..0000000 Binary files a/assets/metal.png and /dev/null differ diff --git a/assets/mindblown.gif b/assets/mindblown.gif deleted file mode 100644 index 48b2d85..0000000 Binary files a/assets/mindblown.gif and /dev/null differ diff --git a/assets/mygoditsfullofstars.png b/assets/mygoditsfullofstars.png deleted file mode 100644 index f97bd49..0000000 Binary files a/assets/mygoditsfullofstars.png and /dev/null differ diff --git a/assets/nice.png b/assets/nice.png deleted file mode 100644 index 99388b4..0000000 Binary files a/assets/nice.png and /dev/null differ diff --git a/assets/noot.png b/assets/noot.png deleted file mode 100644 index 024c89f..0000000 Binary files a/assets/noot.png and /dev/null differ diff --git a/assets/notbad.png b/assets/notbad.png deleted file mode 100644 index 6cd7545..0000000 Binary files a/assets/notbad.png and /dev/null differ diff --git a/assets/nothingtodohere.png b/assets/nothingtodohere.png deleted file mode 100644 index 9764304..0000000 Binary files a/assets/nothingtodohere.png and /dev/null differ diff --git a/assets/ohcrap.png b/assets/ohcrap.png deleted file mode 100644 index 27eb4bc..0000000 Binary files a/assets/ohcrap.png and /dev/null differ diff --git a/assets/ohgodwhy.png b/assets/ohgodwhy.png deleted file mode 100644 index 504b169..0000000 Binary files a/assets/ohgodwhy.png and /dev/null differ diff --git a/assets/ohmy.png b/assets/ohmy.png deleted file mode 100644 index faf27a0..0000000 Binary files a/assets/ohmy.png and /dev/null differ diff --git a/assets/okay.png b/assets/okay.png deleted file mode 100644 index 6f83c59..0000000 Binary files a/assets/okay.png and /dev/null differ diff --git a/assets/poo.png b/assets/poo.png deleted file mode 100644 index f19050b..0000000 Binary files a/assets/poo.png and /dev/null differ diff --git a/assets/ragegirl.png b/assets/ragegirl.png deleted file mode 100644 index 441d66b..0000000 Binary files a/assets/ragegirl.png and /dev/null differ diff --git a/assets/rageguy.png b/assets/rageguy.png deleted file mode 100644 index 3daeedb..0000000 Binary files a/assets/rageguy.png and /dev/null differ diff --git a/assets/sadpanda.png b/assets/sadpanda.png deleted file mode 100644 index 8c71325..0000000 Binary files a/assets/sadpanda.png and /dev/null differ diff --git a/assets/sadtroll.png b/assets/sadtroll.png deleted file mode 100644 index e123fc9..0000000 Binary files a/assets/sadtroll.png and /dev/null differ diff --git a/assets/shipit.png b/assets/shipit.png deleted file mode 100644 index fdc6f0a..0000000 Binary files a/assets/shipit.png and /dev/null differ diff --git a/assets/shrinkray.png b/assets/shrinkray.png deleted file mode 100644 index 80d937a..0000000 Binary files a/assets/shrinkray.png and /dev/null differ diff --git a/assets/smug.gif b/assets/smug.gif deleted file mode 100644 index c806130..0000000 Binary files a/assets/smug.gif and /dev/null differ diff --git a/assets/stare.png b/assets/stare.png deleted file mode 100644 index a0641d0..0000000 Binary files a/assets/stare.png and /dev/null differ diff --git a/assets/sweetjesus.png b/assets/sweetjesus.png deleted file mode 100644 index fc5a91f..0000000 Binary files a/assets/sweetjesus.png and /dev/null differ diff --git a/assets/troll.png b/assets/troll.png deleted file mode 100644 index c22f34a..0000000 Binary files a/assets/troll.png and /dev/null differ diff --git a/assets/truestory.png b/assets/truestory.png deleted file mode 100644 index 465b272..0000000 Binary files a/assets/truestory.png and /dev/null differ diff --git a/assets/unacceptable.png b/assets/unacceptable.png deleted file mode 100644 index b5aaf9b..0000000 Binary files a/assets/unacceptable.png and /dev/null differ diff --git a/assets/waiting.gif b/assets/waiting.gif deleted file mode 100644 index 4a983b8..0000000 Binary files a/assets/waiting.gif and /dev/null differ diff --git a/assets/wat.png b/assets/wat.png deleted file mode 100644 index 500e1d8..0000000 Binary files a/assets/wat.png and /dev/null differ diff --git a/assets/wooow.gif b/assets/wooow.gif deleted file mode 100644 index 654048e..0000000 Binary files a/assets/wooow.gif and /dev/null differ diff --git a/assets/yey.png b/assets/yey.png deleted file mode 100644 index 65bdf64..0000000 Binary files a/assets/yey.png and /dev/null differ diff --git a/build.sh b/build.sh new file mode 100644 index 0000000..e479cbd --- /dev/null +++ b/build.sh @@ -0,0 +1,9 @@ +#!/bin/bash + +set -e + +pyvenv-3.4 env +env/bin/pip install -r requirements.txt + +npm install +npm run build diff --git a/package.json b/package.json index 4cfc690..b480b94 100644 --- a/package.json +++ b/package.json @@ -12,12 +12,12 @@ "test-firefox": "cd firefox/ && jpm run -b /usr/bin/firefox && cd -", "test": "npm run develop && npm run test-firefox", "build-js": "bash build-js.sh", - "develop": "npm run build-assets && npm run build-js && npm run distribute ", - "build-assets": "python3 assets/build-assets.py", - "build-data-files": "python3 firefox/build-package.py && python3 chrome/build-manifest.py", + "develop": "npm run build-js && npm run distribute ", + "build-assets": "env/bin/python3 assets/build-assets.py", + "build-data-files": "env/bin/python3 firefox/build-package.py && env/bin/python3 chrome/build-manifest.py", "distribute": "rm -rf firefox/data/* chrome/data/* && cp -rf build/* firefox/data/ && cp -rf build/* chrome/data/", "build": "npm run create-dirs && npm run build-assets && npm run build-js && npm run distribute && npm run build-data-files", - "clean": "rm -rf firefox/data chrome/data node_modules/ build/" + "clean": "rm -rf firefox/data chrome/data node_modules/ build/ env/" }, "repository": { "type": "git", diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..90136ac --- /dev/null +++ b/requirements.txt @@ -0,0 +1,5 @@ +coverage==3.7.1 +flake8==2.4.1 +lxml==3.4.4 +pep8==1.5.7 +requests==2.7.0