Skip to content

Commit 985b06d

Browse files
committed
Add initial version
0 parents  commit 985b06d

9 files changed

Lines changed: 325 additions & 0 deletions

File tree

.github/build.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/main/ci-build.sh
3+
sh ci-build.sh

.github/setup.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/bin/sh
2+
curl -fsLO https://raw.githubusercontent.com/scijava/scijava-scripts/main/ci-setup-github-actions.sh
3+
sh ci-setup-github-actions.sh

.github/workflows/build.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
tags:
8+
- "*-[0-9]+.*"
9+
pull_request:
10+
branches:
11+
- main
12+
13+
jobs:
14+
build:
15+
runs-on: ubuntu-latest
16+
17+
steps:
18+
- uses: actions/checkout@v2
19+
- name: Set up Java
20+
uses: actions/setup-java@v3
21+
with:
22+
java-version: '11'
23+
distribution: 'zulu'
24+
cache: 'maven'
25+
- name: Set up CI environment
26+
run: .github/setup.sh
27+
- name: Execute the build
28+
run: .github/build.sh
29+
env:
30+
GPG_KEY_NAME: ${{ secrets.GPG_KEY_NAME }}
31+
GPG_PASSPHRASE: ${{ secrets.GPG_PASSPHRASE }}
32+
MAVEN_USER: ${{ secrets.MAVEN_USER }}
33+
MAVEN_PASS: ${{ secrets.MAVEN_PASS }}
34+
CENTRAL_USER: ${{ secrets.CENTRAL_USER }}
35+
CENTRAL_PASS: ${{ secrets.CENTRAL_PASS }}
36+
SIGNING_ASC: ${{ secrets.SIGNING_ASC }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/.idea/
2+
/target/

LICENSE.txt

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
Copyright (c) 2023 - 2025, Fiji developers.
2+
All rights reserved.
3+
4+
Redistribution and use in source and binary forms, with or without modification,
5+
are permitted provided that the following conditions are met:
6+
7+
1. Redistributions of source code must retain the above copyright notice, this
8+
list of conditions and the following disclaimer.
9+
10+
2. Redistributions in binary form must reproduce the above copyright notice,
11+
this list of conditions and the following disclaimer in the documentation
12+
and/or other materials provided with the distribution.
13+
14+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
15+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17+
ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
18+
LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
19+
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
20+
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
21+
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
22+
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
23+
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
24+
POSSIBILITY OF SUCH DAMAGE.

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[![Build Status](https://github.com/fiji/fiji-links/actions/workflows/build.yml/badge.svg)](https://github.com/fiji/fiji-links/actions/workflows/build.yml)
2+
3+
This package implements support for fiji:// links,
4+
built on [scijava-links](https://github.com/scijava/scijava-links).
5+
Support can be extended via `LinkHandler` plugins.

pom.xml

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<parent>
6+
<groupId>org.scijava</groupId>
7+
<artifactId>pom-scijava</artifactId>
8+
<version>43.0.0</version>
9+
<relativePath />
10+
</parent>
11+
12+
<groupId>sc.fiji</groupId>
13+
<artifactId>fiji-links</artifactId>
14+
<version>1.0.0-SNAPSHOT</version>
15+
16+
<name>Fiji Links</name>
17+
<description>Standard fiji:// URL handlers.</description>
18+
<url>https://github.com/fiji/fiji-links</url>
19+
<inceptionYear>2023</inceptionYear>
20+
<organization>
21+
<name>Fiji</name>
22+
<url>https://fiji.sc/</url>
23+
</organization>
24+
25+
<licenses>
26+
<license>
27+
<name>Simplified BSD License</name>
28+
<distribution>repo</distribution>
29+
</license>
30+
</licenses>
31+
32+
<developers>
33+
<developer>
34+
<id>ctrueden</id>
35+
<name>Curtis Rueden</name>
36+
<url>https://imagej.net/people/ctrueden</url>
37+
<roles>
38+
<role>founder</role>
39+
<role>lead</role>
40+
<role>debugger</role>
41+
<role>reviewer</role>
42+
<role>support</role>
43+
<role>maintainer</role>
44+
</roles>
45+
</developer>
46+
</developers>
47+
<contributors>
48+
<contributor>
49+
<name>Marwan Zouinkhi</name>
50+
<url>https://imagej.net/people/mzouink</url>
51+
<roles><role>founder</role></roles>
52+
<properties><id>mzouink</id></properties>
53+
</contributor>
54+
</contributors>
55+
56+
<mailingLists>
57+
<mailingList>
58+
<name>Image.sc Forum</name>
59+
<archive>https://forum.image.sc/tag/scijava</archive>
60+
</mailingList>
61+
</mailingLists>
62+
63+
<scm>
64+
<connection>scm:git:https://github.com/fiji/fiji-links</connection>
65+
<developerConnection>scm:git:git@github.com:fiji/fiji-links</developerConnection>
66+
<tag>HEAD</tag>
67+
<url>https://github.com/fiji/fiji-links</url>
68+
</scm>
69+
70+
<issueManagement>
71+
<system>GitHub Issues</system>
72+
<url>https://github.com/fiji/fiji-links/issues</url>
73+
</issueManagement>
74+
75+
<ciManagement>
76+
<system>GitHub Actions</system>
77+
<url>https://github.com/fiji/fiji-links/actions</url>
78+
</ciManagement>
79+
80+
<properties>
81+
<package-name>sc.fiji.links</package-name>
82+
<scijava.jvm.version>11</scijava.jvm.version>
83+
<license.licenseName>bsd_2</license.licenseName>
84+
<license.copyrightOwners>Fiji developers.</license.copyrightOwners>
85+
86+
<scijava-links.version>1.0.0</scijava-links.version>
87+
</properties>
88+
89+
<dependencies>
90+
<dependency>
91+
<groupId>org.scijava</groupId>
92+
<artifactId>scijava-common</artifactId>
93+
</dependency>
94+
<dependency>
95+
<groupId>org.scijava</groupId>
96+
<artifactId>scijava-links</artifactId>
97+
<version>${scijava-links.version}</version>
98+
</dependency>
99+
<dependency>
100+
<groupId>junit</groupId>
101+
<artifactId>junit</artifactId>
102+
<scope>test</scope>
103+
</dependency>
104+
</dependencies>
105+
</project>
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
/*-
2+
* #%L
3+
* Standard fiji:// URL handlers.
4+
* %%
5+
* Copyright (C) 2023 - 2025 Fiji developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
30+
package sc.fiji.links;
31+
32+
import org.scijava.links.AbstractLinkHandler;
33+
import org.scijava.links.LinkHandler;
34+
import org.scijava.links.Links;
35+
import org.scijava.log.LogService;
36+
import org.scijava.plugin.Parameter;
37+
import org.scijava.plugin.Plugin;
38+
import org.scijava.ui.UIService;
39+
40+
import java.net.URI;
41+
42+
/** Handles {@code fiji://hello} links. */
43+
@Plugin(type = LinkHandler.class)
44+
public class HelloLinkHandler extends AbstractLinkHandler {
45+
46+
@Parameter(required = false)
47+
private LogService log;
48+
49+
@Parameter(required = false)
50+
private UIService ui;
51+
52+
@Override
53+
public boolean supports(final URI uri) {
54+
return "fiji".equals(uri.getScheme()) &&
55+
uri.getHost().equals("hello");
56+
}
57+
58+
@Override
59+
public void handle(final URI uri) {
60+
if (!supports(uri)) throw new UnsupportedOperationException("" + uri);
61+
62+
var operation = Links.operation(uri);
63+
var query = Links.query(uri);
64+
var greeting = query.getOrDefault("greeting", "Hello!");
65+
66+
if ("print".equals(operation)) {
67+
System.out.println(greeting);
68+
}
69+
else if ("log".equals(operation)) {
70+
if (log != null) log.info(greeting);
71+
}
72+
else if ("dialog".equals(operation)) {
73+
if (ui != null) ui.showDialog(greeting);
74+
}
75+
else {
76+
throw new UnsupportedOperationException(
77+
"Unknown hello operation: " + operation);
78+
}
79+
}
80+
}
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*-
2+
* #%L
3+
* Standard fiji:// URL handlers.
4+
* %%
5+
* Copyright (C) 2023 - 2025 Fiji developers.
6+
* %%
7+
* Redistribution and use in source and binary forms, with or without
8+
* modification, are permitted provided that the following conditions are met:
9+
*
10+
* 1. Redistributions of source code must retain the above copyright notice,
11+
* this list of conditions and the following disclaimer.
12+
* 2. Redistributions in binary form must reproduce the above copyright notice,
13+
* this list of conditions and the following disclaimer in the documentation
14+
* and/or other materials provided with the distribution.
15+
*
16+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
17+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR CONTRIBUTORS BE
20+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
21+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
22+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
23+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
24+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
25+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
26+
* POSSIBILITY OF SUCH DAMAGE.
27+
* #L%
28+
*/
29+
30+
package sc.fiji.links;
31+
32+
import org.junit.Test;
33+
import org.scijava.Context;
34+
import org.scijava.console.ConsoleService;
35+
import org.scijava.console.OutputEvent;
36+
import org.scijava.links.LinkService;
37+
38+
import java.net.URI;
39+
import java.net.URISyntaxException;
40+
import java.util.ArrayList;
41+
42+
import static org.junit.Assert.*;
43+
44+
/**
45+
* Tests handling of {@code fiji://} links.
46+
*
47+
* @author Curtis Rueden
48+
*/
49+
public class HelloLinkHandlerTest {
50+
51+
@Test
52+
public void testHelloPrint() throws URISyntaxException {
53+
try (Context ctx = new Context(LinkService.class, ConsoleService.class)) {
54+
var linkService = ctx.service(LinkService.class);
55+
var consoleService = ctx.service(ConsoleService.class);
56+
var output = new ArrayList<OutputEvent>();
57+
consoleService.addOutputListener(output::add);
58+
59+
var uri = new URI("fiji://hello/print?greeting=Yo");
60+
linkService.handle(uri);
61+
62+
assertFalse(output.isEmpty());
63+
assertTrue(output.get(0).isStdout());
64+
assertEquals("Yo", output.get(0).getOutput());
65+
}
66+
}
67+
}

0 commit comments

Comments
 (0)