Skip to content
Stable urls that showcase a Wikidata item's sitelinks, and related items.
PHP JavaScript CSS
Branch: master
Clone or download
evad37 Merge pull request #49 from evad37/mergedItems
Handle redirected/merged items properly
Latest commit cda43c9 Feb 15, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
css Page view tracking and displaying Apr 20, 2018
i18n
img Fix filename (toolforge server is case sensitive) Feb 19, 2018
inc Handle redirected/merged items properly Feb 15, 2019
js Fixed handling when there's no related items/indentifiers Feb 19, 2018
web Handle redirected/merged items properly Feb 15, 2019
.htaccess Refactor (#34) Feb 10, 2018
.lighttpd.conf fix for language code, allow trailing slashes Jan 15, 2018
LICENSE Initial commit Dec 25, 2017
README.md Update login hostname Feb 7, 2019
index.php Page view tracking and displaying Apr 20, 2018
views.php Page view tracking and displaying Apr 20, 2018

README.md

  Try it out: https://tools.wmflabs.org/portal
  See also: Free Knowledge Portal on Wikimedia Meta-Wiki

About

The Free Knowledge Portal is a tool by Evad37 that is a solution to the Wikimedia 2017 Community Wishlist Survey proposal "Qr codes for all items".

Background

The existing QR-encoding tool, QRpedia, allows GLAM instituations, other organisations, or anyone else create a QR code for a Wikipedia article. The QR code is generated based on the article title in a specific primary language. These QR codes can be placed in a relevant physical location, printed on handouts, or otherwise made available so that members of the public can scan them, and get more information from the Wikipedia article.

The problems, per the wishlist proposal, include:

  • Articles can be renamed, breaking the links (e.g. "Foo" is renamed to "Foo (disambiguated)").
  • Only Wikipedia articles can be accessed from the QR codes, despite the wealth of relevant information that might be available in sister projects like Wikivoyage and Wikisource.
  • QR codes for non-Latin languages are very large and more difficult to use (example)

The solution

The solution to all those problems is to use Wikidata:

  • Wikidata item ids are stable, and don't change when pages are moved. If Wikidata items are merged into another item, a redirect is left behind which can be followed.
  • Wikidata item ids store site links to Wikimedia projects. These can be presented to end-users as a portal, so they can choose which of the available wikis to go to, rather than just Wikipedia
  • The length of the url encoded in the QR code is determined by the Wikidata item id, not the page title, so you don't need huge QR codes for non-Latin languages.

The Free Knowledge Portal is a tool (hosted on Wikimedia's Toolforge) that provides this solution.

Additional features

  • Since links are displayed in a portal page, rather than just redirected to Wikipedia, the portal can also show:
    • Related items (items that link to the subject item)
    • Nearby items (for items which have coordinates specified)
    • External identifiers (such as those for GLAM partner institutions)
  • Responsive design that adapts to mobile, tablet, and desktop views
  • Language switcher that not only translates the interface, but also changes the site links to that language version of the site (e.g. French Wikipedia when the language selected is French)
  • Automatically detects device language, and uses that language by default
  • Backwards-compatible with existing QRpedia codes, by using a page title and site to determine the relevant Wikidata item id. (But of course its up to the QRpedia people to redirect the codes to these urls if they choose to)

Examples

Translations

This tool supports internationalisation.

  • Content: Item labels, descriptions, and sitelinks are retrieved from Wikidata in the specified langauge. Any updates need to be made on Wikidata.
  • Interface: Translations for strings used in the interface are located in JSON files in the /i18n directory. To add another langauge:
    • Create a new JSON file, using the same format as the existing files
    • Save it as {lang-code}.json
    • Add the langauge code and name to the /i18n/_langs.json file (sorted in alphabetical order by langauge code)

Updating

This tool is located on the Wikimedia Toolforge, at https://tools.wmflabs.org/portal/. To update:

  1. Login to toolforge with ssh:

    $ ssh -i ~/.ssh/id_rsa user@login-stretch.tools.wmflabs.org

  2. Become the tool account:

    $ become portal

  3. Pull from GitHub repo into the public_html folder:

    $ cd public_html

    $ git pull

  4. If the .lighttpd.conf file has changed, that file needs to be copied to the root directory:

    $ cp public_html/.lighttpd.conf .lighttpd.conf

  5. ...then restart the webservice:

    $ webservice stop

    $ webservice start

Database

Page views are stored in an SQL database. To connect manually:

  1. Login to toolforge with ssh, become the tool account (as above)
  2. Retreive database username: $ cat replica.my.cnf
  3. Connect with mysql: $ mysql --defaults-file=$HOME/replica.my.cnf -h tools.db.svc.eqiad.wmflabs USER__views
You can’t perform that action at this time.