コード例 #1
0
 /** Mark up of URL should consider surrounding markers, if any. */
 public void test2() throws Exception {
   MarkupText m = new MarkupText("{abc='http://url/',def='ghi'}");
   new UrlAnnotator().newInstance(null).annotate(null, m);
   String html = m.toString(false);
   assertTrue(html.contains("<a href='http://url/'>http://url/</a>"));
   System.out.println(html);
 }
コード例 #2
0
ファイル: GitChangeSet.java プロジェクト: thesam/git-plugin
  /** Gets {@linkplain #getComment() the comment} fully marked up by {@link ChangeLogAnnotator}. */
  public String getCommentAnnotated() {
    MarkupText markup = new MarkupText(getComment());
    for (ChangeLogAnnotator a : ChangeLogAnnotator.all())
      a.annotate(getParent().build, this, markup);

    return markup.toString(false);
  }
コード例 #3
0
 @SuppressWarnings("unchecked")
 private String annotate(String text, ConsoleNote... notes) {
   Object context = new Object();
   MarkupText markupText = new MarkupText(text);
   for (ConsoleNote note : notes) {
     note.annotate(context, markupText, 0);
   }
   return markupText.toString(true);
 }
コード例 #4
0
  @Test
  public void testNoWikiLinkToAnnotate() {
    AbstractBuild build = mock(AbstractBuild.class);
    AbstractProject<?, ?> project = mock(AbstractProject.class);
    when(project.getProperty(CodePlexProjectProperty.class))
        .thenReturn(new CodePlexProjectProperty("theproject"));
    when(build.getProject()).thenReturn(project);

    CodePlexChangeLogAnnotator annotator = new CodePlexChangeLogAnnotator();
    MarkupText markupText = new MarkupText("Ordinary commit message without wiki link.");
    annotator.annotate(build, null, markupText);
    assertEquals("Ordinary commit message without wiki link.", markupText.toString());
  }
コード例 #5
0
  @Test
  public void assertWorkItemInBracketsIsAnnotated() {
    AbstractBuild build = mock(AbstractBuild.class);
    AbstractProject<?, ?> project = mock(AbstractProject.class);
    when(project.getProperty(CodePlexProjectProperty.class))
        .thenReturn(new CodePlexProjectProperty("theproject"));
    when(build.getProject()).thenReturn(project);

    CodePlexChangeLogAnnotator annotator = new CodePlexChangeLogAnnotator();
    MarkupText markupText = new MarkupText("Message with [workitem: 12]. Yes a link.");
    annotator.annotate(build, null, markupText);
    assertEquals(
        "Message with <a href='http://www.codeplex.com/theproject/WorkItem/View.aspx?WorkItemId=12'>[workitem: 12]</a>. Yes a link.",
        markupText.toString());
  }
コード例 #6
0
  @Test
  public void assertWikiKeyWordIsAnnotated() {
    AbstractBuild build = mock(AbstractBuild.class);
    AbstractProject<?, ?> project = mock(AbstractProject.class);
    when(project.getProperty(CodePlexProjectProperty.class))
        .thenReturn(new CodePlexProjectProperty("theproject"));
    when(build.getProject()).thenReturn(project);

    CodePlexChangeLogAnnotator annotator = new CodePlexChangeLogAnnotator();
    MarkupText markupText = new MarkupText("Message with wiki:WikiLink. Yes a link.");
    annotator.annotate(build, null, markupText);
    assertEquals(
        "Message with <a href='http://www.codeplex.com/theproject/Wiki/View.aspx?title=WikiLink'>wiki:WikiLink</a>. Yes a link.",
        markupText.toString());
  }
コード例 #7
0
 /**
  * Format the given time-stamp and add it to the mark-up text.
  *
  * @param text the mark-up text
  * @param timestamp the time-stamp to format
  */
 public void markup(MarkupText text, Timestamp timestamp) {
   String timestampString = formatTimestamp.apply(timestamp);
   // Wrap the time-stamp in a span element, which is used to detect the
   // time-stamp when inspecting the page with Javascript.
   String markup = "<span class=\"timestamp\">" + timestampString + "</span>";
   // Add as end tag, which will be inserted prior to tags added by other
   // console notes (e.g. AntTargetNote).
   text.addMarkup(0, 0, "", markup);
 }
コード例 #8
0
 @Override
 public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
   if (text.getText().contains("ERROR"))
     text.addMarkup(0, text.length(), "<span style=\"font-weight: bold; color:red\">", "</span>");
   if (text.getText().contains("INFO"))
     text.addMarkup(0, text.length(), "<span style=\"color:#993300\">", "</span>");
   return null;
 }
コード例 #9
0
 @Override
 public ConsoleAnnotator annotate(Object context, MarkupText text, int charPos) {
   text.addMarkup(0, text.length(), "<span class=error-inline>", "</span>");
   return null;
 }
コード例 #10
0
ファイル: ChangeLogSet.java プロジェクト: stevenzyk/hudson
    /** Gets the text fully marked up by {@link ChangeLogAnnotator}. */
    public String getMsgAnnotated() {
      MarkupText markup = new MarkupText(getMsgEscaped());
      for (ChangeLogAnnotator a : ChangeLogAnnotator.all()) a.annotate(parent.build, this, markup);

      return markup.toString();
    }