/** * Gets the canonical base URL, not including any trailing slash, such as * <code>https://example.com</code> * This is configured in the book via the "canonicalBase" setting. * <p> * TODO: Create central per-request warnings list that could be reported during development mode, include this warning on requests. * TODO: Also could use that for broken link detection instead of throwing exceptions. * </p> */ public static String getCanonicalBase(ServletContext servletContext, HttpServletRequest request, Book book) throws MalformedURLException { String canonicalBase = book.getCanonicalBase(); if(canonicalBase == null) { String autoCanonical = ServletUtil.getAbsoluteURL(request, book.getPathPrefix()); if( // Logger checked first, so if warnings enabled mid-run, will get first warning still logger.isLoggable(Level.WARNING) ) { String bookName = book.getName(); String warningAttribute = CANONICAL_BASE_WARNED_ATTRIBUTE + bookName; if(servletContext.getAttribute(warningAttribute) == null) { servletContext.setAttribute(warningAttribute, true); logger.warning("Using generated canonical base URL, please configure the \"canonicalBase\" setting in the \"" + bookName + "\" book: " + autoCanonical); } } return autoCanonical; } else { return canonicalBase; } }
out.write(" onclick=\""); encodeJavaScriptInXhtmlAttribute("semanticcms_openfile_servlet.openFile(\"", out); NewEncodingUtils.encodeTextInJavaScriptInXhtmlAttribute(pageRef.getBook().getName(), out); encodeJavaScriptInXhtmlAttribute("\", \"", out); NewEncodingUtils.encodeTextInJavaScriptInXhtmlAttribute(pageRef.getPath(), out);