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

knowledgepixels / nanodash / 21766377938

06 Feb 2026 09:20PM UTC coverage: 14.086% (+0.2%) from 13.838%
21766377938

push

github

tkuhn
refactor: use nanopub URI as preview page id instead of random UUID

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

577 of 5266 branches covered (10.96%)

Branch coverage included in aggregate %.

1519 of 9614 relevant lines covered (15.8%)

2.07 hits per line

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

86.61
src/main/java/com/knowledgepixels/nanodash/WicketApplication.java
1
package com.knowledgepixels.nanodash;
2

3
import com.google.gson.Gson;
4
import com.google.gson.reflect.TypeToken;
5
import com.knowledgepixels.nanodash.connector.*;
6
import com.knowledgepixels.nanodash.connector.ios.DsNanopubPage;
7
import com.knowledgepixels.nanodash.connector.ios.DsOverviewPage;
8
import com.knowledgepixels.nanodash.connector.pensoft.BdjNanopubPage;
9
import com.knowledgepixels.nanodash.connector.pensoft.BdjOverviewPage;
10
import com.knowledgepixels.nanodash.connector.pensoft.RioNanopubPage;
11
import com.knowledgepixels.nanodash.connector.pensoft.RioOverviewPage;
12
import com.knowledgepixels.nanodash.page.*;
13
import de.agilecoders.wicket.webjars.WicketWebjars;
14
import org.apache.http.HttpResponse;
15
import org.apache.http.client.methods.HttpGet;
16
import org.apache.http.impl.client.CloseableHttpClient;
17
import org.apache.http.impl.client.HttpClientBuilder;
18
import org.apache.wicket.RuntimeConfigurationType;
19
import org.apache.wicket.Session;
20
import org.apache.wicket.protocol.http.WebApplication;
21
import org.apache.wicket.request.Request;
22
import org.apache.wicket.request.Response;
23
import org.apache.wicket.settings.ExceptionSettings;
24
import org.apache.wicket.util.lang.Bytes;
25
import org.slf4j.Logger;
26
import org.slf4j.LoggerFactory;
27

28
import java.awt.*;
29
import java.io.IOException;
30
import java.io.InputStreamReader;
31
import java.lang.reflect.Type;
32
import java.net.URI;
33
import java.net.URISyntaxException;
34
import java.util.List;
35
import java.util.Properties;
36

37
/**
38
 * WicketApplication is the main application class for the Nanodash web application.
39
 * It initializes the application, mounts pages, and provides version information.
40
 */
