Package freenet.support

Examples of freenet.support.HTMLNode


    if (eta > 0) {
      addChild("br");
      addChild(new SecondCounterNode(eta, false, "ETA: "));
    }
    if (ctx.getContainer().isFProxyJavascriptEnabled()) {
      HTMLNode lastRefreshNode = new HTMLNode("span", "class", "jsonly");
      lastRefreshNode.addChild("br");
      lastRefreshNode.addChild(new SecondCounterNode(0, true, FProxyToadlet.l10n("lastRefresh")));
      addChild(lastRefreshNode);
    }
    if(fr.goneToNetwork)
      addChild("p", FProxyToadlet.l10n("progressDownloading"));
    else
View Full Code Here


  }

  @Override
  public void updateState(boolean initial) {
    children.clear();
    addChild(new HTMLNode("img", "src","/imagecreator/?text="+status+"&width="+Math.min(status+30,300)+"&height="+Math.min(status+30,300)));
  }
View Full Code Here

      } else {
        int total = fr.requiredBlocks;
        int fetchedPercent = (int) (fr.fetchedBlocks / (double) total * 100);
        int failedPercent = (int) (fr.failedBlocks / (double) total * 100);
        int fatallyFailedPercent = (int) (fr.fatallyFailedBlocks / (double) total * 100);
        HTMLNode progressBar = addChild("div", "class", "progressbar");
        progressBar.addChild("div", new String[] { "class", "style" }, new String[] { "progressbar-done", "width: " + fetchedPercent + "%;" });
       
        if (fr.failedBlocks > 0)
          progressBar.addChild("div", new String[] { "class", "style" }, new String[] { "progressbar-failed", "width: " + failedPercent + "%;" });
        if (fr.fatallyFailedBlocks > 0)
          progressBar.addChild("div", new String[] { "class", "style" }, new String[] { "progressbar-failed2", "width: " + fatallyFailedPercent + "%;" });
       
        NumberFormat nf = NumberFormat.getInstance();
        nf.setMaximumFractionDigits(1);
        String prefix = '('+Integer.toString(fr.fetchedBlocks) + "/ " + Integer.toString(total)+"): ";
        if (fr.finalizedBlocks) {
          progressBar.addChild("div", new String[] { "class", "title" }, new String[] { "progress_fraction_finalized", prefix + NodeL10n.getBase().getString("QueueToadlet.progressbarAccurate") }, nf.format((int) ((fr.fetchedBlocks / (double) total) * 1000) / 10.0) + '%');
        } else {
          String text = nf.format((int) ((fr.fetchedBlocks / (double) total) * 1000) / 10.0)+ '%';
          text = "" + fr.fetchedBlocks + " ("+text+"??)";
          progressBar.addChild("div", new String[] { "class", "title" }, new String[] { "progress_fraction_not_finalized", prefix + NodeL10n.getBase().getString("QueueToadlet.progressbarNotAccurate") }, text);
        }
      }
    }
    if (waiter != null) {
      progress.close(waiter);
View Full Code Here

      }
    }

    @Override
    public HTMLNode getEventHTMLText() {
      HTMLNode text = new HTMLNode("div");
      NodeL10n.getBase().addL10nSubstitution(text, "QueueToadlet.downloadSucceeded",
          new String[] { "link", "origlink", "filename", "size" },
          new HTMLNode[] { HTMLNode.link("/"+uri.toASCIIString()+"?max-size="+size), HTMLNode.link("/"+uri.toASCIIString()), HTMLNode.text(uri.getPreferredFilename()), HTMLNode.text(SizeUtil.formatSize(size))});
      return text;
    }
View Full Code Here

      }
    }

    @Override
    public HTMLNode getEventHTMLText() {
      HTMLNode text = new HTMLNode("div");
      NodeL10n.getBase().addL10nSubstitution(text, "QueueToadlet.uploadSucceeded",
          new String[] { "link", "filename", "size" },
          new HTMLNode[] { HTMLNode.link("/"+uri.toASCIIString()), HTMLNode.text(uri.getPreferredFilename()), HTMLNode.text(SizeUtil.formatSize(size))});
      return text;
    }
View Full Code Here

    }

    @Override
    public HTMLNode getEventHTMLText() {
      String name = uri.getPreferredFilename();
      HTMLNode text = new HTMLNode("div");
      NodeL10n.getBase().addL10nSubstitution(text, "QueueToadlet.siteUploadSucceeded",
          new String[] { "link", "filename", "size", "files" },
          new HTMLNode[] { HTMLNode.link("/"+uri.toASCIIString()), HTMLNode.text(name), HTMLNode.text(SizeUtil.formatSize(size)), HTMLNode.text(files) });
      return text;
    }
