private String getLocalizedTemplateName(String templateName, String localePart) { return StringUtils.removeEnd(templateName, "." + getFileExtension()) + "_" + localePart; }
@Override public void setApplicationPath(String applicationPath) { if (StringUtils.isNullOrEmpty(applicationPath) || "/".equals(applicationPath.trim())) { this.applicationPath = ""; } else { this.applicationPath = StringUtils.removeEnd(StringUtils.addStart(applicationPath, "/"), "/"); } }
private String concatUriPattern(String prefix, String uriPattern) { uriPattern = StringUtils.addStart(StringUtils.addStart(uriPattern, "/"), prefix); return "/".equals(uriPattern) ? uriPattern : StringUtils.removeEnd(uriPattern, "/"); }
paths.add(StringUtils.removeEnd(parentPath, "/") + "/" + StringUtils.removeStart(path, "/"));
public List<String> toList(List<String> defaultValue) { if (isNull() || (values.length == 1 && StringUtils.isNullOrEmpty(values[0]))) { return defaultValue; } if (values.length == 1) { String tmp = values[0]; tmp = StringUtils.removeStart(tmp, "["); tmp = StringUtils.removeEnd(tmp, "]"); return StringUtils.getList(tmp, "(,|\\|)"); } return Arrays.asList(values); }
protected List<DirEntry> getDirEntries(RouteContext routeContext, File dir, String absoluteDirUri) { List<DirEntry> list = new ArrayList<>(); for (File file : getFiles(dir)) { String fileUrl = routeContext.getRequest().getApplicationPath() + StringUtils.removeEnd(StringUtils.addStart(absoluteDirUri, "/"), "/") + StringUtils.addStart(file.getName(), "/"); list.add(new DirEntry(fileUrl, file)); } if (comparator != null) { list.sort(comparator); } if (!directory.equals(dir)) { File upDir = new File(dir, "../"); list.add(0, new DirEntry(routeContext.getRequest().getApplicationPath() + StringUtils.removeEnd(StringUtils.addStart(absoluteDirUri, "/"), "/") + StringUtils.addStart(upDir.getName(), "/"), upDir)); } return list; }
public Response(HttpServletResponse httpServletResponse, Application application) { this.httpServletResponse = httpServletResponse; this.contentTypeEngines = application.getContentTypeEngines(); this.templateEngine = application.getTemplateEngine(); this.httpServletResponse.setCharacterEncoding(StandardCharsets.UTF_8.toString()); this.contextPath = application.getRouter().getContextPath(); this.applicationPath = StringUtils.removeEnd(application.getRouter().getApplicationPath(), "/"); this.mimeTypes = application.getMimeTypes(); this.status = 0; }
private PebbleTemplate getTemplate(String templateName, String localePart) throws PebbleException { PebbleTemplate template = null; try { if (StringUtils.isNullOrEmpty(localePart)) { template = engine.getTemplate(templateName); } else { String localizedName = StringUtils.removeEnd(templateName, "." + getFileExtension()) + "_" + localePart; template = engine.getTemplate(localizedName); } } catch (LoaderException e) { log.debug(e.getMessage()); } return template; }
@Override public void handle(RouteContext routeContext) { // get request path Request request = routeContext.getRequest(); String path = request.getPath(); // add or remove trailing slash if (path.length() > 1) { if (addSlash) { path = StringUtils.addEnd(path, "/"); } else { path = StringUtils.removeEnd(path, "/"); } } if (!path.equals(request.getPath())) { // redirect routeContext.redirect(path); } else { // continue with the next handler routeContext.next(); } }
String path = Stream.of(StringUtils.removeEnd(controllerPath, "/"), StringUtils.removeStart(methodPath, "/")) .filter(Objects::nonNull) .collect(Collectors.joining("/"));
templateName = StringUtils.removeEnd(templateName, "." + getFileExtension());
@Override public void init(Application application) { super.init(application); PippoSettings pippoSettings = getPippoSettings(); TemplateConfiguration configuration = new TemplateConfiguration(); configuration.setBaseTemplateClass(PippoGroovyTemplate.class); configuration.setAutoEscape(true); if (pippoSettings.isDev()) { // Do not cache templates in dev mode configuration.setCacheTemplates(false); } else { configuration.setAutoIndent(true); configuration.setAutoNewLine(true); configuration.setAutoIndentString(" "); } String pathPrefix = getTemplatePathPrefix(); pathPrefix = StringUtils.removeStart(pathPrefix, "/"); pathPrefix = StringUtils.removeEnd(pathPrefix, "/"); GroovyTemplateResolver cachingResolver = new GroovyTemplateResolver(pathPrefix); ClassLoader classLoader = getClass().getClassLoader(); // allow custom initialization init(application, configuration); engine = new MarkupTemplateEngine(classLoader, configuration, cachingResolver); }
private String getLocalizedTemplateName(String templateName, String localePart) { return StringUtils.removeEnd(templateName, "." + getFileExtension()) + "_" + localePart; }
private String uriFor(String routeUriPattern) { String uri = addStart(addStart(routeUriPattern, "/"), routeGroupUriPattern); return "/".equals(uri) ? uri : StringUtils.removeEnd(uri, "/"); }
private String uriFor(String routeUriPattern) { String uri = addStart(addStart(routeUriPattern, "/"), routeGroupUriPattern); return "/".equals(uri) ? uri : StringUtils.removeEnd(uri, "/"); }
paths.add(StringUtils.removeEnd(parentPath, "/") + "/" + StringUtils.removeStart(path, "/"));
String fullPath = StringUtils.addStart(StringUtils.removeEnd(controllerPath, "/"), "/"); ControllerHandler handler = new ControllerHandler(injector, controllerClass, method.getName()); handler.validateMethodArgs(fullPath); String path = Joiner.on("/").skipNulls().join(StringUtils.removeEnd(controllerPath, "/"), StringUtils.removeStart(methodPath, "/")); String fullPath = StringUtils.addStart(StringUtils.removeEnd(path, "/"), "/");
String fullPath = StringUtils.addStart(StringUtils.removeEnd(controllerPath, "/"), "/"); ControllerHandler handler = new ControllerHandler(injector, controllerClass, method.getName()); handler.validateMethodArgs(fullPath); String path = Joiner.on("/").skipNulls().join(StringUtils.removeEnd(controllerPath, "/"), StringUtils.removeStart(methodPath, "/")); String fullPath = StringUtils.addStart(StringUtils.removeEnd(path, "/"), "/");
templateName = StringUtils.removeEnd(templateName, "." + getFileExtension());
@Override public void init(Application application) { super.init(application); PippoSettings pippoSettings = getPippoSettings(); TemplateConfiguration configuration = new TemplateConfiguration(); configuration.setBaseTemplateClass(PippoGroovyTemplate.class); configuration.setAutoEscape(true); if (pippoSettings.isDev()) { // Do not cache templates in dev mode configuration.setCacheTemplates(false); } else { configuration.setAutoIndent(true); configuration.setAutoNewLine(true); configuration.setAutoIndentString(" "); } String pathPrefix = getTemplatePathPrefix(); pathPrefix = StringUtils.removeStart(pathPrefix, "/"); pathPrefix = StringUtils.removeEnd(pathPrefix, "/"); GroovyTemplateResolver cachingResolver = new GroovyTemplateResolver(pathPrefix); ClassLoader classLoader = getClass().getClassLoader(); // allow custom initialization init(application, configuration); engine = new MarkupTemplateEngine(classLoader, configuration, cachingResolver); }