Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.knowledgepixels.nanodash;

import com.knowledgepixels.nanodash.component.ButtonList;
import com.knowledgepixels.nanodash.component.ViewDisplayMenu;
import com.knowledgepixels.nanodash.component.menu.ViewDisplayMenu;
import com.knowledgepixels.nanodash.domain.AbstractResourceWithProfile;
import com.knowledgepixels.nanodash.page.NanodashPage;
import org.apache.wicket.behavior.AttributeAppender;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<div class="link-actions-panel">
<a wicket:id="externalLink" target="_blank" rel="noopener noreferrer"></a>

<a wicket:id="copyLinkButton" class="copy-link-btn">
<img wicket:id="copyIcon" alt="Copy link" width="16" height="16"/>
</a>

<wicket:container wicket:id="np">[np]</wicket:container>

<a wicket:id="exploreButton" class="smallbutton button light">Explore</a>
</div>
</wicket:panel>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
package com.knowledgepixels.nanodash.component;

import com.knowledgepixels.nanodash.component.menu.ExploreDisplayMenu;
import com.knowledgepixels.nanodash.page.ExplorePage;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.image.Image;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.apache.wicket.request.resource.ContextRelativeResourceReference;
import org.eclipse.rdf4j.model.IRI;

/**
* External link with Actions Panel that allows to copy the link and explore it through the Nanodash ExplorePage.
*/
public class ExternalLinkWithActionsPanel extends Panel {

private final IModel<String> urlModel;
private IModel<String> labelModel;
private IRI sourceNanopub;

public ExternalLinkWithActionsPanel(String id, IModel<String> urlModel) {
super(id);
this.urlModel = urlModel;
}

public ExternalLinkWithActionsPanel(String id, IModel<String> urlModel, IModel<String> labelModel) {
this(id, urlModel);
this.labelModel = labelModel;
}

public ExternalLinkWithActionsPanel(String id, IModel<String> urlModel, IModel<String> labelModel, IRI sourceNanopub) {
this(id, urlModel, labelModel);
this.sourceNanopub = sourceNanopub;
}

@Override
protected void onInitialize() {
super.onInitialize();

ExternalLink externalLink = new ExternalLink("externalLink", urlModel, urlModel);
add(externalLink);

AjaxLink<Void> copyLinkButton = new AjaxLink<>("copyLinkButton") {
@Override
public void onClick(AjaxRequestTarget target) {
String url = urlModel.getObject();
String escapedUrl = url.replace("'", "\\'");
target.appendJavaScript(
"navigator.clipboard.writeText('" + escapedUrl + "')" +
".then(function() { alert('Link copied to clipboard!'); })" +
".catch(function(err) { console.error('Copy failed:', err); });"
);
}
};
copyLinkButton.add(new Image("copyIcon", new ContextRelativeResourceReference("images/copy-icon.svg", false)));
add(copyLinkButton);

if (sourceNanopub != null) {
add(new Label("exploreButton", "").setVisible(false));
add(new ExploreDisplayMenu("np", urlModel.getObject(), labelModel.getObject(), sourceNanopub));
} else {
add(new Label("np", "").setVisible(false));
if (labelModel != null) {
AjaxLink<Void> exploreButton = new AjaxLink<>("exploreButton") {
@Override
public void onClick(AjaxRequestTarget target) {
setResponsePage(ExplorePage.class, new PageParameters().set("id", urlModel.getObject()).set("label", labelModel.getObject()));
}
};
add(exploreButton);
} else {
add(new Label("exploreButton", "").setVisible(false));
}
}
}

@Override
protected void onDetach() {
super.onDetach();
urlModel.detach();
if (labelModel != null) {
labelModel.detach();
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.knowledgepixels.nanodash.*;
import com.knowledgepixels.nanodash.action.NanopubAction;
import com.knowledgepixels.nanodash.action.RetractionAction;
import com.knowledgepixels.nanodash.component.menu.ActionMenu;
import com.knowledgepixels.nanodash.domain.User;
import com.knowledgepixels.nanodash.page.ListPage;
import com.knowledgepixels.nanodash.page.UserPage;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.knowledgepixels.nanodash.NanodashSession;
import com.knowledgepixels.nanodash.QueryResult;
import com.knowledgepixels.nanodash.ViewDisplay;
import com.knowledgepixels.nanodash.component.menu.ViewDisplayMenu;
import org.apache.wicket.ajax.AjaxRequestTarget;
import org.apache.wicket.ajax.markup.html.AjaxLink;
import org.apache.wicket.behavior.AttributeAppender;
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html xmlns:wicket="http://wicket.apache.org">

<head>
<link rel="stylesheet" href="../../../../../webapp/style.css?for-local-testing-only" type="text/css" media="screen" title="Stylesheet" />
<link rel="stylesheet" href="../../../../../../webapp/style.css?for-local-testing-only" type="text/css" media="screen" title="Stylesheet" />
</head>
<body>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.knowledgepixels.nanodash.component;
package com.knowledgepixels.nanodash.component.menu;

import com.knowledgepixels.nanodash.*;
import com.knowledgepixels.nanodash.action.NanopubAction;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:wicket="http://wicket.apache.org">
<body>
<wicket:panel>
<span class="actionmenu">
<button class="actionmenu-button">▼</button>
<span class="actionmenu-content">
<wicket:child/>
</span>
</span>
</wicket:panel>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package com.knowledgepixels.nanodash.component.menu;

import org.apache.wicket.Component;
import org.apache.wicket.markup.html.panel.Panel;

import java.util.ArrayList;
import java.util.List;

public class BaseDisplayMenu extends Panel {

public record Entry(String wicketId, Component component) {
}

private final List<Entry> entries = new ArrayList<>();

public BaseDisplayMenu(String id) {
super(id);
}

protected void addEntry(String wicketId, Component component) {
entries.add(new Entry(wicketId, component));
}

@Override
protected void onInitialize() {
super.onInitialize();
for (Entry entry : entries) {
add(entry.component());
}
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">

<head>
<link rel="stylesheet" href="../../../../../../webapp/style.css?for-local-testing-only" type="text/css" media="screen"
title="Stylesheet"/>
</head>
<body>

<wicket:extend>
<a wicket:id="explore">explore</a>
<a wicket:id="viewDeclaration">see declaration</a>
</wicket:extend>

</body>

</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package com.knowledgepixels.nanodash.component.menu;

import com.knowledgepixels.nanodash.page.ExplorePage;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.eclipse.rdf4j.model.IRI;

public class ExploreDisplayMenu extends BaseDisplayMenu {

/**
* Constructs a ExploreDisplayMenu.
*
* @param id the Wicket component ID
* @param exploreUri the URI of the resource to explore
* @param exploreLabel the label of the resource to be rendered in the explore page
* @param sourceUri the uri of the source nanopublication defining the resource
*/
public ExploreDisplayMenu(String id, String exploreUri, String exploreLabel, IRI sourceUri) {
super(id);

addEntry("explore", new BookmarkablePageLink<Void>("explore", ExplorePage.class, new PageParameters().set("id", exploreUri).set("label", exploreLabel)));
addEntry("viewDeclaration", new BookmarkablePageLink<Void>("viewDeclaration", ExplorePage.class, new PageParameters().set("id", sourceUri)));
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html xmlns:wicket="http://wicket.apache.org">

<head>
<link rel="stylesheet" href="../../../../../../webapp/style.css?for-local-testing-only" type="text/css" media="screen"
title="Stylesheet"/>
</head>
<body>

<wicket:extend>
<a wicket:id="showQuery">show query</a>
<a wicket:id="adjust">edit view display</a>
<a wicket:id="viewDeclaration">show nanopub</a>
</wicket:extend>

</body>

</html>
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.knowledgepixels.nanodash.component;
package com.knowledgepixels.nanodash.component.menu;

import com.knowledgepixels.nanodash.NanodashSession;
import com.knowledgepixels.nanodash.NanopubElement;
Expand All @@ -13,7 +13,6 @@
import com.knowledgepixels.nanodash.template.TemplateData;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.link.ExternalLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.request.mapper.parameter.PageParameters;
import org.eclipse.rdf4j.model.IRI;
import org.nanopub.extra.services.QueryRef;
Expand All @@ -22,7 +21,7 @@
* A dropdown menu panel for view displays, replacing the "^" source link.
* Provides options to show the query, adjust the view display, and see its declaration.
*/
public class ViewDisplayMenu extends Panel {
public class ViewDisplayMenu extends BaseDisplayMenu {

/**
* Constructs a ViewDisplayMenu.
Expand All @@ -39,7 +38,7 @@ public ViewDisplayMenu(String id, ViewDisplay viewDisplay, QueryRef queryRef, Ab
for (var entry : queryRef.getParams().entries()) {
showQueryParams.add("queryparam_" + entry.getKey(), entry.getValue());
}
add(new BookmarkablePageLink<Void>("showQuery", QueryPage.class, showQueryParams));
addEntry("showQuery", new BookmarkablePageLink<Void>("showQuery", QueryPage.class, showQueryParams));

IRI nanopubId = viewDisplay.getNanopubId();

Expand Down Expand Up @@ -73,9 +72,9 @@ public ViewDisplayMenu(String id, ViewDisplay viewDisplay, QueryRef queryRef, Ab
+ "&template-version=latest";
ExternalLink adjustLink = new ExternalLink("adjust", adjustUrl, "edit view display");
adjustLink.setVisible(showAdjust);
add(adjustLink);
addEntry("adjust", adjustLink);

add(new BookmarkablePageLink<Void>("viewDeclaration", ExplorePage.class,
addEntry("viewDeclaration", new BookmarkablePageLink<Void>("viewDeclaration", ExplorePage.class,
new PageParameters().set("id", nanopubId)));
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/**
* This package contains the menu components.
*/
package com.knowledgepixels.nanodash.component.menu;
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

<h2><span wicket:id="termname"></span></h2>

<p>Full identifier: <a href="#" wicket:id="urilink" id="ref"></a></p>
<span wicket:id="urilink"></span>

<p>
<a class="button" href="." wicket:id="back-to-context-link">back to context</a>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,10 @@ private void initPage() {
}
add(new Label("pagetitle", shortName + " (explore) | nanodash"));
add(new Label("termname", shortName));
add(new ExternalLink("urilink", ref, ref));

//add(new ExternalLink("urilink", ref, ref));
add(new ExternalLinkWithActionsPanel("urilink", Model.of(ref)));

if (publishedNanopub != null) {
add(new Label("statusline", "<h4>Status</h4><p>Successfully published.</p>").setEscapeModelStrings(false));
} else if (isNanopubId && SignatureUtils.seemsToHaveSignature(np)) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="row-section">
<div class="col-12 header">
<h2><span wicket:id="resourcename">Resource ABC</span></h2>
<p><a wicket:id="id" href=".">https://...</a> <wicket:container wicket:id="np">[np]</wicket:container></p>
<p><span wicket:id="id"></span></p>
<p class="hide-if-empty">Namespace: <a wicket:id="namespace" href="." class="hide-if-empty-trigger"></a></p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ public MaintainedResourcePage(final PageParameters parameters) {

add(new Label("pagetitle", resource.getLabel() + " (resource) | nanodash"));
add(new Label("resourcename", resource.getLabel()));
add(new BookmarkablePageLink<Void>("id", ExplorePage.class, parameters.set("label", resource.getLabel())).setBody(Model.of(resource.getId())));
add(new SourceNanopub("np", Values.iri(resource.getNanopubId())));
add(new ExternalLinkWithActionsPanel("id", Model.of(resource.getId()), Model.of(resource.getLabel()), Values.iri(resource.getNanopubId())));

String namespaceUri = resource.getNamespace() == null ? "" : resource.getNamespace();
add(new BookmarkablePageLink<Void>("namespace", ExplorePage.class, new PageParameters().set("id", namespaceUri)).setBody(Model.of(namespaceUri)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<div class="row-section">
<div class="col-12 header">
<h2><span wicket:id="name">ABC</span></h2>
<p><a wicket:id="id" href=".">https://...</a> <wicket:container wicket:id="np">[np]</wicket:container></p>
<p><span wicket:id="id"></span></p>
<p wicket:id="description">Description...</p>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,7 @@ public ResourcePartPage(final PageParameters parameters) {

add(new Label("pagetitle", label + " (resource part) | nanodash"));
add(new Label("name", label));
add(new BookmarkablePageLink<Void>("id", ExplorePage.class, parameters.set("label", label)).setBody(Model.of(id)));
add(new SourceNanopub("np", nanopubId == null ? Values.iri(id) : Values.iri(nanopubId)));
add(new ExternalLinkWithActionsPanel("id", Model.of(id), Model.of(label), nanopubId == null ? Values.iri(id) : Values.iri(nanopubId)));

// TODO Improve this code, e.g. make Space a subclass of MaintainedResource or otherwise refactor:
// we now use the ProfileResource abstraction, but the code still has to be imprved
Expand Down
Loading