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

knowledgepixels / nanodash / 24382503285

14 Apr 2026 05:24AM UTC coverage: 15.886% (-0.2%) from 16.094%
24382503285

push

github

web-flow
Merge pull request #438 from knowledgepixels/feature/item-list-view-435

feat: implement ItemListView and fix async view rendering

789 of 6130 branches covered (12.87%)

Branch coverage included in aggregate %.

1978 of 11288 relevant lines covered (17.52%)

2.4 hits per line

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

78.15
src/main/java/com/knowledgepixels/nanodash/NanodashPreferences.java
1
package com.knowledgepixels.nanodash;
2

3
import org.slf4j.Logger;
4
import org.slf4j.LoggerFactory;
5
import tools.jackson.core.JacksonException;
6
import tools.jackson.databind.ObjectMapper;
7
import tools.jackson.dataformat.yaml.YAMLMapper;
8

9
import java.io.File;
10
import java.io.Serializable;
11
import java.util.ArrayList;
12
import java.util.Arrays;
13
import java.util.List;
14

15
/**
16
 * Class to manage Nanodash preferences.
17
 */
18
public class NanodashPreferences implements Serializable {
6✔
19

20
    private static NanodashPreferences obj;
21
    private static final Logger logger = LoggerFactory.getLogger(NanodashPreferences.class);
12✔
22

23
    /**
24
     * Get the singleton instance of NanodashPreferences.
25
     *
26
     * @return the NanodashPreferences instance
27
     */
28
    public static NanodashPreferences get() {
29
        if (obj == null) {
6✔
30
            File prefFile = new File(System.getProperty("user.home") + DEFAULT_SETTING_PATH);
21✔
31
            if (!prefFile.exists()) {
9✔
32
                return new NanodashPreferences();
12✔
33
            }
34
            ObjectMapper mapper = new YAMLMapper();
12✔
35
            try {
36
                obj = mapper.readValue(prefFile, NanodashPreferences.class);
18✔
37
            } catch (JacksonException ex) {
3✔
38
                obj = new NanodashPreferences();
12✔
39
                logger.error("Could not read preferences file at '{}' using defaults", DEFAULT_SETTING_PATH, ex);
15✔
40
            }
3✔
41
        }
42
        return obj;
6✔
43
    }
44

45
    private List<String> nanopubActions = new ArrayList<>();
15✔
46
    private boolean readOnlyMode = false;
9✔
47
    private String websiteUrl = "http://localhost:37373/";
9✔
48
    private boolean orcidLoginMode = false;
9✔
49
    private String orcidClientId;
50
    private String orcidClientSecret;
51
    private String settingUri;
52
    private String umamiScriptUrl;
53
    private String umamiWebsiteId;
54
    private String homeResource = "https://w3id.org/spaces/knowledgepixels/nanodash/r/home";
12✔
55
    public static final String DEFAULT_SETTING_PATH = "/.nanopub/nanodash-preferences.yml";
56

57
    /**
58
     * Return the list of nanopub actions.
59
     *
60
     * @return list of nanopub actions
61
     */
62
    public List<String> getNanopubActions() {
63
        String s = System.getenv("NANODASH_NANOPUB_ACTIONS");
9✔
64
        if (s != null && !s.isBlank()) {
15✔
65
            return Arrays.asList(s.split(" "));
15✔
66
        }
67
        return nanopubActions;
9✔
68
    }
69

70
    /**
71
     * Set the list of nanopub actions.
72
     *
73
     * @param nanopubActions the list of nanopub actions
74
     */
75
    public void setNanopubActions(List<String> nanopubActions) {
76
        this.nanopubActions = nanopubActions;
9✔
77
    }
3✔
78

79
    /**
80
     * Check if the application is in read-only mode.
81
     *
82
     * @return true if in read-only mode, false otherwise
83
     */
84
    public boolean isReadOnlyMode() {
85
        if ("true".equals(System.getenv("NANODASH_READ_ONLY_MODE"))) {
15✔
86
            logger.debug("Found environment variable NANODASH_READ_ONLY_MODE with value: {}", true);
15✔
87
            return true;
6✔
88
        }
89
        logger.debug("Environment variable NANODASH_READ_ONLY_MODE not set, using default: {}", readOnlyMode);
18✔
90
        return readOnlyMode;
9✔
91
    }
92

93
    /**
94
     * Set the read-only mode.
95
     *
96
     * @param readOnlyMode true to enable read-only mode, false to disable
97
     */
98
    public void setReadOnlyMode(boolean readOnlyMode) {
99
        this.readOnlyMode = readOnlyMode;
9✔
100
    }
3✔
101

102
    /**
103
     * Get the website URL.
104
     *
105
     * @return the website URL
106
     */
107
    public String getWebsiteUrl() {
108
        String s = System.getenv("NANODASH_WEBSITE_URL");
9✔
109
        if (s != null && !s.isBlank()) {
15✔
110
            logger.debug("Found environment variable NANODASH_WEBSITE_URL with value: {}", s);
12✔
111
            return s;
6✔
112
        }
113
        logger.debug("Environment variable NANODASH_WEBSITE_URL not set, using default: {}", websiteUrl);
15✔
114
        return websiteUrl;
9✔
115
    }
116

117
    /**
118
     * Set the website URL.
119
     *
120
     * @param websiteUrl the website URL to set
121
     */
122
    public void setWebsiteUrl(String websiteUrl) {
123
        this.websiteUrl = websiteUrl;
9✔
124
    }
3✔
125

126
    /**
127
     * Check if the application is in ORCID login mode.
128
     *
129
     * @return true if in ORCID login mode, false otherwise
130
     */
131
    public boolean isOrcidLoginMode() {
132
        if ("true".equals(System.getenv("NANODASH_ORCID_LOGIN_MODE"))) {
15✔
133
            logger.debug("Found environment variable NANODASH_ORCID_LOGIN_MODE with value: {}", true);
15✔
134
            return true;
6✔
135
        }
136
        logger.debug("Environment variable NANODASH_ORCID_LOGIN_MODE not set, using default: {}", orcidLoginMode);
18✔
137
        return orcidLoginMode;
9✔
138
    }
139

140
    /**
141
     * Set the ORCID login mode.
142
     *
143
     * @param orcidLoginMode true to enable ORCID login mode, false to disable
144
     */
145
    public void setOrcidLoginMode(boolean orcidLoginMode) {
146
        this.orcidLoginMode = orcidLoginMode;
9✔
147
    }
3✔
148

149
    /**
150
     * Get the ORCID client ID.
151
     *
152
     * @return the ORCID client ID
153
     */
154
    public String getOrcidClientId() {
155
        String s = System.getenv("NANOPUB_ORCID_CLIENT_ID");
9✔
156
        if (s != null && !s.isBlank()) {
15✔
157
            logger.debug("Found environment variable NANOPUB_ORCID_CLIENT_ID with value: {}", s);
12✔
158
            return s;
6✔
159
        }
160
        logger.debug("Environment variable NANOPUB_ORCID_CLIENT_ID not set, using default: {}", orcidClientId);
15✔
161
        return orcidClientId;
9✔
162
    }
163

164
    /**
165
     * Set the ORCID client ID.
166
     *
167
     * @param orcidClientId the ORCID client ID to set
168
     */
169
    public void setOrcidClientId(String orcidClientId) {
170
        this.orcidClientId = orcidClientId;
9✔
171
    }
3✔
172

173
    /**
174
     * Get the ORCID client secret.
175
     * .
176
     *
177
     * @return the ORCID client secret
178
     */
179
    public String getOrcidClientSecret() {
180
        String s = System.getenv("NANOPUB_ORCID_CLIENT_SECRET");
9✔
181
        if (s != null && !s.isBlank()) {
15✔
182
            logger.debug("Found environment variable NANOPUB_ORCID_CLIENT_SECRET");
9✔
183
            return s;
6✔
184
        }
185
        logger.debug("Environment variable NANOPUB_ORCID_CLIENT_SECRET not set, using default");
9✔
186
        return orcidClientSecret;
9✔
187
    }
188

189
    /**
190
     * Set the ORCID client secret.
191
     *
192
     * @param orcidClientSecret the ORCID client secret to set
193
     */
194
    public void setOrcidClientSecret(String orcidClientSecret) {
195
        this.orcidClientSecret = orcidClientSecret;
9✔
196
    }
3✔
197

198
    /**
199
     * Get the setting URI.
200
     *
201
     * @return the setting URI
202
     */
203
    public String getSettingUri() {
204
        return settingUri;
9✔
205
    }
206

207
    /**
208
     * Set the setting URI.
209
     *
210
     * @param settingUri the setting URI to set
211
     */
212
    public void setSettingUri(String settingUri) {
213
        this.settingUri = settingUri;
9✔
214
    }
3✔
215

216
    /**
217
     * Get the Umami analytics script URL.
218
     *
219
     * @return the Umami script URL, or null if not configured
220
     */
221
    public String getUmamiScriptUrl() {
222
        String s = System.getenv("NANODASH_UMAMI_SCRIPT_URL");
9✔
223
        if (s != null && !s.isBlank()) return s;
6!
224
        return umamiScriptUrl;
9✔
225
    }
226

227
    /**
228
     * Set the Umami analytics script URL.
229
     *
230
     * @param umamiScriptUrl the Umami script URL to set
231
     */
232
    public void setUmamiScriptUrl(String umamiScriptUrl) {
233
        this.umamiScriptUrl = umamiScriptUrl;
×
234
    }
×
235

236
    /**
237
     * Get the Umami analytics website ID.
238
     *
239
     * @return the Umami website ID, or null if not configured
240
     */
241
    public String getUmamiWebsiteId() {
242
        String s = System.getenv("NANODASH_UMAMI_WEBSITE_ID");
×
243
        if (s != null && !s.isBlank()) return s;
×
244
        return umamiWebsiteId;
×
245
    }
246

247
    /**
248
     * Set the Umami analytics website ID.
249
     *
250
     * @param umamiWebsiteId the Umami website ID to set
251
     */
252
    public void setUmamiWebsiteId(String umamiWebsiteId) {
253
        this.umamiWebsiteId = umamiWebsiteId;
×
254
    }
×
255

256
    public String getHomeResource() {
257
        String s = System.getenv("NANODASH_HOME_RESOURCE");
×
258
        if (s != null && !s.isBlank()) {
×
259
            logger.debug("Found environment variable NANODASH_HOME_RESOURCE with value: {}", s);
×
260
            return s;
×
261
        }
262
        logger.debug("Environment variable NANODASH_HOME_RESOURCE not set, using default: {}", homeResource);
×
263
        return homeResource;
×
264
    }
265

266
    public void setHomeResource(String homeResource) {
267
        this.homeResource = homeResource;
×
268
    }
×
269

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

© 2026 Coveralls, Inc