Package net.pterodactylus.util.template

Examples of net.pterodactylus.util.template.Template


    templateContextFactory.addProvider(new ClassPathTemplateProvider(WebInterface.class, "/templates/"));
    templateContextFactory.addTemplateObject("webInterface", this);
    templateContextFactory.addTemplateObject("formPassword", formPassword);

    /* create notifications. */
    Template newSoneNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newSoneNotification.html"));
    newSoneNotification = new ListNotification<Sone>("new-sone-notification", "sones", newSoneNotificationTemplate, false);

    Template newPostNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newPostNotification.html"));
    newPostNotification = new ListNotification<Post>("new-post-notification", "posts", newPostNotificationTemplate, false);

    Template localPostNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newPostNotification.html"));
    localPostNotification = new ListNotification<Post>("local-post-notification", "posts", localPostNotificationTemplate, false);

    Template newReplyNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newReplyNotification.html"));
    newReplyNotification = new ListNotification<PostReply>("new-reply-notification", "replies", newReplyNotificationTemplate, false);

    Template localReplyNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/newReplyNotification.html"));
    localReplyNotification = new ListNotification<PostReply>("local-reply-notification", "replies", localReplyNotificationTemplate, false);

    Template mentionNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/mentionNotification.html"));
    mentionNotification = new ListNotification<Post>("mention-notification", "posts", mentionNotificationTemplate, false);

    Template lockedSonesTemplate = TemplateParser.parse(createReader("/templates/notify/lockedSonesNotification.html"));
    lockedSonesNotification = new ListNotification<Sone>("sones-locked-notification", "sones", lockedSonesTemplate);

    Template newVersionTemplate = TemplateParser.parse(createReader("/templates/notify/newVersionNotification.html"));
    newVersionNotification = new TemplateNotification("new-version-notification", newVersionTemplate);

    Template insertingImagesTemplate = TemplateParser.parse(createReader("/templates/notify/inserting-images-notification.html"));
    insertingImagesNotification = new ListNotification<Image>("inserting-images-notification", "images", insertingImagesTemplate);

    Template insertedImagesTemplate = TemplateParser.parse(createReader("/templates/notify/inserted-images-notification.html"));
    insertedImagesNotification = new ListNotification<Image>("inserted-images-notification", "images", insertedImagesTemplate);

    Template imageInsertFailedTemplate = TemplateParser.parse(createReader("/templates/notify/image-insert-failed-notification.html"));
    imageInsertFailedNotification = new ListNotification<Image>("image-insert-failed-notification", "images", imageInsertFailedTemplate);
  }
View Full Code Here


   *            {@code true} if no configuration file existed when Sone was
   *            loaded, {@code false} otherwise
   */
  public void setFirstStart(boolean firstStart) {
    if (firstStart) {
      Template firstStartNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/firstStartNotification.html"));
      Notification firstStartNotification = new TemplateNotification("first-start-notification", firstStartNotificationTemplate);
      notificationManager.addNotification(firstStartNotification);
    }
  }
View Full Code Here

   *            {@code true} if Sone was started with a fresh configuration,
   *            {@code false} if the existing configuration could be read
   */
  public void setNewConfig(boolean newConfig) {
    if (newConfig && !hasFirstStartNotification()) {
      Template configNotReadNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/configNotReadNotification.html"));
      Notification configNotReadNotification = new TemplateNotification("config-not-read-notification", configNotReadNotificationTemplate);
      notificationManager.addNotification(configNotReadNotification);
    }
  }
