1
Fork 0

Fixed markdown support for github comments, and added migrated to github

This commit is contained in:
Jake Howard 2015-08-25 14:27:00 +01:00
parent 23df00a0df
commit c422c8f309
4 changed files with 22 additions and 18 deletions

View file

@ -1,26 +1,31 @@
import json
from glob import glob
ASSETS_URL="https://raw.githubusercontent.com/RealOrangeOne/hipchat-emoticons-for-all/master/assets/"
def get_icon_name(path):
return get_filename(path).replace('.png', '')
def get_filename(path):
return path.replace('assets/', "").replace('.png', '')
return path.replace('assets/', '')
files = glob('assets/*.png')
image_bin = []
images = []
for filename in files:
with open(filename, 'rb') as file:
image_bin.append({ get_filename(filename):
"data:image/png;base64," + (open(filename, 'rb').read().encode('base64').replace('\n', ''))
})
images.append({get_icon_name(filename): ASSETS_URL + get_filename(filename)})
image_decoder = {"images":image_bin}
image_decoder = {"images":images}
image_decoder_json = json.dumps(image_decoder, indent=2, sort_keys=True)
js_file = None
with open('src/image-decoder.js', "r") as file:
js_file = file.read()
js_file = js_file.replace("%image_decoder%", image_decoder_json)
with open('build/image-decoder.js', 'w') as file:
file.write(js_file)

View file

@ -11,6 +11,7 @@
"test-firefox": "cd firefox/ && jpm run -b /usr/bin/firefox && cd -",
"test": "npm run build-assets && npm run build-js && npm run distribute && npm run test-firefox",
"build-js": "bash build-js.sh",
"develop": "npm run build-assets && npm run build-js && npm run distribute ",
"build-assets": "python assets/build-assets.py",
"build-data-files": "python firefox/build-package.py && python chrome/build-manifest.py",
"distribute": "rm -rf firefox/data/* chrome/data/* && cp -rf build/* firefox/data/ && cp -rf build/* chrome/data/",
@ -19,7 +20,7 @@
},
"repository": {
"type": "git",
"url": "https://bitbucket.org/theorangeone/hipchat-emoticons-for-all"
"url": "https://github.com/realorangeone/hipchat-emoticons-for-all"
},
"keywords": [
"hipchat",
@ -28,9 +29,9 @@
"author": "TheOrangeOne",
"license": "MIT",
"bugs": {
"url": "https://bitbucket.org/theorangeone/hipchat-emoticons-for-all/issues"
"url": "https://github.com/realorangeone/hipchat-emoticons-for-all/issues"
},
"homepage": "https://bitbucket.org/theorangeone/hipchat-emoticons-for-all",
"homepage": "https://github.com/realorangeone/hipchat-emoticons-for-all",
"dependencies": {
"ionic-sdk": "=1.0.0",
"jpm":"=1.0.1",

View file

@ -21,13 +21,12 @@ function markdown_injector(ident) {
raw_key = Object.keys(decoder[i]);
image = decoder[i][raw_key];
key = "(" + raw_key + ")";
$(ident).text($(ident).text().replace(key,
$(ident).val($(ident).val().replace(key,
"![" + raw_key + "](" + image + ")"
));
}
}
console.log("Injection");
var image_decoder = %image_decoder%

View file

@ -6,14 +6,13 @@ function change_readme() {
inject_image('#readme');
}
$('#partial-new-comment-form-actions').append('<button id="#markdown-inject-btn" class="btn">Inject Emoticons</button>');
$("button.btn[name='comment_and_close']").prev().on('click', change_comments);
$('.js-comment-container').on('load change', change_comments);
$('#readme').on('load change', change_readme);
$('#markdown-inject-btn').on('click', function() { markdown_injector('#new-comment-field');})
$('.timeline-comment textarea[placeholder="Leave a comment"]').on('change input', function() {
console.log("Change"); markdown_injector('.timeline-comment textarea[placeholder="Leave a comment"]');
});
change_comments();
change_readme();