• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

knowledgepixels / nanodash / 19295211807

12 Nov 2025 11:02AM UTC coverage: 14.151% (+0.5%) from 13.691%
19295211807

push

github

web-flow
Merge pull request #283 from knowledgepixels/282-html-rendering-queryresultlist

Fix the HTML rendering in `QueryResultList`

536 of 4748 branches covered (11.29%)

Branch coverage included in aggregate %.

1376 of 8763 relevant lines covered (15.7%)

0.7 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
src/main/java/com/knowledgepixels/nanodash/component/QueryResultList.java
1
package com.knowledgepixels.nanodash.component;
2

3
import com.knowledgepixels.nanodash.GrlcQuery;
4
import com.knowledgepixels.nanodash.Utils;
5
import com.knowledgepixels.nanodash.ViewDisplay;
6
import com.knowledgepixels.nanodash.page.ExplorePage;
7
import org.apache.wicket.behavior.AttributeAppender;
8
import org.apache.wicket.markup.html.basic.Label;
9
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
10
import org.apache.wicket.markup.html.panel.Panel;
11
import org.apache.wicket.markup.repeater.RepeatingView;
12
import org.apache.wicket.request.mapper.parameter.PageParameters;
13
import org.nanopub.extra.services.ApiResponse;
14
import org.nanopub.extra.services.ApiResponseEntry;
15

16
public class QueryResultList extends Panel {
17

18
    private static final String SEPARATOR = ", ";
19

20
    QueryResultList(String markupId, GrlcQuery grlcQuery, ApiResponse response, ViewDisplay viewDisplay) {
21
        super(markupId);
×
22

23
        add(new AttributeAppender("class", " col-" + viewDisplay.getDisplayWidth()));
×
24

25
        String label = grlcQuery.getLabel();
×
26
        if (viewDisplay.getView().getTitle() != null) {
×
27
            label = viewDisplay.getView().getTitle();
×
28
        }
29
        add(new Label("label", label));
×
30
        if (viewDisplay.getNanopubId() != null) {
×
31
            add(new BookmarkablePageLink<Void>("np", ExplorePage.class, new PageParameters().set("id", viewDisplay.getNanopubId())));
×
32
        } else {
33
            add(new Label("np").setVisible(false));
×
34
        }
35
        RepeatingView listItems = new RepeatingView("listItems");
×
36
        for (ApiResponseEntry entry : response.getData()) {
×
37
            String labelText = buildInlineLabel(entry, response);
×
38
            listItems.add(new Label(listItems.newChildId(), labelText).setEscapeModelStrings(false));
×
39
        }
×
40
        add(listItems);
×
41
    }
×
42

43
    private String buildInlineLabel(ApiResponseEntry entry, ApiResponse response) {
44
        StringBuilder labelBuilder = new StringBuilder();
×
45
        for (String key : response.getHeader()) {
×
46
            if (!key.endsWith("_label")) {
×
47
                String entryValue = entry.get(key);
×
48
                if (entryValue != null && !entryValue.isBlank()) {
×
49
                    if (Utils.looksLikeHtml(entryValue)) {
×
50
                        entryValue = Utils.sanitizeHtml(entryValue);
×
51
                    } else if (entryValue.matches("https?://.+")) {
×
52
                        String label = entry.get(key + "_label");
×
53
                        String anchorElement = "<a href=\"%s\">%s</a>";
×
54
                        if (label != null && !label.isBlank()) {
×
55
                            entryValue = String.format(anchorElement, entryValue, label);
×
56
                        } else {
57
                            entryValue = String.format(anchorElement, entryValue, entryValue);
×
58
                        }
59
                    }
60
                    labelBuilder.append(entryValue).append(SEPARATOR);
×
61
                }
62
            }
63
        }
64
        if (labelBuilder.toString().endsWith(SEPARATOR)) {
×
65
            labelBuilder.setLength(labelBuilder.length() - 2);
×
66
        }
67
        return labelBuilder.toString();
×
68
    }
69

70
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc