-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add referencePreview feature #140
Conversation
- fix a bug where all urls would be concatenated as a common url - fix a visual bug where the preview button would be cut in case of short urls - refactor the code used to append the preview button into a general function
Can the button be more subtile? It's quite prominent now for such a feature. |
Yes, it can. I will try a different style in the next few days 😃 |
@sjoerddebruin , maybe you can give an example of what you mean with subtile ? |
A black button seems very off with the rest of the Wikidata user interface. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for this change. Here are some comments related mostly on how to improve the implementation.
PS: There is also a conflict with the current master version. May you do a rebase?
frontend/freebase2wikidata.js
Outdated
|
||
var async = module.exports; | ||
var ps = mw.ps || {}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure that having a such global is needed. You could just declare the openNav and closeNav functions inside of the main PrimarySources closure and call them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I initially put the functions in the closure, as you suggested. The problem is that they are called from an onClick of a button, and they are not visible from outside of the closure. If you have any suggestion on how to fix this I could remove the global object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Instead of building the HTML from a string and on*
attributes you could maybe build it using jQuery or something similar, allowing you to call functions declared in the closure. Eg.
$('<div>').attr('id', 'myNav').addClass('overlay')
.append(
$('<a>').addClass('closebtn).click(closeNav),
$('<div>').attr('id', "blackboard").addClass("overlay-content")
);
It's probably even going to make more sense if you use OOjs UI.
type: 'GET', | ||
url: 'https://tools.wmflabs.org/strephit/search?url=' + encodeURI(referenceURL), | ||
success: function(msg) { | ||
$('.loader').remove(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use the OOjs UI progress bar to fit more into MediaWiki UI and to avoid to have to write extra code https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.ProgressBarWidget
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loader is pure css and it is not related to "real" progress, it is just used to signal the user that the tool is not blocked but it is waiting for the backend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok! If you do not set specific progress level OO.ui.ProgressBarWidget is going to be in "indeterminate" state and display a visual motion.
var item = data[index]; | ||
if(index != 'url' && item !== null){ | ||
if( index == 'other' ) { | ||
while(typeof item == 'string'){ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems quite dangerous (but it's maybe what should be done)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can see your point, but atm I'm not able to provide a better solution for this, as I don't have a consistent format for the data I get from the api.
frontend/freebase2wikidata.js
Outdated
@@ -34,9 +34,9 @@ | |||
*/ | |||
|
|||
$(function() { | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have a good reason to drop the "use strict" option?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We dropped it in this commit, if you remember, as a temporary fix for the tool. I also think that this is the source of the conflict as it is a duplicate commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thank you! Sorry, for not remembering.
frontend/freebase2wikidata.js
Outdated
} | ||
} | ||
} | ||
else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file seems to use the K&R coding style. Example:
if(foo) {
bar;
} else {
baz;
}
It's not important but it's better for consistency.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will fix this
frontend/freebase2wikidata.js
Outdated
ps.openNav = function openNav(itemLabel, propertyLabel, propertyValue, referenceURL, buttons) { | ||
$('#myNav').width('100%'); | ||
|
||
var blackboard = $('#blackboard'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of building your own window system you could maybe rely on https://doc.wikimedia.org/oojs-ui/master/js/#!/api/OO.ui.ProcessDialog that seems to fit quite well this use case.
PrimarySources is already using it for the PrimarySources list feature and there is already a windowManager created at the end of this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great suggestion. I used a simple div as a window system as it seemed the fastest and easiest way to me. I will try to look into the OO.ui library.
This PR will add a new feature to the PST.
The referencePreview feature will enable the user to preview (and to approve or reject) a reference without opening it in another tab.
If the reference is fetched from a dataset that makes its corpus available (e.g. StrepHit) the corpus itself will be used to create a preview.
If the corpus is not available (e.g. Freebase) a generic scraper will be used to create a "best effort" preview.
In the preview the item label, the property label and the value will be highlighted (yellow marker in the previous image) through text search.