diff --git a/docs/asciidoc/modules/modules.adoc b/docs/asciidoc/modules/modules.adoc index 4c72696387..e538064796 100644 --- a/docs/asciidoc/modules/modules.adoc +++ b/docs/asciidoc/modules/modules.adoc @@ -37,8 +37,6 @@ Modules are distributed as separate dependencies. Below is the catalog of offici ==== Development Tools * link:{uiVersion}/#tooling-and-operations-development[Jooby Run]: Run and hot reload your application. * link:{uiVersion}/modules/whoops[Whoops]: Pretty page stacktrace reporter. - * link:{uiVersion}/modules/metrics[Metrics]: Application metrics from the excellent metrics library. - * link:{uiVersion}/modules/opentelemetry[Open Telemetry]: Application metrics using Open Telemetry library. ==== Event Bus * link:{uiVersion}/modules/camel[Camel]: Camel module for Jooby. @@ -51,6 +49,10 @@ Modules are distributed as separate dependencies. Below is the catalog of offici * link:{uiVersion}/modules/jackson3[Jackson3]: Jackson3 module for Jooby. * link:{uiVersion}/modules/yasson[Yasson]: JSON-B module for Jooby. +==== Metrics + * link:{uiVersion}/modules/metrics[Metrics]: Application metrics from the excellent metrics library. + * link:{uiVersion}/modules/opentelemetry[Open Telemetry]: Application metrics using Open Telemetry library. + ==== OpenAPI * link:{uiVersion}/modules/openapi[OpenAPI]: OpenAPI supports. diff --git a/docs/images/whoops.png b/docs/images/whoops.png index e0851f06a2..453bfe426b 100644 Binary files a/docs/images/whoops.png and b/docs/images/whoops.png differ diff --git a/docs/js/styles/theme.css b/docs/js/styles/theme.css index e1591769f6..3ee9a6e2ec 100644 --- a/docs/js/styles/theme.css +++ b/docs/js/styles/theme.css @@ -806,3 +806,10 @@ html, body { overflow-wrap: break-word; word-break: break-word; } + +/* Responsive images */ +#content img { + max-width: 100%; + height: auto; + border-radius: var(--border-radius); +} diff --git a/modules/jooby-whoops/NOTE.md b/modules/jooby-whoops/NOTE.md index 3bf6559a96..b4077acf48 100644 --- a/modules/jooby-whoops/NOTE.md +++ b/modules/jooby-whoops/NOTE.md @@ -1,9 +1,4 @@ To make a new release: - https://github.com/filp/whoops/tags -- This repo used 2.15.4 -- Unzip the release -- copy *.php files to test/resources/whoops/views -- Run GenerateHTML -- Verify all php lines were converted (manually) -- Run WhoopsTest +- This repo used 2.18.4 diff --git a/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/Frame.java b/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/Frame.java index 2692c0db03..fc26202205 100644 --- a/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/Frame.java +++ b/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/Frame.java @@ -8,16 +8,36 @@ import static java.util.Optional.ofNullable; import java.io.File; -import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Arrays; import java.util.Collections; +import java.util.HashSet; import java.util.LinkedList; import java.util.List; +import java.util.Set; import java.util.stream.Collectors; import java.util.stream.Stream; public class Frame { private static final int SAMPLE_SIZE = 10; + private static final Set VENDOR_PACKAGES = + new HashSet<>( + Arrays.asList( + "java.", + "javax.", + "jakarta.", + "sun.", + "com.sun.", + "org.eclipse.", + "io.netty.", + "org.hibernate.", + "com.fasterxml.", + "tools.jackson.", + "org.slf4j", + "io.undertow.", + "io.jooby.")); + private String fileName; private String methodName; @@ -75,7 +95,15 @@ public List getComments() { } public boolean hasSource() { - return source != null && source.length() > 0; + return source != null && !source.isEmpty(); + } + + public boolean shouldScan() { + return VENDOR_PACKAGES.stream().noneMatch(it -> getClassName().startsWith(it)); + } + + public boolean isApplication() { + return hasSource(); } public static List toFrames(SourceLocator locator, Throwable cause) { @@ -89,8 +117,7 @@ public static List toFrames(SourceLocator locator, Throwable cause) { Stream.of(head.getStackTrace()).map(e -> toFrame(locator, head, e)).forEach(frames::add); - // Keep application frames (ignore all others) - return frames.stream().filter(Frame::hasSource).collect(Collectors.toList()); + return frames.stream().toList(); } static Frame toFrame( @@ -100,28 +127,37 @@ static Frame toFrame( String[] names = className.split("\\."); String filename = ofNullable(e.getFileName()).orElse(names[names.length - 1]); - StringBuilder path = new StringBuilder(); - Stream.of(names).limit(names.length - 1).forEach(it -> path.append(it).append(File.separator)); - path.append(names[names.length - 1]); - SourceLocator.Source source = locator.source(path.toString()); - SourceLocator.Preview preview = source.preview(line, SAMPLE_SIZE); - Frame frame = new Frame(); frame.fileName = filename; frame.methodName = ofNullable(e.getMethodName()).orElse("~unknown"); - frame.lineStart = preview.getLineStart(); frame.line = line; - frame.location = - Files.exists(source.getPath()) - ? locator.getBasedir().relativize(source.getPath()).toString() - : filename; - frame.source = preview.getCode(); - frame.open = false; frame.className = className // clean up kotlin generated class name: App$1$1 => App .replaceAll("\\$\\d+", ""); frame.comments = Collections.singletonList(cause); + + if (frame.shouldScan()) { + StringBuilder path = new StringBuilder(); + Stream.of(names) + .limit(names.length - 1) + .forEach(it -> path.append(it).append(File.separator)); + path.append(names[names.length - 1]); + SourceLocator.Source source = locator.source(path.toString()); + SourceLocator.Preview preview = source.preview(line, SAMPLE_SIZE); + + frame.lineStart = preview.getLineStart(); + Path sourcePath = source.getPath(); + frame.location = + sourcePath != null && sourcePath.isAbsolute() + ? locator.getBasedir().relativize(sourcePath).toString() + : filename; + frame.source = preview.getCode(); + } else { + frame.location = filename; + } + + frame.open = false; return frame; } diff --git a/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/SourceLocator.java b/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/SourceLocator.java index c89a7865a6..30b1b969bc 100644 --- a/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/SourceLocator.java +++ b/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/SourceLocator.java @@ -5,6 +5,7 @@ */ package io.jooby.internal.whoops; +import java.io.BufferedReader; import java.io.File; import java.io.IOException; import java.nio.charset.StandardCharsets; @@ -16,7 +17,6 @@ import java.nio.file.attribute.BasicFileAttributes; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import java.util.Set; @@ -49,8 +49,6 @@ public String getCode() { } public static class Source { - private static final int[] RANGE = {0, 0}; - private final Path path; public Source(final Path path) { @@ -62,42 +60,35 @@ public Path getPath() { } public Preview preview(final int line, final int size) { - List lines = getLines(); - - int[] range = range(line, size, lines.size()); - int from = range[0]; - int to = range[1]; - - String code; - if (from >= 0 && to <= lines.size()) { - code = - lines.subList(from, to).stream() - .map(l -> l.length() == 0 ? " " : l) - .collect(Collectors.joining("\n")); - } else { - code = ""; + int start = Math.max(1, line - size); + int end = line + size; + List codeLines = new ArrayList<>(); + int lineStart = -1; + + try (BufferedReader reader = Files.newBufferedReader(path, StandardCharsets.UTF_8)) { + String l; + int n = 1; + while ((l = reader.readLine()) != null) { + if (n >= start) { + if (lineStart == -1) { + lineStart = n; + } + codeLines.add(l.length() == 0 ? " " : l); + } + if (n >= end) { + break; + } + n++; + } + } catch (IOException x) { + return new Preview("", 1); } - return new Preview(code, from + 1); - } - private int[] range(final int line, final int size, int totalSize) { - if (line < totalSize) { - int from = Math.max(line - size, 0); - int toset = Math.max((line - from) - size, 0); - int to = Math.min(from + toset + size * 2, totalSize); - int fromset = Math.abs((to - line) - size); - from = Math.max(from - fromset, 0); - return new int[] {from, to}; + if (lineStart == -1) { + return new Preview("", 1); } - return RANGE; - } - private List getLines() { - try { - return Files.readAllLines(path, StandardCharsets.UTF_8); - } catch (IOException x) { - return Collections.emptyList(); - } + return new Preview(String.join("\n", codeLines), lineStart); } @Override @@ -111,6 +102,8 @@ public String toString() { private Path basedir; private Map sources = new ConcurrentHashMap<>(); + private final Map> sourceIndex = new ConcurrentHashMap<>(); + private volatile boolean indexBuilt = false; public SourceLocator(Path basedir) { this.basedir = basedir; @@ -124,58 +117,78 @@ public Source source(String filename) { return sources.computeIfAbsent( filename, f -> { - Set skip = - Stream.of("target", "bin", "build", "tmp", "temp", "node_modules", "node") - .collect(Collectors.toSet()); - try { - List files = - Arrays.asList( - filename, - filename.replace(".", File.separator) + ".java", - filename.replace(".", File.separator) + ".kt", - filename.replace(".", File.separator) + "Kt.kt"); - List source = new ArrayList<>(); - source.add(Paths.get(filename)); - log.debug("scanning {}", basedir); - Files.walkFileTree( - basedir, - new SimpleFileVisitor() { - @Override - public FileVisitResult preVisitDirectory( - final Path dir, final BasicFileAttributes attrs) throws IOException { - String dirName = dir.getFileName().toString(); - if (Files.isHidden(dir) || dirName.startsWith(".")) { - log.debug("skipping hidden directory: {}", dir); - return FileVisitResult.SKIP_SUBTREE; - } - if (skip.contains(dirName)) { - log.debug("skipping binary directory: {}", dir); - return FileVisitResult.SKIP_SUBTREE; - } - log.debug("found directory: {}", dir); - return FileVisitResult.CONTINUE; + buildIndexIfNeeded(); + + String simpleName = f.substring(f.lastIndexOf(File.separator) + 1); + List searchFiles = + Arrays.asList(simpleName + ".java", simpleName + ".kt", simpleName + "Kt.kt"); + + List candidateSuffixes = + Arrays.asList(f + ".java", f + ".kt", f.replace(".", File.separator) + "Kt.kt"); + + for (String searchFile : searchFiles) { + List paths = sourceIndex.get(searchFile); + if (paths != null) { + for (Path path : paths) { + String pathStr = path.toString(); + for (String suffix : candidateSuffixes) { + if (pathStr.endsWith(suffix)) { + return new Source(path); } - - @Override - public FileVisitResult visitFile( - final Path file, final BasicFileAttributes attrs) { - return files.stream() - .filter(f -> file.toString().endsWith(f)) - .findFirst() - .map( - f -> { - source.add(0, file.toAbsolutePath()); - return FileVisitResult.TERMINATE; - }) - .orElse(FileVisitResult.CONTINUE); - } - }); - return new Source(source.get(0)); - } catch (IOException x) { - return new Source(Paths.get(filename)); - } finally { - log.debug("done scanning {}", basedir); + } + } + } } + return new Source(Paths.get(filename)); }); } + + private void buildIndexIfNeeded() { + if (indexBuilt) { + return; + } + synchronized (this) { + if (indexBuilt) { + return; + } + try { + log.debug("scanning {}", basedir); + Set skip = + Stream.of("target", "bin", "build", "tmp", "temp", "node_modules", "node") + .collect(Collectors.toSet()); + Files.walkFileTree( + basedir, + new SimpleFileVisitor() { + @Override + public FileVisitResult preVisitDirectory( + final Path dir, final BasicFileAttributes attrs) throws IOException { + String dirName = dir.getFileName().toString(); + if (Files.isHidden(dir) || dirName.startsWith(".")) { + log.debug("skipping hidden directory: {}", dir); + return FileVisitResult.SKIP_SUBTREE; + } + if (skip.contains(dirName)) { + log.debug("skipping binary directory: {}", dir); + return FileVisitResult.SKIP_SUBTREE; + } + return FileVisitResult.CONTINUE; + } + + @Override + public FileVisitResult visitFile(final Path file, final BasicFileAttributes attrs) { + String fileName = file.getFileName().toString(); + if (fileName.endsWith(".java") || fileName.endsWith(".kt")) { + sourceIndex.computeIfAbsent(fileName, k -> new ArrayList<>()).add(file); + } + return FileVisitResult.CONTINUE; + } + }); + } catch (IOException x) { + log.error("source index failed", x); + } finally { + log.debug("done scanning {}", basedir); + indexBuilt = true; + } + } + } } diff --git a/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/Whoops.java b/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/Whoops.java index b667f2cf3d..c9920de02e 100644 --- a/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/Whoops.java +++ b/modules/jooby-whoops/src/main/java/io/jooby/internal/whoops/Whoops.java @@ -12,13 +12,7 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.nio.file.Path; -import java.util.Arrays; -import java.util.Collections; -import java.util.HashMap; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.Optional; +import java.util.*; import java.util.function.BiConsumer; import org.slf4j.Logger; @@ -119,9 +113,10 @@ public Result render(Context ctx, Throwable cause, StatusCode code) { cpath = ""; } model.put("stylesheet", cpath + "/whoops/css/whoops.base.css"); - model.put("prettify", cpath + "/whoops/js/prettify.min.js"); + model.put("prismCss", cpath + "/whoops/css/prism.css"); model.put("clipboard", cpath + "/whoops/js/clipboard.min.js"); model.put("zepto", cpath + "/whoops/js/zepto.min.js"); + model.put("prism", cpath + "/whoops/js/prism.js"); model.put("javascript", cpath + "/whoops/js/whoops.base.js"); model.put("frames", frames); @@ -129,6 +124,20 @@ public Result render(Context ctx, Throwable cause, StatusCode code) { model.put("causeName", Arrays.asList(cause.getClass().getName().split("\\."))); model.put("stacktrace", stacktrace.toString()); model.put("code", code); + model.put("title", cause.getClass().getSimpleName() + " - Whoops!"); + model.put("hasFrameTabs", true); // Or false if you only ever show one list + model.put("activeFramesTab", "application"); // "application" or "all" + long appFramesCount = frames.stream().filter(Frame::isApplication).count(); + model.put("appFramesCount", appFramesCount); + + List previousMessages = new ArrayList<>(); + var current = cause.getCause(); + while (current != null) { + previousMessages.add( + Optional.ofNullable(current.getMessage()).orElse(current.getClass().getName())); + current = current.getCause(); + } + model.put("previousMessages", previousMessages); // environment model.put("env", environment(ctx, code)); diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/css/prism.css b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/css/prism.css index a03db53d48..45ebad5f6f 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/css/prism.css +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/css/prism.css @@ -1,4 +1,4 @@ -/* PrismJS 1.29.0 +/* PrismJS 1.30.0 https://prismjs.com/download.html#themes=prism-tomorrow&languages=markup+markup-templating+php&plugins=line-highlight+line-numbers */ code[class*=language-],pre[class*=language-]{color:#ccc;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#2d2d2d}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.block-comment,.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#999}.token.punctuation{color:#ccc}.token.attr-name,.token.deleted,.token.namespace,.token.tag{color:#e2777a}.token.function-name{color:#6196cc}.token.boolean,.token.function,.token.number{color:#f08d49}.token.class-name,.token.constant,.token.property,.token.symbol{color:#f8c555}.token.atrule,.token.builtin,.token.important,.token.keyword,.token.selector{color:#cc99cd}.token.attr-value,.token.char,.token.regex,.token.string,.token.variable{color:#7ec699}.token.entity,.token.operator,.token.url{color:#67cdcc}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.inserted{color:green} pre[data-line]{position:relative;padding:1em 0 1em 3em}.line-highlight{position:absolute;left:0;right:0;padding:inherit 0;margin-top:1em;background:hsla(24,20%,50%,.08);background:linear-gradient(to right,hsla(24,20%,50%,.1) 70%,hsla(24,20%,50%,0));pointer-events:none;line-height:inherit;white-space:pre}@media print{.line-highlight{-webkit-print-color-adjust:exact;color-adjust:exact}}.line-highlight:before,.line-highlight[data-end]:after{content:attr(data-start);position:absolute;top:.4em;left:.6em;min-width:1em;padding:0 .5em;background-color:hsla(24,20%,50%,.4);color:#f4f1ef;font:bold 65%/1.5 sans-serif;text-align:center;vertical-align:.3em;border-radius:999px;text-shadow:none;box-shadow:0 1px #fff}.line-highlight[data-end]:after{content:attr(data-end);top:auto;bottom:.4em}.line-numbers .line-highlight:after,.line-numbers .line-highlight:before{content:none}pre[id].linkable-line-numbers span.line-numbers-rows{pointer-events:all}pre[id].linkable-line-numbers span.line-numbers-rows>span:before{cursor:pointer}pre[id].linkable-line-numbers span.line-numbers-rows>span:hover:before{background-color:rgba(128,128,128,.2)} diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/css/whoops.base.css b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/css/whoops.base.css index edd5cd8ec8..9abd15f509 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/css/whoops.base.css +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/css/whoops.base.css @@ -230,10 +230,6 @@ header { font-weight: bold; } - .frame-line:before { - content: ":"; - } - .frame-code { padding: 5px; background: #303030; @@ -558,3 +554,11 @@ pre.sf-dump { .search-for-help li a svg path { background-size: contain; } + +.line-numbers-rows span { + pointer-events: auto; + cursor: pointer; +} +.line-numbers-rows span:hover { + text-decoration: underline; +} diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/clipboard.min.js b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/clipboard.min.js index 36a75a466b..1103f811ed 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/clipboard.min.js +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/clipboard.min.js @@ -1,7 +1,7 @@ /*! - * clipboard.js v1.5.3 - * https://zenorocha.github.io/clipboard.js + * clipboard.js v2.0.11 + * https://clipboardjs.com/ * * Licensed MIT © Zeno Rocha */ -!function(t){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var e;e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,e.Clipboard=t()}}(function(){var t,e,n;return function t(e,n,r){function o(a,c){if(!n[a]){if(!e[a]){var s="function"==typeof require&&require;if(!c&&s)return s(a,!0);if(i)return i(a,!0);var u=new Error("Cannot find module '"+a+"'");throw u.code="MODULE_NOT_FOUND",u}var l=n[a]={exports:{}};e[a][0].call(l.exports,function(t){var n=e[a][1][t];return o(n?n:t)},l,l.exports,t,e,n,r)}return n[a].exports}for(var i="function"==typeof require&&require,a=0;ar;r++)n[r].fn.apply(n[r].ctx,e);return this},off:function(t,e){var n=this.e||(this.e={}),r=n[t],o=[];if(r&&e)for(var i=0,a=r.length;a>i;i++)r[i].fn!==e&&r[i].fn._!==e&&o.push(r[i]);return o.length?n[t]=o:delete n[t],this}},e.exports=r},{}],8:[function(t,e,n){"use strict";function r(t){return t&&t.__esModule?t:{"default":t}}function o(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}n.__esModule=!0;var i=function(){function t(t,e){for(var n=0;n=g.reach);A+=w.value.length,w=w.next){var E=w.value;if(n.length>e.length)return;if(!(E instanceof i)){var P,L=1;if(y){if(!(P=l(b,A,e,m))||P.index>=e.length)break;var S=P.index,O=P.index+P[0].length,j=A;for(j+=w.value.length;S>=j;)j+=(w=w.next).value.length;if(A=j-=w.value.length,w.value instanceof i)continue;for(var C=w;C!==n.tail&&(jg.reach&&(g.reach=W);var z=w.prev;if(_&&(z=u(n,z,_),A+=_.length),c(n,z,L),w=u(n,z,new i(f,p?a.tokenize(N,p):N,k,N)),M&&u(n,w,M),L>1){var I={cause:f+","+d,reach:W};o(e,n,t,w.prev,A,I),g&&I.reach>g.reach&&(g.reach=I.reach)}}}}}}function s(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function u(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function c(e,n,t){for(var r=n.next,a=0;a"+i.content+""},!e.document)return e.addEventListener?(a.disableWorkerMessageHandler||e.addEventListener("message",(function(n){var t=JSON.parse(n.data),r=t.language,i=t.code,l=t.immediateClose;e.postMessage(a.highlight(i,a.languages[r],r)),l&&e.close()}),!1),a):a;var g=a.util.currentScript();function f(){a.manual||a.highlightAll()}if(g&&(a.filename=g.src,g.hasAttribute("data-manual")&&(a.manual=!0)),!a.manual){var h=document.readyState;"loading"===h||"interactive"===h&&g&&g.defer?document.addEventListener("DOMContentLoaded",f):window.requestAnimationFrame?window.requestAnimationFrame(f):window.setTimeout(f,16)}return a}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(e){var n=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,t=0,r={},a={manual:e.Prism&&e.Prism.manual,disableWorkerMessageHandler:e.Prism&&e.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof i?new i(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&").replace(/=g.reach);A+=w.value.length,w=w.next){var P=w.value;if(n.length>e.length)return;if(!(P instanceof i)){var E,S=1;if(y){if(!(E=l(b,A,e,m))||E.index>=e.length)break;var L=E.index,O=E.index+E[0].length,C=A;for(C+=w.value.length;L>=C;)C+=(w=w.next).value.length;if(A=C-=w.value.length,w.value instanceof i)continue;for(var j=w;j!==n.tail&&(Cg.reach&&(g.reach=W);var I=w.prev;if(_&&(I=u(n,I,_),A+=_.length),c(n,I,S),w=u(n,I,new i(f,p?a.tokenize(N,p):N,k,N)),M&&u(n,w,M),S>1){var T={cause:f+","+d,reach:W};o(e,n,t,w.prev,A,T),g&&T.reach>g.reach&&(g.reach=T.reach)}}}}}}function s(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function u(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function c(e,n,t){for(var r=n.next,a=0;a"+i.content+""},!e.document)return e.addEventListener?(a.disableWorkerMessageHandler||e.addEventListener("message",(function(n){var t=JSON.parse(n.data),r=t.language,i=t.code,l=t.immediateClose;e.postMessage(a.highlight(i,a.languages[r],r)),l&&e.close()}),!1),a):a;var g=a.util.currentScript();function f(){a.manual||a.highlightAll()}if(g&&(a.filename=g.src,g.hasAttribute("data-manual")&&(a.manual=!0)),!a.manual){var h=document.readyState;"loading"===h||"interactive"===h&&g&&g.defer?document.addEventListener("DOMContentLoaded",f):window.requestAnimationFrame?window.requestAnimationFrame(f):window.setTimeout(f,16)}return a}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); Prism.languages.markup={comment:{pattern://,greedy:!0},prolog:{pattern:/<\?[\s\S]+?\?>/,greedy:!0},doctype:{pattern:/"'[\]]|"[^"]*"|'[^']*')+(?:\[(?:[^<"'\]]|"[^"]*"|'[^']*'|<(?!!--)|)*\]\s*)?>/i,greedy:!0,inside:{"internal-subset":{pattern:/(^[^\[]*\[)[\s\S]+(?=\]>$)/,lookbehind:!0,greedy:!0,inside:null},string:{pattern:/"[^"]*"|'[^']*'/,greedy:!0},punctuation:/^$|[[\]]/,"doctype-tag":/^DOCTYPE/i,name:/[^\s<>'"]+/}},cdata:{pattern://i,greedy:!0},tag:{pattern:/<\/?(?!\d)[^\s>\/=$<%]+(?:\s(?:\s*[^\s>\/=]+(?:\s*=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+(?=[\s>]))|(?=[\s/>])))+)?\s*\/?>/,greedy:!0,inside:{tag:{pattern:/^<\/?[^\s>\/]+/,inside:{punctuation:/^<\/?/,namespace:/^[^\s>\/:]+:/}},"special-attr":[],"attr-value":{pattern:/=\s*(?:"[^"]*"|'[^']*'|[^\s'">=]+)/,inside:{punctuation:[{pattern:/^=/,alias:"attr-equals"},{pattern:/^(\s*)["']|["']$/,lookbehind:!0}]}},punctuation:/\/?>/,"attr-name":{pattern:/[^\s>\/]+/,inside:{namespace:/^[^\s>\/:]+:/}}}},entity:[{pattern:/&[\da-z]{1,8};/i,alias:"named-entity"},/&#x?[\da-f]{1,8};/i]},Prism.languages.markup.tag.inside["attr-value"].inside.entity=Prism.languages.markup.entity,Prism.languages.markup.doctype.inside["internal-subset"].inside=Prism.languages.markup,Prism.hooks.add("wrap",(function(a){"entity"===a.type&&(a.attributes.title=a.content.replace(/&/,"&"))})),Object.defineProperty(Prism.languages.markup.tag,"addInlined",{value:function(a,e){var s={};s["language-"+e]={pattern:/(^$)/i,lookbehind:!0,inside:Prism.languages[e]},s.cdata=/^$/i;var t={"included-cdata":{pattern://i,inside:s}};t["language-"+e]={pattern:/[\s\S]+/,inside:Prism.languages[e]};var n={};n[a]={pattern:RegExp("(<__[^>]*>)(?:))*\\]\\]>|(?!)".replace(/__/g,(function(){return a})),"i"),lookbehind:!0,greedy:!0,inside:t},Prism.languages.insertBefore("markup","cdata",n)}}),Object.defineProperty(Prism.languages.markup.tag,"addAttribute",{value:function(a,e){Prism.languages.markup.tag.inside["special-attr"].push({pattern:RegExp("(^|[\"'\\s])(?:"+a+")\\s*=\\s*(?:\"[^\"]*\"|'[^']*'|[^\\s'\">=]+(?=[\\s>]))","i"),lookbehind:!0,inside:{"attr-name":/^[^\s=]+/,"attr-value":{pattern:/=[\s\S]+/,inside:{value:{pattern:/(^=\s*(["']|(?!["'])))\S[\s\S]*(?=\2$)/,lookbehind:!0,alias:[e,"language-"+e],inside:Prism.languages[e]},punctuation:[{pattern:/^=/,alias:"attr-equals"},/"|'/]}}}})}}),Prism.languages.html=Prism.languages.markup,Prism.languages.mathml=Prism.languages.markup,Prism.languages.svg=Prism.languages.markup,Prism.languages.xml=Prism.languages.extend("markup",{}),Prism.languages.ssml=Prism.languages.xml,Prism.languages.atom=Prism.languages.xml,Prism.languages.rss=Prism.languages.xml; !function(e){function n(e,n){return"___"+e.toUpperCase()+n+"___"}Object.defineProperties(e.languages["markup-templating"]={},{buildPlaceholders:{value:function(t,a,r,o){if(t.language===a){var c=t.tokenStack=[];t.code=t.code.replace(r,(function(e){if("function"==typeof o&&!o(e))return e;for(var r,i=c.length;-1!==t.code.indexOf(r=n(a,i));)++i;return c[i]=e,r})),t.grammar=e.languages.markup}}},tokenizePlaceholders:{value:function(t,a){if(t.language===a&&t.tokenStack){t.grammar=e.languages[a];var r=0,o=Object.keys(t.tokenStack);!function c(i){for(var u=0;u=o.length);u++){var g=i[u];if("string"==typeof g||g.content&&"string"==typeof g.content){var l=o[r],s=t.tokenStack[l],f="string"==typeof g?g:g.content,p=n(a,l),k=f.indexOf(p);if(k>-1){++r;var m=f.substring(0,k),d=new e.Token(a,e.tokenize(s,t.grammar),"language-"+a,s),h=f.substring(k+p.length),v=[];m&&v.push.apply(v,c([m])),v.push(d),h&&v.push.apply(v,c([h])),"string"==typeof g?i.splice.apply(i,[u,1].concat(v)):g.content=v}}else g.content&&c(g.content)}return i}(t.tokens)}}}})}(Prism); !function(e){var a=/\/\*[\s\S]*?\*\/|\/\/.*|#(?!\[).*/,t=[{pattern:/\b(?:false|true)\b/i,alias:"boolean"},{pattern:/(::\s*)\b[a-z_]\w*\b(?!\s*\()/i,greedy:!0,lookbehind:!0},{pattern:/(\b(?:case|const)\s+)\b[a-z_]\w*(?=\s*[;=])/i,greedy:!0,lookbehind:!0},/\b(?:null)\b/i,/\b[A-Z_][A-Z0-9_]*\b(?!\s*\()/],i=/\b0b[01]+(?:_[01]+)*\b|\b0o[0-7]+(?:_[0-7]+)*\b|\b0x[\da-f]+(?:_[\da-f]+)*\b|(?:\b\d+(?:_\d+)*\.?(?:\d+(?:_\d+)*)?|\B\.\d+)(?:e[+-]?\d+)?/i,n=/|\?\?=?|\.{3}|\??->|[!=]=?=?|::|\*\*=?|--|\+\+|&&|\|\||<<|>>|[?~]|[/^|%*&<>.+-]=?/,s=/[{}\[\](),:;]/;e.languages.php={delimiter:{pattern:/\?>$|^<\?(?:php(?=\s)|=)?/i,alias:"important"},comment:a,variable:/\$+(?:\w+\b|(?=\{))/,package:{pattern:/(namespace\s+|use\s+(?:function\s+)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,lookbehind:!0,inside:{punctuation:/\\/}},"class-name-definition":{pattern:/(\b(?:class|enum|interface|trait)\s+)\b[a-z_]\w*(?!\\)\b/i,lookbehind:!0,alias:"class-name"},"function-definition":{pattern:/(\bfunction\s+)[a-z_]\w*(?=\s*\()/i,lookbehind:!0,alias:"function"},keyword:[{pattern:/(\(\s*)\b(?:array|bool|boolean|float|int|integer|object|string)\b(?=\s*\))/i,alias:"type-casting",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|object|self|static|string)\b(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b(?:array(?!\s*\()|bool|callable|(?:false|null)(?=\s*\|)|float|int|iterable|mixed|never|object|self|static|string|void)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/\b(?:array(?!\s*\()|bool|float|int|iterable|mixed|object|string|void)\b/i,alias:"type-declaration",greedy:!0},{pattern:/(\|\s*)(?:false|null)\b|\b(?:false|null)(?=\s*\|)/i,alias:"type-declaration",greedy:!0,lookbehind:!0},{pattern:/\b(?:parent|self|static)(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(\byield\s+)from\b/i,lookbehind:!0},/\bclass\b/i,{pattern:/((?:^|[^\s>:]|(?:^|[^-])>|(?:^|[^:]):)\s*)\b(?:abstract|and|array|as|break|callable|case|catch|clone|const|continue|declare|default|die|do|echo|else|elseif|empty|enddeclare|endfor|endforeach|endif|endswitch|endwhile|enum|eval|exit|extends|final|finally|fn|for|foreach|function|global|goto|if|implements|include|include_once|instanceof|insteadof|interface|isset|list|match|namespace|never|new|or|parent|print|private|protected|public|readonly|require|require_once|return|self|static|switch|throw|trait|try|unset|use|var|while|xor|yield|__halt_compiler)\b/i,lookbehind:!0}],"argument-name":{pattern:/([(,]\s*)\b[a-z_]\w*(?=\s*:(?!:))/i,lookbehind:!0},"class-name":[{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self|\s+static))\s+|\bcatch\s*\()\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/(\|\s*)\b[a-z_]\w*(?!\\)\b/i,greedy:!0,lookbehind:!0},{pattern:/\b[a-z_]\w*(?!\\)\b(?=\s*\|)/i,greedy:!0},{pattern:/(\|\s*)(?:\\?\b[a-z_]\w*)+\b/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(?:\\?\b[a-z_]\w*)+\b(?=\s*\|)/i,alias:"class-name-fully-qualified",greedy:!0,inside:{punctuation:/\\/}},{pattern:/(\b(?:extends|implements|instanceof|new(?!\s+self\b|\s+static\b))\s+|\bcatch\s*\()(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:"class-name-fully-qualified",greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*\$)/i,alias:"type-declaration",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-declaration"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/\b[a-z_]\w*(?=\s*::)/i,alias:"static-context",greedy:!0},{pattern:/(?:\\?\b[a-z_]\w*)+(?=\s*::)/i,alias:["class-name-fully-qualified","static-context"],greedy:!0,inside:{punctuation:/\\/}},{pattern:/([(,?]\s*)[a-z_]\w*(?=\s*\$)/i,alias:"type-hint",greedy:!0,lookbehind:!0},{pattern:/([(,?]\s*)(?:\\?\b[a-z_]\w*)+(?=\s*\$)/i,alias:["class-name-fully-qualified","type-hint"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}},{pattern:/(\)\s*:\s*(?:\?\s*)?)\b[a-z_]\w*(?!\\)\b/i,alias:"return-type",greedy:!0,lookbehind:!0},{pattern:/(\)\s*:\s*(?:\?\s*)?)(?:\\?\b[a-z_]\w*)+\b(?!\\)/i,alias:["class-name-fully-qualified","return-type"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:t,function:{pattern:/(^|[^\\\w])\\?[a-z_](?:[\w\\]*\w)?(?=\s*\()/i,lookbehind:!0,inside:{punctuation:/\\/}},property:{pattern:/(->\s*)\w+/,lookbehind:!0},number:i,operator:n,punctuation:s};var l={pattern:/\{\$(?:\{(?:\{[^{}]+\}|[^{}]+)\}|[^{}])+\}|(^|[^\\{])\$+(?:\w+(?:\[[^\r\n\[\]]+\]|->\w+)?)/,lookbehind:!0,inside:e.languages.php},r=[{pattern:/<<<'([^']+)'[\r\n](?:.*[\r\n])*?\1;/,alias:"nowdoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<'[^']+'|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<'?|[';]$/}}}},{pattern:/<<<(?:"([^"]+)"[\r\n](?:.*[\r\n])*?\1;|([a-z_]\w*)[\r\n](?:.*[\r\n])*?\2;)/i,alias:"heredoc-string",greedy:!0,inside:{delimiter:{pattern:/^<<<(?:"[^"]+"|[a-z_]\w*)|[a-z_]\w*;$/i,alias:"symbol",inside:{punctuation:/^<<<"?|[";]$/}},interpolation:l}},{pattern:/`(?:\\[\s\S]|[^\\`])*`/,alias:"backtick-quoted-string",greedy:!0},{pattern:/'(?:\\[\s\S]|[^\\'])*'/,alias:"single-quoted-string",greedy:!0},{pattern:/"(?:\\[\s\S]|[^\\"])*"/,alias:"double-quoted-string",greedy:!0,inside:{interpolation:l}}];e.languages.insertBefore("php","variable",{string:r,attribute:{pattern:/#\[(?:[^"'\/#]|\/(?![*/])|\/\/.*$|#(?!\[).*$|\/\*(?:[^*]|\*(?!\/))*\*\/|"(?:\\[\s\S]|[^\\"])*"|'(?:\\[\s\S]|[^\\'])*')+\](?=\s*[a-z$#])/im,greedy:!0,inside:{"attribute-content":{pattern:/^(#\[)[\s\S]+(?=\]$)/,lookbehind:!0,inside:{comment:a,string:r,"attribute-class-name":[{pattern:/([^:]|^)\b[a-z_]\w*(?!\\)\b/i,alias:"class-name",greedy:!0,lookbehind:!0},{pattern:/([^:]|^)(?:\\?\b[a-z_]\w*)+/i,alias:["class-name","class-name-fully-qualified"],greedy:!0,lookbehind:!0,inside:{punctuation:/\\/}}],constant:t,number:i,operator:n,punctuation:s}},delimiter:{pattern:/^#\[|\]$/,alias:"punctuation"}}}}),e.hooks.add("before-tokenize",(function(a){/<\?/.test(a.code)&&e.languages["markup-templating"].buildPlaceholders(a,"php",/<\?(?:[^"'/#]|\/(?![*/])|("|')(?:\\[\s\S]|(?!\1)[^\\])*\1|(?:\/\/|#(?!\[))(?:[^?\n\r]|\?(?!>))*(?=$|\?>|[\r\n])|#\[|\/\*(?:[^*]|\*(?!\/))*(?:\*\/|$))*?(?:\?>|$)/g)})),e.hooks.add("after-tokenize",(function(a){e.languages["markup-templating"].tokenizePlaceholders(a,"php")}))}(Prism); diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/whoops.base.js b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/whoops.base.js index 22a0d7bb23..ccce086798 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/whoops.base.js +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/whoops.base.js @@ -43,8 +43,11 @@ Zepto(function($) { }); var line = $activeFrame.find('.code-block .line-highlight').first()[0]; - line.scrollIntoView(); - line.parentElement.scrollTop -= 180; + // [internal] frames might not contain a code-block + if (line) { + line.scrollIntoView(); + line.parentElement.scrollTop -= 180; + } $container.scrollTop(0); } @@ -76,7 +79,7 @@ Zepto(function($) { }); - var clipboard = new Clipboard('.clipboard'); + var clipboard = new ClipboardJS('.clipboard'); var showTooltip = function(elem, msg) { elem.classList.add('tooltipped', 'tooltipped-s'); elem.setAttribute('aria-label', msg); @@ -183,6 +186,30 @@ Zepto(function($) { setActiveFramesTab($(this)); }); + // Open editor from code block rows number + $(document).delegate('.line-numbers-rows > span', 'click', function(e) { + var linkTag = $(this).closest('.frame-code').find('.editor-link'); + if (!linkTag) return; + var editorUrl = linkTag.attr('href'); + var requiresAjax = linkTag.data('ajax'); + + var lineOffset = $(this).closest('[data-line-offset]').data('line-offset'); + var lineNumber = lineOffset + $(this).index(); + + var realLine = $(this).closest('[data-line]').data('line'); + if (!realLine) return; + var fileUrl = editorUrl.replace( + new RegExp('([:=])' + realLine), + '$1' + lineNumber + ); + + if (requiresAjax) { + $.get(fileUrl); + } else { + $('').attr('href', fileUrl).trigger('click'); + } + }); + // Render late enough for highlightCurrentLine to be ready renderCurrentCodeblock(); }); diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/zepto.min.js b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/zepto.min.js index 0b2f97adbb..4821a1caee 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/zepto.min.js +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/js/zepto.min.js @@ -1,2 +1,2 @@ -/* Zepto v1.1.3 - zepto event ajax form ie - zeptojs.com/license */ -var Zepto=function(){function L(t){return null==t?String(t):j[T.call(t)]||"object"}function Z(t){return"function"==L(t)}function $(t){return null!=t&&t==t.window}function _(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function D(t){return"object"==L(t)}function R(t){return D(t)&&!$(t)&&Object.getPrototypeOf(t)==Object.prototype}function M(t){return"number"==typeof t.length}function k(t){return s.call(t,function(t){return null!=t})}function z(t){return t.length>0?n.fn.concat.apply([],t):t}function F(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function q(t){return t in f?f[t]:f[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function H(t,e){return"number"!=typeof e||c[F(t)]?e:e+"px"}function I(t){var e,n;return u[t]||(e=a.createElement(t),a.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),u[t]=n),u[t]}function V(t){return"children"in t?o.call(t.children):n.map(t.childNodes,function(t){return 1==t.nodeType?t:void 0})}function U(n,i,r){for(e in i)r&&(R(i[e])||A(i[e]))?(R(i[e])&&!R(n[e])&&(n[e]={}),A(i[e])&&!A(n[e])&&(n[e]=[]),U(n[e],i[e],r)):i[e]!==t&&(n[e]=i[e])}function B(t,e){return null==e?n(t):n(t).filter(e)}function J(t,e,n,i){return Z(e)?e.call(t,n,i):e}function X(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function W(e,n){var i=e.className,r=i&&i.baseVal!==t;return n===t?r?i.baseVal:i:void(r?i.baseVal=n:e.className=n)}function Y(t){var e;try{return t?"true"==t||("false"==t?!1:"null"==t?null:/^0/.test(t)||isNaN(e=Number(t))?/^[\[\{]/.test(t)?n.parseJSON(t):t:e):t}catch(i){return t}}function G(t,e){e(t);for(var n in t.childNodes)G(t.childNodes[n],e)}var t,e,n,i,C,N,r=[],o=r.slice,s=r.filter,a=window.document,u={},f={},c={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},l=/^\s*<(\w+|!)[^>]*>/,h=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,p=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,d=/^(?:body|html)$/i,m=/([A-Z])/g,g=["val","css","html","text","data","width","height","offset"],v=["after","prepend","before","append"],y=a.createElement("table"),x=a.createElement("tr"),b={tr:a.createElement("tbody"),tbody:y,thead:y,tfoot:y,td:x,th:x,"*":a.createElement("div")},w=/complete|loaded|interactive/,E=/^[\w-]*$/,j={},T=j.toString,S={},O=a.createElement("div"),P={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},A=Array.isArray||function(t){return t instanceof Array};return S.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var i,r=t.parentNode,o=!r;return o&&(r=O).appendChild(t),i=~S.qsa(r,e).indexOf(t),o&&O.removeChild(t),i},C=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},N=function(t){return s.call(t,function(e,n){return t.indexOf(e)==n})},S.fragment=function(e,i,r){var s,u,f;return h.test(e)&&(s=n(a.createElement(RegExp.$1))),s||(e.replace&&(e=e.replace(p,"<$1>")),i===t&&(i=l.test(e)&&RegExp.$1),i in b||(i="*"),f=b[i],f.innerHTML=""+e,s=n.each(o.call(f.childNodes),function(){f.removeChild(this)})),R(r)&&(u=n(s),n.each(r,function(t,e){g.indexOf(t)>-1?u[t](e):u.attr(t,e)})),s},S.Z=function(t,e){return t=t||[],t.__proto__=n.fn,t.selector=e||"",t},S.isZ=function(t){return t instanceof S.Z},S.init=function(e,i){var r;if(!e)return S.Z();if("string"==typeof e)if(e=e.trim(),"<"==e[0]&&l.test(e))r=S.fragment(e,RegExp.$1,i),e=null;else{if(i!==t)return n(i).find(e);r=S.qsa(a,e)}else{if(Z(e))return n(a).ready(e);if(S.isZ(e))return e;if(A(e))r=k(e);else if(D(e))r=[e],e=null;else if(l.test(e))r=S.fragment(e.trim(),RegExp.$1,i),e=null;else{if(i!==t)return n(i).find(e);r=S.qsa(a,e)}}return S.Z(r,e)},n=function(t,e){return S.init(t,e)},n.extend=function(t){var e,n=o.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){U(t,n,e)}),t},S.qsa=function(t,e){var n,i="#"==e[0],r=!i&&"."==e[0],s=i||r?e.slice(1):e,a=E.test(s);return _(t)&&a&&i?(n=t.getElementById(s))?[n]:[]:1!==t.nodeType&&9!==t.nodeType?[]:o.call(a&&!i?r?t.getElementsByClassName(s):t.getElementsByTagName(e):t.querySelectorAll(e))},n.contains=function(t,e){return t!==e&&t.contains(e)},n.type=L,n.isFunction=Z,n.isWindow=$,n.isArray=A,n.isPlainObject=R,n.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},n.inArray=function(t,e,n){return r.indexOf.call(e,t,n)},n.camelCase=C,n.trim=function(t){return null==t?"":String.prototype.trim.call(t)},n.uuid=0,n.support={},n.expr={},n.map=function(t,e){var n,r,o,i=[];if(M(t))for(r=0;r=0?e:e+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return r.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return Z(t)?this.not(this.not(t)):n(s.call(this,function(e){return S.matches(e,t)}))},add:function(t,e){return n(N(this.concat(n(t,e))))},is:function(t){return this.length>0&&S.matches(this[0],t)},not:function(e){var i=[];if(Z(e)&&e.call!==t)this.each(function(t){e.call(this,t)||i.push(this)});else{var r="string"==typeof e?this.filter(e):M(e)&&Z(e.item)?o.call(e):n(e);this.forEach(function(t){r.indexOf(t)<0&&i.push(t)})}return n(i)},has:function(t){return this.filter(function(){return D(t)?n.contains(this,t):n(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!D(t)?t:n(t)},last:function(){var t=this[this.length-1];return t&&!D(t)?t:n(t)},find:function(t){var e,i=this;return e="object"==typeof t?n(t).filter(function(){var t=this;return r.some.call(i,function(e){return n.contains(e,t)})}):1==this.length?n(S.qsa(this[0],t)):this.map(function(){return S.qsa(this,t)})},closest:function(t,e){var i=this[0],r=!1;for("object"==typeof t&&(r=n(t));i&&!(r?r.indexOf(i)>=0:S.matches(i,t));)i=i!==e&&!_(i)&&i.parentNode;return n(i)},parents:function(t){for(var e=[],i=this;i.length>0;)i=n.map(i,function(t){return(t=t.parentNode)&&!_(t)&&e.indexOf(t)<0?(e.push(t),t):void 0});return B(e,t)},parent:function(t){return B(N(this.pluck("parentNode")),t)},children:function(t){return B(this.map(function(){return V(this)}),t)},contents:function(){return this.map(function(){return o.call(this.childNodes)})},siblings:function(t){return B(this.map(function(t,e){return s.call(V(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return n.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=I(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=Z(t);if(this[0]&&!e)var i=n(t).get(0),r=i.parentNode||this.length>1;return this.each(function(o){n(this).wrapAll(e?t.call(this,o):r?i.cloneNode(!0):i)})},wrapAll:function(t){if(this[0]){n(this[0]).before(t=n(t));for(var e;(e=t.children()).length;)t=e.first();n(t).append(this)}return this},wrapInner:function(t){var e=Z(t);return this.each(function(i){var r=n(this),o=r.contents(),s=e?t.call(this,i):t;o.length?o.wrapAll(s):r.append(s)})},unwrap:function(){return this.parent().each(function(){n(this).replaceWith(n(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(e){return this.each(function(){var i=n(this);(e===t?"none"==i.css("display"):e)?i.show():i.hide()})},prev:function(t){return n(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return n(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0===arguments.length?this.length>0?this[0].innerHTML:null:this.each(function(e){var i=this.innerHTML;n(this).empty().append(J(this,t,e,i))})},text:function(e){return 0===arguments.length?this.length>0?this[0].textContent:null:this.each(function(){this.textContent=e===t?"":""+e})},attr:function(n,i){var r;return"string"==typeof n&&i===t?0==this.length||1!==this[0].nodeType?t:"value"==n&&"INPUT"==this[0].nodeName?this.val():!(r=this[0].getAttribute(n))&&n in this[0]?this[0][n]:r:this.each(function(t){if(1===this.nodeType)if(D(n))for(e in n)X(this,e,n[e]);else X(this,n,J(this,i,t,this.getAttribute(n)))})},removeAttr:function(t){return this.each(function(){1===this.nodeType&&X(this,t)})},prop:function(e,n){return e=P[e]||e,n===t?this[0]&&this[0][e]:this.each(function(t){this[e]=J(this,n,t,this[e])})},data:function(e,n){var i=this.attr("data-"+e.replace(m,"-$1").toLowerCase(),n);return null!==i?Y(i):t},val:function(t){return 0===arguments.length?this[0]&&(this[0].multiple?n(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value):this.each(function(e){this.value=J(this,t,e,this.value)})},offset:function(t){if(t)return this.each(function(e){var i=n(this),r=J(this,t,e,i.offset()),o=i.offsetParent().offset(),s={top:r.top-o.top,left:r.left-o.left};"static"==i.css("position")&&(s.position="relative"),i.css(s)});if(0==this.length)return null;var e=this[0].getBoundingClientRect();return{left:e.left+window.pageXOffset,top:e.top+window.pageYOffset,width:Math.round(e.width),height:Math.round(e.height)}},css:function(t,i){if(arguments.length<2){var r=this[0],o=getComputedStyle(r,"");if(!r)return;if("string"==typeof t)return r.style[C(t)]||o.getPropertyValue(t);if(A(t)){var s={};return n.each(A(t)?t:[t],function(t,e){s[e]=r.style[C(e)]||o.getPropertyValue(e)}),s}}var a="";if("string"==L(t))i||0===i?a=F(t)+":"+H(t,i):this.each(function(){this.style.removeProperty(F(t))});else for(e in t)t[e]||0===t[e]?a+=F(e)+":"+H(e,t[e])+";":this.each(function(){this.style.removeProperty(F(e))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(n(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return t?r.some.call(this,function(t){return this.test(W(t))},q(t)):!1},addClass:function(t){return t?this.each(function(e){i=[];var r=W(this),o=J(this,t,e,r);o.split(/\s+/g).forEach(function(t){n(this).hasClass(t)||i.push(t)},this),i.length&&W(this,r+(r?" ":"")+i.join(" "))}):this},removeClass:function(e){return this.each(function(n){return e===t?W(this,""):(i=W(this),J(this,e,n,i).split(/\s+/g).forEach(function(t){i=i.replace(q(t)," ")}),void W(this,i.trim()))})},toggleClass:function(e,i){return e?this.each(function(r){var o=n(this),s=J(this,e,r,W(this));s.split(/\s+/g).forEach(function(e){(i===t?!o.hasClass(e):i)?o.addClass(e):o.removeClass(e)})}):this},scrollTop:function(e){if(this.length){var n="scrollTop"in this[0];return e===t?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=e}:function(){this.scrollTo(this.scrollX,e)})}},scrollLeft:function(e){if(this.length){var n="scrollLeft"in this[0];return e===t?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=e}:function(){this.scrollTo(e,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),i=this.offset(),r=d.test(e[0].nodeName)?{top:0,left:0}:e.offset();return i.top-=parseFloat(n(t).css("margin-top"))||0,i.left-=parseFloat(n(t).css("margin-left"))||0,r.top+=parseFloat(n(e[0]).css("border-top-width"))||0,r.left+=parseFloat(n(e[0]).css("border-left-width"))||0,{top:i.top-r.top,left:i.left-r.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||a.body;t&&!d.test(t.nodeName)&&"static"==n(t).css("position");)t=t.offsetParent;return t})}},n.fn.detach=n.fn.remove,["width","height"].forEach(function(e){var i=e.replace(/./,function(t){return t[0].toUpperCase()});n.fn[e]=function(r){var o,s=this[0];return r===t?$(s)?s["inner"+i]:_(s)?s.documentElement["scroll"+i]:(o=this.offset())&&o[e]:this.each(function(t){s=n(this),s.css(e,J(this,r,t,s[e]()))})}}),v.forEach(function(t,e){var i=e%2;n.fn[t]=function(){var t,o,r=n.map(arguments,function(e){return t=L(e),"object"==t||"array"==t||null==e?e:S.fragment(e)}),s=this.length>1;return r.length<1?this:this.each(function(t,a){o=i?a:a.parentNode,a=0==e?a.nextSibling:1==e?a.firstChild:2==e?a:null,r.forEach(function(t){if(s)t=t.cloneNode(!0);else if(!o)return n(t).remove();G(o.insertBefore(t,a),function(t){null==t.nodeName||"SCRIPT"!==t.nodeName.toUpperCase()||t.type&&"text/javascript"!==t.type||t.src||window.eval.call(window,t.innerHTML)})})})},n.fn[i?t+"To":"insert"+(e?"Before":"After")]=function(e){return n(e)[t](this),this}}),S.Z.prototype=n.fn,S.uniq=N,S.deserializeValue=Y,n.zepto=S,n}();window.Zepto=Zepto,void 0===window.$&&(window.$=Zepto),function(t){function l(t){return t._zid||(t._zid=e++)}function h(t,e,n,i){if(e=p(e),e.ns)var r=d(e.ns);return(s[l(t)]||[]).filter(function(t){return!(!t||e.e&&t.e!=e.e||e.ns&&!r.test(t.ns)||n&&l(t.fn)!==l(n)||i&&t.sel!=i)})}function p(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function d(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function m(t,e){return t.del&&!u&&t.e in f||!!e}function g(t){return c[t]||u&&f[t]||t}function v(e,i,r,o,a,u,f){var h=l(e),d=s[h]||(s[h]=[]);i.split(/\s/).forEach(function(i){if("ready"==i)return t(document).ready(r);var s=p(i);s.fn=r,s.sel=a,s.e in c&&(r=function(e){var n=e.relatedTarget;return!n||n!==this&&!t.contains(this,n)?s.fn.apply(this,arguments):void 0}),s.del=u;var l=u||r;s.proxy=function(t){if(t=j(t),!t.isImmediatePropagationStopped()){t.data=o;var i=l.apply(e,t._args==n?[t]:[t].concat(t._args));return i===!1&&(t.preventDefault(),t.stopPropagation()),i}},s.i=d.length,d.push(s),"addEventListener"in e&&e.addEventListener(g(s.e),s.proxy,m(s,f))})}function y(t,e,n,i,r){var o=l(t);(e||"").split(/\s/).forEach(function(e){h(t,e,n,i).forEach(function(e){delete s[o][e.i],"removeEventListener"in t&&t.removeEventListener(g(e.e),e.proxy,m(e,r))})})}function j(e,i){return(i||!e.isDefaultPrevented)&&(i||(i=e),t.each(E,function(t,n){var r=i[t];e[t]=function(){return this[n]=x,r&&r.apply(i,arguments)},e[n]=b}),(i.defaultPrevented!==n?i.defaultPrevented:"returnValue"in i?i.returnValue===!1:i.getPreventDefault&&i.getPreventDefault())&&(e.isDefaultPrevented=x)),e}function T(t){var e,i={originalEvent:t};for(e in t)w.test(e)||t[e]===n||(i[e]=t[e]);return j(i,t)}var n,e=1,i=Array.prototype.slice,r=t.isFunction,o=function(t){return"string"==typeof t},s={},a={},u="onfocusin"in window,f={focus:"focusin",blur:"focusout"},c={mouseenter:"mouseover",mouseleave:"mouseout"};a.click=a.mousedown=a.mouseup=a.mousemove="MouseEvents",t.event={add:v,remove:y},t.proxy=function(e,n){if(r(e)){var i=function(){return e.apply(n,arguments)};return i._zid=l(e),i}if(o(n))return t.proxy(e[n],e);throw new TypeError("expected function")},t.fn.bind=function(t,e,n){return this.on(t,e,n)},t.fn.unbind=function(t,e){return this.off(t,e)},t.fn.one=function(t,e,n,i){return this.on(t,e,n,i,1)};var x=function(){return!0},b=function(){return!1},w=/^([A-Z]|returnValue$|layer[XY]$)/,E={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};t.fn.delegate=function(t,e,n){return this.on(e,t,n)},t.fn.undelegate=function(t,e,n){return this.off(e,t,n)},t.fn.live=function(e,n){return t(document.body).delegate(this.selector,e,n),this},t.fn.die=function(e,n){return t(document.body).undelegate(this.selector,e,n),this},t.fn.on=function(e,s,a,u,f){var c,l,h=this;return e&&!o(e)?(t.each(e,function(t,e){h.on(t,s,a,e,f)}),h):(o(s)||r(u)||u===!1||(u=a,a=s,s=n),(r(a)||a===!1)&&(u=a,a=n),u===!1&&(u=b),h.each(function(n,r){f&&(c=function(t){return y(r,t.type,u),u.apply(this,arguments)}),s&&(l=function(e){var n,o=t(e.target).closest(s,r).get(0);return o&&o!==r?(n=t.extend(T(e),{currentTarget:o,liveFired:r}),(c||u).apply(o,[n].concat(i.call(arguments,1)))):void 0}),v(r,e,u,a,s,l||c)}))},t.fn.off=function(e,i,s){var a=this;return e&&!o(e)?(t.each(e,function(t,e){a.off(t,i,e)}),a):(o(i)||r(s)||s===!1||(s=i,i=n),s===!1&&(s=b),a.each(function(){y(this,e,s,i)}))},t.fn.trigger=function(e,n){return e=o(e)||t.isPlainObject(e)?t.Event(e):j(e),e._args=n,this.each(function(){"dispatchEvent"in this?this.dispatchEvent(e):t(this).triggerHandler(e,n)})},t.fn.triggerHandler=function(e,n){var i,r;return this.each(function(s,a){i=T(o(e)?t.Event(e):e),i._args=n,i.target=a,t.each(h(a,e.type||e),function(t,e){return r=e.proxy(i),i.isImmediatePropagationStopped()?!1:void 0})}),r},"focusin focusout load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(e){t.fn[e]=function(t){return t?this.bind(e,t):this.trigger(e)}}),["focus","blur"].forEach(function(e){t.fn[e]=function(t){return t?this.bind(e,t):this.each(function(){try{this[e]()}catch(t){}}),this}}),t.Event=function(t,e){o(t)||(e=t,t=e.type);var n=document.createEvent(a[t]||"Events"),i=!0;if(e)for(var r in e)"bubbles"==r?i=!!e[r]:n[r]=e[r];return n.initEvent(t,i,!0),j(n)}}(Zepto),function(t){function l(e,n,i){var r=t.Event(n);return t(e).trigger(r,i),!r.isDefaultPrevented()}function h(t,e,i,r){return t.global?l(e||n,i,r):void 0}function p(e){e.global&&0===t.active++&&h(e,null,"ajaxStart")}function d(e){e.global&&!--t.active&&h(e,null,"ajaxStop")}function m(t,e){var n=e.context;return e.beforeSend.call(n,t,e)===!1||h(e,n,"ajaxBeforeSend",[t,e])===!1?!1:void h(e,n,"ajaxSend",[t,e])}function g(t,e,n,i){var r=n.context,o="success";n.success.call(r,t,o,e),i&&i.resolveWith(r,[t,o,e]),h(n,r,"ajaxSuccess",[e,n,t]),y(o,e,n)}function v(t,e,n,i,r){var o=i.context;i.error.call(o,n,e,t),r&&r.rejectWith(o,[n,e,t]),h(i,o,"ajaxError",[n,i,t||e]),y(e,n,i)}function y(t,e,n){var i=n.context;n.complete.call(i,e,t),h(n,i,"ajaxComplete",[e,n]),d(n)}function x(){}function b(t){return t&&(t=t.split(";",2)[0]),t&&(t==f?"html":t==u?"json":s.test(t)?"script":a.test(t)&&"xml")||"text"}function w(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function E(e){e.processData&&e.data&&"string"!=t.type(e.data)&&(e.data=t.param(e.data,e.traditional)),!e.data||e.type&&"GET"!=e.type.toUpperCase()||(e.url=w(e.url,e.data),e.data=void 0)}function j(e,n,i,r){return t.isFunction(n)&&(r=i,i=n,n=void 0),t.isFunction(i)||(r=i,i=void 0),{url:e,data:n,success:i,dataType:r}}function S(e,n,i,r){var o,s=t.isArray(n),a=t.isPlainObject(n);t.each(n,function(n,u){o=t.type(u),r&&(n=i?r:r+"["+(a||"object"==o||"array"==o?n:"")+"]"),!r&&s?e.add(u.name,u.value):"array"==o||!i&&"object"==o?S(e,u,i,n):e.add(n,u)})}var i,r,e=0,n=window.document,o=/)<[^<]*)*<\/script>/gi,s=/^(?:text|application)\/javascript/i,a=/^(?:text|application)\/xml/i,u="application/json",f="text/html",c=/^\s*$/;t.active=0,t.ajaxJSONP=function(i,r){if(!("type"in i))return t.ajax(i);var f,h,o=i.jsonpCallback,s=(t.isFunction(o)?o():o)||"jsonp"+ ++e,a=n.createElement("script"),u=window[s],c=function(e){t(a).triggerHandler("error",e||"abort")},l={abort:c};return r&&r.promise(l),t(a).on("load error",function(e,n){clearTimeout(h),t(a).off().remove(),"error"!=e.type&&f?g(f[0],l,i,r):v(null,n||"error",l,i,r),window[s]=u,f&&t.isFunction(u)&&u(f[0]),u=f=void 0}),m(l,i)===!1?(c("abort"),l):(window[s]=function(){f=arguments},a.src=i.url.replace(/\?(.+)=\?/,"?$1="+s),n.head.appendChild(a),i.timeout>0&&(h=setTimeout(function(){c("timeout")},i.timeout)),l)},t.ajaxSettings={type:"GET",beforeSend:x,success:x,error:x,complete:x,context:null,global:!0,xhr:function(){return new window.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:u,xml:"application/xml, text/xml",html:f,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0},t.ajax=function(e){var n=t.extend({},e||{}),o=t.Deferred&&t.Deferred();for(i in t.ajaxSettings)void 0===n[i]&&(n[i]=t.ajaxSettings[i]);p(n),n.crossDomain||(n.crossDomain=/^([\w-]+:)?\/\/([^\/]+)/.test(n.url)&&RegExp.$2!=window.location.host),n.url||(n.url=window.location.toString()),E(n),n.cache===!1&&(n.url=w(n.url,"_="+Date.now()));var s=n.dataType,a=/\?.+=\?/.test(n.url);if("jsonp"==s||a)return a||(n.url=w(n.url,n.jsonp?n.jsonp+"=?":n.jsonp===!1?"":"callback=?")),t.ajaxJSONP(n,o);var j,u=n.accepts[s],f={},l=function(t,e){f[t.toLowerCase()]=[t,e]},h=/^([\w-]+:)\/\//.test(n.url)?RegExp.$1:window.location.protocol,d=n.xhr(),y=d.setRequestHeader;if(o&&o.promise(d),n.crossDomain||l("X-Requested-With","XMLHttpRequest"),l("Accept",u||"*/*"),(u=n.mimeType||u)&&(u.indexOf(",")>-1&&(u=u.split(",",2)[0]),d.overrideMimeType&&d.overrideMimeType(u)),(n.contentType||n.contentType!==!1&&n.data&&"GET"!=n.type.toUpperCase())&&l("Content-Type",n.contentType||"application/x-www-form-urlencoded"),n.headers)for(r in n.headers)l(r,n.headers[r]);if(d.setRequestHeader=l,d.onreadystatechange=function(){if(4==d.readyState){d.onreadystatechange=x,clearTimeout(j);var e,i=!1;if(d.status>=200&&d.status<300||304==d.status||0==d.status&&"file:"==h){s=s||b(n.mimeType||d.getResponseHeader("content-type")),e=d.responseText;try{"script"==s?(1,eval)(e):"xml"==s?e=d.responseXML:"json"==s&&(e=c.test(e)?null:t.parseJSON(e))}catch(r){i=r}i?v(i,"parsererror",d,n,o):g(e,d,n,o)}else v(d.statusText||null,d.status?"error":"abort",d,n,o)}},m(d,n)===!1)return d.abort(),v(null,"abort",d,n,o),d;if(n.xhrFields)for(r in n.xhrFields)d[r]=n.xhrFields[r];var T="async"in n?n.async:!0;d.open(n.type,n.url,T,n.username,n.password);for(r in f)y.apply(d,f[r]);return n.timeout>0&&(j=setTimeout(function(){d.onreadystatechange=x,d.abort(),v(null,"timeout",d,n,o)},n.timeout)),d.send(n.data?n.data:null),d},t.get=function(){return t.ajax(j.apply(null,arguments))},t.post=function(){var e=j.apply(null,arguments);return e.type="POST",t.ajax(e)},t.getJSON=function(){var e=j.apply(null,arguments);return e.dataType="json",t.ajax(e)},t.fn.load=function(e,n,i){if(!this.length)return this;var a,r=this,s=e.split(/\s/),u=j(e,n,i),f=u.success;return s.length>1&&(u.url=s[0],a=s[1]),u.success=function(e){r.html(a?t("
").html(e.replace(o,"")).find(a):e),f&&f.apply(r,arguments)},t.ajax(u),this};var T=encodeURIComponent;t.param=function(t,e){var n=[];return n.add=function(t,e){this.push(T(t)+"="+T(e))},S(n,t,e),n.join("&").replace(/%20/g,"+")}}(Zepto),function(t){t.fn.serializeArray=function(){var n,e=[];return t([].slice.call(this.get(0).elements)).each(function(){n=t(this);var i=n.attr("type");"fieldset"!=this.nodeName.toLowerCase()&&!this.disabled&&"submit"!=i&&"reset"!=i&&"button"!=i&&("radio"!=i&&"checkbox"!=i||this.checked)&&e.push({name:n.attr("name"),value:n.val()})}),e},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(e)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(Zepto),function(t){"__proto__"in{}||t.extend(t.zepto,{Z:function(e,n){return e=e||[],t.extend(e,t.fn),e.selector=n||"",e.__Z=!0,e},isZ:function(e){return"array"===t.type(e)&&"__Z"in e}});try{getComputedStyle(void 0)}catch(e){var n=getComputedStyle;window.getComputedStyle=function(t){try{return n(t)}catch(e){return null}}}}(Zepto); +/* Zepto v1.2.0 - zepto event ajax form ie - zeptojs.com/license */ +!function(t,e){"function"==typeof define&&define.amd?define(function(){return e(t)}):e(t)}(this,function(t){var e=function(){function $(t){return null==t?String(t):S[C.call(t)]||"object"}function F(t){return"function"==$(t)}function k(t){return null!=t&&t==t.window}function M(t){return null!=t&&t.nodeType==t.DOCUMENT_NODE}function R(t){return"object"==$(t)}function Z(t){return R(t)&&!k(t)&&Object.getPrototypeOf(t)==Object.prototype}function z(t){var e=!!t&&"length"in t&&t.length,n=r.type(t);return"function"!=n&&!k(t)&&("array"==n||0===e||"number"==typeof e&&e>0&&e-1 in t)}function q(t){return a.call(t,function(t){return null!=t})}function H(t){return t.length>0?r.fn.concat.apply([],t):t}function I(t){return t.replace(/::/g,"/").replace(/([A-Z]+)([A-Z][a-z])/g,"$1_$2").replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/_/g,"-").toLowerCase()}function V(t){return t in l?l[t]:l[t]=new RegExp("(^|\\s)"+t+"(\\s|$)")}function _(t,e){return"number"!=typeof e||h[I(t)]?e:e+"px"}function B(t){var e,n;return c[t]||(e=f.createElement(t),f.body.appendChild(e),n=getComputedStyle(e,"").getPropertyValue("display"),e.parentNode.removeChild(e),"none"==n&&(n="block"),c[t]=n),c[t]}function U(t){return"children"in t?u.call(t.children):r.map(t.childNodes,function(t){return 1==t.nodeType?t:void 0})}function X(t,e){var n,r=t?t.length:0;for(n=0;r>n;n++)this[n]=t[n];this.length=r,this.selector=e||""}function J(t,r,i){for(n in r)i&&(Z(r[n])||L(r[n]))?(Z(r[n])&&!Z(t[n])&&(t[n]={}),L(r[n])&&!L(t[n])&&(t[n]=[]),J(t[n],r[n],i)):r[n]!==e&&(t[n]=r[n])}function W(t,e){return null==e?r(t):r(t).filter(e)}function Y(t,e,n,r){return F(e)?e.call(t,n,r):e}function G(t,e,n){null==n?t.removeAttribute(e):t.setAttribute(e,n)}function K(t,n){var r=t.className||"",i=r&&r.baseVal!==e;return n===e?i?r.baseVal:r:void(i?r.baseVal=n:t.className=n)}function Q(t){try{return t?"true"==t||("false"==t?!1:"null"==t?null:+t+""==t?+t:/^[\[\{]/.test(t)?r.parseJSON(t):t):t}catch(e){return t}}function tt(t,e){e(t);for(var n=0,r=t.childNodes.length;r>n;n++)tt(t.childNodes[n],e)}var e,n,r,i,O,P,o=[],s=o.concat,a=o.filter,u=o.slice,f=t.document,c={},l={},h={"column-count":1,columns:1,"font-weight":1,"line-height":1,opacity:1,"z-index":1,zoom:1},p=/^\s*<(\w+|!)[^>]*>/,d=/^<(\w+)\s*\/?>(?:<\/\1>|)$/,m=/<(?!area|br|col|embed|hr|img|input|link|meta|param)(([\w:]+)[^>]*)\/>/gi,g=/^(?:body|html)$/i,v=/([A-Z])/g,y=["val","css","html","text","data","width","height","offset"],x=["after","prepend","before","append"],b=f.createElement("table"),E=f.createElement("tr"),j={tr:f.createElement("tbody"),tbody:b,thead:b,tfoot:b,td:E,th:E,"*":f.createElement("div")},w=/complete|loaded|interactive/,T=/^[\w-]*$/,S={},C=S.toString,N={},A=f.createElement("div"),D={tabindex:"tabIndex",readonly:"readOnly","for":"htmlFor","class":"className",maxlength:"maxLength",cellspacing:"cellSpacing",cellpadding:"cellPadding",rowspan:"rowSpan",colspan:"colSpan",usemap:"useMap",frameborder:"frameBorder",contenteditable:"contentEditable"},L=Array.isArray||function(t){return t instanceof Array};return N.matches=function(t,e){if(!e||!t||1!==t.nodeType)return!1;var n=t.matches||t.webkitMatchesSelector||t.mozMatchesSelector||t.oMatchesSelector||t.matchesSelector;if(n)return n.call(t,e);var r,i=t.parentNode,o=!i;return o&&(i=A).appendChild(t),r=~N.qsa(i,e).indexOf(t),o&&A.removeChild(t),r},O=function(t){return t.replace(/-+(.)?/g,function(t,e){return e?e.toUpperCase():""})},P=function(t){return a.call(t,function(e,n){return t.indexOf(e)==n})},N.fragment=function(t,n,i){var o,s,a;return d.test(t)&&(o=r(f.createElement(RegExp.$1))),o||(t.replace&&(t=t.replace(m,"<$1>")),n===e&&(n=p.test(t)&&RegExp.$1),n in j||(n="*"),a=j[n],a.innerHTML=""+t,o=r.each(u.call(a.childNodes),function(){a.removeChild(this)})),Z(i)&&(s=r(o),r.each(i,function(t,e){y.indexOf(t)>-1?s[t](e):s.attr(t,e)})),o},N.Z=function(t,e){return new X(t,e)},N.isZ=function(t){return t instanceof N.Z},N.init=function(t,n){var i;if(!t)return N.Z();if("string"==typeof t)if(t=t.trim(),"<"==t[0]&&p.test(t))i=N.fragment(t,RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}else{if(F(t))return r(f).ready(t);if(N.isZ(t))return t;if(L(t))i=q(t);else if(R(t))i=[t],t=null;else if(p.test(t))i=N.fragment(t.trim(),RegExp.$1,n),t=null;else{if(n!==e)return r(n).find(t);i=N.qsa(f,t)}}return N.Z(i,t)},r=function(t,e){return N.init(t,e)},r.extend=function(t){var e,n=u.call(arguments,1);return"boolean"==typeof t&&(e=t,t=n.shift()),n.forEach(function(n){J(t,n,e)}),t},N.qsa=function(t,e){var n,r="#"==e[0],i=!r&&"."==e[0],o=r||i?e.slice(1):e,s=T.test(o);return t.getElementById&&s&&r?(n=t.getElementById(o))?[n]:[]:1!==t.nodeType&&9!==t.nodeType&&11!==t.nodeType?[]:u.call(s&&!r&&t.getElementsByClassName?i?t.getElementsByClassName(o):t.getElementsByTagName(e):t.querySelectorAll(e))},r.contains=f.documentElement.contains?function(t,e){return t!==e&&t.contains(e)}:function(t,e){for(;e&&(e=e.parentNode);)if(e===t)return!0;return!1},r.type=$,r.isFunction=F,r.isWindow=k,r.isArray=L,r.isPlainObject=Z,r.isEmptyObject=function(t){var e;for(e in t)return!1;return!0},r.isNumeric=function(t){var e=Number(t),n=typeof t;return null!=t&&"boolean"!=n&&("string"!=n||t.length)&&!isNaN(e)&&isFinite(e)||!1},r.inArray=function(t,e,n){return o.indexOf.call(e,t,n)},r.camelCase=O,r.trim=function(t){return null==t?"":String.prototype.trim.call(t)},r.uuid=0,r.support={},r.expr={},r.noop=function(){},r.map=function(t,e){var n,i,o,r=[];if(z(t))for(i=0;i=0?t:t+this.length]},toArray:function(){return this.get()},size:function(){return this.length},remove:function(){return this.each(function(){null!=this.parentNode&&this.parentNode.removeChild(this)})},each:function(t){return o.every.call(this,function(e,n){return t.call(e,n,e)!==!1}),this},filter:function(t){return F(t)?this.not(this.not(t)):r(a.call(this,function(e){return N.matches(e,t)}))},add:function(t,e){return r(P(this.concat(r(t,e))))},is:function(t){return this.length>0&&N.matches(this[0],t)},not:function(t){var n=[];if(F(t)&&t.call!==e)this.each(function(e){t.call(this,e)||n.push(this)});else{var i="string"==typeof t?this.filter(t):z(t)&&F(t.item)?u.call(t):r(t);this.forEach(function(t){i.indexOf(t)<0&&n.push(t)})}return r(n)},has:function(t){return this.filter(function(){return R(t)?r.contains(this,t):r(this).find(t).size()})},eq:function(t){return-1===t?this.slice(t):this.slice(t,+t+1)},first:function(){var t=this[0];return t&&!R(t)?t:r(t)},last:function(){var t=this[this.length-1];return t&&!R(t)?t:r(t)},find:function(t){var e,n=this;return e=t?"object"==typeof t?r(t).filter(function(){var t=this;return o.some.call(n,function(e){return r.contains(e,t)})}):1==this.length?r(N.qsa(this[0],t)):this.map(function(){return N.qsa(this,t)}):r()},closest:function(t,e){var n=[],i="object"==typeof t&&r(t);return this.each(function(r,o){for(;o&&!(i?i.indexOf(o)>=0:N.matches(o,t));)o=o!==e&&!M(o)&&o.parentNode;o&&n.indexOf(o)<0&&n.push(o)}),r(n)},parents:function(t){for(var e=[],n=this;n.length>0;)n=r.map(n,function(t){return(t=t.parentNode)&&!M(t)&&e.indexOf(t)<0?(e.push(t),t):void 0});return W(e,t)},parent:function(t){return W(P(this.pluck("parentNode")),t)},children:function(t){return W(this.map(function(){return U(this)}),t)},contents:function(){return this.map(function(){return this.contentDocument||u.call(this.childNodes)})},siblings:function(t){return W(this.map(function(t,e){return a.call(U(e.parentNode),function(t){return t!==e})}),t)},empty:function(){return this.each(function(){this.innerHTML=""})},pluck:function(t){return r.map(this,function(e){return e[t]})},show:function(){return this.each(function(){"none"==this.style.display&&(this.style.display=""),"none"==getComputedStyle(this,"").getPropertyValue("display")&&(this.style.display=B(this.nodeName))})},replaceWith:function(t){return this.before(t).remove()},wrap:function(t){var e=F(t);if(this[0]&&!e)var n=r(t).get(0),i=n.parentNode||this.length>1;return this.each(function(o){r(this).wrapAll(e?t.call(this,o):i?n.cloneNode(!0):n)})},wrapAll:function(t){if(this[0]){r(this[0]).before(t=r(t));for(var e;(e=t.children()).length;)t=e.first();r(t).append(this)}return this},wrapInner:function(t){var e=F(t);return this.each(function(n){var i=r(this),o=i.contents(),s=e?t.call(this,n):t;o.length?o.wrapAll(s):i.append(s)})},unwrap:function(){return this.parent().each(function(){r(this).replaceWith(r(this).children())}),this},clone:function(){return this.map(function(){return this.cloneNode(!0)})},hide:function(){return this.css("display","none")},toggle:function(t){return this.each(function(){var n=r(this);(t===e?"none"==n.css("display"):t)?n.show():n.hide()})},prev:function(t){return r(this.pluck("previousElementSibling")).filter(t||"*")},next:function(t){return r(this.pluck("nextElementSibling")).filter(t||"*")},html:function(t){return 0 in arguments?this.each(function(e){var n=this.innerHTML;r(this).empty().append(Y(this,t,e,n))}):0 in this?this[0].innerHTML:null},text:function(t){return 0 in arguments?this.each(function(e){var n=Y(this,t,e,this.textContent);this.textContent=null==n?"":""+n}):0 in this?this.pluck("textContent").join(""):null},attr:function(t,r){var i;return"string"!=typeof t||1 in arguments?this.each(function(e){if(1===this.nodeType)if(R(t))for(n in t)G(this,n,t[n]);else G(this,t,Y(this,r,e,this.getAttribute(t)))}):0 in this&&1==this[0].nodeType&&null!=(i=this[0].getAttribute(t))?i:e},removeAttr:function(t){return this.each(function(){1===this.nodeType&&t.split(" ").forEach(function(t){G(this,t)},this)})},prop:function(t,e){return t=D[t]||t,1 in arguments?this.each(function(n){this[t]=Y(this,e,n,this[t])}):this[0]&&this[0][t]},removeProp:function(t){return t=D[t]||t,this.each(function(){delete this[t]})},data:function(t,n){var r="data-"+t.replace(v,"-$1").toLowerCase(),i=1 in arguments?this.attr(r,n):this.attr(r);return null!==i?Q(i):e},val:function(t){return 0 in arguments?(null==t&&(t=""),this.each(function(e){this.value=Y(this,t,e,this.value)})):this[0]&&(this[0].multiple?r(this[0]).find("option").filter(function(){return this.selected}).pluck("value"):this[0].value)},offset:function(e){if(e)return this.each(function(t){var n=r(this),i=Y(this,e,t,n.offset()),o=n.offsetParent().offset(),s={top:i.top-o.top,left:i.left-o.left};"static"==n.css("position")&&(s.position="relative"),n.css(s)});if(!this.length)return null;if(f.documentElement!==this[0]&&!r.contains(f.documentElement,this[0]))return{top:0,left:0};var n=this[0].getBoundingClientRect();return{left:n.left+t.pageXOffset,top:n.top+t.pageYOffset,width:Math.round(n.width),height:Math.round(n.height)}},css:function(t,e){if(arguments.length<2){var i=this[0];if("string"==typeof t){if(!i)return;return i.style[O(t)]||getComputedStyle(i,"").getPropertyValue(t)}if(L(t)){if(!i)return;var o={},s=getComputedStyle(i,"");return r.each(t,function(t,e){o[e]=i.style[O(e)]||s.getPropertyValue(e)}),o}}var a="";if("string"==$(t))e||0===e?a=I(t)+":"+_(t,e):this.each(function(){this.style.removeProperty(I(t))});else for(n in t)t[n]||0===t[n]?a+=I(n)+":"+_(n,t[n])+";":this.each(function(){this.style.removeProperty(I(n))});return this.each(function(){this.style.cssText+=";"+a})},index:function(t){return t?this.indexOf(r(t)[0]):this.parent().children().indexOf(this[0])},hasClass:function(t){return t?o.some.call(this,function(t){return this.test(K(t))},V(t)):!1},addClass:function(t){return t?this.each(function(e){if("className"in this){i=[];var n=K(this),o=Y(this,t,e,n);o.split(/\s+/g).forEach(function(t){r(this).hasClass(t)||i.push(t)},this),i.length&&K(this,n+(n?" ":"")+i.join(" "))}}):this},removeClass:function(t){return this.each(function(n){if("className"in this){if(t===e)return K(this,"");i=K(this),Y(this,t,n,i).split(/\s+/g).forEach(function(t){i=i.replace(V(t)," ")}),K(this,i.trim())}})},toggleClass:function(t,n){return t?this.each(function(i){var o=r(this),s=Y(this,t,i,K(this));s.split(/\s+/g).forEach(function(t){(n===e?!o.hasClass(t):n)?o.addClass(t):o.removeClass(t)})}):this},scrollTop:function(t){if(this.length){var n="scrollTop"in this[0];return t===e?n?this[0].scrollTop:this[0].pageYOffset:this.each(n?function(){this.scrollTop=t}:function(){this.scrollTo(this.scrollX,t)})}},scrollLeft:function(t){if(this.length){var n="scrollLeft"in this[0];return t===e?n?this[0].scrollLeft:this[0].pageXOffset:this.each(n?function(){this.scrollLeft=t}:function(){this.scrollTo(t,this.scrollY)})}},position:function(){if(this.length){var t=this[0],e=this.offsetParent(),n=this.offset(),i=g.test(e[0].nodeName)?{top:0,left:0}:e.offset();return n.top-=parseFloat(r(t).css("margin-top"))||0,n.left-=parseFloat(r(t).css("margin-left"))||0,i.top+=parseFloat(r(e[0]).css("border-top-width"))||0,i.left+=parseFloat(r(e[0]).css("border-left-width"))||0,{top:n.top-i.top,left:n.left-i.left}}},offsetParent:function(){return this.map(function(){for(var t=this.offsetParent||f.body;t&&!g.test(t.nodeName)&&"static"==r(t).css("position");)t=t.offsetParent;return t})}},r.fn.detach=r.fn.remove,["width","height"].forEach(function(t){var n=t.replace(/./,function(t){return t[0].toUpperCase()});r.fn[t]=function(i){var o,s=this[0];return i===e?k(s)?s["inner"+n]:M(s)?s.documentElement["scroll"+n]:(o=this.offset())&&o[t]:this.each(function(e){s=r(this),s.css(t,Y(this,i,e,s[t]()))})}}),x.forEach(function(n,i){var o=i%2;r.fn[n]=function(){var n,a,s=r.map(arguments,function(t){var i=[];return n=$(t),"array"==n?(t.forEach(function(t){return t.nodeType!==e?i.push(t):r.zepto.isZ(t)?i=i.concat(t.get()):void(i=i.concat(N.fragment(t)))}),i):"object"==n||null==t?t:N.fragment(t)}),u=this.length>1;return s.length<1?this:this.each(function(e,n){a=o?n:n.parentNode,n=0==i?n.nextSibling:1==i?n.firstChild:2==i?n:null;var c=r.contains(f.documentElement,a);s.forEach(function(e){if(u)e=e.cloneNode(!0);else if(!a)return r(e).remove();a.insertBefore(e,n),c&&tt(e,function(e){if(!(null==e.nodeName||"SCRIPT"!==e.nodeName.toUpperCase()||e.type&&"text/javascript"!==e.type||e.src)){var n=e.ownerDocument?e.ownerDocument.defaultView:t;n.eval.call(n,e.innerHTML)}})})})},r.fn[o?n+"To":"insert"+(i?"Before":"After")]=function(t){return r(t)[n](this),this}}),N.Z.prototype=X.prototype=r.fn,N.uniq=P,N.deserializeValue=Q,r.zepto=N,r}();return t.Zepto=e,void 0===t.$&&(t.$=e),function(e){function h(t){return t._zid||(t._zid=n++)}function p(t,e,n,r){if(e=d(e),e.ns)var i=m(e.ns);return(a[h(t)]||[]).filter(function(t){return t&&(!e.e||t.e==e.e)&&(!e.ns||i.test(t.ns))&&(!n||h(t.fn)===h(n))&&(!r||t.sel==r)})}function d(t){var e=(""+t).split(".");return{e:e[0],ns:e.slice(1).sort().join(" ")}}function m(t){return new RegExp("(?:^| )"+t.replace(" "," .* ?")+"(?: |$)")}function g(t,e){return t.del&&!f&&t.e in c||!!e}function v(t){return l[t]||f&&c[t]||t}function y(t,n,i,o,s,u,f){var c=h(t),p=a[c]||(a[c]=[]);n.split(/\s/).forEach(function(n){if("ready"==n)return e(document).ready(i);var a=d(n);a.fn=i,a.sel=s,a.e in l&&(i=function(t){var n=t.relatedTarget;return!n||n!==this&&!e.contains(this,n)?a.fn.apply(this,arguments):void 0}),a.del=u;var c=u||i;a.proxy=function(e){if(e=T(e),!e.isImmediatePropagationStopped()){e.data=o;var n=c.apply(t,e._args==r?[e]:[e].concat(e._args));return n===!1&&(e.preventDefault(),e.stopPropagation()),n}},a.i=p.length,p.push(a),"addEventListener"in t&&t.addEventListener(v(a.e),a.proxy,g(a,f))})}function x(t,e,n,r,i){var o=h(t);(e||"").split(/\s/).forEach(function(e){p(t,e,n,r).forEach(function(e){delete a[o][e.i],"removeEventListener"in t&&t.removeEventListener(v(e.e),e.proxy,g(e,i))})})}function T(t,n){return(n||!t.isDefaultPrevented)&&(n||(n=t),e.each(w,function(e,r){var i=n[e];t[e]=function(){return this[r]=b,i&&i.apply(n,arguments)},t[r]=E}),t.timeStamp||(t.timeStamp=Date.now()),(n.defaultPrevented!==r?n.defaultPrevented:"returnValue"in n?n.returnValue===!1:n.getPreventDefault&&n.getPreventDefault())&&(t.isDefaultPrevented=b)),t}function S(t){var e,n={originalEvent:t};for(e in t)j.test(e)||t[e]===r||(n[e]=t[e]);return T(n,t)}var r,n=1,i=Array.prototype.slice,o=e.isFunction,s=function(t){return"string"==typeof t},a={},u={},f="onfocusin"in t,c={focus:"focusin",blur:"focusout"},l={mouseenter:"mouseover",mouseleave:"mouseout"};u.click=u.mousedown=u.mouseup=u.mousemove="MouseEvents",e.event={add:y,remove:x},e.proxy=function(t,n){var r=2 in arguments&&i.call(arguments,2);if(o(t)){var a=function(){return t.apply(n,r?r.concat(i.call(arguments)):arguments)};return a._zid=h(t),a}if(s(n))return r?(r.unshift(t[n],t),e.proxy.apply(null,r)):e.proxy(t[n],t);throw new TypeError("expected function")},e.fn.bind=function(t,e,n){return this.on(t,e,n)},e.fn.unbind=function(t,e){return this.off(t,e)},e.fn.one=function(t,e,n,r){return this.on(t,e,n,r,1)};var b=function(){return!0},E=function(){return!1},j=/^([A-Z]|returnValue$|layer[XY]$|webkitMovement[XY]$)/,w={preventDefault:"isDefaultPrevented",stopImmediatePropagation:"isImmediatePropagationStopped",stopPropagation:"isPropagationStopped"};e.fn.delegate=function(t,e,n){return this.on(e,t,n)},e.fn.undelegate=function(t,e,n){return this.off(e,t,n)},e.fn.live=function(t,n){return e(document.body).delegate(this.selector,t,n),this},e.fn.die=function(t,n){return e(document.body).undelegate(this.selector,t,n),this},e.fn.on=function(t,n,a,u,f){var c,l,h=this;return t&&!s(t)?(e.each(t,function(t,e){h.on(t,n,a,e,f)}),h):(s(n)||o(u)||u===!1||(u=a,a=n,n=r),(u===r||a===!1)&&(u=a,a=r),u===!1&&(u=E),h.each(function(r,o){f&&(c=function(t){return x(o,t.type,u),u.apply(this,arguments)}),n&&(l=function(t){var r,s=e(t.target).closest(n,o).get(0);return s&&s!==o?(r=e.extend(S(t),{currentTarget:s,liveFired:o}),(c||u).apply(s,[r].concat(i.call(arguments,1)))):void 0}),y(o,t,u,a,n,l||c)}))},e.fn.off=function(t,n,i){var a=this;return t&&!s(t)?(e.each(t,function(t,e){a.off(t,n,e)}),a):(s(n)||o(i)||i===!1||(i=n,n=r),i===!1&&(i=E),a.each(function(){x(this,t,i,n)}))},e.fn.trigger=function(t,n){return t=s(t)||e.isPlainObject(t)?e.Event(t):T(t),t._args=n,this.each(function(){t.type in c&&"function"==typeof this[t.type]?this[t.type]():"dispatchEvent"in this?this.dispatchEvent(t):e(this).triggerHandler(t,n)})},e.fn.triggerHandler=function(t,n){var r,i;return this.each(function(o,a){r=S(s(t)?e.Event(t):t),r._args=n,r.target=a,e.each(p(a,t.type||t),function(t,e){return i=e.proxy(r),r.isImmediatePropagationStopped()?!1:void 0})}),i},"focusin focusout focus blur load resize scroll unload click dblclick mousedown mouseup mousemove mouseover mouseout mouseenter mouseleave change select keydown keypress keyup error".split(" ").forEach(function(t){e.fn[t]=function(e){return 0 in arguments?this.bind(t,e):this.trigger(t)}}),e.Event=function(t,e){s(t)||(e=t,t=e.type);var n=document.createEvent(u[t]||"Events"),r=!0;if(e)for(var i in e)"bubbles"==i?r=!!e[i]:n[i]=e[i];return n.initEvent(t,r,!0),T(n)}}(e),function(e){function p(t,n,r){var i=e.Event(n);return e(t).trigger(i,r),!i.isDefaultPrevented()}function d(t,e,n,i){return t.global?p(e||r,n,i):void 0}function m(t){t.global&&0===e.active++&&d(t,null,"ajaxStart")}function g(t){t.global&&!--e.active&&d(t,null,"ajaxStop")}function v(t,e){var n=e.context;return e.beforeSend.call(n,t,e)===!1||d(e,n,"ajaxBeforeSend",[t,e])===!1?!1:void d(e,n,"ajaxSend",[t,e])}function y(t,e,n,r){var i=n.context,o="success";n.success.call(i,t,o,e),r&&r.resolveWith(i,[t,o,e]),d(n,i,"ajaxSuccess",[e,n,t]),b(o,e,n)}function x(t,e,n,r,i){var o=r.context;r.error.call(o,n,e,t),i&&i.rejectWith(o,[n,e,t]),d(r,o,"ajaxError",[n,r,t||e]),b(e,n,r)}function b(t,e,n){var r=n.context;n.complete.call(r,e,t),d(n,r,"ajaxComplete",[e,n]),g(n)}function E(t,e,n){if(n.dataFilter==j)return t;var r=n.context;return n.dataFilter.call(r,t,e)}function j(){}function w(t){return t&&(t=t.split(";",2)[0]),t&&(t==c?"html":t==f?"json":a.test(t)?"script":u.test(t)&&"xml")||"text"}function T(t,e){return""==e?t:(t+"&"+e).replace(/[&?]{1,2}/,"?")}function S(t){t.processData&&t.data&&"string"!=e.type(t.data)&&(t.data=e.param(t.data,t.traditional)),!t.data||t.type&&"GET"!=t.type.toUpperCase()&&"jsonp"!=t.dataType||(t.url=T(t.url,t.data),t.data=void 0)}function C(t,n,r,i){return e.isFunction(n)&&(i=r,r=n,n=void 0),e.isFunction(r)||(i=r,r=void 0),{url:t,data:n,success:r,dataType:i}}function O(t,n,r,i){var o,s=e.isArray(n),a=e.isPlainObject(n);e.each(n,function(n,u){o=e.type(u),i&&(n=r?i:i+"["+(a||"object"==o||"array"==o?n:"")+"]"),!i&&s?t.add(u.name,u.value):"array"==o||!r&&"object"==o?O(t,u,r,n):t.add(n,u)})}var i,o,n=+new Date,r=t.document,s=/)<[^<]*)*<\/script>/gi,a=/^(?:text|application)\/javascript/i,u=/^(?:text|application)\/xml/i,f="application/json",c="text/html",l=/^\s*$/,h=r.createElement("a");h.href=t.location.href,e.active=0,e.ajaxJSONP=function(i,o){if(!("type"in i))return e.ajax(i);var c,p,s=i.jsonpCallback,a=(e.isFunction(s)?s():s)||"Zepto"+n++,u=r.createElement("script"),f=t[a],l=function(t){e(u).triggerHandler("error",t||"abort")},h={abort:l};return o&&o.promise(h),e(u).on("load error",function(n,r){clearTimeout(p),e(u).off().remove(),"error"!=n.type&&c?y(c[0],h,i,o):x(null,r||"error",h,i,o),t[a]=f,c&&e.isFunction(f)&&f(c[0]),f=c=void 0}),v(h,i)===!1?(l("abort"),h):(t[a]=function(){c=arguments},u.src=i.url.replace(/\?(.+)=\?/,"?$1="+a),r.head.appendChild(u),i.timeout>0&&(p=setTimeout(function(){l("timeout")},i.timeout)),h)},e.ajaxSettings={type:"GET",beforeSend:j,success:j,error:j,complete:j,context:null,global:!0,xhr:function(){return new t.XMLHttpRequest},accepts:{script:"text/javascript, application/javascript, application/x-javascript",json:f,xml:"application/xml, text/xml",html:c,text:"text/plain"},crossDomain:!1,timeout:0,processData:!0,cache:!0,dataFilter:j},e.ajax=function(n){var u,f,s=e.extend({},n||{}),a=e.Deferred&&e.Deferred();for(i in e.ajaxSettings)void 0===s[i]&&(s[i]=e.ajaxSettings[i]);m(s),s.crossDomain||(u=r.createElement("a"),u.href=s.url,u.href=u.href,s.crossDomain=h.protocol+"//"+h.host!=u.protocol+"//"+u.host),s.url||(s.url=t.location.toString()),(f=s.url.indexOf("#"))>-1&&(s.url=s.url.slice(0,f)),S(s);var c=s.dataType,p=/\?.+=\?/.test(s.url);if(p&&(c="jsonp"),s.cache!==!1&&(n&&n.cache===!0||"script"!=c&&"jsonp"!=c)||(s.url=T(s.url,"_="+Date.now())),"jsonp"==c)return p||(s.url=T(s.url,s.jsonp?s.jsonp+"=?":s.jsonp===!1?"":"callback=?")),e.ajaxJSONP(s,a);var P,d=s.accepts[c],g={},b=function(t,e){g[t.toLowerCase()]=[t,e]},C=/^([\w-]+:)\/\//.test(s.url)?RegExp.$1:t.location.protocol,N=s.xhr(),O=N.setRequestHeader;if(a&&a.promise(N),s.crossDomain||b("X-Requested-With","XMLHttpRequest"),b("Accept",d||"*/*"),(d=s.mimeType||d)&&(d.indexOf(",")>-1&&(d=d.split(",",2)[0]),N.overrideMimeType&&N.overrideMimeType(d)),(s.contentType||s.contentType!==!1&&s.data&&"GET"!=s.type.toUpperCase())&&b("Content-Type",s.contentType||"application/x-www-form-urlencoded"),s.headers)for(o in s.headers)b(o,s.headers[o]);if(N.setRequestHeader=b,N.onreadystatechange=function(){if(4==N.readyState){N.onreadystatechange=j,clearTimeout(P);var t,n=!1;if(N.status>=200&&N.status<300||304==N.status||0==N.status&&"file:"==C){if(c=c||w(s.mimeType||N.getResponseHeader("content-type")),"arraybuffer"==N.responseType||"blob"==N.responseType)t=N.response;else{t=N.responseText;try{t=E(t,c,s),"script"==c?(1,eval)(t):"xml"==c?t=N.responseXML:"json"==c&&(t=l.test(t)?null:e.parseJSON(t))}catch(r){n=r}if(n)return x(n,"parsererror",N,s,a)}y(t,N,s,a)}else x(N.statusText||null,N.status?"error":"abort",N,s,a)}},v(N,s)===!1)return N.abort(),x(null,"abort",N,s,a),N;var A="async"in s?s.async:!0;if(N.open(s.type,s.url,A,s.username,s.password),s.xhrFields)for(o in s.xhrFields)N[o]=s.xhrFields[o];for(o in g)O.apply(N,g[o]);return s.timeout>0&&(P=setTimeout(function(){N.onreadystatechange=j,N.abort(),x(null,"timeout",N,s,a)},s.timeout)),N.send(s.data?s.data:null),N},e.get=function(){return e.ajax(C.apply(null,arguments))},e.post=function(){var t=C.apply(null,arguments);return t.type="POST",e.ajax(t)},e.getJSON=function(){var t=C.apply(null,arguments);return t.dataType="json",e.ajax(t)},e.fn.load=function(t,n,r){if(!this.length)return this;var a,i=this,o=t.split(/\s/),u=C(t,n,r),f=u.success;return o.length>1&&(u.url=o[0],a=o[1]),u.success=function(t){i.html(a?e("
").html(t.replace(s,"")).find(a):t),f&&f.apply(i,arguments)},e.ajax(u),this};var N=encodeURIComponent;e.param=function(t,n){var r=[];return r.add=function(t,n){e.isFunction(n)&&(n=n()),null==n&&(n=""),this.push(N(t)+"="+N(n))},O(r,t,n),r.join("&").replace(/%20/g,"+")}}(e),function(t){t.fn.serializeArray=function(){var e,n,r=[],i=function(t){return t.forEach?t.forEach(i):void r.push({name:e,value:t})};return this[0]&&t.each(this[0].elements,function(r,o){n=o.type,e=o.name,e&&"fieldset"!=o.nodeName.toLowerCase()&&!o.disabled&&"submit"!=n&&"reset"!=n&&"button"!=n&&"file"!=n&&("radio"!=n&&"checkbox"!=n||o.checked)&&i(t(o).val())}),r},t.fn.serialize=function(){var t=[];return this.serializeArray().forEach(function(e){t.push(encodeURIComponent(e.name)+"="+encodeURIComponent(e.value))}),t.join("&")},t.fn.submit=function(e){if(0 in arguments)this.bind("submit",e);else if(this.length){var n=t.Event("submit");this.eq(0).trigger(n),n.isDefaultPrevented()||this.get(0).submit()}return this}}(e),function(){try{getComputedStyle(void 0)}catch(e){var n=getComputedStyle;t.getComputedStyle=function(t,e){try{return n(t,e)}catch(r){return null}}}}(),e}); \ No newline at end of file diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/env_details.html b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/env_details.html index 16b82be0c3..4c58bd1137 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/env_details.html +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/env_details.html @@ -1,30 +1,39 @@