41
public class WicketApplication extends WebApplication {
42

43
    /**
44
     * URL to fetch the latest release information from GitHub.
45
     * This URL points to the releases of the Nanodash repository.
46
     */
47
    public static final String LATEST_RELEASE_URL = "https://api.github.com/repos/knowledgepixels/nanodash/releases";
48
    private static final Logger logger = LoggerFactory.getLogger(WicketApplication.class);
9✔
49

50
    /**
51
     * Constructor for the WicketApplication.
52
     * Displays version information and provides instructions for accessing the application.
53
     */
54
    public WicketApplication() {
6✔
55
        if (Desktop.isDesktopSupported() && Desktop.getDesktop().isSupported(Desktop.Action.BROWSE)) {
6!
56
            try {
57
                Desktop.getDesktop().browse(new URI("http://localhost:37373"));
×
58
            } catch (IOException | URISyntaxException ex) {
×
59
                logger.error("Error in opening browser", ex);
×
60
            }
×
61
        }
62
        String v = getThisVersion();
6✔
63
        String lv = getLatestVersion();
6✔
64
        System.err.println("");
9✔
65
        System.err.println("----------------------------------------");
9✔
66
        System.err.println("               Nanodash");
9✔
67
        System.err.println("----------------------------------------");
9✔
68
        System.err.println(" You are using version: " + v);
12✔
69
        System.err.println(" Latest public version: " + lv);
12✔
70
        System.err.println("----------------------------------------");
9✔
71
        System.err.println(" Your browser should show the Nanodash");
9✔
72
        System.err.println(" interface in a few seconds.");
9✔
73
        System.err.println("");
9✔
74
        System.err.println(" If not, point your browser to:");
9✔
75
        System.err.println(" http://localhost:37373");
9✔
76
        System.err.println("----------------------------------------");
9✔
77
        System.err.println("");
9✔
78
    }
3✔
79

80
    /**
81
     * Returns the home page class for the application.
82
     *
83
     * @return The HomePage class.
84
     */
85
    public Class<HomePage> getHomePage() {
86
        return HomePage.class;
6✔
87
    }
88

89
    /**
90
     * {@inheritDoc}
91
     * <p>
92
     * Initializes the application settings and mounts pages.
93
     */
94
    @Override
95
    protected void init() {
96
        super.init();
6✔
97
        WicketWebjars.install(this);
6✔
98

99
        getMarkupSettings().setDefaultMarkupEncoding("UTF-8");
15✔
100

101
        getExceptionSettings().setUnexpectedExceptionDisplay(ExceptionSettings.SHOW_NO_EXCEPTION_PAGE);
15✔
102

103
        mountPage(ErrorPage.MOUNT_PATH, ErrorPage.class);
15✔
104
        mountPage("/error/404", ErrorPage.class);
15✔
105
        mountPage("/error/500", ErrorPage.class);
15✔
106

107
        mountPage(UserPage.MOUNT_PATH, UserPage.class);
15✔
108
        mountPage(ChannelPage.MOUNT_PATH, ChannelPage.class);
15✔
109
        mountPage(SearchPage.MOUNT_PATH, SearchPage.class);
15✔
110
        mountPage(ExplorePage.MOUNT_PATH, ExplorePage.class);
15✔
111
        mountPage(PublishPage.MOUNT_PATH, PublishPage.class);
15✔
112
        mountPage(PreviewPage.MOUNT_PATH, PreviewPage.class);
15✔
113
        mountPage(ProfilePage.MOUNT_PATH, ProfilePage.class);
15✔
114
        mountPage(UserListPage.MOUNT_PATH, UserListPage.class);
15✔
115
        mountPage(GroupDemoPage.MOUNT_PATH, GroupDemoPage.class);
15✔
116
        mountPage(GroupDemoPageSoc.MOUNT_PATH, GroupDemoPageSoc.class);
15✔
117
        mountPage(OrcidLinkingPage.MOUNT_PATH, OrcidLinkingPage.class);
15✔
118
        mountPage(OrcidLoginPage.MOUNT_PATH, OrcidLoginPage.class);
15✔
119
        mountPage(SpaceListPage.MOUNT_PATH, SpaceListPage.class);
15✔
120
        mountPage(MyChannelPage.MOUNT_PATH, MyChannelPage.class);
15✔
121
        mountPage(TermForwarder.MOUNT_PATH, TermForwarder.class);
15✔
122
        mountPage(ViewPage.MOUNT_PATH, ViewPage.class);
15✔
123
        mountPage(GetViewPage.MOUNT_PATH, GetViewPage.class);
15✔
124
        mountPage(DsOverviewPage.MOUNT_PATH, DsOverviewPage.class);
15✔
125
        mountPage(DsNanopubPage.MOUNT_PATH, DsNanopubPage.class);
15✔
126
        mountPage(RioOverviewPage.MOUNT_PATH, RioOverviewPage.class);
15✔
127
        mountPage(RioNanopubPage.MOUNT_PATH, RioNanopubPage.class);
15✔
128
        mountPage(BdjOverviewPage.MOUNT_PATH, BdjOverviewPage.class);
15✔
129
        mountPage(BdjNanopubPage.MOUNT_PATH, BdjNanopubPage.class);
15✔
130
        mountPage(FdoForwarder.MOUNT_PATH, FdoForwarder.class);
15✔
131
        mountPage(GetNamePage.MOUNT_PATH, GetNamePage.class);
15✔
132
        mountPage(TestPage.MOUNT_PATH, TestPage.class);
15✔
133
        mountPage(ResultTablePage.MOUNT_PATH, ResultTablePage.class);
15✔
134
        mountPage(GenOverviewPage.MOUNT_PATH, GenOverviewPage.class);
15✔
135
        mountPage(GenSelectPage.MOUNT_PATH, GenSelectPage.class);
15✔
136
        mountPage(GenPublishPage.MOUNT_PATH, GenPublishPage.class);
15✔
137
        mountPage(GenConnectPage.MOUNT_PATH, GenConnectPage.class);
15✔
138
        mountPage(GenNanopubPage.MOUNT_PATH, GenNanopubPage.class);
15✔
139
        mountPage(ProjectPage.MOUNT_PATH, ProjectPage.class);
15✔
140
        mountPage(SpacePage.MOUNT_PATH, SpacePage.class);
15✔
141
        mountPage(QueryPage.MOUNT_PATH, QueryPage.class);
15✔
142
        mountPage(QueryListPage.MOUNT_PATH, QueryListPage.class);
15✔
143
        mountPage(ListPage.MOUNT_PATH, ListPage.class);
15✔
144
        mountPage(MaintainedResourcePage.MOUNT_PATH, MaintainedResourcePage.class);
15✔
145
        mountPage(ResourcePartPage.MOUNT_PATH, ResourcePartPage.class);
15✔
146

147
        getCspSettings().blocking().disabled();
15✔
148
        getStoreSettings().setMaxSizePerSession(Bytes.MAX);
15✔
149
    }
3✔
150

151
    /**
152
     * {@inheritDoc}
153
     * <p>
154
     * Returns the runtime configuration type for the application.
155
     */
156
    @Override
157
    public RuntimeConfigurationType getConfigurationType() {
158
        return RuntimeConfigurationType.DEPLOYMENT;
6✔
159
    }
160

161

162
    private static String latestVersion = null;
6✔
163

164
    /**
165
     * Retrieves the latest version of the application from the GitHub API.
166
     *
167
     * @return The latest version as a string.
168
     */
169
    public static String getLatestVersion() {
170
        if (latestVersion != null) return latestVersion;
12✔
171
        try (CloseableHttpClient client = HttpClientBuilder.create().build()) {
9✔
172
            HttpResponse resp = client.execute(new HttpGet(LATEST_RELEASE_URL));
21✔
173
            int c = resp.getStatusLine().getStatusCode();
12✔
174
            if (c < 200 || c >= 300) {
18!
175
                throw new HttpStatusException(c);
×
176
            }
177

178
            Gson gson = new Gson();
12✔
179
            Type nanopubReleasesType = new TypeToken<List<NanodashRelease>>() {
18✔
180
            }.getType();
6✔
181

182
            List<NanodashRelease> releases = gson.fromJson(new InputStreamReader(resp.getEntity().getContent()), nanopubReleasesType);
33✔
183
            if (!releases.isEmpty()) {
9!
184
                latestVersion = releases.getFirst().getVersionNumber();
15✔
185
            }
186
        } catch (Exception ex) {
×
187
            logger.error("Error in fetching latest version", ex);
×
188
        }
3✔
189
        return latestVersion;
6✔
190
    }
191

192
    /**
193
     * Properties object to hold application properties.
194
     */
195
    public final static Properties properties = new Properties();
12✔
196

197
    static {
198
        try {
199
            properties.load(WicketApplication.class.getClassLoader().getResourceAsStream("nanodash.properties"));
18✔
200
        } catch (IOException ex) {
×
201
            logger.error("Error in loading properties", ex);
×
202
        }
3✔
203
    }
3✔
204

205
    /**
206
     * Retrieves the current version of the application.
207
     *
208
     * @return The current version as a string.
209
     */
210
    public static String getThisVersion() {
211
        return properties.getProperty("nanodash.version");
12✔
212
    }
213

214
    /**
215
     * {@inheritDoc}
216
     */
217
    @Override
218
    public Session newSession(Request request, Response response) {
219
        return new NanodashSession(request);
15✔
220
    }
221

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