Skip to content

Commit

Permalink
renaming the servlet extension from .txt to .json. Fixing the copy to…
Browse files Browse the repository at this point in the history
… clipboard js.
  • Loading branch information
Krassimir Boyanov committed Dec 9, 2024
1 parent 285625a commit f05279c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,14 +55,14 @@
@SlingServletResourceTypes(
resourceTypes = PublishUrlServlet.RESOURCE_TYPE,
methods = HttpConstants.METHOD_GET,
extensions = PublishUrlServlet.TXT_EXTENSION
extensions = PublishUrlServlet.JSON_EXTENSION
)
@Designate(ocd = PublishUrlServlet.PublishUrlServletConfig.class)
public class PublishUrlServlet extends SlingSafeMethodsServlet implements Serializable {

private static final long serialVersionUID = 1L;
protected static final String RESOURCE_TYPE = "acs-commons/components/utilities/publish-url";
protected static final String TXT_EXTENSION = "txt";
protected static final String JSON_EXTENSION = "json";
private static final String PATH = "path";
private static final String JSON_TYPE = "application/json";
private String[] externalizerKeys;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
var modalBody = $(e.target).find('coral-dialog-content'),
failureMessage = Granite.I18n.get('An error occurred determining the page\'s publish URLs.'),
missingConfigMessage = Granite.I18n.get('Missing configs for the Publish URL servlet or Externalizer.'),
publishUrl = Granite.HTTP.externalize('/apps/acs-commons/components/utilities/sites-publish-url.txt'),
publishUrl = Granite.HTTP.externalize('/apps/acs-commons/components/utilities/sites-publish-url.json'),
path = $(e.target).data('assetpath');

var result =
Expand Down Expand Up @@ -69,14 +69,8 @@
button.addEventListener('click', function() {
var key = this.getAttribute('data-copy-target');
var inputField = this.previousElementSibling;
var textToCopy = inputField.value;
inputField.select();
try {
navigator.clipboard.writeText(textToCopy);
console.log("Text copied to clipboard");
} catch (err) {
console.error("Failed to copy: ", err);
}
document.execCommand("copy");
});
});
});
Expand Down

0 comments on commit f05279c

Please sign in to comment.