View Full Code Here

    for(int i = 0; i < items.size(); i++) {
      BookmarkItem item =  items.get(i);
       
      String itemPath = URLEncoder.encode(path + item.getName(), false);
      HTMLNode li = new HTMLNode("li", "class", "item", item.getVisibleName());
            String explain = item.getShortDescription();
            if(explain != null && explain.length() > 0) {
              li.addChild("#", " (");
              li.addChild("#", explain);
              li.addChild("#", ")");
            }

      HTMLNode actions = new HTMLNode("span", "class", "actions");
      actions.addChild("a", "href", "?action=edit&bookmark=" + itemPath).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/edit.png", edit, edit});

      actions.addChild("a", "href", "?action=del&bookmark=" + itemPath).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/delete.png", delete, delete});

      if(cutedPath == null)
        actions.addChild("a", "href", "?action=cut&bookmark=" + itemPath).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/cut.png", cut, cut});

      if(i != 0)
        actions.addChild("a", "href", "?action=up&bookmark=" + itemPath).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/go-up.png", moveUp, moveUp});

      if(i != items.size() - 1)
        actions.addChild("a", "href", "?action=down&bookmark=" + itemPath).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/go-down.png", moveDown, moveDown});

      if(hasFriends)
        actions.addChild("a", "href", "?action=share&bookmark=" + itemPath, NodeL10n.getBase().getString("BookmarkEditorToadlet.share"));

      li.addChild(actions);
      list.addChild(li);
    }

    List<BookmarkCategory> cats = cat.getSubCategories();
    for(int i = 0; i < cats.size(); i++) {
      String catPath = path + cats.get(i).getName() + '/';
      String catPathEncoded = URLEncoder.encode(catPath, false);

      HTMLNode subCat = list.addChild("li", "class", "cat", cats.get(i).getVisibleName());

      HTMLNode actions = new HTMLNode("span", "class", "actions");

      actions.addChild("a", "href", "?action=edit&bookmark=" + catPathEncoded).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/edit.png", edit, edit});

      actions.addChild("a", "href", "?action=del&bookmark=" + catPathEncoded).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/delete.png", delete, delete});

      actions.addChild("a", "href", "?action=addItem&bookmark=" + catPathEncoded).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/bookmark-new.png", addBookmark, addBookmark});

      actions.addChild("a", "href", "?action=addCat&bookmark=" + catPathEncoded).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/folder-new.png", addCategory, addCategory});

      if(cutedPath == null)
        actions.addChild("a", "href", "?action=cut&bookmark=" + catPathEncoded).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/cut.png", cut, cut});

      if(i != 0)
        actions.addChild("a", "href", "?action=up&bookmark=" + catPathEncoded).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/go-up.png", moveUp, moveUp});

      if(i != cats.size() - 1)
        actions.addChild("a", "href", "?action=down&bookmark=" + catPathEncoded).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/go-down.png", moveDown, moveDown});

      if(cutedPath != null && !catPathEncoded.startsWith(cutedPath) && !catPathEncoded.equals(bookmarkManager.parentPath(cutedPath)))
        actions.addChild("a", "href", "?action=paste&bookmark=" + catPathEncoded).addChild("img", new String[]{"src", "alt", "title"}, new String[]{"/static/icon/paste.png", paste, paste});

      subCat.addChild(actions);
      if(cats.get(i).size() != 0)
        addCategoryToList(cats.get(i), catPath, list.addChild("li").addChild("ul"), bookmarkManager);
    }
View Full Code Here

   * Renders hidden fields.
   * @param fieldPairs Pairs of values to be rendered
   * @return result HTMLNode containing hidden persistence fields
   */
  private HTMLNode renderPersistenceFields (Hashtable<String, String> fieldPairs) {
    HTMLNode result = new HTMLNode("div", "id", "persistenceFields");
    for (Map.Entry<String,String> entry : fieldPairs.entrySet()) {
      result.addChild("input",
              new String[] { "type", "name", "value" },
              new String[] { "hidden", entry.getKey(), entry.getValue() });
    }
    return result;
  }
