add regex testing files

This commit is contained in:
Frank Xu
2022-04-22 23:30:05 -04:00
parent 10f53feba8
commit 96a3843e34
20 changed files with 5530 additions and 0 deletions

View File

@@ -0,0 +1,111 @@
<!DOCTYPE html>
<html>
<head>
<title>Lottie Animation</title>
<style type="text/css">
.showbackup {
z-index: 1;
position: fixed;
height: auto;
width: 100%;
display: block;
}
.lottie-anim {
z-index: -1;
position: fixed;
width: 100%;
height: 100%;
}
.hide-img {
display: none;
}
</style>
<script src="lottie.min.js" type="text/javascript"></script>
<script id="fileName" type="text/javascript"></script>
<script type="text/javascript">
// TODO(ashli): wrap this in function and add try-catch
// Parse file name and isDarkMode from URL query parameters
var temp = location.search.substring(1).split('&');
window.params = {};
window.isDarkMode = false;
for (var i=0; i < temp.length; i++) {
var pair = temp[i].split('=');
window.params[pair[0]] = pair[1];
}
if (window.params["isDarkMode"] === 'y')
{
window.isDarkMode = true;
document.getElementById('fileName').src="images/darkTheme/" + window.params["file"];
}
else
{
document.getElementById('fileName').src="images/lightTheme/" + window.params["file"];
}
</script>
<script type="text/javascript">
function startAnimation() {
window.state = 'play';
var element = document.getElementById("lottie");
console.log("Element is" + element);
try {
var animation = lottie.loadAnimation({
container: element, // the dom element that will contain the animation
renderer: 'canvas',
loop: true,
autoplay: true,
animationData: code
});
animation.addEventListener("data_failed", function() {
showImgIfNeeded("backup");
});
}
catch (err) {
console.log("load lottie animation failed \n");
}
}
function showImgIfNeeded(id) {
var img = document.getElementById(id);
if (img != null) {
img.classList.remove("hide-img");
img.classList.add("showbackup");
var lottieAnim = document.querySelector(".lottie-anim");
lottieAnim.style.display = "none";
}
}
function updateIfDarkMode() {
// Update to neutralDark background
var testName = window.params["file"].split('.');
if (window.isDarkMode)
{
document.body.style.backgroundColor = "#292827";
document.getElementById("backup").src = "images/darkTheme/" + testName[0] + ".svg";
}
else
{
document.body.style.backgroundColor = "#ffffff";
document.getElementById("backup").src = "images/lightTheme/" + testName[0] + ".svg";
}
}
window.onload = function () {
updateIfDarkMode();
startAnimation();
}
</script>
</head>
<body>
<div class="lottie-anim" id="lottie"></div>
<img class= "hide-img" id="backup">
</body>
</html>

View File

