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

knowledgepixels / nanodash / 17852532121

19 Sep 2025 08:10AM UTC coverage: 13.568% (-0.3%) from 13.87%
17852532121

push

github

tkuhn
feat: Switch to QueryRef provided by nanopub, using multimap

428 of 4008 branches covered (10.68%)

Branch coverage included in aggregate %.

1104 of 7283 relevant lines covered (15.16%)

0.68 hits per line

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

0.0
src/main/java/com/knowledgepixels/nanodash/page/HomePage.java
1
package com.knowledgepixels.nanodash.page;
2

3
import com.knowledgepixels.nanodash.*;
4
import com.knowledgepixels.nanodash.component.ApiResultComponent;
5
import com.knowledgepixels.nanodash.component.ItemListElement;
6
import com.knowledgepixels.nanodash.component.ItemListPanel;
7
import com.knowledgepixels.nanodash.component.NanopubResults;
8
import com.knowledgepixels.nanodash.component.TemplateItem;
9
import com.knowledgepixels.nanodash.component.TitleBar;
10
import com.knowledgepixels.nanodash.template.Template;
11
import com.knowledgepixels.nanodash.template.TemplateData;
12

13
import java.util.ArrayList;
14
import java.util.List;
15

16
import org.apache.wicket.Component;
17
import org.apache.wicket.markup.html.basic.Label;
18
import org.apache.wicket.request.mapper.parameter.PageParameters;
19
import org.eclipse.rdf4j.model.IRI;
20
import org.nanopub.extra.services.ApiResponse;
21
import org.nanopub.extra.services.ApiResponseEntry;
22
import org.nanopub.extra.services.QueryRef;
23

24
/**
25
 * The home page of Nanodash, which shows the most recent nanopublications
26
 * and the latest accepted nanopublications.
27
 */
28
public class HomePage extends NanodashPage {
29

30
    /**
31
     * The mount path for this page.
32
     */
33
    public static final String MOUNT_PATH = "/";
34

35
    /**
36
     * {@inheritDoc}
37
     */
38
    @Override
39
    public String getMountPath() {
40
        return MOUNT_PATH;
×
41
    }
42

43
    /**
44
     * Constructor for the home page.
45
     *
46
     * @param parameters the page parameters
47
     */
48
    public HomePage(final PageParameters parameters) {
49
        super(parameters);
×
50

51
        add(new TitleBar("titlebar", this, null));
×
52
        final NanodashSession session = NanodashSession.get();
×
53
        String v = WicketApplication.getThisVersion();
×
54
        String lv = WicketApplication.getLatestVersion();
×
55
        if (NanodashPreferences.get().isOrcidLoginMode()) {
×
56
            add(new Label("warning", ""));
×
57
        } else if (v.endsWith("-SNAPSHOT")) {
×
58
            add(new Label("warning", "You are running a temporary snapshot version of Nanodash (" + v + "). The latest public version is " + lv + "."));
×
59
        } else if (lv != null && !v.equals(lv)) {
×
60
            add(new Label("warning", "There is a new version available: " + lv + ". You are currently using " + v + ". " +
×
61
                                     "Run 'update' (Unix/Mac) or 'update-under-windows.bat' (Windows) to update to the latest version, or manually download it " +
62
                                     "<a href=\"" + WicketApplication.LATEST_RELEASE_URL + "\">here</a>.").setEscapeModelStrings(false));
×
63
        } else {
64
            add(new Label("warning", ""));
×
65
        }
66
        if (NanodashPreferences.get().isReadOnlyMode()) {
×
67
            add(new Label("text", "This is a read-only instance, so you cannot publish new nanopublications here."));
×
68
        } else if (NanodashSession.get().isProfileComplete()) {
×
69
            add(new Label("text", ""));
×
70
        } else if (NanodashPreferences.get().isOrcidLoginMode() && session.getUserIri() == null) {
×
71
            String loginUrl = OrcidLoginPage.getOrcidLoginUrl(".");
×
72
            add(new Label("text", "In order to see your own nanopublications and publish new ones, <a href=\"" + loginUrl + "\">login to ORCID</a> first.").setEscapeModelStrings(false));
×
73
        } else {
×
74
            add(new Label("text", "Before you can start, you first need to <a href=\"" + ProfilePage.MOUNT_PATH + "\">complete your profile</a>.").setEscapeModelStrings(false));
×
75
        }
76

77
        setOutputMarkupId(true);
×
78

79
        final QueryRef rQueryRef = new QueryRef("get-most-recent-nanopubs");
×
80
        ApiResponse rResponse = ApiCache.retrieveResponse(rQueryRef);
×
81
        if (rResponse != null) {
×
82
            add(NanopubResults.fromApiResponse("mostrecent", rResponse));
×
83
        } else {
84
            add(new ApiResultComponent("mostrecent", rQueryRef) {
×
85

86
                @Override
87
                public Component getApiResultComponent(String markupId, ApiResponse response) {
88
                    return NanopubResults.fromApiResponse(markupId, response);
×
89
                }
90
            });
91

92
        }
93

94
        add(new ItemListPanel<IRI>(
×
95
                "topcreators",
96
                "Most Active Nanopublishers Last Month",
97
                new QueryRef("get-top-creators-last30d"),
98
                (apiResponse) -> {
99
                    List<IRI> users = new ArrayList<>();
×
100
                    for (ApiResponseEntry e : apiResponse.getData()) {
×
101
                        users.add(Utils.vf.createIRI(e.get("userid")));
×
102
                    }
×
103
                    return users;
×
104
                },
105
                (userIri) -> {
106
                    return new ItemListElement("item", UserPage.class, new PageParameters().add("id", userIri), User.getShortDisplayName(userIri));
×
107
                }
108
            ));
109

110
        add(new ItemListPanel<Template>(
×
111
                "getstarted-templates",
112
                "Suggested Templates to Start Publishing",
113
                new QueryRef("get-suggested-templates-to-get-started"),
114
                TemplateData::getTemplateList,
115
                (template) -> new TemplateItem("item", template)
×
116
        ));
117

118
    }
×
119

120
}
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