/** * Renders the right click directive from the JavaScript file * * @return */ @Override public String renderFunction() { return FileTemplates.getFileTemplate(BSCarouselSlideEventDirective.class, "BSCarouselSlideEvent", "BSCarouselSlideEvent.min.js") .toString(); }
/** * Get the map of all the template scripts * * @param template * * @return A final HashMap */ public static StringBuilder renderTemplateScripts(String template) { if (TemplateScripts.containsKey(template) && TemplateScripts.get(template) != null) { return processTemplate(template, getTemplateScripts().get(template) .toString()); } return new StringBuilder(); }
/** * Replaces all instances of the following * <p> * %%APP%% - the angular module application name %%DIRECTIVES%% - the angular directives %%MODULES%% the modules generates * %%CONTROLLER%% the modules generates * * @param referenceClass * The class to find where the file is at * @param templateName * the template to use * * @return the name */ public static StringBuilder compileTemplate(Class referenceClass, String templateName) { String template = getFileTemplate(referenceClass, templateName).toString(); return processTemplate(templateName, template); }
/** * When to perform any commands */ @Override public void perform() { HttpServletRequest request = GuiceContext.get(GuicedServletKeys.getHttpServletRequestKey()); FileTemplates.getFileTemplate(JWScriptServlet.class, JWScriptServlet.FILE_TEMPLATE_NAME, "siteloader"); FileTemplates.getTemplateVariables() .put("SITEADDRESSINSERT", new StringBuilder(request.getRequestURL() .toString() .replace("jwscr", ""))); StringBuilder output = FileTemplates.renderTemplateScripts(JWScriptServlet.FILE_TEMPLATE_NAME); writeOutput(output, StaticStrings.HTML_HEADER_JAVASCRIPT, StaticStrings.UTF8_CHARSET); }
/** * When to perform any commands */ @Override public void perform() { Page page = GuiceContext.get(Page.class); HttpServletRequest request = GuiceContext.get(GuicedServletKeys.getHttpServletRequestKey()); readBrowserInformation(request); GuiceContext.get(AjaxCallInterceptorKey) .forEach(AjaxCallIntercepter::intercept); if (!page.isConfigured()) { page.preConfigure(); } FileTemplates.removeTemplate(JavaScriptServlet.scriptReplacement); FileTemplates.getFileTemplate(JavaScriptServlet.class, JavaScriptServlet.scriptReplacement, "javascriptScript"); FileTemplates.getTemplateVariables() .put(JavaScriptServlet.scriptReplacement, page.renderJavascript()); StringBuilder scripts = FileTemplates.renderTemplateScripts(JavaScriptServlet.scriptReplacement); writeOutput(scripts, StaticStrings.HTML_HEADER_JAVASCRIPT, Charset.forName("UTF-8")); FileTemplates.getTemplateVariables() .remove(JavaScriptServlet.scriptReplacement); } }
/** * compiles the global JW Angular Module, where the separate modules get listed inside of JWAngularModule * * @return The rendered modules */ @NotNull private StringBuilder compileModules() { StringBuilder output = new StringBuilder(); List<AngularModuleBase> angulars = new ArrayList<>(); angulars.add(jwAngularApp); angulars.forEach(module -> output.append(FileTemplates.compileTemplate(module.getReferenceName(), module.renderFunction()))); return output; }
if (FileTemplates.getTemplateVariables() .get("PACE_TRACK_START") == null) FileTemplates.getTemplateVariables() .put("PACE_TRACK_START;", new StringBuilder(StaticStrings.STRING_EMPTY)); if (FileTemplates.getTemplateVariables() .get("PACE_TRACK_END") == null) FileTemplates.getTemplateVariables() .put("PACE_TRACK_END;", new StringBuilder(StaticStrings.STRING_EMPTY)); FileTemplates.getTemplateVariables() .put("JW_APP_NAME", new StringBuilder(AngularFeature.getAppName())); FileTemplates.getTemplateVariables() .put("JW_MODULES", new StringBuilder(compileModules())); FileTemplates.getTemplateVariables() .put("JW_FACTORIES", new StringBuilder(compileFactories())); FileTemplates.getTemplateVariables() .put("JW_CONFIGURATIONS", new StringBuilder(compileConfigurations())); FileTemplates.getTemplateVariables() .put("JW_DIRECTIVES", new StringBuilder(compileDirectives())); FileTemplates.getTemplateVariables() .put("JW_APP_CONTROLLER", new StringBuilder(AngularFeature.getControllerName())); FileTemplates.getTemplateVariables() .put("JW_WATCHERS;", compileWatchers()); FileTemplates.getTemplateVariables() .put("CONTROLLER_INSERTIONS", new StringBuilder(compileControllerInsertions()));
protected StringBuilder renderHTML(int tabCount) return FileTemplates.renderTemplateScripts(templateName);
/** * Constructs a new instance of an imported file via a stream * * @param templateName * The name of the template * @param inputStream * The given input stream to read from * * @throws java.io.IOException * In case of anything */ public ImportFile(@NotNull String templateName, @NotNull InputStream inputStream) throws IOException { super(ComponentTypes.Comment); this.templateName = templateName; setTag(""); StringBuilder sb; try (InputStreamReader isr = new InputStreamReader(inputStream); BufferedReader br = new BufferedReader(isr)) { sb = new StringBuilder(); br.lines() .forEach(sb::append); } inputStream.close(); FileTemplates.setTemplateScript(templateName, sb); }
for (String templateVariable : getTemplateVariables().keySet()) templateScript = Matcher.quoteReplacement(getTemplateVariables().get(templateVariable) .toString()); templateOutput = templateOutput.replaceAll(StaticStrings.STRING_EMPTY + templateVariable + StaticStrings.STRING_EMPTY, templateScript);
/** * Replaces all instances of the following * <p> * %%APP%% - the angular module application name %%DIRECTIVES%% - the angular directives %%MODULES%% the modules generates * %%CONTROLLER%% the modules generates * * @param templateName * The template name * @param template * the template to build * * @return the name */ public static StringBuilder compileTemplate(String templateName, String template) { return processTemplate(templateName, template); }
/** * When to perform any commands */ @Override public void perform() { HttpServletRequest request = GuiceContext.get(GuicedServletKeys.getHttpServletRequestKey()); FileTemplates.getFileTemplate(JWScriptServlet.class, JWScriptServlet.FILE_TEMPLATE_NAME, "siteloader"); FileTemplates.getTemplateVariables() .put("SITEADDRESSINSERT", new StringBuilder(request.getRequestURL() .toString() .replace("jwscr", ""))); StringBuilder output = FileTemplates.renderTemplateScripts(JWScriptServlet.FILE_TEMPLATE_NAME); writeOutput(output, StaticStrings.HTML_HEADER_JAVASCRIPT, StaticStrings.UTF8_CHARSET); }
/** * When to perform any commands */ @Override public void perform() { Page page = GuiceContext.get(Page.class); HttpServletRequest request = GuiceContext.get(GuicedServletKeys.getHttpServletRequestKey()); readBrowserInformation(request); GuiceContext.get(AjaxCallInterceptorKey) .forEach(AjaxCallIntercepter::intercept); if (!page.isConfigured()) { page.preConfigure(); } FileTemplates.removeTemplate(JavaScriptServlet.scriptReplacement); FileTemplates.getFileTemplate(JavaScriptServlet.class, JavaScriptServlet.scriptReplacement, "javascriptScript"); FileTemplates.getTemplateVariables() .put(JavaScriptServlet.scriptReplacement, page.renderJavascript()); StringBuilder scripts = FileTemplates.renderTemplateScripts(JavaScriptServlet.scriptReplacement); writeOutput(scripts, StaticStrings.HTML_HEADER_JAVASCRIPT, Charset.forName("UTF-8")); FileTemplates.getTemplateVariables() .remove(JavaScriptServlet.scriptReplacement); } }
/** * Replaces all instances of the following * <p> * %%APP%% - the angular module application name %%DIRECTIVES%% - the angular directives %%MODULES%% the modules generates * %%CONTROLLER%% the modules generates * * @param referenceClass * The class to find where the file is at * @param templateName * the template to use * * @return the name */ public static StringBuilder compileTemplate(Class referenceClass, String templateName) { String template = getFileTemplate(referenceClass, templateName).toString(); return processTemplate(templateName, template); }
/** * compiles the global JW Angular Module, where the separate modules get listed inside of JWAngularModule * * @return The rendered modules */ @NotNull private StringBuilder compileModules() { StringBuilder output = new StringBuilder(); List<AngularModuleBase> angulars = new ArrayList<>(); angulars.add(jwAngularApp); angulars.forEach(module -> output.append(FileTemplates.compileTemplate(module.getReferenceName(), module.renderFunction()))); return output; }
if (FileTemplates.getTemplateVariables() .get("PACE_TRACK_START") == null) FileTemplates.getTemplateVariables() .put("PACE_TRACK_START;", new StringBuilder(StaticStrings.STRING_EMPTY)); if (FileTemplates.getTemplateVariables() .get("PACE_TRACK_END") == null) FileTemplates.getTemplateVariables() .put("PACE_TRACK_END;", new StringBuilder(StaticStrings.STRING_EMPTY)); FileTemplates.getTemplateVariables() .put("JW_APP_NAME", new StringBuilder(AngularFeature.getAppName())); FileTemplates.getTemplateVariables() .put("JW_MODULES", new StringBuilder(compileModules())); FileTemplates.getTemplateVariables() .put("JW_FACTORIES", new StringBuilder(compileFactories())); FileTemplates.getTemplateVariables() .put("JW_CONFIGURATIONS", new StringBuilder(compileConfigurations())); FileTemplates.getTemplateVariables() .put("JW_DIRECTIVES", new StringBuilder(compileDirectives())); FileTemplates.getTemplateVariables() .put("JW_APP_CONTROLLER", new StringBuilder(AngularFeature.getControllerName())); FileTemplates.getTemplateVariables() .put("JW_WATCHERS;", compileWatchers()); FileTemplates.getTemplateVariables() .put("CONTROLLER_INSERTIONS", new StringBuilder(compileControllerInsertions()));
protected StringBuilder renderHTML(int tabCount) return FileTemplates.renderTemplateScripts(templateName);
/** * Constructs a new instance of an imported file via a stream * * @param templateName * The name of the template * @param inputStream * The given input stream to read from * * @throws java.io.IOException * In case of anything */ public ImportFile(@NotNull String templateName, @NotNull InputStream inputStream) throws IOException { super(ComponentTypes.Comment); this.templateName = templateName; setTag(""); StringBuilder sb; try (InputStreamReader isr = new InputStreamReader(inputStream); BufferedReader br = new BufferedReader(isr)) { sb = new StringBuilder(); br.lines() .forEach(sb::append); } inputStream.close(); FileTemplates.setTemplateScript(templateName, sb); }
for (String templateVariable : getTemplateVariables().keySet()) templateScript = Matcher.quoteReplacement(getTemplateVariables().get(templateVariable) .toString()); templateOutput = templateOutput.replaceAll(StaticStrings.STRING_EMPTY + templateVariable + StaticStrings.STRING_EMPTY, templateScript);
/** * Replaces all instances of the following * <p> * %%APP%% - the angular module application name %%DIRECTIVES%% - the angular directives %%MODULES%% the modules generates * %%CONTROLLER%% the modules generates * * @param templateName * The template name * @param template * the template to build * * @return the name */ public static StringBuilder compileTemplate(String templateName, String template) { return processTemplate(templateName, template); }