@@ -0,0 +1,296 @@
/**
* Copyright (c) 2000-present Liferay, Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or modify it under
* the terms of the GNU Lesser General Public License as published by the Free
* Software Foundation; either version 2.1 of the License, or (at your option)
* any later version.
*
* This library is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
* FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
* details.
*/
package com.liferay.dynamic.data.mapping.util.impl;
import com.liferay.dynamic.data.mapping.io.DDMFormJSONDeserializer;
import com.liferay.dynamic.data.mapping.io.DDMFormLayoutJSONDeserializer;
import com.liferay.dynamic.data.mapping.io.DDMFormXSDDeserializer;
import com.liferay.dynamic.data.mapping.model.DDMForm;
import com.liferay.dynamic.data.mapping.model.DDMFormLayout;
import com.liferay.dynamic.data.mapping.model.DDMStructure;
import com.liferay.dynamic.data.mapping.model.DDMStructureConstants;
import com.liferay.dynamic.data.mapping.model.DDMTemplateConstants;
import com.liferay.dynamic.data.mapping.service.DDMStructureLocalService;
import com.liferay.dynamic.data.mapping.service.DDMTemplateLocalService;
import com.liferay.dynamic.data.mapping.storage.StorageType;
import com.liferay.dynamic.data.mapping.util.DDM;
import com.liferay.dynamic.data.mapping.util.DDMXML;
import com.liferay.dynamic.data.mapping.util.DefaultDDMStructureHelper;
import com.liferay.portal.kernel.language.LanguageUtil;
import com.liferay.portal.kernel.template.TemplateConstants;
import com.liferay.portal.kernel.upgrade.util.UpgradeProcessUtil;
import com.liferay.portal.kernel.util.FileUtil;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.LocaleUtil;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.kernel.util.StringUtil;
import com.liferay.portal.kernel.workflow.WorkflowConstants;
import com.liferay.portal.kernel.xml.Attribute;
import com.liferay.portal.kernel.xml.Document;
import com.liferay.portal.kernel.xml.Element;
import com.liferay.portal.kernel.xml.UnsecureSAXReaderUtil;
import com.liferay.portal.service.ServiceContext;
import com.liferay.portal.util.PortalUtil;
import com.liferay.portlet.documentlibrary.model.DLFileEntryTypeConstants;
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
import java.util.Map;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Reference;
/**
* @author Michael C. Han
*/
@Component(immediate = true)
public class DefaultDDMStructureHelperImpl
implements DefaultDDMStructureHelper {
@Override
public void addDDMStructures(
long userId, long groupId, long classNameId,
ClassLoader classLoader, String fileName,
ServiceContext serviceContext)
throws Exception {
Locale locale = PortalUtil.getSiteDefaultLocale(groupId);
List<Element> structureElements = getDDMStructures(
classLoader, fileName, locale);
for (Element structureElement : structureElements) {
boolean dynamicStructure = GetterUtil.getBoolean(
structureElement.elementText("dynamic-structure"));
if (dynamicStructure) {
continue;
}
String name = structureElement.elementText("name");
String description = structureElement.elementText("description");
String ddmStructureKey = name;
DDMStructure ddmStructure =
_ddmStructureLocalService.fetchStructure(
groupId, classNameId, ddmStructureKey);
if (ddmStructure != null) {
continue;
}
Map<Locale, String> nameMap = new HashMap<>();
Map<Locale, String> descriptionMap = new HashMap<>();
for (Locale curLocale : LanguageUtil.getAvailableLocales(groupId)) {
nameMap.put(curLocale, LanguageUtil.get(curLocale, name));
descriptionMap.put(
curLocale, LanguageUtil.get(curLocale, description));
}
if (name.equals(DLFileEntryTypeConstants.NAME_IG_IMAGE) &&
!UpgradeProcessUtil.isCreateIGImageDocumentType()) {
continue;
}
DDMForm ddmForm = getDDMForm(structureElement, locale);
DDMFormLayout ddmFormLayout = getDDMFormLayout(
structureElement, ddmForm);
serviceContext.setAttribute(
"status", WorkflowConstants.STATUS_APPROVED);
ddmStructure = _ddmStructureLocalService.addStructure(
userId, groupId,
DDMStructureConstants.DEFAULT_PARENT_STRUCTURE_ID, classNameId,
ddmStructureKey, nameMap, descriptionMap, ddmForm,
ddmFormLayout, StorageType.JSON.toString(),
DDMStructureConstants.TYPE_DEFAULT, serviceContext);
Element templateElement = structureElement.element("template");
if (templateElement == null) {
continue;
}
String templateFileName = templateElement.elementText("file-name");
String script = StringUtil.read(
classLoader,
FileUtil.getPath(fileName) + StringPool.SLASH +
templateFileName);
boolean cacheable = GetterUtil.getBoolean(
templateElement.elementText("cacheable"));
_ddmTemplateLocalService.addTemplate(
userId, groupId, PortalUtil.getClassNameId(DDMStructure.class),
ddmStructure.getStructureId(), ddmStructure.getClassNameId(),
null, nameMap, null, DDMTemplateConstants.TEMPLATE_TYPE_DISPLAY,
DDMTemplateConstants.TEMPLATE_MODE_CREATE,
TemplateConstants.LANG_TYPE_FTL, script, cacheable, false,
StringPool.BLANK, null, serviceContext);
}
}
@Override
public String getDynamicDDMStructureDefinition(
ClassLoader classLoader, String fileName,
String dynamicDDMStructureName, Locale locale)
throws Exception {
List<Element> structureElements = getDDMStructures(
classLoader, fileName, locale);
for (Element structureElement : structureElements) {
boolean dynamicStructure = GetterUtil.getBoolean(
structureElement.elementText("dynamic-structure"));
if (!dynamicStructure) {
continue;
}
String name = structureElement.elementText("name");
if (!name.equals(dynamicDDMStructureName)) {
continue;
}
Element structureElementRootElement = structureElement.element(
"root");
return structureElementRootElement.asXML();
}
return null;
}
protected DDMForm getDDMForm(Element structureElement, Locale locale)
throws Exception {
Element structureElementDefinitionElement = structureElement.element(
"definition");
if (structureElementDefinitionElement != null) {
return _ddmFormJSONDeserializer.deserialize(
structureElementDefinitionElement.getTextTrim());
}
Element structureElementRootElement = structureElement.element("root");
String definition = structureElementRootElement.asXML();
Attribute defaultLocaleAttribute =
structureElementRootElement.attribute("default-locale");
Locale ddmStructureDefaultLocale = LocaleUtil.fromLanguageId(
defaultLocaleAttribute.getValue());
definition = _ddmXML.updateXMLDefaultLocale(
definition, ddmStructureDefaultLocale, locale);
return _ddmFormXSDDeserializer.deserialize(definition);
}
protected DDMFormLayout getDDMFormLayout(
Element structureElement, DDMForm ddmForm)
throws Exception {
Element structureElementLayoutElement = structureElement.element(
"layout");
if (structureElementLayoutElement != null) {
return _ddmFormLayoutJSONDeserializer.deserialize(
structureElementLayoutElement.getTextTrim());
}
return _ddm.getDefaultDDMFormLayout(ddmForm);
}
protected List<Element> getDDMStructures(
ClassLoader classLoader, String fileName, Locale locale)
throws Exception {
String xml = StringUtil.read(classLoader, fileName);
xml = StringUtil.replace(xml, "[$LOCALE_DEFAULT$]", locale.toString());
Document document = UnsecureSAXReaderUtil.read(xml);
Element rootElement = document.getRootElement();
return rootElement.elements("structure");
}
@Reference(unbind = "-")
protected void setDDM(DDM ddm) {
_ddm = ddm;
}
@Reference(unbind = "-")
protected void setDDMFormJSONDeserializer(
DDMFormJSONDeserializer ddmFormJSONDeserializer) {
_ddmFormJSONDeserializer = ddmFormJSONDeserializer;
}
@Reference(unbind = "-")
protected void setDDMFormLayoutJSONDeserializer(
DDMFormLayoutJSONDeserializer ddmFormLayoutJSONDeserializer) {
_ddmFormLayoutJSONDeserializer = ddmFormLayoutJSONDeserializer;
}
@Reference(unbind = "-")
protected void setDDMFormXSDDeserializer(
DDMFormXSDDeserializer ddmFormXSDDeserializer) {
_ddmFormXSDDeserializer = ddmFormXSDDeserializer;
}
@Reference(unbind = "-")
protected void setDDMStructureLocalService(
DDMStructureLocalService ddmStructureLocalService) {
_ddmStructureLocalService = ddmStructureLocalService;
}
@Reference(unbind = "-")
protected void setDDMTemplateLocalService(
DDMTemplateLocalService ddmTemplateLocalService) {
_ddmTemplateLocalService = ddmTemplateLocalService;
}
@Reference(unbind = "-")
protected void setDDMXML(DDMXML ddmXML) {
_ddmXML = ddmXML;
}
private volatile DDM _ddm;
private volatile DDMFormJSONDeserializer _ddmFormJSONDeserializer;
private volatile DDMFormLayoutJSONDeserializer
_ddmFormLayoutJSONDeserializer;
private volatile DDMFormXSDDeserializer _ddmFormXSDDeserializer;
private volatile DDMStructureLocalService _ddmStructureLocalService;
private volatile DDMTemplateLocalService _ddmTemplateLocalService;
private volatile DDMXML _ddmXML;
}

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 50 KiB