Environment & details:

+
{% for scope in env %} -
- {% if scope is not empty %} - - - - - - - - - {% for data in scope.value %} - - - - - {% endfor %} -
KeyValue
{{data.key}}{{data.value}}
- {% else %} - - empty - {% endif %} -
+
+ {% if scope.value is not empty %} + + + + + + + + + {% for data in scope.value %} + + + + + {% endfor %} +
KeyValue
{{ data.key | escape }}{{ data.value | escape }}
+ {% else %} + + empty + {% endif %} +
+ {% endfor %} +
+ +
+ + {% for h in handlers %} +
+ {{ loop.index + 1 }}. {{ h | escape }} +
{% endfor %}
-
diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frame_code.html b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frame_code.html index ff27399427..7b49e7ca38 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frame_code.html +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frame_code.html @@ -1,40 +1,34 @@ -
- {% for frame in frames %} -
-
- {% if frame.open %} - - Open: - {{frame.fileName}} - - {% else %} - {{frame.fileName}} - {% endif %} -
- {% if frame.source != null %} -
{{frame.source}}
- {% endif %} - {% if frame.args != null %} -
- Arguments -
-
- {{frame.args}} -
- {% endif %} -
- {% for comment in frame.comments %} -
- {{comment.class.name}} - {{comment.message}} -
- {% endfor %} -
+
+ {% for frame in frames %} +
+
+ {% if frame.open %} + + Open: + {{ frame.fileName | escape }} + + {% else %} + {{ frame.fileName | escape }} + {% endif %} +
+ + {% if frame.hasSource %} +
{{ frame.source | escape }}
+ {% endif %} + +
+ {% for comment in frame.comments %} +
+ {{ comment.class.name | escape }} + {{ comment.message | escape }}
+ {% endfor %} +
+ +
{% endfor %}
- diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frame_list.html b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frame_list.html index dd52e05f43..f289145f4c 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frame_list.html +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frame_list.html @@ -1,13 +1,14 @@ {% for frame in frames %} -
- {{ loop.length - loop.index - 1 }} -
- {{frame.className}} - {{frame.method}} -
-
- {{frame.location}}{{frame.line}} -
+
+ {# loop.revindex is 1-indexed, subtracting 1 matches the 0-indexed PHP count logic #} + {{ loop.revindex - 1 }} +
+ {{ frame.className | escape }} + {{ frame.methodName | escape }}
+ +
+ {{ frame.location | default('<#unknown>') | escape }}:{{ frame.line }} +
+
{% endfor %} diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frames_container.html b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frames_container.html index 7fa575ef5e..37f5193a31 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frames_container.html +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frames_container.html @@ -1,3 +1,3 @@ -
+
{% include "frame_list" %}
diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frames_description.html b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frames_description.html index 46a6551fb6..78afa570df 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frames_description.html +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/frames_description.html @@ -1,14 +1,14 @@ -
+
{% if hasFrameTabs %} - - Application frames (countIsApplication() ?>) - - - All frames ({{frames.size}}) - + + Application frames ({{ appFramesCount }}) + + + All frames ({{ frames | length }}) + {% else %} - - Stack frames ({{frames.size}}) + + Stack frames ({{ frames | length }}) {% endif %}
diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/header.html b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/header.html index 308e40c196..df21f95657 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/header.html +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/header.html @@ -1,40 +1,32 @@
- {% for name in causeName %} - {% if loop.index == causeName.size - 1 %} - {{name}} - {% else %} - {{name}}. - {% endif %} - {% endfor %} - {%if code != null %} - : {{code}} + {% for name in causeName %} {% if loop.index == causeName.size - 1 %} + {{name}} + {% else %} {{name}}. {% endif %} {% endfor %} {%if code != null %} + : {{code}} {% endif %}
{% if cause.message != null %} - {{cause.message}} - {% if previousMessages is not empty %} -
- Previous exceptions -
-
    - {% for previousMessage in previousMessages %} -
  • - {{previousMessage}} - () -
  • - {% endfor %} -
- {% endif %} - {% else %} - No message - {% endif %} - + + {{cause.message}} + + {% if previousMessages is not empty %} +
+ Previous exceptions +
+
    + {% for previousMessage in previousMessages %} +
  • + {{previousMessage}} + () +
  • + {% endfor %} +
+ {% endif %} {% else %} + No message + {% endif %} {{stacktrace}} - - +
diff --git a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/layout.html b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/layout.html index 9a83882bec..767dff4f97 100644 --- a/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/layout.html +++ b/modules/jooby-whoops/src/main/resources/io/jooby/whoops/views/layout.html @@ -6,7 +6,7 @@ {{title}} - +
@@ -15,7 +15,7 @@ {% include "panel_details_outer" %}
- + diff --git a/modules/jooby-whoops/src/test/java/generator/GenerateHTML.java b/modules/jooby-whoops/src/test/java/generator/GenerateHTML.java deleted file mode 100644 index 9c18cb63af..0000000000 --- a/modules/jooby-whoops/src/test/java/generator/GenerateHTML.java +++ /dev/null @@ -1,447 +0,0 @@ -/* - * Jooby https://jooby.io - * Apache License Version 2.0 https://jooby.io/LICENSE.txt - * Copyright 2014 Edgar Espina - */ -package generator; - -import java.io.IOException; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; - -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; - -import io.jooby.SneakyThrows; - -public class GenerateHTML { - private Path basedir; - private Path output; - - public GenerateHTML(Path basedir, Path output) { - this.basedir = basedir; - this.output = output; - } - - public Path doEnvDetails() throws IOException { - String filename = "env_details.html"; - Path output = output(filename, basedir); - StringBuilder lines = new StringBuilder(); - for (String line : phpFile(filename)) { - line = - line.replace("", "") - .replace(" $data): ?>", "{% for scope in env %}") - .replace("escape($tpl->slug($label)) ?>", "{{scope.key}}") - .replace("", "{% if scope is not empty %}") - .replace("escape($label) ?>", "{{scope.key}}") - .replace(" $value): ?>", "{% for data in scope.value %}") - .replace("escape($k) ?>", "{{data.key}}") - .replace("dump($value) ?>", "{{data.value}}") - .replace("", "{% endfor %}") - .replace("", "{% else %}") - .replace("escape($label) ?>", "{{scope.key}}") - .replace("", "{% endif %}") - .replace("", "{% endfor %}") - // TODO - .replace( - "", - "") - .replace(" $h): ?>", "{% for h in handlers %}") - .replace("", "") - .replace(". escape(get_class($h)) ?>", "{{h}}") - .replace("", "{% endfor %}"); - if (line.trim().length() > 0) { - lines.append(line).append(System.getProperty("line.separator")); - } - } - Document doc = Jsoup.parse(lines.toString()); - doc.select("#handlers").remove(); - Document.OutputSettings settings = new Document.OutputSettings(); - settings.prettyPrint(false); - settings.indentAmount(2); - settings.outline(true); - Files.write(output, Arrays.asList(doc.outputSettings(settings).body().children().toString())); - return output; - } - - public Path doFrameCode() throws IOException { - String filename = "frame_code.html"; - Path output = output(filename, basedir); - StringBuilder lines = new StringBuilder(); - for (String line : phpFile(filename)) { - line = - line.replace("", "") - .replace( - "", - "{% if frames.empty %}empty{% endif %}") - .replace("foreach ($frames as $i => $frame):", "{% for frame in frames %}") - .replace("$line = $frame->getLine();", "") - .replace( - "\" id=\"frame-code-", - "{% if loop.index == 0 %}active{% endif %}\" id=\"frame-code-{{loop.index}}") - .replace( - "echo ($handler->getEditorAjax($filePath, (int) $line) ? ' data-ajax' : '')", "") - .replace("getFile(); ?>", "{% if frame.open %}") - .replace( - "getEditorHref($filePath, (int)" - + " $line)): ?>", - "") - .replace("", "{% else %}") - .replace( - "breakOnDelimiter('/', $tpl->escape($filePath ?: '<#unknown>'))" - + " ?>", - "{{frame.fileName}}") - .replace("", "{% endif %}") - // .replace("getFileLines($line - 20, 40);", "") - .replace("// getFileLines can return null if there is no source code", "") - .replace("if ($range):", "") - .replace( - "$range = array_map(function ($line) { return empty($line) ? ' ' : $line;}," - + " $range);", - "") - .replace("$start = key($range) + 1;", "") - .replace("$code = join(\"\\n\", $range);", "") - // .replace("?>", "") - .replace("", "{{loop.index}}") - .replace("", "{{frame.lineStart}}") - .replace("escape($code) ?>", "{{frame.source}}") - .replace("dumpArgs($frame); ?>", "") - .replace("", "{% if frame.args != null %}") - .replace("", "{{frame.args}}") - .replace("// Append comments for this frame", "") - .replace("$comments = $frame->getComments();", "") - .replace( - "", - "{% if frame.comments.size == 0 %}empty{% endif %}") - .replace( - " $comment): ?>", - "{% for comment in frame.comments %}") - .replace("", "") - .replace("", "{{loop.index}}") - .replace("escape($context) ?>", "{{comment.class.name}}") - .replace("escapeButPreserveUris($comment) ?>", "{{comment.message}}") - .replace("", "{% endfor %}") - .replace("", ""); - if (line.trim().length() > 0) { - lines.append(line).append(System.getProperty("line.separator")); - } - } - Files.write( - output, - Arrays.asList( - lines - .toString() - .replace( - "{% endif %}\n" + " {% if frame.args != null %}", - "{% if frame.args != null %}"))); - return output; - } - - public Path doFrameList() throws IOException { - String filename = "frame_list.html"; - Path output = output(filename, basedir); - List lines = new ArrayList<>(); - for (String line : phpFile(filename)) { - line = - line.replace("", "") - .replace(" $frame): ?>", "{% for frame in frames %}") - .replace( - " isApplication() ?" - + " 'frame-application' : '') ?>\" id=\"frame-line-\"", - "{% if loop.index == 0 %}active{% endif %}{% if frame.source != null %} source{%" - + " endif %}\" id=\"frame-line-{{loop.index}}\"") - .replace( - "", "{{ loop.length - loop.index - 1 }}") - .replace( - "breakOnDelimiter('\\\\', $tpl->escape($frame->getClass() ?:" - + " '')) ?>", - "{{frame.className}}") - .replace( - "breakOnDelimiter('\\\\', $tpl->escape($frame->getFunction() ?:" - + " '')) ?>", - "{{frame.method}}") - .replace( - "getFile() ? $tpl->breakOnDelimiter('/'," - + " $tpl->shorten($tpl->escape($frame->getFile()))) : '<#unknown>' ?>", - "{{frame.location}}") - .replace("getLine() ?>", "{{frame.line}}") - .replace(" 0) { - lines.add(line); - } - } - Files.write(output, lines); - return output; - } - - public Path doFramesContainer() throws IOException { - String filename = "frames_container.html"; - Path output = output(filename, basedir); - List lines = new ArrayList<>(); - for (String line : phpFile(filename)) { - line = - line.replace( - "", - "{{activeFramesTab}}") - .replace("render($frame_list) ?>", "{% include \"frame_list\" %}"); - if (line.trim().length() > 0) { - lines.add(line); - } - } - Files.write(output, lines); - return output; - } - - public Path doFramesDescription() throws IOException { - String filename = "frames_description.html"; - Path output = output(filename, basedir); - List lines = new ArrayList<>(); - for (String line : phpFile(filename)) { - line = - line.replace( - "", - "{{framesDescriptionTab}}") - .replace("", "{% if hasFrameTabs %}") - .replace( - "", - "{{activeFramesTab}}") - .replace( - "", - "{{activeFramesTab}}") - .replace("", "{{frames.size}}") - .replace("", "{% else %}") - .replace("", "{% endif %}"); - if (line.trim().length() > 0) { - lines.add(line); - } - } - Files.write(output, lines); - return output; - } - - public Path doHeader() throws IOException { - String filename = "header.html"; - Path output = output(filename, basedir); - StringBuilder lines = new StringBuilder(); - for (String line : phpFile(filename)) { - line = - line.replace( - " $nameSection): ?>", "{% for name in causeName %}") - .replace( - "", - "{% if loop.index == causeName.size - 1 %}") - .replace("escape($nameSection) ?>", "{{name}}") - .replace("", "{% else %}") - .replace("escape($nameSection) . ' \\\\' ?>", "{{name}}.") - .replace("", "{% endif %}") - .replace("", "{% endfor %}") - .replace("", "{%if code != null %}") - .replace("(escape($code) ?>)", ": {{code}}") - .replace("", "{% if cause.message != null %}") - .replace("escape($message) ?>", "{{cause.message}}") - .replace( - "", - "{% if previousMessages is not empty %}") - .replace( - " $previousMessage): ?>", - "{% for previousMessage in previousMessages %}") - .replace("escape($previousMessage) ?>", "{{previousMessage}}") - .replace("", "") - .replace("", "{% endfor %}") - .replace("", "{% if docref_url != null %}") - .replace("escape($plain_exception) ?>", "{{stacktrace}}") - .replace("", ""); - - if (line.trim().length() > 0) { - lines.append(line).append(System.getProperty("line.separator")); - } - } - String html = lines.toString(); - Document doc = Jsoup.parse(html); - doc.select(".search-for-help").remove(); - doc.select("#hide-error").remove(); - Document.OutputSettings settings = new Document.OutputSettings(); - settings.prettyPrint(false); - settings.indentAmount(2); - settings.outline(true); - Files.write(output, Arrays.asList(doc.outputSettings(settings).body().children().toString())); - return output; - } - - public Path doHeaderOuter() throws IOException { - String filename = "header_outer.html"; - Path output = output(filename, basedir); - List lines = new ArrayList<>(); - for (String line : phpFile(filename)) { - line = line.replace("render($header) ?>", "{% include \"header\" %}"); - if (line.trim().length() > 0) { - lines.add(line); - } - } - Files.write(output, lines); - return output; - } - - public Path doLayout() throws IOException { - String filename = "layout.html"; - Path output = output(filename, basedir); - List lines = new ArrayList<>(); - for (String line : phpFile(filename)) { - line = - line.replace("", "") - .replace("escape($page_title) ?>", "{{title}}") - .replace( - "", - "") - .replace( - "render($panel_left_outer) ?>", "{% include\"panel_left_outer\" %}") - .replace( - "render($panel_details_outer) ?>", - "{% include \"panel_details_outer\" %}") - .replace( - "", - "") - .replace( - "", "") - .replace( - "", - "") - .replace( - "", - "") - .replace("", ""); - if (line.trim().length() > 0) { - lines.add(line); - } - } - Files.write(output, lines); - return output; - } - - public Path doPanelDetails() throws IOException { - String filename = "panel_details.html"; - Path output = output(filename, basedir); - List lines = new ArrayList<>(); - for (String line : phpFile(filename)) { - line = - line.replace("render($frame_code) ?>", "{% include \"frame_code\" %}") - .replace("render($env_details) ?>", "{% include \"env_details\" %}"); - if (line.trim().length() > 0) { - lines.add(line); - } - } - Files.write(output, lines); - return output; - } - - public Path doPanelDetailsOuter() throws IOException { - String filename = "panel_details_outer.html"; - Path output = output(filename, basedir); - List lines = new ArrayList<>(); - for (String line : phpFile(filename)) { - line = - line.replace("render($panel_details) ?>", "{% include \"panel_details\" %}"); - if (line.trim().length() > 0) { - lines.add(line); - } - } - Files.write(output, lines); - return output; - } - - public Path doPanelLeft() throws IOException { - String filename = "panel_left.html"; - Path output = output(filename, basedir); - List lines = new ArrayList<>(); - for (String line : phpFile(filename)) { - line = - line.replace("render($header_outer);", "{% include \"header_outer\" %}") - .replace("$tpl->render($frames_description);", "{% include \"frames_description\" %}") - .replace("$tpl->render($frames_container);", "{% include \"frames_container\" %}"); - if (line.trim().length() > 0) { - lines.add(line); - } - } - Files.write(output, lines); - return output; - } - - public Path doPanelLeftOuter() throws IOException { - String filename = "panel_left_outer.html"; - Path output = output(filename, basedir); - List lines = new ArrayList<>(); - for (String line : phpFile(filename)) { - line = line.replace("render($panel_left) ?>", "{% include \"panel_left\" %}"); - if (line.trim().length() > 0) { - lines.add(line); - } - } - Files.write(output, lines); - return output; - } - - public void generate() { - try { - doEnvDetails(); - doFrameCode(); - doFrameList(); - doFramesContainer(); - doFramesDescription(); - doHeader(); - doHeaderOuter(); - doLayout(); - doPanelDetails(); - doPanelDetailsOuter(); - doPanelLeft(); - doPanelLeftOuter(); - } catch (Exception x) { - throw SneakyThrows.propagate(x); - } - } - - public static void main(String[] args) { - create().generate(); - } - - public static GenerateHTML create() { - return new GenerateHTML( - Paths.get(basedir(), "src", "test", "resources", "whoops", "views"), - Paths.get(basedir(), "src", "main", "resources", "io", "jooby", "whoops", "views")); - } - - private static String basedir() { - Path basedir = Paths.get(System.getProperty("user.dir")); - if (!basedir.getFileName().toString().equals("jooby-whoops")) { - // IDE vs Maven - basedir = basedir.resolve("modules").resolve("jooby-whoops"); - } - return basedir.toString(); - } - - private List phpFile(String filename) throws IOException { - return Files.readAllLines(basedir.resolve(filename + ".php")); - } - - private Path output(String filename, Path basedir) { - return output.resolve(filename); - } -} diff --git a/modules/jooby-whoops/src/test/java/io/jooby/internal/whoops/WhoopsTest.java b/modules/jooby-whoops/src/test/java/io/jooby/internal/whoops/WhoopsTest.java index 27dbad8538..19b5ca4c44 100644 --- a/modules/jooby-whoops/src/test/java/io/jooby/internal/whoops/WhoopsTest.java +++ b/modules/jooby-whoops/src/test/java/io/jooby/internal/whoops/WhoopsTest.java @@ -5,6 +5,8 @@ */ package io.jooby.internal.whoops; +import java.io.IOException; + import org.junit.jupiter.api.Test; import io.pebbletemplates.pebble.PebbleEngine; @@ -12,7 +14,7 @@ public class WhoopsTest { @Test - public void shouldParseTemplates() { + public void shouldParseTemplates() throws IOException { PebbleEngine engine = Whoops.engine(); String[] templates = { "env_details", diff --git a/modules/jooby-whoops/src/test/resources/whoops/views/frame_list.html.php b/modules/jooby-whoops/src/test/resources/whoops/views/frame_list.html.php index a4bc338c2b..deb202d488 100644 --- a/modules/jooby-whoops/src/test/resources/whoops/views/frame_list.html.php +++ b/modules/jooby-whoops/src/test/resources/whoops/views/frame_list.html.php @@ -11,7 +11,7 @@
getFile() ? $tpl->breakOnDelimiter('/', $tpl->shorten($tpl->escape($frame->getFile()))) : '<#unknown>' ?>getLine() ?> + -->:getLine() ?>