A need for a direct link to the widget
Closed this issue · 2 comments
It is not presently possible to share a direct link to the widget.
It would be very useful if the users can enter the widget using a direct link, not entering first on the front page of the vocabulary/ontology. An implementation needs certain changes to the ways the widget is loaded. To initialize the widget properly (with the direct link), the widget needs information from the Skosmos (Finto) and the vocabulary. The properties needed in the initialization phase: UI lang, vocabulary id, concept URI (if suggesting a change to the existing concept) and URL.
The direct link could be constructed with two parts. The first part is a vocabulary URL, and the second, a fragment part, could be for example #suggest. A complete URL would then be https://finto.fi/yso/fi/#suggest.
While loading the widget, a new code should be run doing the trick. The code checks if the URL includes the fragment part (#suggest). If the fragment part is included, the widget will be opened like it was opened by clicking the link on the YSO page.
Furthermore, after entering the widget, the URL with the fragment part can be copied from the browser's address bar for later use. It can be shared keeping the binding between the state of the widget and the web address.
It is quite likely that some technical challenges will be faced, but the basic idea is clear. Implementing the improvement requires more technical specification.
I think this should be pretty straightforward and doable without any changes to Skosmos code.
The widget JS code is already initialized after the page has fully loaded. Currently it just adds the link to the page. But it could also check if the URL fragment equals #suggest
(using a check like window.location.hash == "suggest"
). In that case, it can look up the necessary information (UI lang, vocabulary id, concept URI...) from the global variables defined by Skosmos. For example, the English language front page of YSO includes this JS block in the HTML code:
<!-- variables passed through to javascript -->
var lang = "en";
var content_lang = "en";
var vocab = "yso";
var uriSpace = "http://www.yso.fi/onto/yso/";
var showNotation = true;
var languageOrder = ["en","fi","sv"];
var vocShortName = "YSO";
var explicitLangCodes = false;
var pluginParameters = [];
I think this should be all the widget needs (and more).
Direct link to the front page:
https://dev.finto.fi/yso/en/#directnew
Direct link to the concept page:
https://dev.finto.fi/yso/sv/page/p26179#directmodify
If you are constructing a direct link with an url and a fragment part and you want to test it, remember to submit the constructed url to a new tab in the browser (imitating a real life situation where a user enters the widget after clicking a link to it)