View File

@@ -0,0 +1,98 @@
/*
* 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.
*/
package org.apache.cocoon.components.flow.javascript;
import java.util.Locale;
import org.apache.commons.jxpath.ri.QName;
import org.apache.commons.jxpath.ri.model.NodePointer;
import org.apache.commons.jxpath.ri.model.beans.PropertyPointer;
import org.apache.commons.jxpath.ri.model.dynamic.DynamicPointer;
import org.mozilla.javascript.NativeArray;
import org.mozilla.javascript.Scriptable;
import org.mozilla.javascript.ScriptableObject;
import org.mozilla.javascript.Wrapper;
/**
*
* @version CVS $Id: ScriptablePointer.java 433543 2006-08-22 06:22:54Z crossley $
*/
public class ScriptablePointer extends DynamicPointer {
Scriptable node;
final static ScriptablePropertyHandler handler =
new ScriptablePropertyHandler();
public ScriptablePointer(NodePointer parent,
QName name,
Scriptable object) {
super(parent, name, object, handler);
node = object;
}
public ScriptablePointer(QName name,
Scriptable object,
Locale locale) {
super(name, object, handler, locale);
node = object;
}
public PropertyPointer getPropertyPointer(){
return new ScriptablePropertyPointer(this, handler);
}
public int getLength() {
Object obj = getBaseValue();
if (obj instanceof Scriptable) {
Scriptable node = (Scriptable)obj;
if (node instanceof NativeArray) {
return (int)((NativeArray)node).jsGet_length();
}
if (ScriptableObject.hasProperty(node, "length")) {
Object val = ScriptableObject.getProperty(node, "length");
if (val instanceof Number) {
return ((Number)val).intValue();
}
}
}
return super.getLength();
}
public Object getImmediateNode() {
Object value;
if (index == WHOLE_COLLECTION) {
value = node;
} else {
value = ScriptableObject.getProperty(node, index);
if (value == Scriptable.NOT_FOUND) {
value = node; // hack: same behavior as ValueUtils.getValue()
}
}
if (value instanceof Wrapper) {
value = ((Wrapper)value).unwrap();
}
return value;
}
public void setValue(Object value){
if (getParent() != null) {
getParent().setValue(value);
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,62 @@
"""
pygments.lexers.iolang
~~~~~~~~~~~~~~~~~~~~~~
Lexers for the Io language.
:copyright: Copyright 2006-2021 by the Pygments team, see AUTHORS.
:license: BSD, see LICENSE for details.
"""
from pygments.lexer import RegexLexer
from pygments.token import Text, Comment, Operator, Keyword, Name, String, \
Number
__all__ = ['IoLexer']
class IoLexer(RegexLexer):
"""
For `Io <http://iolanguage.com/>`_ (a small, prototype-based
programming language) source.
.. versionadded:: 0.10
"""
name = 'Io'
filenames = ['*.io']
aliases = ['io']
mimetypes = ['text/x-iosrc']
tokens = {
'root': [
(r'\n', Text),
(r'\s+', Text),
# Comments
(r'//(.*?)\n', Comment.Single),
(r'#(.*?)\n', Comment.Single),
(r'/(\\\n)?[*](.|\n)*?[*](\\\n)?/', Comment.Multiline),
(r'/\+', Comment.Multiline, 'nestedcomment'),
# DoubleQuotedString
(r'"(\\\\|\\[^\\]|[^"\\])*"', String),
# Operators
(r'::=|:=|=|\(|\)|;|,|\*|-|\+|>|<|@|!|/|\||\^|\.|%|&|\[|\]|\{|\}',
Operator),
# keywords
(r'(clone|do|doFile|doString|method|for|if|else|elseif|then)\b',
Keyword),
# constants
(r'(nil|false|true)\b', Name.Constant),
# names
(r'(Object|list|List|Map|args|Sequence|Coroutine|File)\b',
Name.Builtin),
(r'[a-zA-Z_]\w*', Name),
# numbers
(r'(\d+\.?\d*|\d*\.\d+)([eE][+-]?[0-9]+)?', Number.Float),
(r'\d+', Number.Integer)
],
'nestedcomment': [
(r'[^+/]+', Comment.Multiline),
(r'/\+', Comment.Multiline, '#push'),
(r'\+/', Comment.Multiline, '#pop'),
(r'[+/]', Comment.Multiline),
]
}

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 15 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.9 KiB