This is an automated email from the ASF dual-hosted git repository. joshtynjala pushed a commit to branch develop in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
commit 47893a80409aac8fb84f4a23f89e5f8f582a51d7 Author: Josh Tynjala <[email protected]> AuthorDate: Mon May 5 12:56:32 2025 -0700 BE0012_Using_external_javascript_libraries_in_Apache_Royale: updated for new included scripts/css/assets Fixed copying as3code.txt to both js-debug and js-release --- .../asconfig.json | 9 +++- .../pom.xml | 54 +++++++++++++++++++++- .../rat-excludes.txt | 22 +++++++++ .../highlight.js/9.12.0/LICENSE-highlightjs | 29 ++++++++++++ .../highlight.js/9.12.0/atom-one-dark.min.css | 34 ++++++++++++++ .../highlight.js/9.12.0/highlight.min.js | 3 ++ .../resources/jewel-example-index-template.html | 4 +- ...rnal_javascript_libraries_in_Apache_Royale.mxml | 4 +- .../src/main/royale/hljs.as | 13 ------ 9 files changed, 153 insertions(+), 19 deletions(-) diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/asconfig.json b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/asconfig.json index c3fe24592f..d849b9df92 100644 --- a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/asconfig.json +++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/asconfig.json @@ -23,10 +23,15 @@ "targets": ["JSRoyale"], "source-map": true, "html-template": "src/main/resources/jewel-example-index-template.html", - "theme": "${royalelib}/themes/JewelTheme/src/main/resources/defaults.css" + "theme": "${royalelib}/themes/JewelTheme/src/main/resources/defaults.css", + "remove-circulars": true }, "copySourcePathAssets": true, - "additionalOptions": "-remove-circulars -js-output-optimization=skipAsCoercions", + "additionalOptions": [ + "-js-output-optimization=skipAsCoercions", + "-js-include-script+=src/main/assembly/third-party/highlight.js/9.12.0/highlight.min.js", + "-js-include-css+=src/main/assembly/third-party/highlight.js/9.12.0/atom-one-dark.min.css" + ], "files": [ "src/main/royale/BE0012_Using_external_javascript_libraries_in_Apache_Royale.mxml" diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/pom.xml b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/pom.xml index 8305efb918..f027045f28 100644 --- a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/pom.xml +++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/pom.xml @@ -43,9 +43,61 @@ <targets>${royale.targets}</targets> <debug>false</debug> <htmlTemplate>${basedir}/target/javascript/bin/js-debug/jewel-example-index-template.html</htmlTemplate> - <additionalCompilerOptions>-source-map=true;</additionalCompilerOptions> + <additionalCompilerOptions> + -source-map=true; + -js-include-script+=${basedir}/src/main/assembly/third-party/highlight.js/9.12.0/highlight.min.js; + -js-include-css+=${basedir}/src/main/assembly/third-party/highlight.js/9.12.0/atom-one-dark.min.css; + </additionalCompilerOptions> </configuration> </plugin> + <plugin> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <version>0.16.1</version> + <configuration> + <excludesFile>${project.basedir}/rat-excludes.txt</excludesFile> + </configuration> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-resources-plugin</artifactId> + <version>3.1.0</version> + <executions> + <execution> + <id>copy-resources-debug</id> + <phase>validate</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <outputDirectory>${compiler.output-dir-debug}</outputDirectory> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> + </configuration> + </execution> + <execution> + <id>copy-resources-release</id> + <phase>validate</phase> + <goals> + <goal>copy-resources</goal> + </goals> + <configuration> + <!-- Copy the assets to the assets output directory --> + <outputDirectory>${compiler.output-dir-release}</outputDirectory> + <resources> + <resource> + <directory>src/main/resources</directory> + <filtering>true</filtering> + </resource> + </resources> + </configuration> + </execution> + </executions> + </plugin> </plugins> </build> diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/rat-excludes.txt b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/rat-excludes.txt new file mode 100644 index 0000000000..16395e18e7 --- /dev/null +++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/rat-excludes.txt @@ -0,0 +1,22 @@ +################################################################################ +## +## Licensed to the Apache Software Foundation (ASF) under one or more +## contributor license agreements. See the NOTICE file distributed with +## this work for additional information regarding copyright ownership. +## The ASF licenses this file to You under the Apache License, Version 2.0 +## (the "License"); you may not use this file except in compliance with +## the License. You may obtain a copy of the License at +## +## http://www.apache.org/licenses/LICENSE-2.0 +## +## Unless required by applicable law or agreed to in writing, software +## distributed under the License is distributed on an "AS IS" BASIS, +## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +## See the License for the specific language governing permissions and +## limitations under the License. +## +################################################################################ + +# highlight.js is BSD-3-Clause +src/main/assembly/third-party/highlight.js/9.12.0/atom-one-dark.min.css +src/main/assembly/third-party/highlight.js/9.12.0/highlight.min.js \ No newline at end of file diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/assembly/third-party/highlight.js/9.12.0/LICENSE-highlightjs b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/assembly/third-party/highlight.js/9.12.0/LICENSE-highlightjs new file mode 100644 index 0000000000..2250cc7eca --- /dev/null +++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/assembly/third-party/highlight.js/9.12.0/LICENSE-highlightjs @@ -0,0 +1,29 @@ +BSD 3-Clause License + +Copyright (c) 2006, Ivan Sagalaev. +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 the copyright holder 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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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. diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/assembly/third-party/highlight.js/9.12.0/atom-one-dark.min.css b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/assembly/third-party/highlight.js/9.12.0/atom-one-dark.min.css new file mode 100644 index 0000000000..f2a2dad684 --- /dev/null +++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/assembly/third-party/highlight.js/9.12.0/atom-one-dark.min.css @@ -0,0 +1,34 @@ +/* +//////////////////////////////////////////////////////////////////////////////// +// BSD 3-Clause License +// +// Copyright (c) 2006, Ivan Sagalaev. +// 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 the copyright holder 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 THE COPYRIGHT HOLDER OR CONTRIBUTORS 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. +//////////////////////////////////////////////////////////////////////////////// +*/ +.hljs{display:block;overflow-x:auto;padding:0.5em;color:#abb2bf;background:#282c34}.hljs-comment,.hljs-quote{color:#5c6370;font-style:italic}.hljs-doctag,.hljs-keyword,.hljs-formula{color:#c678dd}.hljs-section,.hljs-name,.hljs-selector-tag,.hljs-deletion,.hljs-subst{color:#e06c75}.hljs-literal{color:#56b6c2}.hljs-string,.hljs-regexp,.hljs-addition,.hljs-attribute,.hljs-meta-string{color:#98c379}.hljs-built_in,.hljs-class .hljs-title{color:#e6c07b}.hljs-attr,.hljs-variable,.hljs-template- [...] \ No newline at end of file diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/assembly/third-party/highlight.js/9.12.0/highlight.min.js b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/assembly/third-party/highlight.js/9.12.0/highlight.min.js new file mode 100644 index 0000000000..f30a334c9d --- /dev/null +++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/assembly/third-party/highlight.js/9.12.0/highlight.min.js @@ -0,0 +1,3 @@ +/*! highlight.js v9.12.0 | BSD3 License | git.io/hljslicense */ +!function(e){var t="object"==typeof window&&window||"object"==typeof self&&self;"undefined"!=typeof exports?e(exports):t&&(t.hljs=e({}),"function"==typeof define&&define.amd&&define([],function(){return t.hljs}))}(function(e){function t(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function r(e){return e.nodeName.toLowerCase()}function a(e,t){var r=e&&e.exec(t);return r&&0===r.index}function n(e){return E.test(e)}function i(e){var t,r,a,i,s=e.className+" ";i [...] +var t="[a-zA-Z_]\\w*[!?=]?|[-+~]\\@|<<|>>|=~|===?|<=>|[<>]=?|\\*\\*|[-/+%^&*~`|]|\\[\\]=?",r={keyword:"and then defined module in return redo if BEGIN retry end for self when next until do begin unless END rescue else break undef not super class case require yield alias while ensure elsif or include attr_reader attr_writer attr_accessor",literal:"true false nil"},a={cN:"doctag",b:"@[A-Za-z]+"},n={b:"#<",e:">"},i=[e.C("#","$",{c:[a]}),e.C("^\\=begin","^\\=end",{c:[a],r:10}),e.C("^__END__" [...] \ No newline at end of file diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/resources/jewel-example-index-template.html b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/resources/jewel-example-index-template.html index 140ba985a1..c4b9aa3ba5 100644 --- a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/resources/jewel-example-index-template.html +++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/resources/jewel-example-index-template.html @@ -17,11 +17,11 @@ <!DOCTYPE html> <html> <head> - <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <meta name="Custom Template for injecting custom style CSS"> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0"> <link rel="stylesheet" type="text/css" href="${application}.css"> - <link href="https://fonts.googleapis.com/css?family=Lato:400,700" rel="stylesheet"> ${head} </head> <body> diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/BE0012_Using_external_javascript_libraries_in_Apache_Royale.mxml b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/BE0012_Using_external_javascript_libraries_in_Apache_Royale.mxml index 90991d61b5..31dfaa7956 100644 --- a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/BE0012_Using_external_javascript_libraries_in_Apache_Royale.mxml +++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/BE0012_Using_external_javascript_libraries_in_Apache_Royale.mxml @@ -55,7 +55,9 @@ </j:CardHeader> <j:CardPrimaryContent> - <j:Label html="This example uses hljs library to highligh a piece of code"/> + <j:Label> + <j:html><![CDATA[This example uses the <strong>hljs</strong> library to highlight some code]]></j:html> + </j:Label> <html:Pre height="300" width="100%" style="background-color: white"> <html:beads> diff --git a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/hljs.as b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/hljs.as index 1a045c7b7c..7f192f0a40 100644 --- a/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/hljs.as +++ b/examples/blog/BE0012_Using_external_javascript_libraries_in_Apache_Royale/src/main/royale/hljs.as @@ -24,19 +24,6 @@ package COMPILE::JS public class hljs { - /** - * <inject_script> - * var script = document.createElement("script"); - * script.setAttribute("src", "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"); - * document.head.appendChild(script); - * var link = document.createElement("link"); - * link.setAttribute("rel", "stylesheet"); - * link.setAttribute("title", "Atom One Dark"); - * link.setAttribute("type", "text/css"); - * link.setAttribute("href", "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/atom-one-dark.min.css"); - * document.head.appendChild(link); - * </inject_script> - */ public function hljs(){} public static function highlightBlock(block:Element):void {}
