diff --git a/build_and_release.py b/build_and_release.py index 6406704..35f593a 100644 --- a/build_and_release.py +++ b/build_and_release.py @@ -7,9 +7,9 @@ version = os.environ.get("GITHUB_REF").split("/")[-1] if version == "dev": - version = "0.0" + version_manifest = "0.0" else: - version = version.replace("v","") + version_manifest = version.replace("v","") is_tag = os.environ.get("GITHUB_REF").split("/")[-2] == "tags" @@ -20,7 +20,7 @@ def create_manifest(): json_manifest = json.load(open("manifest.json.tpl")) user = gh_user.user(username=os.environ.get("GITHUB_ACTOR")) json_manifest["author"] = "%s <%s>" % (user.name, user.email) - json_manifest["version"] = version + json_manifest["version"] = version_manifest if len(sys.argv) == 2 and sys.argv[1] == "--firefox": json_manifest["browser_specific_settings"] = { diff --git a/manifest.firefox.json b/manifest.firefox.json deleted file mode 100644 index da4c910..0000000 --- a/manifest.firefox.json +++ /dev/null @@ -1,34 +0,0 @@ -{ - "name": "Splunk XML Formatter", - "version": "1.1", - "description": "With this extension, you can add syntax highlight / formatting for XML events in Splunk", - "manifest_version": 2, - "author": "Jean-Yves NOLEN ", - "short_name": "SplkXMLFormat", - "permissions": [ - "tabs", - "activeTab", - "storage" - ], - "background": { - "scripts": ["background.js"] - }, - "options_ui": { - "page": "options.html", - "open_in_tab": false - }, - "content_scripts": [ - { - "matches": ["http://*/*", "https://*/*"], - "js": ["./jquery.min.js", "./highlight.pack.js", "./splunk_xml.js"], - "css":["./styles/splunk_xml.css", "./styles/github-gist.css"], - "run_at": "document_end" - } - ], - "browser_specific_settings": { - "gecko": { - "id": "splunk_xml_formatter_test@jynolen.com", - "strict_min_version": "57.0" - } - } -} \ No newline at end of file diff --git a/splunk_xml.js b/splunk_xml.js index 2a0289f..9a265b7 100644 --- a/splunk_xml.js +++ b/splunk_xml.js @@ -1,30 +1,25 @@ -let highlightStyle = {"a11y-dark": "A 11 Y Dark", "a11y-light": "A 11 Y Light", "agate": "Agate", "an-old-hope": "An Old Hope", "androidstudio": "Androidstudio", "arduino-light": "Arduino Light", "arta": "Arta", "ascetic": "Ascetic", "atelier-cave-dark": "Atelier Cave Dark", "atelier-cave-light": "Atelier Cave Light", "atelier-dune-dark": "Atelier Dune Dark", "atelier-dune-light": "Atelier Dune Light", "atelier-estuary-dark": "Atelier Estuary Dark", "atelier-estuary-light": "Atelier Estuary Light", "atelier-forest-dark": "Atelier Forest Dark", "atelier-forest-light": "Atelier Forest Light", "atelier-heath-dark": "Atelier Heath Dark", "atelier-heath-light": "Atelier Heath Light", "atelier-lakeside-dark": "Atelier Lakeside Dark", "atelier-lakeside-light": "Atelier Lakeside Light", "atelier-plateau-dark": "Atelier Plateau Dark", "atelier-plateau-light": "Atelier Plateau Light", "atelier-savanna-dark": "Atelier Savanna Dark", "atelier-savanna-light": "Atelier Savanna Light", "atelier-seaside-dark": "Atelier Seaside Dark", "atelier-seaside-light": "Atelier Seaside Light", "atelier-sulphurpool-dark": "Atelier Sulphurpool Dark", "atelier-sulphurpool-light": "Atelier Sulphurpool Light", "atom-one-dark-reasonable": "Atom One Dark Reasonable", "atom-one-dark": "Atom One Dark", "atom-one-light": "Atom One Light", "brown-paper": "Brown Paper", "codepen-embed": "Codepen Embed", "color-brewer": "Color Brewer", "darcula": "Darcula", "dark": "Dark", "default": "Default", "docco": "Docco", "dracula": "Dracula", "far": "Far", "foundation": "Foundation", "github-gist": "Github Gist", "github": "Github", "gml": "Gml", "googlecode": "Googlecode", "gradient-dark": "Gradient Dark", "grayscale": "Grayscale", "gruvbox-dark": "Gruvbox Dark", "gruvbox-light": "Gruvbox Light", "hopscotch": "Hopscotch", "hybrid": "Hybrid", "idea": "Idea", "ir-black": "Ir Black", "isbl-editor-dark": "Isbl Editor Dark", "isbl-editor-light": "Isbl Editor Light", "kimbie.dark": "Kimbie Dark", "kimbie.light": "Kimbie Light", "lightfair": "Lightfair", "magula": "Magula", "mono-blue": "Mono Blue", "monokai-sublime": "Monokai Sublime", "monokai": "Monokai", "night-owl": "Night Owl", "nord": "Nord", "obsidian": "Obsidian", "ocean": "Ocean", "paraiso-dark": "Paraiso Dark", "paraiso-light": "Paraiso Light", "pojoaque": "Pojoaque", "purebasic": "Purebasic", "qtcreator_dark": "Qtcreator Dark", "qtcreator_light": "Qtcreator Light", "railscasts": "Railscasts", "rainbow": "Rainbow", "routeros": "Routeros", "school-book": "School Book", "shades-of-purple": "Shades Of Purple", "solarized-dark": "Solarized Dark", "solarized-light": "Solarized Light", "srcery": "Srcery", "sunburst": "Sunburst", "tomorrow-night-blue": "Tomorrow Night Blue", "tomorrow-night-bright": "Tomorrow Night Bright", "tomorrow-night-eighties": "Tomorrow Night Eighties", "tomorrow-night": "Tomorrow Night", "tomorrow": "Tomorrow", "vs": "Vs", "vs2015": "Vs 2015", "xcode": "Xcode", "xt256": "Xt 256"} -var Formatter = function (options) { +let highlightStyle = {"a11y-dark": "A 11 Y Dark", "a11y-light": "A 11 Y Light", "agate": "Agate", "an-old-hope": "An Old Hope", "androidstudio": "Androidstudio", "arduino-light": "Arduino Light", "arta": "Arta", "ascetic": "Ascetic", "atelier-cave-dark": "Atelier Cave Dark", "atelier-cave-light": "Atelier Cave Light", "atelier-dune-dark": "Atelier Dune Dark", "atelier-dune-light": "Atelier Dune Light", "atelier-estuary-dark": "Atelier Estuary Dark", "atelier-estuary-light": "Atelier Estuary Light", "atelier-forest-dark": "Atelier Forest Dark", "atelier-forest-light": "Atelier Forest Light", "atelier-heath-dark": "Atelier Heath Dark", "atelier-heath-light": "Atelier Heath Light", "atelier-lakeside-dark": "Atelier Lakeside Dark", "atelier-lakeside-light": "Atelier Lakeside Light", "atelier-plateau-dark": "Atelier Plateau Dark", "atelier-plateau-light": "Atelier Plateau Light", "atelier-savanna-dark": "Atelier Savanna Dark", "atelier-savanna-light": "Atelier Savanna Light", "atelier-seaside-dark": "Atelier Seaside Dark", "atelier-seaside-light": "Atelier Seaside Light", "atelier-sulphurpool-dark": "Atelier Sulphurpool Dark", "atelier-sulphurpool-light": "Atelier Sulphurpool Light", "atom-one-dark-reasonable": "Atom One Dark Reasonable", "atom-one-dark": "Atom One Dark", "atom-one-light": "Atom One Light", "brown-paper": "Brown Paper", "codepen-embed": "Codepen Embed", "color-brewer": "Color Brewer", "darcula": "Darcula", "dark": "Dark", "default": "Default", "docco": "Docco", "dracula": "Dracula", "far": "Far", "foundation": "Foundation", "github-gist": "Github Gist", "github": "Github", "gml": "Gml", "googlecode": "Googlecode", "gradient-dark": "Gradient Dark", "grayscale": "Grayscale", "gruvbox-dark": "Gruvbox Dark", "gruvbox-light": "Gruvbox Light", "hopscotch": "Hopscotch", "hybrid": "Hybrid", "idea": "Idea", "ir-black": "Ir Black", "isbl-editor-dark": "Isbl Editor Dark", "isbl-editor-light": "Isbl Editor Light", "kimbie.dark": "Kimbie Dark", "kimbie.light": "Kimbie Light", "lightfair": "Lightfair", "magula": "Magula", "mono-blue": "Mono Blue", "monokai-sublime": "Monokai Sublime", "monokai": "Monokai", "night-owl": "Night Owl", "nord": "Nord", "obsidian": "Obsidian", "ocean": "Ocean", "paraiso-dark": "Paraiso Dark", "paraiso-light": "Paraiso Light", "pojoaque": "Pojoaque", "purebasic": "Purebasic", "qtcreator_dark": "Qtcreator Dark", "qtcreator_light": "Qtcreator Light", "railscasts": "Railscasts", "rainbow": "Rainbow", "routeros": "Routeros", "school-book": "School Book", "shades-of-purple": "Shades Of Purple", "solarized-dark": "Solarized Dark", "solarized-light": "Solarized Light", "srcery": "Srcery", "sunburst": "Sunburst", "tomorrow-night-blue": "Tomorrow Night Blue", "tomorrow-night-bright": "Tomorrow Night Bright", "tomorrow-night-eighties": "Tomorrow Night Eighties", "tomorrow-night": "Tomorrow Night", "tomorrow": "Tomorrow", "vs": "Vs", "vs2015": "Vs 2015", "xcode": "Xcode", "xt256": "Xt 256"}; +let Formatter = function (options) { this.init(options); - //TODO - if options object maps any functions, add them as appropriately named methods - var methodName = this.options.method; + let methodName = this.options.method; if (!jQuery.isFunction(this[methodName])) { jQuery.error("'" + methodName + "' is not a Formatter method."); - }; - this.format = function(text) { //alias to currently selected method + } + this.format = function(text) { return this[this.options.method].call(this, text); }; }; -/** - * putting the methods into the prototype instead of the constructor method - * enables more efficient on-the-fly creation of Formatter instances - */ -var createShiftArr=function (step) { - var space = ' '; - if ( isNaN(parseInt(step)) ) { // argument is string +let createShiftArr=function (step) { + let space = " "; + if ( Number.isNaN(parseInt(step)) ) { space = step; - } else { // argument is integer - space = new Array(step + 1).join(' '); //space is result of join (a string), not an array + } else { + space = new Array(step + 1).join(' '); } - var shift = ['\n']; // array of shifts - for(var ix=0;ix<100;ix++){ + let shift = ["\n"]; + for(let ix=0; ix<100; ix++){ shift.push(shift[ix]+space); } return shift; @@ -41,15 +36,15 @@ Formatter.prototype = { }, xml: function(text) { - var ar = text.replace(/>\s{0,}<") + let ar = text.replace(/>\s{0,}<") .replace(/ // if( /^<\w/.exec(ar[ix-1]) && /^<\/\w/.exec(ar[ix]) && - /^<[\w:\-\.\,]+/.exec(ar[ix-1]) == /^<\/[\w:\-\.\,]+/.exec(ar[ix])[0].replace('/','')) { + /^<[\w:\-\.\,]+/.exec(ar[ix-1]) == /^<\/[\w:\-\.\,]+/.exec(ar[ix])[0].replace("/","")) { str += ar[ix]; if(!inComment) deep--; } else @@ -103,22 +98,22 @@ Formatter.prototype = { } } - return (str[0] == '\n') ? str.slice(1) : str; + return (str[0] == "\n") ? str.slice(1) : str; } }; if (!String.prototype.encodeHTML) { String.prototype.encodeHTML = function () { - return this.replace(/&/g, '&') - .replace(//g, '>') - .replace(/"/g, '"') - .replace(/'/g, '''); + return this.replace(/&/g, "&") + .replace(//g, ">") + .replace(/"/g, """) + .replace(/'/g, "'"); }; } -var waitForEl = function(selector, callback) { +let waitForEl = function(selector, callback) { if (jQuery(selector).length) { callback(); @@ -129,18 +124,18 @@ var waitForEl = function(selector, callback) { } }; -function checkForSplunk() +let checkForSplunk = function() { - const metas = document.getElementsByTagName('meta'); + const metas = document.getElementsByTagName("meta"); for (let i = 0; i < metas.length; i++) { - if (metas[i].getAttribute('name') === "author") { - return metas[i].getAttribute('content') === "Splunk Inc."; + if (metas[i].getAttribute("name") === "author") { + return metas[i].getAttribute("content") === "Splunk Inc."; } } - return False + return false; }; -function is_string_valid_xml(data) +let is_string_valid_xml = function(data) { try { jQuery.parseXML(data); @@ -151,21 +146,18 @@ function is_string_valid_xml(data) } }; -function formatXml(text) { - var fmt = new Formatter({method: 'xml', step: '\t'}); +let formatXml = function(text) { + let fmt = new Formatter({method: "xml", step: "\t"}); return fmt.xml(text); }; -function htmlEntities(str) { - return String(str).replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/(?:\r\n|\r|\n)/g, '
'); -}; -function searchXMLEvent() { +let searchXMLEvent = function() { jQuery("td.event").find(".raw-event").each(function( index ) { if( is_string_valid_xml( jQuery(this).text() )) { let content=jQuery(''); - block=jQuery('
'+htmlEntities(formatXml(jQuery(this).text()))+'
'); - hljs.configure({ tabReplace: ' '}); + block=jQuery("
"+formatXml(jQuery(this).text()).encodeHTML()+"
"); + hljs.configure({ tabReplace: " "}); hljs.highlightBlock(block[0]); content.append(block); if(jQuery(this).parent().find(".xml-event.xml-valid").length == 0) @@ -174,8 +166,8 @@ function searchXMLEvent() { else { let content=jQuery(''); block=jQuery('
'+jQuery(this).text().encodeHTML()+'
'); - warning=jQuery('
 This event has an invalid XML content, try expend to all lines before toggle format XML again
') - hljs.configure({ tabReplace: ' '}); + warning=jQuery('
 This event has an invalid XML content, try expend to all lines before toggle format XML again
'); + hljs.configure({ tabReplace: " "}); hljs.highlightBlock(block[0]); content.append(block); content.append(warning); @@ -190,20 +182,20 @@ function searchXMLEvent() { jQuery(this).toggle(); }); }); -} +}; -function highlighStyleChoice(recordStyle="github-gist") { +let highlighStyleChoice = function(recordStyle="github-gist") { let mainBlock = jQuery('