コード例 #1
0
  public void make() throws RedirectException {
    if (mOwnIdentity == null) {
      throw new RedirectException(logIn);
    }

    makeBreadcrumbs();

    boolean subscribe = mRequest.isPartSet("Subscribe");
    boolean unsubscribe = mRequest.isPartSet("Unsubscribe");

    if ((subscribe ^ unsubscribe) && mRequest.getMethod().equals("POST")) {
      String boardName =
          mRequest.getPartAsStringFailsafe("BoardName", Board.MAX_BOARDNAME_TEXT_LENGTH);

      try {
        MessageManager messageManager = mFreetalk.getMessageManager();

        if (subscribe) {
          SubscribedBoard board = messageManager.subscribeToBoard(mOwnIdentity, boardName);

          HTMLNode successBox =
              addContentBox(l10n().getString("SelectBoardsPage.SubscriptionSucceededBox.Header"));
          l10n()
              .addL10nSubstitution(
                  successBox.addChild("div"),
                  "SelectBoardsPage.SubscriptionSucceededBox.Text",
                  new String[] {"link", "boardname"},
                  new HTMLNode[] {
                    HTMLNode.link(BoardPage.getURI(board)), HTMLNode.text(board.getName())
                  });
        } else if (unsubscribe) {
          messageManager.unsubscribeFromBoard(mOwnIdentity, boardName);

          HTMLNode successBox =
              addContentBox(l10n().getString("SelectBoardsPage.UnsubscriptionSucceededBox.Header"));
          l10n()
              .addL10nSubstitution(
                  successBox.addChild("div"),
                  "SelectBoardsPage.UnsubscriptionSucceededBox.Text",
                  new String[] {"boardname"},
                  new HTMLNode[] {HTMLNode.text(boardName)});
        }
      } catch (Exception e) {
        HTMLNode alertBox =
            addAlertBox(
                subscribe
                    ? l10n().getString("SelectBoardsPage.SubscribeFailed")
                    : l10n().getString("SelectBoardsPage.UnsubscribeFailed"));
        alertBox.addChild("div", e.getMessage());

        Logger.error(this, subscribe ? "subscribe failed" : "unsubscribe failed", e);
      }
    }

    makeBoardsList();
  }
コード例 #2
0
  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, "freesite-insert", true);

    contentBox.addChild("p", l10n("content1"));

    NodeL10n.getBase()
        .addL10nSubstitution(
            contentBox.addChild("p"),
            "InsertFreesiteToadlet.contentFlogHelper",
            new String[] {"plugins"},
            new HTMLNode[] {HTMLNode.link(PproxyToadlet.PATH)});

    NodeL10n.getBase()
        .addL10nSubstitution(
            contentBox.addChild("p"),
            "InsertFreesiteToadlet.content2",
            new String[] {"jsite-http", "jsite-freenet", "jsite-freenet-version", "jsite-info"},
            new HTMLNode[] {
              HTMLNode.link(
                  ExternalLinkToadlet.escape("http://downloads.freenetproject.org/alpha/jSite/")),
              HTMLNode.link(
                  "/CHK@1bWi9EOtVyY77cJfioG7BvWzSlU-2j7dNG55c6KlpNk,5EsWJj4BjJa51K6kLTLWb64DEJQ3qHEEmFBITZMtcIw,AAMC--8/jSite-0.11.1-jar-with-dependencies.jar"),
              HTMLNode.text("0.11.1"),
              HTMLNode.link(
                  "/SSK@1waTsw46L9-JEQ8yX1khjkfHcn--g0MlMsTlYHax9zQ,oYyxr5jyFnaTsVGDQWk9e3ddOWGKnqEASxAk08MHT2Y,AQACAAE/jSite-6/"),
            });
    contentBox.addChild("p", l10n("content3"));
    HTMLNode ul = contentBox.addChild("ul");
    HTMLNode li = ul.addChild("li");
    li.addChild(
        "a",
        "href",
        "/SSK@940RYvj1-aowEHGsb5HeMTigq8gnV14pbKNsIvUO~-0,FdTbR3gIz21QNfDtnK~MiWgAf2kfwHe-cpyJXuLHdOE,AQACAAE/publish-3/",
        "Publish!");
    li.addChild("#", " - " + l10n("publishExplanation"));
    li = ul.addChild("li");
    li.addChild(
        "a",
        "href",
        "/SSK@8r-uSRcJPkAr-3v3YJR16OCx~lyV2XOKsiG4MOQQBMM,P42IgNemestUdaI7T6z3Og6P-Hi7g9U~e37R3kWGVj8,AQACAAE/freesite-HOWTO-4/",
        "Freesite HOWTO");
    li.addChild("#", " - " + l10n("freesiteHowtoExplanation"));

    NodeL10n.getBase()
        .addL10nSubstitution(
            contentBox.addChild("p"),
            "InsertFreesiteToadlet.contentThingamablog",
            new String[] {"thingamablog", "thingamablog-freenet"},
            new HTMLNode[] {
              HTMLNode.link(
                  ExternalLinkToadlet.escape(
                      "http://downloads.freenetproject.org/alpha/thingamablog/thingamablog.zip")),
              HTMLNode.link(
                  "/CHK@o8j9T2Ghc9cfKMLvv9aLrHbvW5XiAMEGwGDqH2UANTk,sVxLdxoNL-UAsvrlXRZtI5KyKlp0zv3Ysk4EcO627V0,AAIC--8/thingamablog.zip")
            });

    this.writeHTMLReply(ctx, 200, "OK", pageNode.generate());
  }