Scholia development is hosted at https://github.com/WDscholia/scholia.
Scholia is mainly based on
- Python (>= 2.7)
- HTML with Bootstrap CSS
- JavaScript with jQuery and wikidata-sdk
- SPARQL to query the Wikidata Query Service
Clone Scholia repository from GitHub
$ git clone https://github.com/WDscholia/scholia.git # via HTTPS $ git clone [email protected]:WDscholia/scholia.git # or via SSH
Install required Python libraries:
$ pip install -r requirements.txt # either globally $ pip install -r requirements.txt # or locally
On Debian 8/9 you need to install the packages python3, python3-pip, and python3-flask and use pip3:
$ apt-get install python3 python3-pip python3-flask $ pip3 install -r requirements.txt
Run Scholia functionality as a script, e.g.:
$ python -m scholia.query twitter-to-q fnielsen Q20980928
Run Scholia locally as a web application
python runserver.py
Rudimentary testing and code style checking are implemented via tox. Before committing, please run the following code in the main directory, as pull requests which give tox errors are not directly merged:
tox
The style is checked with flake8. Also follow the commit message recommendations, cf. Writing good commit messages.
- Pull requests should have a reference to an issue number.
- Branches should be properly named with a name that is self-explanatory and has a reference to an issue number.
- The code must be run with tox for style, and test checks and any errors should be addressed. If it is not possible to fix the tox error, then it should be indicated and discussed.
- Pull requests should only address one single problem.
- Pull requests should not have superfluous code: Code used for debugging, code used to do other work.
- The code should be of a proper standard.
Adding new SPARQL queries to Scholia:
- Assign the task for yourself (if it is in an issue tracker)
- Write a new query and add it in a template file (e.g. in
/app/templates/sparql/author_awards.sparql
) where the file names starts with the aspect name. Note that{{ q }}
will be formatted based on the page that renders the template. See example at https://github.com/WDscholia/scholia/pull/848/files.
SELECT DISTINCT ?author ?authorLabel ?award ?awardLabel WHERE {
?item wdt:P1433 wd:{{ q }} ;
wdt:P50 ?author .
?author wdt:P166 ?award .
SERVICE wikibase:label { bd:serviceParam wikibase:language "[AUTO_LANGUAGE],en". }
}
- The external SPARQL can be included in the templating system for both tables and iframes:
{{ sparql_to_table('recent-literature') }}
{{ sparql_to_iframe('publications-per-year') }}
- Add some table formatting
<h2 id="recent-literature-header">Structural Information</h2>
<table class="table table-hover" id="recent-literature-table"></table>
And iframe formatting:
<h2 id="publications-per-year">Publications per year</h2>
<div class="embed-responsive embed-responsive-16by9">
<iframe class="embed-responsive-item" id="publications-per-year-iframe" ></iframe>
</div>
- Add the whole thing to your version/fork of the file https://github.com/WDscholia/scholia/tree/master/scholia/[…]. Pull request to master branch.