View Full Code Here

   * @throws IOException
   * @throws RedirectException
   */
  private void renderPage (Hashtable<String, String> fieldPairs, String path, final ToadletContext ctx, String filename)
          throws ToadletContextClosedException, IOException, RedirectException {
    HTMLNode persistenceFields = renderPersistenceFields(fieldPairs);

    if (filename != null) {
      File file = new File(filename);
      if (file.isDirectory()) lastSuccessful = file.getAbsoluteFile();
      else lastSuccessful = file.getParentFile().getAbsoluteFile();

      try {
        throw new RedirectException(postTo());
      } catch (URISyntaxException e) {
        sendErrorPage(ctx, 500, NodeL10n.getBase().getString("Toadlet.internalErrorPleaseReport"),
                      e.getMessage());
      }
    }

    if (path.length() == 0) {
      if (lastSuccessful != null && lastSuccessful.isDirectory() && allowedDir(lastSuccessful)) {
        path = lastSuccessful.getAbsolutePath();
      } else {
        path = startingDir();
      }
    }

    File currentPath = new File(path).getCanonicalFile();
    //For use in error messages.
    String attemptedPath = currentPath == null ? "null" : currentPath.getAbsolutePath();

    PageMaker pageMaker = ctx.getPageMaker();

    if (currentPath != null && !allowedDir(currentPath)) {
      PageNode page = pageMaker.getPageNode(l10n("listingTitle", "path", attemptedPath), ctx);
      pageMaker.getInfobox("infobox-error""Forbidden", page.content, "access-denied", true).
              addChild("#", l10n("dirAccessDenied"));

      sendErrorPage(ctx, 403, "Forbidden", l10n("dirAccessDenied"));
      return;
    }
   
    HTMLNode pageNode;

    if (currentPath != null && currentPath.exists() && currentPath.isDirectory() && currentPath.canRead()) {
      PageNode page = pageMaker.getPageNode(l10n("listingTitle", "path",
              currentPath.getAbsolutePath()), ctx);
      pageNode = page.outer;
      HTMLNode contentNode = page.content;
      if (ctx.isAllowedFullAccess()) contentNode.addChild(ctx.getAlertManager().createSummary());
     
      HTMLNode infoboxDiv = contentNode.addChild("div", "class", "infobox");
      infoboxDiv.addChild("div", "class", "infobox-header", l10n("listing", "path",
              currentPath.getAbsolutePath()));
      HTMLNode listingDiv = infoboxDiv.addChild("div", "class", "infobox-content");
     
      File[] files = currentPath.listFiles();
     
      if (files == null) {
        sendErrorPage(ctx, 403, "Forbidden", l10n("dirAccessDenied"));
        return;
      }
     
      Arrays.sort(files, new Comparator<File>() {
        @Override
        public int compare(File firstFile, File secondFile) {
          /* Put directories above files, sorting each alphabetically and
           * case-insensitively.
           */
          if (firstFile.isDirectory() && !secondFile.isDirectory()) {
            return -1;
          }
          if (!firstFile.isDirectory() && secondFile.isDirectory()) {
            return 1;
          }
          return firstFile.getName().compareToIgnoreCase(secondFile.getName());
        }
      });
      HTMLNode listingTable = listingDiv.addChild("table");
      HTMLNode headerRow = listingTable.addChild("tr");
      headerRow.addChild("th");
      headerRow.addChild("th", l10n("fileHeader"));
      headerRow.addChild("th", l10n("sizeHeader"));
      /* add filesystem roots (fsck windows) */
      for (File currentRoot : File.listRoots()) {
        if (allowedDir(currentRoot)) {
        HTMLNode rootRow = listingTable.addChild("tr");
        rootRow.addChild("td");
        HTMLNode rootLinkCellNode = rootRow.addChild("td");
        HTMLNode rootLinkFormNode = ctx.addFormChild(rootLinkCellNode, path(),
                "insertLocalFileForm");
          createChangeDirButton(rootLinkFormNode, currentRoot.getCanonicalPath(),
                  currentRoot.getAbsolutePath(), persistenceFields);
        rootRow.addChild("td");
        }
      }
      /* add back link */
      if (currentPath.getParent() != null) {
        if (allowedDir(currentPath.getParentFile())) {
        HTMLNode backlinkRow = listingTable.addChild("tr");
        backlinkRow.addChild("td");
        HTMLNode backLinkCellNode = backlinkRow.addChild("td");
        HTMLNode backLinkFormNode = ctx.addFormChild(backLinkCellNode, path(),
                "insertLocalFileForm");
          createChangeDirButton(backLinkFormNode, "..", currentPath.getParent(), persistenceFields);
        backlinkRow.addChild("td");
        }
      }
      for (File currentFile : files) {
        if(currentFile.isHidden()) {
          // It won't be inserted if we insert the whole folder.
          // So lets just ignore it, less confusing.
          // FIXME in advanced mode, show them, and have a different style, and a toggle for whether to include them in a folder insert.
          continue;
        }
        HTMLNode fileRow = listingTable.addChild("tr");
        if (currentFile.isDirectory()) {
          if (currentFile.canRead()) {
            // Select directory
            if (allowedDir(currentFile)) {
            HTMLNode cellNode = fileRow.addChild("td");
            HTMLNode formNode = ctx.addFormChild(cellNode, path(),
                    "insertLocalFileForm");

              createSelectDirectoryButton(formNode, currentFile.getAbsolutePath(),
                      persistenceFields);

            // Change directory
            HTMLNode directoryCellNode = fileRow.addChild("td");
            HTMLNode directoryFormNode = ctx.addFormChild(directoryCellNode, path(),
                    "insertLocalFileForm");
              createChangeDirButton(directoryFormNode, currentFile.getName(),
                      currentFile.getAbsolutePath(), persistenceFields);
            }
          } else {
            fileRow.addChild("td");
            fileRow.addChild("td", "class", "unreadable-file",
                    currentFile.getName());
          }
          fileRow.addChild("td");
        } else {
          if (currentFile.canRead()) {
            //Select file
            HTMLNode cellNode = fileRow.addChild("td");
            HTMLNode formNode = ctx.addFormChild(cellNode, path(),
                    "insertLocalFileForm");
            createSelectFileButton(formNode, currentFile.getAbsolutePath(),
                    persistenceFields);
           
            fileRow.addChild("td", currentFile.getName());
            fileRow.addChild("td", "class", "right-align",
                    String.valueOf(currentFile.length()));
          } else {
            fileRow.addChild("td");
            fileRow.addChild("td", "class", "unreadable-file",
                    currentFile.getName());
            fileRow.addChild("td", "class", "right-align",
                    String.valueOf(currentFile.length()));
          }
        }
      }
    } else {
      PageNode page = pageMaker.getPageNode(l10n("listingTitle", "path", attemptedPath), ctx);
      pageNode = page.outer;
      HTMLNode contentNode = page.content;
      if (ctx.isAllowedFullAccess()) contentNode.addChild(ctx.getAlertManager().createSummary());
     
      HTMLNode infoboxDiv = contentNode.addChild("div", "class", "infobox");
      infoboxDiv.addChild("div", "class", "infobox-header", l10n("listing", "path", attemptedPath));
      HTMLNode listingDiv = infoboxDiv.addChild("div", "class", "infobox-content");

      listingDiv.addChild("#", l10n("dirCannotBeRead", "path", attemptedPath));
      HTMLNode ulNode = listingDiv.addChild("ul");
      ulNode.addChild("li", l10n("checkPathExist"));
      ulNode.addChild("li", l10n("checkPathIsDir"));
      ulNode.addChild("li", l10n("checkPathReadable"));
    }
    writeHTMLReply(ctx, 200, "OK", pageNode.generate());
  }
