diff --git a/.gitignore b/.gitignore index b0d374d..141839d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,11 +1,11 @@ # Chrome extension files chrome/key.pem chrome/data -*.crx +chrome/*.crx # Firefox extension files firefox/data -*.xpi +firefox/*.xpi # Source build/ diff --git a/README.md b/README.md index e6833b0..d03f2d8 100644 --- a/README.md +++ b/README.md @@ -1,18 +1,16 @@ # Hipchat Emoticons for all! # + ## Building for yourself ## Whilst I recommend that you use the plugins that are on the add-on stores of the respective browsers, building the apps yourself is perfectly possible. I build the apps on ubuntu, so have made sure that the build scripts work for me, use on other platforms may vary. + + ### Commands: ### - npm clean npm install npm run build - npm run build-extensions - ### To-Do ### -* Create chrome version -* Create script to copy files from common to platform directories * Add other sites support (currently facebook messages popup only) diff --git a/chrome/build-manifest.py b/chrome/build-manifest.py index 3e1488b..ad39bd0 100644 --- a/chrome/build-manifest.py +++ b/chrome/build-manifest.py @@ -1,11 +1,12 @@ import json +import os +current_dir = os.path.dirname(os.path.realpath(__file__)) + "/" - -with open("../package.json") as json_file: +with open(current_dir + "../package.json") as json_file: project_package = json.load(json_file) -with open("manifest.json") as json_file: +with open(current_dir + "manifest.json") as json_file: manifest = json.load(json_file) @@ -16,24 +17,25 @@ switcher = { } -for key, value in enumerate(switcher): +for key, value in switcher.items(): manifest[value] = project_package[key] -with open("data/site-decoder.json") as json_file: - site_decoder = json.load(json_file) +with open(current_dir + "data/site-decoder.json") as json_file: + site_decoder = json.load(json_file)['sites'] content_scripts = [] -for ident, script in enumerate(site_decoder): +for site in site_decoder: + site = list(site.items())[0] temp = {} - temp['matches'] = [ident] - temp['js'] = ['data/lib/jquery.js', 'data/image_lookup.js', 'data/injections/' + script] + temp['matches'] = [site[0]] + temp['js'] = ['data/lib/jquery.js', 'data/image_lookup.js', 'data/injections/' + site[1]] content_scripts.append(temp) manifest['content_scripts'] = content_scripts -with open('package.json', 'w') as file: - json.dump(manifest, file) \ No newline at end of file +with open(current_dir + 'manifest.json', 'w') as file: + json.dump(manifest, file, indent=2, sort_keys=True) diff --git a/chrome/manifest.json b/chrome/manifest.json index 1c683eb..7cfd922 100644 --- a/chrome/manifest.json +++ b/chrome/manifest.json @@ -1,14 +1,18 @@ { - "manifest_version": 2, - - "name": "Hipchat Emoticons for all", - "description": "Allows use of hipchat emoticons on other websites", - "version": "ALPHA", - "content_scripts": [ { - "matches": ["http://www.google.com/*"], - "js": ["jquery.js", "myscript.js"] + "js": [ + "data/lib/jquery.js", + "data/image_lookup.js", + "data/injections/facebook.js" + ], + "matches": [ + "*.facebook.com" + ] } - ], + ], + "description": "Use hipchat emoticons on other sites", + "manifest_version": 2, + "name": "Hipchat-Emoticons-for-all", + "version": "0.0.0" } \ No newline at end of file diff --git a/firefox/build-package.py b/firefox/build-package.py index 9bfb791..c546b89 100644 --- a/firefox/build-package.py +++ b/firefox/build-package.py @@ -1,22 +1,23 @@ import json +import os +current_dir = os.path.dirname(os.path.realpath(__file__)) + "/" -with open("../package.json") as json_file: +with open(current_dir + "../package.json") as json_file: project_package = json.load(json_file) -with open("package.json") as json_file: +with open(current_dir + "package.json") as json_file: ext_package = json.load(json_file) switcher = { 'name': 'title', - 'name': 'name', 'version': 'version', 'description': 'description', 'author': 'author', 'license': 'license' } -for key, value in enumerate(switcher): +for key, value in switcher.items(): ext_package[value] = project_package[key] -with open('package.json', 'w') as file: - json.dump(ext_package, file) \ No newline at end of file +with open(current_dir + 'package.json', 'w') as file: + json.dump(ext_package, file, indent=2, sort_keys=True) diff --git a/firefox/package.json b/firefox/package.json index c07f791..4e4c853 100644 --- a/firefox/package.json +++ b/firefox/package.json @@ -1,13 +1,14 @@ { - "title": "Hipchat Emoticons for all", - "name": "Hipchat emoticons for all", - "version": "ALPHA", - "description": "Use Hipchat emoticons on other sites", - "main": "index.js", - "author": "TheOrangeOne", + "author": "TheOrangeOne", + "description": "Use hipchat emoticons on other sites", "engines": { - "firefox": ">=38.0a1", - "fennec": ">=38.0a1" - }, - "license": "MIT" -} + "fennec": ">=38.0a1", + "firefox": ">=38.0a1" + }, + "id": "Hipchat-Emoticons-for-all@jetpack", + "license": "MIT", + "main": "index.js", + "name": "hipchat emoticons for all", + "title": "Hipchat-Emoticons-for-all", + "version": "0.0.0" +} \ No newline at end of file diff --git a/package.json b/package.json index cfdbc09..fb337fa 100644 --- a/package.json +++ b/package.json @@ -7,11 +7,11 @@ "create-dirs": "mkdir -p firefox/data chrome/data build/injections", "build-extensions": "npm run build-firefox && npm run build-chrome", "build-firefox": "cd firefox/ && jpm xpi && cd -", - "build-chrome": "crx pack chrome -o hipchat-emoticons-for-all.crx -p chrome/key.pem", + "build-chrome": "crx pack chrome -o chrome/hipchat-emoticons-for-all.crx -p chrome/key.pem", "build-js": "bash build-js.sh", "build-data-files": "python firefox/build-package.py && python chrome/build-manifest.py", "distribute": "cp -r build/* firefox/data/ && cp -r build/* chrome/data/", - "build": "npm run clean && npm run create-dirs && npm install && npm run build-js && npm run distribute && npm run build-data-files && npm run build-extensions", + "build": "npm run clean && npm run create-dirs && npm run build-js && npm run distribute && npm run build-data-files && npm run build-extensions", "clean": "rm -rf firefox/data chrome/data node_modules/" }, "repository": { @@ -30,12 +30,10 @@ "homepage": "https://bitbucket.org/theorangeone/hipchat-emoticons-for-all", "dependencies": { "ionic-sdk": "=1.0.0", - "less": "=2.4.0", - "jquery": "=2.1.4" - }, - "devDependencies": { "jpm":"=1.0.1", "uglify-js":"=2.4.24", - "crx": "=3.0.3" + "crx": "=3.0.3", + "less": "=2.4.0", + "jquery": "=2.1.4" } } diff --git a/src/site-decoder.json b/src/site-decoder.json index b58eda9..9248f38 100644 --- a/src/site-decoder.json +++ b/src/site-decoder.json @@ -1,3 +1,5 @@ -{ // Site Identifier : Injection JS - "*.facebook.com":"facebook.js", +{ + "sites": [ + {"*.facebook.com":"facebook.js"} + ] } \ No newline at end of file