This is an automated email from the ASF dual-hosted git repository. rombert pushed a commit to annotated tag org.apache.sling.scripting.sightly.repl-1.0.2 in repository https://gitbox.apache.org/repos/asf/sling-org-apache-sling-scripting-sightly-repl.git
commit 8269d6c94542b2e45aea402fabbee4bcfe4df367 Author: Radu Cotescu <[email protected]> AuthorDate: Tue May 12 15:39:47 2015 +0000 SLING-4704 - Move the Sightly scripting engine artifacts from contrib to bundles * moved Sightly artifacts from contrib to bundles * updated SCM info git-svn-id: https://svn.apache.org/repos/asf/sling/trunk/bundles/scripting/sightly/repl@1678979 13f79535-47bb-0310-9956-ffa450edef68 --- NOTICE | 5 + README.md | 11 ++ pom.xml | 77 +++++++++++ .../SLING-INF/apps/repl/components/repl/logic.js | 23 ++++ .../SLING-INF/apps/repl/components/repl/repl.html | 76 +++++++++++ .../SLING-INF/apps/repl/components/repl/repl.js | 49 +++++++ .../apps/repl/components/repl/template.html | 30 ++++ .../etc/clientlibs/repl/images/sightly.svg | 114 ++++++++++++++++ .../SLING-INF/etc/clientlibs/repl/script.js | 152 +++++++++++++++++++++ .../SLING-INF/etc/clientlibs/repl/style.css | 51 +++++++ src/main/resources/SLING-INF/sightly/repl.json | 4 + 11 files changed, 592 insertions(+) diff --git a/NOTICE b/NOTICE new file mode 100644 index 0000000..96a49f3 --- /dev/null +++ b/NOTICE @@ -0,0 +1,5 @@ +Apache Sling Scripting Sightly Read-Eval-Print-Loop Environment +Copyright 2014 The Apache Software Foundation + +The Apache Sling Sightly REPL bundle is based on source code originally developed +by Adobe Systems Inc. (http://www.adobe.com/). diff --git a/README.md b/README.md new file mode 100644 index 0000000..f1de1e0 --- /dev/null +++ b/README.md @@ -0,0 +1,11 @@ +Apache Sling Scripting Sightly Read-Eval-Print Loop Environment +==== + +To install: +``` +mvn clean install sling:install +``` + +Then just browse to [http://localhost:8080/sightly/repl.html](http://localhost:8080/sightly/repl.html). + + diff --git a/pom.xml b/pom.xml new file mode 100644 index 0000000..9ac1113 --- /dev/null +++ b/pom.xml @@ -0,0 +1,77 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + ~ 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. + --> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <groupId>org.apache.sling</groupId> + <artifactId>sling</artifactId> + <version>22</version> + <relativePath /> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>org.apache.sling.scripting.sightly.repl</artifactId> + <version>1.0.1-SNAPSHOT</version> + <packaging>bundle</packaging> + + <name>Apache Sling Scripting Sightly Read-Eval-Print Loop Environment</name> + <description>REPL for Apache Sling Scripting Sightly engine</description> + + <scm> + <connection>scm:svn:http://svn.apache.org/repos/asf/sling/trunk/bundles/scripting/sightly/repl</connection> + <developerConnection>scm:svn:https://svn.apache.org/repos/asf/sling/trunk/bundles/scripting/sightly/repl</developerConnection> + <url>http://svn.apache.org/viewvc/sling/trunk/bundles/scripting/sightly/repl</url> + </scm> + + <properties> + <sling.java.version>6</sling.java.version> + </properties> + + <build> + <pluginManagement> + <plugins> + <plugin> + <!-- Extend RAT configuration from parent pom --> + <groupId>org.apache.rat</groupId> + <artifactId>apache-rat-plugin</artifactId> + <configuration> + <excludes combine.children="append"> + <exclude>src/main/resources/SLING-INF/**/*.json</exclude> + <exclude>src/main/resources/SLING-INF/**/*.svg</exclude> + </excludes> + </configuration> + </plugin> + </plugins> + </pluginManagement> + + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + <configuration> + <instructions> + <Sling-Initial-Content>SLING-INF;overwrite=true</Sling-Initial-Content> + <Require-Capability>io.sightly; filter:="(&(version>=1.0)(!(version>=2.0)))"</Require-Capability> + </instructions> + </configuration> + </plugin> + </plugins> + </build> +</project> diff --git a/src/main/resources/SLING-INF/apps/repl/components/repl/logic.js b/src/main/resources/SLING-INF/apps/repl/components/repl/logic.js new file mode 100644 index 0000000..29c5948 --- /dev/null +++ b/src/main/resources/SLING-INF/apps/repl/components/repl/logic.js @@ -0,0 +1,23 @@ +/******************************************************************************* + * 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. + ******************************************************************************/ +use(function () { + return { + message: 'hello world' + }; +}); diff --git a/src/main/resources/SLING-INF/apps/repl/components/repl/repl.html b/src/main/resources/SLING-INF/apps/repl/components/repl/repl.html new file mode 100644 index 0000000..a41811f --- /dev/null +++ b/src/main/resources/SLING-INF/apps/repl/components/repl/repl.html @@ -0,0 +1,76 @@ +<!DOCTYPE html> +<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> +<html lang="en"> + <head> + <meta charset="utf-8"> + <meta http-equiv="X-UA-Compatible" content="IE=edge"> + <meta name="viewport" content="width=device-width, initial-scale=1"> + + <title>Sightly REPL</title> + + <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css"> + <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap-theme.min.css"> + + <link rel="stylesheet" type="text/css" href="/etc/clientlibs/repl/style.css"> + </head> + + <body data-sly-use.repl="repl.js"> + <div id="logo"> </div> + <h1><small>Read-Eval-Print Loop</small></h1> + + <div id="main" class="row"> + <div id="input" class="col-xs-6"> + <div class="editorContainer"> + <p class="lead">template.html</p> + <div id="template" class="editor" data-src="/apps/repl/components/repl/template.html" data-mode="ace/mode/html" data-writeable></div> + </div> + + <div class="editorContainer"> + <p class="lead">logic.js</p> + <div id="logic" class="editor" data-src="/apps/repl/components/repl/logic.js" data-mode="ace/mode/javascript" data-writeable></div> + </div> + </div> + <div id="output" class="editorContainer col-xs-6"> + <div class="clearfix"> + <p class="lead pull-left">output.html</p> + <ul class="nav nav-pills navbar-right"> + <li class="active"><a data-toggle="tab" href="#source">Source</a></li> + <li><a data-toggle="tab" href="#view">View</a></li> + <li><a data-toggle="tab" href="#java">Java</a></li> + </ul> + </div> + <div id="source" class="output-view editor" data-src="/sightly/repl.template.html" data-mode="ace/mode/html"></div> + <iframe id="view" class="output-view hidden" src="/sightly/repl.template.html"></iframe> + <div id="java" class="output-view editor hidden" data-src="${repl.classPath}" data-mode="ace/mode/java"></div> + </div> + </div> + + <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> + <script src="//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"></script> + <script src="//cdnjs.cloudflare.com/ajax/libs/ace/1.1.01/ace.js"></script> + + <!--[if lt IE 9]> + <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script> + <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script> + <![endif]--> + + <script src="/etc/clientlibs/repl/script.js"></script> + </body> +</html> diff --git a/src/main/resources/SLING-INF/apps/repl/components/repl/repl.js b/src/main/resources/SLING-INF/apps/repl/components/repl/repl.js new file mode 100644 index 0000000..09ca13a --- /dev/null +++ b/src/main/resources/SLING-INF/apps/repl/components/repl/repl.js @@ -0,0 +1,49 @@ +/******************************************************************************* + * 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. + ******************************************************************************/ +use(function () { + + var slingSettings = sling.getService(Packages.org.apache.sling.settings.SlingSettingsService); + var CLASS_ROOT_FOLDER = '/var/classes/' + slingSettings.getSlingId() + '/sightly'; + var COMPONENT_PATH = '/apps/repl/components/repl'; + var JAVA_TEMPLATE_FILE = 'SightlyJava_template.java'; + + // Recursively walks down the given path until it finds an apps folder, then returns the full path of the Java compiled template file. + function getAppsPath(res) { + return res.getChildren().then(function (children) { + var length = children.length; + + // Let's see if one of the children is the apps folder. + for (var i = 0; i < length; i++) { + if (children[i].name === 'apps') { + return res.path + COMPONENT_PATH + '/' + JAVA_TEMPLATE_FILE; + } + } + + // If apps wasn't found but there's only one child folder, then let's recrusively walk that one down. + if (length === 1) { + return getAppsPath(children[0]); + } + }); + } + + return { + classPath: sightly.resource.resolve(CLASS_ROOT_FOLDER).then(getAppsPath) + }; + +}); diff --git a/src/main/resources/SLING-INF/apps/repl/components/repl/template.html b/src/main/resources/SLING-INF/apps/repl/components/repl/template.html new file mode 100644 index 0000000..c5a3f5b --- /dev/null +++ b/src/main/resources/SLING-INF/apps/repl/components/repl/template.html @@ -0,0 +1,30 @@ +<!DOCTYPE html> +<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ~ 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. + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~--> +<html> +<head> + <title>Sightly REPL</title> + <meta charset="utf-8"> +</head> +<body data-sly-use.obj="logic.js"> + + <p>Message is ${obj.message}</p> + +</body> +</html> diff --git a/src/main/resources/SLING-INF/etc/clientlibs/repl/images/sightly.svg b/src/main/resources/SLING-INF/etc/clientlibs/repl/images/sightly.svg new file mode 100644 index 0000000..4e43a19 --- /dev/null +++ b/src/main/resources/SLING-INF/etc/clientlibs/repl/images/sightly.svg @@ -0,0 +1,114 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- Generator: Adobe Illustrator 18.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) --> +<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"> +<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px" + viewBox="0 0 340.2 141.7" enable-background="new 0 0 340.2 141.7" xml:space="preserve"> +<g> + <path fill="#389DD7" d="M45.5,57.5c-0.9-0.9-2-1.6-3.3-2.3c-1.3-0.7-2.8-1.4-4.4-2.1c-1.6-0.7-2.9-1.3-4-1.8 + c-1.1-0.5-1.9-1.1-2.6-1.6c-0.6-0.5-1.1-1.1-1.3-1.7c-0.3-0.6-0.4-1.3-0.4-2.1c0-1.4,0.6-2.5,1.7-3.3c1.1-0.8,2.8-1.2,5.2-1.2 + c1.6,0,3.2,0.3,4.8,0.8c1.6,0.5,3.1,1.1,4.6,1.7l2.2-5.1c-1.7-0.8-3.4-1.4-5.3-1.9c-1.9-0.5-3.9-0.7-6.2-0.7c-2,0-3.8,0.2-5.4,0.7 + c-1.6,0.4-3,1.1-4.1,1.9c-1.2,0.9-2.1,1.9-2.7,3.2c-0.6,1.3-1,2.7-1,4.3c0,1.5,0.3,2.9,0.8,4c0.5,1.1,1.2,2.1,2.1,2.9 + c0.9,0.9,2,1.6,3.4,2.3c1.3,0.7,2.8,1.4,4.5,2.1c1.6,0.7,3,1.4,4.1,1.9c1.1,0.6,1.9,1.1,2.5,1.7c0.6,0.6,1,1.1,1.3,1.7 + c0.2,0.6,0.3,1.2,0.3,1.9c0,0.8-0.2,1.6-0.4,2.2c-0.3,0.7-0.8,1.2-1.4,1.7c-0.7,0.5-1.5,0.8-2.5,1.1c-1,0.2-2.3,0.4-3.8,0.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9-0.3,2.6-1c0.7-0.7,1.1-1.7,1.1-3c0-0.7-0.1-1.3-0.3-1.8 + C63.9,24.3,63.7,23.9,63.3,23.6z"/> + <path fill="#389DD7" d="M168.9,70.1c-0.5,0.1-1,0.1-1.5,0.2c-0.5,0-1,0.1-1.4,0.1c-1.7,0-2.9-0.6-3.6-1.7c-0.7-1.1-1.1-2.8-1.1-5.1 + V41.4h9.6v-4.5h-9.6v-8.7h-3.6l-2.7,8l-5.4,2.6v2.7h5.4v22.2c0,2.3,0.2,4.3,0.8,5.8c0.5,1.5,1.2,2.8,2.1,3.7 + c0.9,0.9,1.9,1.5,3.2,1.9c1.2,0.4,2.6,0.6,4,0.6c0.6,0,1.2,0,1.8-0.1c0.6-0.1,1.2-0.1,1.7-0.2c0.6-0.1,1.1-0.2,1.5-0.4 + c0.5-0.1,0.8-0.3,1.1-0.4v-4.8c-0.2,0.1-0.5,0.2-0.9,0.2C169.8,70,169.4,70.1,168.9,70.1z"/> + <rect x="178.5" y="21" fill="#454545" width="6.3" height="53.9"/> + <path fill="#389DD7" d="M130,36.2c-1.1,0-2.2,0.1-3.2,0.3c-1.1,0.2-2.1,0.6-3,1.1c-0.9,0.5-1.8,1.1-2.6,1.8 + c-0.8,0.7-1.5,1.6-2.1,2.6h-0.3l0.3-5V21h-6.3v53.9h6.3V55.2c0-2.2,0.2-4.2,0.5-5.9c0.3-1.7,0.9-3.1,1.7-4.3 + c0.8-1.2,1.8-2.1,3.1-2.7c1.3-0.6,2.8-0.9,4.7-0.9c2.6,0,4.5,0.8,5.7,2.3c1.2,1.5,1.8,3.7,1.8,6.7v24.5h6.3V50.1 + c0-4.8-1.1-8.4-3.2-10.6C137.5,37.3,134.3,36.2,130,36.2z"/> + <path fill="#389DD7" d="M105.9,56.9c0-7.3-4.2-13.7-10.4-16.7V20.8h-6v17.7c-0.7-0.1-1.4-0.1-2.1-0.1c-10.3,0-18.6,8.3-18.6,18.6 + S77,75.5,87.3,75.5c0.7,0,1.4,0,2.1-0.1v16.4c-0.7-0.1-1.4-0.1-2.1-0.1c-10.3,0-18.6,8.3-18.6,18.6s8.3,18.6,18.6,18.6 + c10.3,0,18.6-8.3,18.6-18.6c0-7.3-4.2-13.7-10.4-16.7V73.6C101.7,70.6,105.9,64.2,105.9,56.9z M99.6,110.2c0,6.6-5.5,12-12.3,12 + c-6.8,0-12.3-5.4-12.3-12c0-6.6,5.5-12,12.3-12C94.1,98.2,99.6,103.6,99.6,110.2z M87.3,68.9c-6.8,0-12.3-5.4-12.3-12 + c0-6.6,5.5-12,12.3-12c6.8,0,12.3,5.4,12.3,12C99.6,63.5,94.1,68.9,87.3,68.9z"/> + <path fill="#303030" d="M124.9,112c1-0.5,1.6-1.2,1.6-2.3c0-0.3-0.1-0.6-0.2-0.9c-0.1-0.3-0.2-0.5-0.4-0.7 + c-0.2-0.2-0.4-0.4-0.7-0.6c-0.3-0.2-0.6-0.3-1-0.4c-0.4-0.1-0.8-0.1-1.3-0.1h-3.3c-0.4,0-0.8,0.1-1,0.3c-0.2,0.2-0.3,0.5-0.3,1v7.8 + c0,0.4,0.1,0.8,0.3,1c0.2,0.2,0.5,0.3,1,0.3h3.2c0.5,0,1,0,1.4-0.1c0.4-0.1,0.8-0.2,1.1-0.3c0.5-0.2,0.9-0.6,1.2-1 + c0.3-0.5,0.4-1,0.4-1.6C126.9,113.3,126.2,112.4,124.9,112z M120.4,108.7h1.7c0.8,0,1.3,0.1,1.7,0.3c0.4,0.2,0.6,0.5,0.6,1 + c0,0.2-0.1,0.5-0.2,0.7c-0.2,0.3-0.4,0.5-0.7,0.6c-0.3,0.1-0.7,0.2-1.2,0.2h-1.9V108.7z M122.7,115.9h-2.2v-3h2.2 + c0.7,0,1.3,0.1,1.6,0.3c0.4,0.2,0.5,0.6,0.5,1.1C124.8,115.4,124.1,115.9,122.7,115.9z"/> + <path fill="#303030" d="M139.4,115.8h-4.9v-2.9h4.3c0.3,0,0.6-0.1,0.7-0.2c0.2-0.2,0.2-0.3,0.2-0.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c0-0.4-0.1-0.7-0.3-0.9 + c-0.2-0.2-0.4-0.3-0.8-0.3c-0.3,0-0.6,0.1-0.8,0.3c-0.2,0.2-0.3,0.5-0.3,0.9v5c0,0.8,0.1,1.4,0.3,2c0.2,0.6,0.4,1,0.8,1.4 + c0.4,0.4,0.8,0.6,1.4,0.8c0.6,0.2,1.3,0.3,2.1,0.3c0.7,0,1.2-0.1,1.7-0.2c0.5-0.2,0.9-0.4,1.3-0.8c0.4-0.4,0.7-0.9,0.9-1.4 + c0.2-0.5,0.2-1.2,0.2-2v-5c0-0.4-0.1-0.7-0.3-0.9C167.5,107.1,167.3,107,167,107z"/> + <path fill="#303030" d="M180.7,107.1h-6.7c-0.3,0-0.6,0.1-0.8,0.2c-0.2,0.2-0.3,0.4-0.3,0.6c0,0.3,0.1,0.5,0.3,0.6 + c0.2,0.2,0.4,0.2,0.8,0.2h2.3v7.5c0,0.4,0.1,0.7,0.3,1c0.2,0.2,0.4,0.3,0.8,0.3c0.3,0,0.6-0.1,0.7-0.3c0.2-0.2,0.3-0.5,0.3-1v-7.5 + h2.3c0.4,0,0.6-0.1,0.8-0.2c0.2-0.2,0.3-0.4,0.3-0.6c0-0.3-0.1-0.5-0.3-0.6C181.3,107.2,181.1,107.1,180.7,107.1z"/> +</g> +</svg> diff --git a/src/main/resources/SLING-INF/etc/clientlibs/repl/script.js b/src/main/resources/SLING-INF/etc/clientlibs/repl/script.js new file mode 100644 index 0000000..0f96a71 --- /dev/null +++ b/src/main/resources/SLING-INF/etc/clientlibs/repl/script.js @@ -0,0 +1,152 @@ +/******************************************************************************* + * 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. + ******************************************************************************/ +/* global jQuery, ace, document, setTimeout, clearTimeout, console */ +jQuery(function ($) { + + 'use strict'; + + var currentState = 'source'; + + // Limits the number of times the function gets called for event handlers + function debounce(fn, delay) { + var timer = null; + + return function () { + var context = this; + var args = arguments; + + clearTimeout(timer); + timer = setTimeout(function () { + fn.apply(context, args); + }, delay); + }; + } + + /** + * The editor object, it will take it's configuration from following attributes: + * id: The unique identifier of the editor (will be used as key in the Editor.all map object). + * data-src: The URL from which the editor's content has to be loaded. + * data-mode: The ACE editor's language mode. + * data-writeable: Boolean attribute to make the editor persisted to the data-src location. + */ + function Editor(DOMElement, reloadOutputCallback) { + var that = this; + var element = $(DOMElement); + var editor = ace.edit(DOMElement); + var mode = element.data('mode'); + var url = element.data('src'); + var isWriteable = element.is('[data-writeable]'); + + function attachSaveHandler() { + if (isWriteable) { + editor.session.on('change', debounce(function () { + that.saveChanges(); + }), 500); + } + } + + function init() { + Editor.all[element.attr('id')] = that; + + editor.renderer.setShowGutter(false); + editor.setHighlightActiveLine(false); + editor.setShowPrintMargin(false); + editor.setReadOnly(!isWriteable); + editor.session.setUseWorker(false); + editor.session.setMode(mode); + + if (element.is(':visible')) { + that.loadContent(attachSaveHandler); + } else { + attachSaveHandler(); + } + } + + that.saveChanges = function (cb) { + if (isWriteable) { + $.ajax({ + url: url, + type: 'PUT', + data: editor.getValue(), + contentType: 'plain/text', + success: reloadOutputCallback, + complete: cb + }); + } + }; + + that.loadContent = function (cb) { + $.ajax(url, { + type: 'GET', + dataType: 'text', + cache: false, + processData: false, + success: function (data) { + editor.setValue(data); + editor.clearSelection(); + }, + error: function (req, textStatus, message) { + editor.setValue(req.responseText); + editor.clearSelection(); + console.error(message); + }, + complete: cb + }); + }; + + init(); + } + + // A map of all the editors, the id attribute of their parent DOM element is used as key. + Editor.all = {}; + + // Refreshes the output after changes were made + function reloadOutput() { + if (Editor.all[currentState] !== undefined) { + Editor.all[currentState].loadContent(); + } else { + document.getElementsByTagName('iframe')[0].contentDocument.location.reload(true); + } + } + + function init() { + // Setup editors + $('.editor').each(function () { + new Editor(this, reloadOutput); + }); + + // Setup output tabs + var allTargets = $('.output-view'); + $('a[data-toggle=tab]').each(function () { + var link = $(this); + var target = allTargets.filter(link.attr('href')); + var state = target.attr('id'); + + link.click(function () { + currentState = state; + allTargets.addClass('hidden'); + target.removeClass('hidden'); + reloadOutput(); + }); + }); + } + + init(); + +}); diff --git a/src/main/resources/SLING-INF/etc/clientlibs/repl/style.css b/src/main/resources/SLING-INF/etc/clientlibs/repl/style.css new file mode 100644 index 0000000..839b4cc --- /dev/null +++ b/src/main/resources/SLING-INF/etc/clientlibs/repl/style.css @@ -0,0 +1,51 @@ +/******************************************************************************* + * 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. + ******************************************************************************/ +body { + margin: 0 10px; +} +h1 { + margin-top: 10px; +} +iframe { + border: none; + width: 100%; +} +#logo { + min-height: 100px; + background: url('./images/sightly.svg') no-repeat 50% 100%; +} +#input .editor { + height: 300px; +} +#output .editor { + height: 650px; +} +@media (max-width: 768px) { + #output .lead { + display: none; + } +} +#output .nav { + margin-top: -3px; +} +@media (max-width: 768px) { + #output .nav { + margin: -8px 0 10px; + } +} diff --git a/src/main/resources/SLING-INF/sightly/repl.json b/src/main/resources/SLING-INF/sightly/repl.json new file mode 100644 index 0000000..aa5081f --- /dev/null +++ b/src/main/resources/SLING-INF/sightly/repl.json @@ -0,0 +1,4 @@ +{ + "jcr:primaryType" : "nt:unstructured", + "sling:resourceType":"repl/components/repl" +} -- To stop receiving notification emails like this one, please contact "[email protected]" <[email protected]>.