View Full Code Here

    this.plugins = plugins;
  }

  public void handleMethodGET(URI uri, HTTPRequest req, ToadletContext ctx) throws ToadletContextClosedException, IOException {
    PageNode page = ctx.getPageMaker().getPageNode(l10n("title"), ctx);
    HTMLNode pageNode = page.outer;
    HTMLNode contentNode = page.content;
   
    contentNode.addChild(ctx.getAlertManager().createSummary());
   
    HTMLNode contentBox = ctx.getPageMaker().getInfobox("infobox-information", l10n("title"), contentNode, "chat-list", true);

    NodeL10n.getBase().addL10nSubstitution(contentBox.addChild("p"), "ChatForumsToadlet.fsng",
        new String[] { "fsng" },
        new HTMLNode[] { HTMLNode.link("/USK@t5zaONbYd5DvGNNSokVnDCdrIEytn9U5SSD~pYF0RTE,guWyS9aCMcywU5PFBrKsMiXs7LzwKfQlGSRi17fpffc,AQACAAE/fsng/56/") });

   
    HTMLNode ul = contentBox.addChild("ul");
    HTMLNode li = ul.addChild("li");
    NodeL10n.getBase().addL10nSubstitution(li, "ChatForumsToadlet.fms",
            new String[] { "fms", "fms-help" },
            new HTMLNode[] { HTMLNode.link("/USK@0npnMrqZNKRCRoGojZV93UNHCMN-6UU3rRSAmP6jNLE,~BG-edFtdCC1cSH4O3BWdeIYa8Sw5DfyrSV-TKdO5ec,AQACAAE/fms/137/"),
                    HTMLNode.link("/SSK@ugb~uuscsidMI-Ze8laZe~o3BUIb3S50i25RIwDH99M,9T20t3xoG-dQfMO94LGOl9AxRTkaz~TykFY-voqaTQI,AQACAAE/FAFS-49/files/fms.htm")});
    li = ul.addChild("li");
View Full Code Here

TOP

Related Classes of freenet.support.HTMLNode

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.