-
Notifications
You must be signed in to change notification settings - Fork 81
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 the ability to select a batch of QuickStatements to run #2345
Closed
Closed
Changes from 29 commits
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
399fd17
Start adding functionality for mutiple ArXiv IDs
carlinmack a344bd6
Add support for multiple quickstatements
carlinmack 940ed73
Copy editing
carlinmack 64e5cae
Minor linting improvements
carlinmack 2ced1d1
add warning message
carlinmack 6a723bb
Rename tool
carlinmack c29a0ce
Redirect arxiv-to-quickstatements
carlinmack f9a739c
Add ability to find dois, improve regexs
carlinmack 55af8a7
First part working with arxivs
carlinmack 7f861a8
Get first part working with DOI
carlinmack 944a3dd
Add doi get metadata
carlinmack 696ad4f
Add metadata_to_quickstatements to utils
carlinmack 60de60f
replace format strings with f-strings
carlinmack a7402f4
Date handling improvements
carlinmack 848ab06
Copy editing and linting
carlinmack 806a6e4
Add error handling
carlinmack b48e54e
Add error checking for arxiv.py
carlinmack 6ba2d45
Improve error handling for doi metadata
carlinmack 3d51dea
Refactor
carlinmack e38ff89
Add section for IDs which failed and describe why
carlinmack af517e7
Fix error with author names
carlinmack bf5d373
Fix codacy issues
carlinmack 85c88c2
Improve string_to_type
carlinmack e7d2b0b
Add number found/etc to headings
carlinmack 22632ea
Update UI
carlinmack ec0a31d
Activate Select all button and add invert selection button
carlinmack 461ba6c
Activate copy buttons
carlinmack 34776d5
Activate copy all button
carlinmack d355adb
Activate submit all button
carlinmack c3e1a32
formatting and fix
carlinmack File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,200 @@ | ||
{% extends "base.html" %} | ||
|
||
|
||
{% block page_content %} | ||
|
||
<h1>Identifier to QuickStatements</h1> | ||
|
||
|
||
<h2>Input</h2> | ||
|
||
<form action="" id="form" method="GET" class="form-horizontal mb-3"> | ||
<div class="input-group"> | ||
{% if query %} | ||
<input type="text" class="form-control" placeholder="Enter a single or list of arXiv IDs or DOIs" | ||
value="{{ query }}" id="searchterm" name="query" /> | ||
{% else %} | ||
<input type="text" class="form-control" placeholder="Enter a single or list of arXiv IDs or DOIs" id="searchterm" | ||
name="query" /> | ||
{% endif %} | ||
<span class="input-group-append"> | ||
<button class="btn btn-primary" type="submit"> | ||
Submit | ||
</button> | ||
</span> | ||
</div> | ||
</form> | ||
|
||
<p>Enter a single or list of <a href="https://arxiv.org">arXiv</a> identifiers or <a href="https://doi.org">DOIs</a> to | ||
retrieve their Wikidata items or QuickStatements to create items for them.</p> | ||
|
||
<p>Bare IDs (such as "1703.06103" or "10.1371/JOURNAL.PONE.0029797") or URLs (such as "https://arxiv.org/abs/1703.06103" | ||
or "https://doi.org/10.1371/JOURNAL.PONE.0029797") can be used and the list can be | ||
comma, space, pipe or tab separated. Note that new items in Wikidata may not be immediately found because of caching. | ||
</p> | ||
|
||
{% if error %} | ||
<div class="alert alert-warning" role="alert"> | ||
No results returned, potentially due to the upstream server being down. Please try again later. If the issue persists | ||
<a | ||
href="https://github.com/WDscholia/scholia/issues/new?assignees=&labels=bug&projects=&template=bug_report.md&title=">submit | ||
a bug report on GitHub</a>. | ||
</div> | ||
{% endif %} | ||
|
||
{% if (qs|length) > 0 %} | ||
<h2>{{ qs|length}} Found</h2> | ||
{% endif %} | ||
|
||
{% if (qs|length) == 1 %} | ||
|
||
<div id="searchresult">{{ qs[0][0] }} has been entered as <a href="work/{{ qs[0][1] }}">{{ qs[0][1] }}</a></div> | ||
|
||
{% endif %} | ||
|
||
{% if (qs|length) > 1 %} | ||
|
||
<div id="searchresult">In Wikidata: | ||
<ul> | ||
{% for q in qs %} | ||
<li>{{ q[0] }}: <a href="work/{{ q[1] }}">{{ q[1] }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
</div> | ||
|
||
{% endif %} | ||
|
||
{% if (quickstatements|length) > 0 %} | ||
<h2>{{(quickstatements|length)}} Not Found</h2> | ||
|
||
<blockquote>Select statements which you want to contribute and use the buttons at the bottom of the section to complete | ||
the action.</blockquote> | ||
<input type="checkbox" class="d-none" id="select-all-state" /> | ||
<button class="btn btn-secondary select-all">Select all</button> <button class="btn btn-secondary invert-selection">Invert selection</button> | ||
<div class="container"> | ||
{% for quickstatement in quickstatements %} | ||
<div class="row"> | ||
<div class="col-1 align-self-center"> | ||
<input type="checkbox" class="select-item checkbox large-checkbox" name="select-item" value="{{loop.index}}" /> | ||
</div> | ||
<div class="col-8"> | ||
<pre>{{ quickstatement }}</pre> | ||
</div> | ||
<div class="d-none" id="qs-{{loop.index}}-url">{{ quickstatement | replace('\t', '|') | replace('\n', '||') | urlencode | ||
| replace('/','%2F') }}</div> | ||
<div class="d-none" id="qs-{{loop.index}}-plain">{{ quickstatement | replace('\t', '|') | replace('\n', '||') | ||
| replace('/','%2F') }}</div> | ||
<div class="col-3 align-self-center"> | ||
<a | ||
href="https://quickstatements.toolforge.org/#/v1={{ quickstatement | replace('\t', '|') | replace('\n', '||') | urlencode | replace('/','%2F') }}"><button | ||
class="btn btn-outline-secondary">Submit to Quickstatements ↗</button></a> | ||
<button class="btn btn-outline-secondary copy-button" name="{{loop.index}}">Copy to clipboard</button> | ||
</div> | ||
</div> | ||
{% endfor %} | ||
</div> | ||
|
||
<div class="d-flex justify-content-between"> | ||
<div> | ||
<button class="btn btn-primary select-all">Select all</button> | ||
<button class="btn btn-primary invert-selection">Invert selection</button> | ||
</div> | ||
<div> | ||
<button class="btn btn-primary ml-auto" id="submit-all-button">Submit to Quickstatements ↗</button> | ||
<button class="btn btn-primary" id="copy-all-button">Copy to clipboard</button> | ||
</div> | ||
</div> | ||
</div> | ||
|
||
|
||
{% endif %} | ||
|
||
{% if (failed|length) > 0 %} | ||
<h2>{{(failed|length)}} Failed</h2> | ||
|
||
<ul> | ||
{% for fail in failed %} | ||
<li>{{ fail[0] }}: {{ fail[1] }}</a></li> | ||
{% endfor %} | ||
</ul> | ||
{% endif %} | ||
|
||
|
||
{% endblock %} | ||
|
||
{% block scripts %} | ||
{{super()}} | ||
<script type="text/javascript"> | ||
const select_alls = document.getElementsByClassName("select-all"); | ||
const select_all_state = document.getElementById("select-all-state"); | ||
for (const select_all of select_alls) { | ||
select_all.addEventListener("click", () => { | ||
select_all_state.checked = !select_all_state.checked; | ||
const checked = select_all_state.checked; | ||
const checkboxes = document.getElementsByClassName("checkbox"); | ||
for (const checkbox of checkboxes) { | ||
checkbox.checked = checked; | ||
} | ||
}) | ||
} | ||
|
||
const invert_selections = document.getElementsByClassName("invert-selection"); | ||
for (const invert_selection of invert_selections) { | ||
invert_selection.addEventListener("click", () => { | ||
const checkboxes = document.getElementsByClassName("checkbox"); | ||
for (const checkbox of checkboxes) { | ||
checkbox.checked = !checkbox.checked; | ||
} | ||
}) | ||
} | ||
|
||
const copy_buttons = document.getElementsByClassName("copy-button"); | ||
for (const copy_button of copy_buttons) { | ||
copy_button.addEventListener("click", () => { | ||
const qs_id = copy_button["name"]; | ||
const quickstatements = document.getElementById("qs-" + qs_id + "-plain"); | ||
if (navigator.clipboard) { | ||
navigator.clipboard.writeText(quickstatements.innerText) | ||
} | ||
}) | ||
} | ||
|
||
const copy_all = document.getElementById("copy-all-button"); | ||
copy_all.addEventListener("click", () => { | ||
var items = []; | ||
document.querySelectorAll("input.select-item:checked:checked").forEach((item, index) => { | ||
console.log(index) | ||
console.log(item) | ||
const qs_id = item["value"]; | ||
const quickstatements = document.getElementById("qs-" + qs_id + "-plain"); | ||
items.push(quickstatements.innerText); | ||
}); | ||
if (items.length < 1) { | ||
const parent = copy_all.parentNode.parentNode; | ||
parent.insertAdjacentHTML('afterend', `<div class="alert alert-warning" role="alert">Select at least one row using the checkbox on the left</div>`); | ||
} else { | ||
var values = items.join('\n\n'); | ||
if (navigator.clipboard) { | ||
navigator.clipboard.writeText(values) | ||
} | ||
} | ||
}); | ||
|
||
const submit_all = document.getElementById("submit-all-button"); | ||
submit_all.addEventListener("click", () => { | ||
var items = []; | ||
document.querySelectorAll("input.select-item:checked:checked").forEach((item, index) => { | ||
const qs_id = item["value"]; | ||
const quickstatements = document.getElementById("qs-" + qs_id + "-url"); | ||
items.push(quickstatements.innerText); | ||
}); | ||
if (items.length < 1) { | ||
const parent = submit_all.parentNode.parentNode; | ||
parent.insertAdjacentHTML('afterend', `<div class="alert alert-warning" role="alert">Select at least one row using the checkbox on the left</div>`); | ||
} else { | ||
const values = items.join('||'); | ||
window.location.href = "https://quickstatements.toolforge.org/#/v1=" + values | ||
} | ||
}); | ||
</script> | ||
{% endblock %} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check warning
Code scanning / CodeQL
DOM text reinterpreted as HTML Medium
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.
values
is urlencoded on line 83 so I think it's okay