Page MenuHomePhabricator

New extension for chemical substance identifiers
Closed, ResolvedPublic

Description

Author: Beetstra.wiki

Description:
Dear all, within the chemistry part of the wikipedia, we are trying to get rid of excessive, and biased
external links on chemical substance-pages. Since every chemical substance gets assigned some unique
identifiers, it would be possible to collate all the external links into a page (a rough setup is on
http://en.wikipedia.org/wiki/Wikipedia:Chemical_sources), and then have a special page creating the
links, just like the special:booksources page. I would like to have some help setting this up, I do not
have a live server to run a test wikipedia on, I have not much of a clue about php, and don't know how
to get my hands on an example (probs a copy of the special:booksources page.
For as far as I now can see, it boils down to making a copy of the special:booksources page, which loads
the chemical sources page. The special page has to be able to take more than one unique identifier, and
fill them in (maybe in some cases using some extra handling). I expect that the second step might be
also creating the magiclinks, but to start with I would be satisfied with templates calling the special
page.
Can somebody have a look if what we would like to have is possible, and then help us set this up?
Cheers, Dirk.


Version: unspecified
Severity: enhancement
URL: http://en.wikipedia.org/wiki/Wikipedia:Chemical_sources

Details

Reference
bz7364

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:25 PM
bzimport set Reference to bz7364.

Beetstra.wiki wrote:

New Special Page

Hi, managed to get a working wikipedia on my pc, could not get the newest
version to run (requires php5 (got that) and mysql, but errormessages and
install instructions are not helpful).

This file creates a special page that works under 1.6.8. Added a line to
Specialpage.php:

'ChemicalSources' => new SpecialPage('ChemicalSources' ),

and some variables to messages.php:
'Chemicalsources' => 'Chemical sources',
'Cas' => 'CAS-Number ',
'Einecs' => 'EINECS',
'PubChem' => 'PubChem',
'SMILES' => 'SMILES',
'InChI' => 'InChI',
'ATCCode' => 'ATC-Code',
'DrugBank' => 'DrugBank',
'Formula' => 'Molecular Formula',
'Name' => 'IUPAC Name',
'Chemicalsourcetext' => "Below is a list of links to other sites that sell
chemicals,
and may also have further information about chemicals you are looking for.",

Not sure how to proceed from here. Could someone give me a hand on this?
Cheers. Dirk

attachment SpecialChemicalSources.php ignored as obsolete

Beetstra.wiki wrote:

New version of Special:ChemicalSources (vide supra)

New version, other files changed (in version 1.6.8)

*New line in includes\specialpage (before line 67):
'ChemicalSources' => new SpecialPage('ChemicalSources'),

*Addition to languages\Messages.php (before line 1010):
'Chemicalsources' => 'Chemical sources',
'Cas' => 'CAS-Number ',
'Einecs' => 'EINECS',
'PubChem' => 'PubChem',
'SMILES' => 'SMILES',
'InChI' => 'InChI',
'CHEBI' => 'ChEBI',
'ATCCode' => 'ATC-Code',
'DrugBank' => 'DrugBank',
'Formula' => 'Molecular Formula',
'Name' => 'IUPAC Name',
'Chemicalsourcetext' => "Below is a list of links to other sites that may
provide information about
the chemical substance you are looking for.",

*Addition to languages\Language.php (before line 173):
/* private */ $wgChemicalstoreListEn = array(

'NIST WEbbook' => 'http://webbook.nist.gov/cgi/cbook.cgi?ID=$1&Units=SI',
'Oxford MSDS' => 'http://ptcl.chem.ox.ac.uk/MSDS/',
'ACROS MSDS (commercial supplier)' =>

'http://www.acros.be/DesktopModules/Acros_Search_Results/Acros_Search_Results.aspx?search_type=CatalogSearch&SearchString=$1'

);

*And addition to languages\Language.php (before line 345):

/**
 * Exports $wgChemicalstoreListEn
 * @return array
 */
function getChemicalstoreList() {

global $wgChemicalstoreListEn ;
return $wgChemicalstoreListEn ;

}

Hope to hear more about this soon! Cheers! Dirk.

attachment SpecialChemicalSources.php ignored as obsolete

Beetstra.wiki wrote:

If I see correctly the only thing different from the above mentioned changes in the files, is that in
1.7.1 includes\Specialpage.php should get as an extra line:
'ChemicalSources' => array( 'SpecialPage', 'ChemicalSources' ),
(instead of thementioned 'ChemicalSources' => new SpecialPage('ChemicalSources'),). The other changes
should be correct.

Dirk.

Beetstra.wiki wrote:

Updated chemicalsources php

updated file, no other changes made

attachment SpecialChemicalsources.php ignored as obsolete

jimmy.collins wrote:

Can't you rewrite this as a "real" extension. See
http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/examples/SpecialIncludable.php?revision=11132&view=markup
for an example.

Elsewhere you can hack MediaWiki itself, but then you should provide a unified
patch. But IMHO it better should be an extension.

Cheers Jimmy

Beetstra.wiki wrote:

Addition of ChemicalSources functionality

First attempt to a patch, hope this is all OK

attachment mediawiki.patch.txt ignored as obsolete

Beetstra.wiki wrote:

New Chemicalsources specialpage

Discard other patch, forgot to turn of a redirect function. This is the
correct version.
Cheers. Dirk

attachment patch.txt ignored as obsolete

Beetstra.wiki wrote:

New version of special:chemicalsources

Added extra functionality to special:Chemicalsources (more parameters, checking
of some parameters)

attachment patch.diff.txt ignored as obsolete

Beetstra.wiki wrote:

Upgraded patch

Bit extra functionality in patch compared to last.

attachment patch.diff ignored as obsolete

Beetstra.wiki wrote:

Special:Chemicalsources written as an extension

This patch yields the same result as patch 2424, mediawiki gets a
special:chemicalsources, but this time the page is written as an extension.
The patch contains the extension, and some variables which are added to
Language.php and MessagesEN.php.
People at en.wikipedia.org would like to see this extension (or patch 2424)
added, since it gives us a better possibility to link to external chemical
sources (which yield a wealth of info), an option which is now impossible
without bias.

attachment specialchemicalsourcesextension.diff.txt ignored as obsolete

dto wrote:

Extensions should probably not modify core code. You could check some of the
extensions in SVN to see how custom messages can be added without changing
languages/* files and with support for internationalization.

Beetstra.wiki wrote:

internationalised, only files in extensions, now.

Extensions for use in wikipedia that have [[chemical substances]] in them.
Three files:
SpecialChemicalsources.php, creates a specialpage, similar to the booksources
page.
ChemFunctions.php, creates a new tag <chemform>, to use with chemical formulae.

ChemFunctions.i18n.php, an internationalisation file, is used by both
SpecialChemicalsources.php and ChemFunctions.php (overlapping data).

Could these three files be uploaded into the extensions directory, in a own
subdir 'Chemistry' (or something similar)?

After uploading, could a core dev. please test these, see if they do no harm,
and if so, install them both in the wikipedia (en.wikipedia.org, calling
SpecialChemicalsources.php and ChemFunctions.php from localsettings.php, that
is also thé way to uninstall them again).

Cheers! Dirk.

attachment ChemFunctions.diff.txt ignored as obsolete

Beetstra.wiki wrote:

New version of the extensions

New version, code more optimised! Could use some feedback!

attachment ChemFunctionsExtensions.diff.txt ignored as obsolete

jeluf wrote:

This extension allows the use of HTML in pages, without checking the user
supplied HTML code for sanity, and could thus be used by an attacker to gather
user passwords and session cookies.

Beetstra.wiki wrote:

New version

Forced output through the parser, added new option to <chemform>-tag, added
support for nl

attachment specialchemicalsourcesextension.diff.txt ignored as obsolete

Beetstra.wiki wrote:

new diff

Good version

attachment ChemFunctions.diff.txt ignored as obsolete

Beetstra.wiki wrote:

remove one file, needs more work

Remove one not working part, needs work to remove arbitrary HTML. Will add
other extension seperately.

attachment ChemFunctions.diff.txt ignored as obsolete

Beetstra.wiki wrote:

ChemFunctions files

See comment #12

@ comment #14, the chemform tag now filters the two tags that are used through
the sanitizer. SpecialChemicalPages.php does not use any arbitrary html.

attachment ChemFunctions.diff.txt ignored as obsolete

rotemliss wrote:

Added the extension files in r16831.

Beetstra.wiki wrote:

Patch some changes

Removed link, added possibility to explanation in i18n

attachment ChemFunctions.2.diff.txt ignored as obsolete

jimmy.collins wrote:

(In reply to comment #20)

Created an attachment (id=2475) [edit]
Patch some changes

Removed link, added possibility to explanation in i18n

In r16843.

Beetstra.wiki wrote:

Invert working of one option

Working of the option 'nolink' has been removed and changed into the option
'link' (so the extension only links when the option is given, not the other way
around).

attachment ChemFunctions.patch ignored as obsolete

jimmy.collins wrote:

(In reply to comment #22)

Created an attachment (id=2488) [edit]
Invert working of one option

Committed in r16895.

Beetstra.wiki wrote:

cleanup of code, make code more general, easier to adapt

Cleanup of code, removing empty lines, adding some comments.

Parameters and variables have been generalized a bit, so that adapting the page
for other functions is easier.

Attached:

jimmy.collins wrote:

(In reply to comment #24)

Created an attachment (id=2531) [edit]

Appled in r17153. Please open a *new* bug next time.