View Full Code Here

   */
  public void start() {
    registerToadlets();

    /* notification templates. */
    Template startupNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/startupNotification.html"));

    final TemplateNotification startupNotification = new TemplateNotification("startup-notification", startupNotificationTemplate);
    notificationManager.addNotification(startupNotification);

    ticker.schedule(new Runnable() {

      @Override
      public void run() {
        startupNotification.dismiss();
      }
    }, 2, TimeUnit.MINUTES);

    Template wotMissingNotificationTemplate = TemplateParser.parse(createReader("/templates/notify/wotMissingNotification.html"));
    final TemplateNotification wotMissingNotification = new TemplateNotification("wot-missing-notification", wotMissingNotificationTemplate);
    ticker.scheduleAtFixedRate(new Runnable() {

      @Override
      @SuppressWarnings("synthetic-access")
View Full Code Here

  /**
   * Register all toadlets.
   */
  private void registerToadlets() {
    Template emptyTemplate = TemplateParser.parse(new StringReader(""));
    Template loginTemplate = TemplateParser.parse(createReader("/templates/login.html"));
    Template indexTemplate = TemplateParser.parse(createReader("/templates/index.html"));
    Template newTemplate = TemplateParser.parse(createReader("/templates/new.html"));
    Template knownSonesTemplate = TemplateParser.parse(createReader("/templates/knownSones.html"));
    Template createSoneTemplate = TemplateParser.parse(createReader("/templates/createSone.html"));
    Template createPostTemplate = TemplateParser.parse(createReader("/templates/createPost.html"));
    Template createReplyTemplate = TemplateParser.parse(createReader("/templates/createReply.html"));
    Template bookmarksTemplate = TemplateParser.parse(createReader("/templates/bookmarks.html"));
    Template searchTemplate = TemplateParser.parse(createReader("/templates/search.html"));
    Template editProfileTemplate = TemplateParser.parse(createReader("/templates/editProfile.html"));
    Template editProfileFieldTemplate = TemplateParser.parse(createReader("/templates/editProfileField.html"));
    Template deleteProfileFieldTemplate = TemplateParser.parse(createReader("/templates/deleteProfileField.html"));
    Template viewSoneTemplate = TemplateParser.parse(createReader("/templates/viewSone.html"));
    Template viewPostTemplate = TemplateParser.parse(createReader("/templates/viewPost.html"));
    Template deletePostTemplate = TemplateParser.parse(createReader("/templates/deletePost.html"));
    Template deleteReplyTemplate = TemplateParser.parse(createReader("/templates/deleteReply.html"));
    Template deleteSoneTemplate = TemplateParser.parse(createReader("/templates/deleteSone.html"));
    Template imageBrowserTemplate = TemplateParser.parse(createReader("/templates/imageBrowser.html"));
    Template createAlbumTemplate = TemplateParser.parse(createReader("/templates/createAlbum.html"));
    Template deleteAlbumTemplate = TemplateParser.parse(createReader("/templates/deleteAlbum.html"));
    Template deleteImageTemplate = TemplateParser.parse(createReader("/templates/deleteImage.html"));
    Template noPermissionTemplate = TemplateParser.parse(createReader("/templates/noPermission.html"));
    Template optionsTemplate = TemplateParser.parse(createReader("/templates/options.html"));
    Template rescueTemplate = TemplateParser.parse(createReader("/templates/rescue.html"));
    Template aboutTemplate = TemplateParser.parse(createReader("/templates/about.html"));
    Template invalidTemplate = TemplateParser.parse(createReader("/templates/invalid.html"));
    Template postTemplate = TemplateParser.parse(createReader("/templates/include/viewPost.html"));
    Template replyTemplate = TemplateParser.parse(createReader("/templates/include/viewReply.html"));
    Template openSearchTemplate = TemplateParser.parse(createReader("/templates/xml/OpenSearch.xml"));

    PageToadletFactory pageToadletFactory = new PageToadletFactory(sonePlugin.pluginRespirator().getHLSimpleClient(), "/Sone/");
    pageToadlets.add(pageToadletFactory.createPageToadlet(new RedirectPage<FreenetRequest>("", "index.html")));
    pageToadlets.add(pageToadletFactory.createPageToadlet(new IndexPage(indexTemplate, this), "Index"));
    pageToadlets.add(pageToadletFactory.createPageToadlet(new NewPage(newTemplate, this), "New"));
View Full Code Here

     * @return The manifest element
     */
    @SuppressWarnings("synthetic-access")
    private ManifestElement createManifestElement(String name, String contentType, String templateName) {
      InputStreamReader templateInputStreamReader = null;
      Template template;
      try {
        templateInputStreamReader = new InputStreamReader(getClass().getResourceAsStream(templateName), utf8Charset);
        template = TemplateParser.parse(templateInputStreamReader);
      } catch (TemplateException te1) {
        logger.log(Level.SEVERE, String.format("Could not parse template ā€œ%sā€!", templateName), te1);
        return null;
      } finally {
        Closer.close(templateInputStreamReader);
      }

      TemplateContext templateContext = templateContextFactory.createTemplateContext();
      templateContext.set("core", core);
      templateContext.set("currentSone", soneProperties);
      templateContext.set("currentEdition", core.getUpdateChecker().getLatestEdition());
      templateContext.set("version", SonePlugin.VERSION);
      StringWriter writer = new StringWriter();
      StringBucket bucket = null;
      try {
        template.render(templateContext, writer);
        bucket = new StringBucket(writer.toString(), utf8Charset);
        return new ManifestElement(name, bucket, contentType, bucket.size());
      } catch (TemplateException te1) {
        logger.log(Level.SEVERE, String.format("Could not render template ā€œ%sā€!", templateName), te1);
        return null;
View Full Code Here

   *
   * @param listNotification
   *            The list notification to copy
   */
  public ListNotification(ListNotification<T> listNotification) {
    super(listNotification.getId(), listNotification.getCreatedTime(), listNotification.getLastUpdatedTime(), listNotification.isDismissable(), new Template());
    this.key = listNotification.key;
    getTemplate().add(listNotification.getTemplate());
    getTemplate().getInitialContext().set(key, elements);
  }
View Full Code Here

TOP

Related Classes of net.pterodactylus.util.template.Template

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.