From 23055a2fcf00e4e8c55ec2e11aba41aa6b626780 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Wed, 9 Apr 2014 09:08:14 -0400 Subject: [PATCH 1/5] add dockerfile mode --- lib/ace/mode/css.js | 1 - lib/ace/mode/dockerfile.js | 50 +++++++++++++++++++ lib/ace/mode/dockerfile_highlight_rules.js | 56 ++++++++++++++++++++++ lib/ace/mode/sh.js | 1 - 4 files changed, 106 insertions(+), 2 deletions(-) create mode 100644 lib/ace/mode/dockerfile.js create mode 100644 lib/ace/mode/dockerfile_highlight_rules.js diff --git a/lib/ace/mode/css.js b/lib/ace/mode/css.js index 6ef2dfdd..c74bd654 100644 --- a/lib/ace/mode/css.js +++ b/lib/ace/mode/css.js @@ -33,7 +33,6 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var CssHighlightRules = require("./css_highlight_rules").CssHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var WorkerClient = require("../worker/worker_client").WorkerClient; diff --git a/lib/ace/mode/dockerfile.js b/lib/ace/mode/dockerfile.js new file mode 100644 index 00000000..5a19d89b --- /dev/null +++ b/lib/ace/mode/dockerfile.js @@ -0,0 +1,50 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var ShMode = require("./sh").Mode; +var Dockerfile = require("./sh_highlight_rules").Dockerfile; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function() { + this.HighlightRules = Dockerfile; + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, ShMode); + +(function() { + this.$id = "ace/mode/dockerfile"; +}).call(Mode.prototype); + +exports.Mode = Mode; +}); diff --git a/lib/ace/mode/dockerfile_highlight_rules.js b/lib/ace/mode/dockerfile_highlight_rules.js new file mode 100644 index 00000000..7860aaee --- /dev/null +++ b/lib/ace/mode/dockerfile_highlight_rules.js @@ -0,0 +1,56 @@ +/* ***** BEGIN LICENSE BLOCK ***** + * Distributed under the BSD license: + * + * Copyright (c) 2010, Ajax.org B.V. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * * Neither the name of Ajax.org B.V. nor the + * names of its contributors may be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED + * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + * DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY + * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES + * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND + * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * ***** END LICENSE BLOCK ***** */ + +define(function(require, exports, module) { +"use strict"; + +var oop = require("../lib/oop"); +var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules; + +var SvgHighlightRules = function() { + ShHighlightRules.call(this); + + var startRules = this.$rules.start; + for (var i = 0; i < startRules.length; i++) { + if (startRules[i].token == "variable.language") { + startRules.splice(i, 0, { + token: "keyword", + regexp: "(?:FROM|MAINTAINER|RUN|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)", + caseInsensitive: true + }); + break; + } + } +}; + +oop.inherits(SvgHighlightRules, ShHighlightRules); + +exports.SvgHighlightRules = SvgHighlightRules; +}); diff --git a/lib/ace/mode/sh.js b/lib/ace/mode/sh.js index 7b20109d..b7837ae2 100644 --- a/lib/ace/mode/sh.js +++ b/lib/ace/mode/sh.js @@ -33,7 +33,6 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules; var Range = require("../range").Range; var CStyleFoldMode = require("./folding/cstyle").FoldMode; From 4d24573946b6a86f6e4247f2a5cf3002008211d5 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Sun, 13 Apr 2014 16:07:34 +0000 Subject: [PATCH 2/5] use wildcard protocol for external resources. Otherwise we can't serve it over https --- demo/emmet.html | 2 +- demo/kitchen-sink/demo.js | 2 +- kitchen-sink.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/emmet.html b/demo/emmet.html index 57f13f67..d5a7c0e0 100644 --- a/demo/emmet.html +++ b/demo/emmet.html @@ -27,7 +27,7 @@ - + + From 7767efe0f61f736432d8fbc8fa42a520c9432a60 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Sun, 13 Apr 2014 16:08:45 +0000 Subject: [PATCH 3/5] fix dockerfile mode --- demo/kitchen-sink/docs/Dockerfile | 53 ++++++++++++++++++++++ lib/ace/ext/modelist.js | 1 + lib/ace/mode/dockerfile.js | 4 +- lib/ace/mode/dockerfile_highlight_rules.js | 11 +++-- lib/ace/mode/svg.js | 1 - lib/ace/mode/text_highlight_rules.js | 6 +-- 6 files changed, 65 insertions(+), 11 deletions(-) create mode 100644 demo/kitchen-sink/docs/Dockerfile diff --git a/demo/kitchen-sink/docs/Dockerfile b/demo/kitchen-sink/docs/Dockerfile new file mode 100644 index 00000000..70270cbf --- /dev/null +++ b/demo/kitchen-sink/docs/Dockerfile @@ -0,0 +1,53 @@ +# +# example Dockerfile for http://docs.docker.io/en/latest/examples/postgresql_service/ +# + +FROM ubuntu +MAINTAINER SvenDowideit@docker.com + +# Add the PostgreSQL PGP key to verify their Debian packages. +# It should be the same key as https://www.postgresql.org/media/keys/ACCC4CF8.asc +RUN apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys B97B0AFCAA1A47F044F244A07FCC7D46ACCC4CF8 + +# Add PostgreSQL's repository. It contains the most recent stable release +# of PostgreSQL, ``9.3``. +RUN echo "deb http://apt.postgresql.org/pub/repos/apt/ precise-pgdg main" > /etc/apt/sources.list.d/pgdg.list + +# Update the Ubuntu and PostgreSQL repository indexes +RUN apt-get update + +# Install ``python-software-properties``, ``software-properties-common`` and PostgreSQL 9.3 +# There are some warnings (in red) that show up during the build. You can hide +# them by prefixing each apt-get statement with DEBIAN_FRONTEND=noninteractive +RUN apt-get -y -q install python-software-properties software-properties-common +RUN apt-get -y -q install postgresql-9.3 postgresql-client-9.3 postgresql-contrib-9.3 + +# Note: The official Debian and Ubuntu images automatically ``apt-get clean`` +# after each ``apt-get`` + +# Run the rest of the commands as the ``postgres`` user created by the ``postgres-9.3`` package when it was ``apt-get installed`` +USER postgres + +# Create a PostgreSQL role named ``docker`` with ``docker`` as the password and +# then create a database `docker` owned by the ``docker`` role. +# Note: here we use ``&&\`` to run commands one after the other - the ``\`` +# allows the RUN command to span multiple lines. +RUN /etc/init.d/postgresql start &&\ + psql --command "CREATE USER docker WITH SUPERUSER PASSWORD 'docker';" &&\ + createdb -O docker docker + +# Adjust PostgreSQL configuration so that remote connections to the +# database are possible. +RUN echo "host all all 0.0.0.0/0 md5" >> /etc/postgresql/9.3/main/pg_hba.conf + +# And add ``listen_addresses`` to ``/etc/postgresql/9.3/main/postgresql.conf`` +RUN echo "listen_addresses='*'" >> /etc/postgresql/9.3/main/postgresql.conf + +# Expose the PostgreSQL port +EXPOSE 5432 + +# Add VOLUMEs to allow backup of config, logs and databases +VOLUME ["/etc/postgresql", "/var/log/postgresql", "/var/lib/postgresql"] + +# Set the default command to run when starting the container +CMD ["/usr/lib/postgresql/9.3/bin/postgres", "-D", "/var/lib/postgresql/9.3/main", "-c", "config_file=/etc/postgresql/9.3/main/postgresql.conf"] \ No newline at end of file diff --git a/lib/ace/ext/modelist.js b/lib/ace/ext/modelist.js index 2f67bee6..66fe3de8 100644 --- a/lib/ace/ext/modelist.js +++ b/lib/ace/ext/modelist.js @@ -63,6 +63,7 @@ var supportedModes = { D: ["d|di"], Dart: ["dart"], Diff: ["diff|patch"], + Dockerfile: ["^Dockerfile"], Dot: ["dot"], Erlang: ["erl|hrl"], EJS: ["ejs"], diff --git a/lib/ace/mode/dockerfile.js b/lib/ace/mode/dockerfile.js index 5a19d89b..732cb33a 100644 --- a/lib/ace/mode/dockerfile.js +++ b/lib/ace/mode/dockerfile.js @@ -33,11 +33,11 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var ShMode = require("./sh").Mode; -var Dockerfile = require("./sh_highlight_rules").Dockerfile; +var DockerfileHighlightRules = require("./dockerfile_highlight_rules").DockerfileHighlightRules; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { - this.HighlightRules = Dockerfile; + this.HighlightRules = DockerfileHighlightRules; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, ShMode); diff --git a/lib/ace/mode/dockerfile_highlight_rules.js b/lib/ace/mode/dockerfile_highlight_rules.js index 7860aaee..ab431eb3 100644 --- a/lib/ace/mode/dockerfile_highlight_rules.js +++ b/lib/ace/mode/dockerfile_highlight_rules.js @@ -34,23 +34,24 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules; -var SvgHighlightRules = function() { +var DockerfileHighlightRules = function() { ShHighlightRules.call(this); var startRules = this.$rules.start; for (var i = 0; i < startRules.length; i++) { if (startRules[i].token == "variable.language") { startRules.splice(i, 0, { - token: "keyword", - regexp: "(?:FROM|MAINTAINER|RUN|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)", + token: "variable.language", + regex: "(?:^(?:FROM|MAINTAINER|RUN|CMD|EXPOSE|ENV|ADD|ENTRYPOINT|VOLUME|USER|WORKDIR|ONBUILD)\\b)", caseInsensitive: true }); break; } } + }; -oop.inherits(SvgHighlightRules, ShHighlightRules); +oop.inherits(DockerfileHighlightRules, ShHighlightRules); -exports.SvgHighlightRules = SvgHighlightRules; +exports.DockerfileHighlightRules = DockerfileHighlightRules; }); diff --git a/lib/ace/mode/svg.js b/lib/ace/mode/svg.js index aede9c0a..8c608e82 100644 --- a/lib/ace/mode/svg.js +++ b/lib/ace/mode/svg.js @@ -34,7 +34,6 @@ define(function(require, exports, module) { var oop = require("../lib/oop"); var XmlMode = require("./xml").Mode; var JavaScriptMode = require("./javascript").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var SvgHighlightRules = require("./svg_highlight_rules").SvgHighlightRules; var MixedFoldMode = require("./folding/mixed").FoldMode; var XmlFoldMode = require("./folding/xml").FoldMode; diff --git a/lib/ace/mode/text_highlight_rules.js b/lib/ace/mode/text_highlight_rules.js index c4fcf588..07285661 100644 --- a/lib/ace/mode/text_highlight_rules.js +++ b/lib/ace/mode/text_highlight_rules.js @@ -189,7 +189,7 @@ var TextHighlightRules = function() { // skip included rules since they are already processed //i += args.length - 3; i--; - toInsert = null + toInsert = null; } if (rule.keywordMap) { @@ -199,7 +199,7 @@ var TextHighlightRules = function() { delete rule.defaultToken; } } - }; + } Object.keys(rules).forEach(processState, this); }; @@ -223,7 +223,7 @@ var TextHighlightRules = function() { return ignoreCase ? function(value) {return keywords[value.toLowerCase()] || defaultToken } : function(value) {return keywords[value] || defaultToken }; - } + }; this.getKeywords = function() { return this.$keywords; From 1bd5b56793316eba55b5f5ae95a09f2e2cb5eb4c Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Sun, 13 Apr 2014 16:16:30 +0000 Subject: [PATCH 4/5] minor fix --- lib/ace/mode/dockerfile.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/ace/mode/dockerfile.js b/lib/ace/mode/dockerfile.js index 732cb33a..26d546b4 100644 --- a/lib/ace/mode/dockerfile.js +++ b/lib/ace/mode/dockerfile.js @@ -37,6 +37,8 @@ var DockerfileHighlightRules = require("./dockerfile_highlight_rules").Dockerfil var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { + ShMode.call(this); + this.HighlightRules = DockerfileHighlightRules; this.foldingRules = new CStyleFoldMode(); }; From 75bac806b0a8a79f316442a38a690cbcfe917f3e Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Sun, 13 Apr 2014 16:20:02 +0000 Subject: [PATCH 5/5] always use https --- demo/emmet.html | 2 +- demo/kitchen-sink/demo.js | 2 +- kitchen-sink.html | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/demo/emmet.html b/demo/emmet.html index d5a7c0e0..1a1ed6ba 100644 --- a/demo/emmet.html +++ b/demo/emmet.html @@ -27,7 +27,7 @@ - + +