Hello,
I am interested in developing an extension for handling molecular files (files containing informations about chemical molecules : atoms, bonds, ...). If I understand correctly it will enable me to display specific informations in the File:... page, like what MediaWiki does for simple images. Something like existing extensions (FlvHandler, OggHandler, PagedTiffHandler, PNGHandler, TimedMediaHandler in SVN trunk for example).
I have read several pages on MediaWiki about writing extensions, but they are not very detailed for media handler extensions. I have also written an extension to display and interact with moleculeshttp://wiki.jmol.org/index.php/Jmol_MediaWiki_Extension, but I still have several questions on how I can create a handler for molecular files in MediaWiki. Any help or links to some explanations will be appreciated.
Molecular files exist in several formats : pdb, cif, mol, xyz, cml, ... Usually they are detected as simple MIME types (either text/plain or application/xml) by MediaWiki and not as more precise types (even if this types exist : chemical/x-pdb, chemical/x-xyz, ...). It seems that to register a Media handler, I have to add an entry to $wgMediaHandlers[] : $wgMediaHandler['text/plain'] = 'MolecularHandler'; Will it be a problem to use such a general MIME type to register the handler ? Especially for files of the same MIME type but that are not molecular files ? Are there some precautions to take into account ? (like letting an other handler deal with the file if it's not a molecular file, ...)
I want to use the Jmol http://www.jmol.org/ applet for displaying the molecule in 3d, and allowing the user to manipulate it. But the applet is about 1M in size, so it takes time to load the first time, then to start and load the molecular file. I would like to start showing a still image (generated on the server) and a button to let the user decide when loading the applet if interested in. Several questions for doing this with MediaWiki :
- What hook / event should I use to be able to add this content in the File:... page ? - Is there a way to start displaying the File:... page, compute the still image in the background,and add it in the File:... page after ? - Are there any good practices for doing this kind of things ?
Is it also possible to create thumbnails in articles if they include links to a molecular file (like [[File:example.pdb]]) ? What hook should I use ? Is it possible to compute the thumbnail in the background ?
Any other advice for writing a media handler extension ? Or other possibilities that could enhance the extension ? Among the few handler extensions in SVN, which is the better example ?
Thanks for any help Nico
Hi Nicolas,
There is a bug open for CML support.
https://bugzilla.wikimedia.org/show_bug.cgi?id=16491
and a tracking bug for other chemistry related improvements
https://bugzilla.wikimedia.org/show_bug.cgi?id=17598
djbeetstra@hotmail.com (user:Beetstra) has done some related extension work and may be keen to help.
-- John Vandenberg
On Tue, Nov 23, 2010 at 8:03 AM, Nicolas Vervelle nvervelle@gmail.com wrote:
Hello,
I am interested in developing an extension for handling molecular files (files containing informations about chemical molecules : atoms, bonds, ...). If I understand correctly it will enable me to display specific informations in the File:... page, like what MediaWiki does for simple images. Something like existing extensions (FlvHandler, OggHandler, PagedTiffHandler, PNGHandler, TimedMediaHandler in SVN trunk for example).
I have read several pages on MediaWiki about writing extensions, but they are not very detailed for media handler extensions. I have also written an extension to display and interact with moleculeshttp://wiki.jmol.org/index.php/Jmol_MediaWiki_Extension, but I still have several questions on how I can create a handler for molecular files in MediaWiki. Any help or links to some explanations will be appreciated.
Molecular files exist in several formats : pdb, cif, mol, xyz, cml, ... Usually they are detected as simple MIME types (either text/plain or application/xml) by MediaWiki and not as more precise types (even if this types exist : chemical/x-pdb, chemical/x-xyz, ...). It seems that to register a Media handler, I have to add an entry to $wgMediaHandlers[] : $wgMediaHandler['text/plain'] = 'MolecularHandler'; Will it be a problem to use such a general MIME type to register the handler ? Especially for files of the same MIME type but that are not molecular files ? Are there some precautions to take into account ? (like letting an other handler deal with the file if it's not a molecular file, ...)
I want to use the Jmol http://www.jmol.org/ applet for displaying the molecule in 3d, and allowing the user to manipulate it. But the applet is about 1M in size, so it takes time to load the first time, then to start and load the molecular file. I would like to start showing a still image (generated on the server) and a button to let the user decide when loading the applet if interested in. Several questions for doing this with MediaWiki :
- What hook / event should I use to be able to add this content in the File:... page ? - Is there a way to start displaying the File:... page, compute the still image in the background,and add it in the File:... page after ? - Are there any good practices for doing this kind of things ?
Is it also possible to create thumbnails in articles if they include links to a molecular file (like [[File:example.pdb]]) ? What hook should I use ? Is it possible to compute the thumbnail in the background ?
Any other advice for writing a media handler extension ? Or other possibilities that could enhance the extension ? Among the few handler extensions in SVN, which is the better example ?
Thanks for any help Nico _______________________________________________ Wikitech-l mailing list Wikitech-l@lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/wikitech-l
Hi John,
Thanks for the links to the bugs, interesting informations. I did most of the development of the Jmol extension mentioned in n°16491 but I wasn't aware of this bug report ;) I upgraded it this weekend to be compatible with MW 1.16 and get rid of its dependency on StubManager.
I am trying now to implement something similar to what is described in n°16491, a media handler using Jmol applet to view molecules online, or Jmol application to render still images on the server. Help is really welcome, because Media extensions seem quite complex to write and finding informations in MediaWiki source code is also difficult. So, if djbeetstra can help, that's really good news :)
Thanks, Nico
On Mon, Nov 22, 2010 at 11:41 PM, John Vandenberg jayvdb@gmail.com wrote:
Hi Nicolas,
There is a bug open for CML support.
https://bugzilla.wikimedia.org/show_bug.cgi?id=16491
and a tracking bug for other chemistry related improvements
https://bugzilla.wikimedia.org/show_bug.cgi?id=17598
djbeetstra@hotmail.com (user:Beetstra) has done some related extension work and may be keen to help.
-- John Vandenberg
On Mon, Nov 22, 2010 at 1:03 PM, Nicolas Vervelle nvervelle@gmail.comwrote:
Molecular files exist in several formats : pdb, cif, mol, xyz, cml, ... Usually they are detected as simple MIME types (either text/plain or application/xml) by MediaWiki and not as more precise types (even if this types exist : chemical/x-pdb, chemical/x-xyz, ...). It seems that to register a Media handler, I have to add an entry to $wgMediaHandlers[] : $wgMediaHandler['text/plain'] = 'MolecularHandler'; Will it be a problem to use such a general MIME type to register the handler ? Especially for files of the same MIME type but that are not molecular files ?
You'd want to make sure the type detection correctly identifies your files so you can associate the handler types, or it's going to make things confusing.
For XML files, you should usually be able to add to the $wgXMLMimeTypes array, which by default recognizes the root elements for HTML, SVG, and Dia vector drawings -- see the entries in DefaultSettings.php as examples. It can recognize XML files by either bare or namespaced root element name, and associates the files with the given MIME type.
For plaintext types that aren't currently recognized I'm not 100% sure how best to proceed; might have to override $wgMimeTypesFile or even make some changes to MimeMagic.php (the class that encapsulates most of the file type detection).
I want to use the Jmol http://www.jmol.org/ applet for displaying the molecule in 3d, and allowing the user to manipulate it. But the applet is about 1M in size, so it takes time to load the first time, then to start and load the molecular file. I would like to start showing a still image (generated on the server) and a button to let the user decide when loading the applet if interested in. Several questions for doing this with MediaWiki :
- What hook / event should I use to be able to add this content in the
File:... page ?
- Is there a way to start displaying the File:... page, compute the still
image in the background,and add it in the File:... page after ?
- Are there any good practices for doing this kind of things ?
You might want to look at OggHandler as an example. It too needs to create still-image thumbnails and delay loading of the actual video via Java applet, direct embedding, or HTML 5 <video> tag, and hooks various spots in order to do so.
-- brion
On Mon, Nov 22, 2010 at 11:57 PM, Brion Vibber brion@pobox.com wrote:
On Mon, Nov 22, 2010 at 1:03 PM, Nicolas Vervelle <nvervelle@gmail.com
wrote:
Molecular files exist in several formats : pdb, cif, mol, xyz, cml, ... Usually they are detected as simple MIME types (either text/plain or application/xml) by MediaWiki and not as more precise types (even if this types exist : chemical/x-pdb, chemical/x-xyz, ...). It seems that to register a Media handler, I have to add an entry to $wgMediaHandlers[] : $wgMediaHandler['text/plain'] = 'MolecularHandler'; Will it be a problem to use such a general MIME type to register the handler ? Especially for files of the same MIME type but that are not molecular files ?
You'd want to make sure the type detection correctly identifies your files so you can associate the handler types, or it's going to make things confusing.
For XML files, you should usually be able to add to the $wgXMLMimeTypes array, which by default recognizes the root elements for HTML, SVG, and Dia vector drawings -- see the entries in DefaultSettings.php as examples. It can recognize XML files by either bare or namespaced root element name, and associates the files with the given MIME type.
Oh, good, that's what I need for file types like CML (Chemical Markup Language). I will start working on the media handler only with this kind of files, easier to begin with them.
For plaintext types that aren't currently recognized I'm not 100% sure how best to proceed; might have to override $wgMimeTypesFile or even make some changes to MimeMagic.php (the class that encapsulates most of the file type detection).
Ok, but detection of mime type for some chemical file formats will be quite difficult. Some file formats are just a list of atom coordinates with bonds (each line is simply several numbers separated by a tab). I will take a look at $wgMimeTypesFile or MimeMagic.php after I manage to work with XML files.
I want to use the Jmol http://www.jmol.org/ applet for displaying the molecule in 3d, and allowing the user to manipulate it. But the applet is about 1M in size, so it takes time to load the first time, then to start and load the molecular file. I would like to start showing a still image (generated on the server) and
a
button to let the user decide when loading the applet if interested in. Several questions for doing this with MediaWiki :
- What hook / event should I use to be able to add this content in the
File:... page ?
- Is there a way to start displaying the File:... page, compute the
still
image in the background,and add it in the File:... page after ?
- Are there any good practices for doing this kind of things ?
You might want to look at OggHandler as an example. It too needs to create still-image thumbnails and delay loading of the actual video via Java applet, direct embedding, or HTML 5 <video> tag, and hooks various spots in order to do so.
Ok, thanks, I will try to understand how OggHandler works.
Nico
Hi Brion and others,
On Tue, Nov 23, 2010 at 12:46 AM, Nicolas Vervelle nvervelle@gmail.comwrote:
On Mon, Nov 22, 2010 at 11:57 PM, Brion Vibber brion@pobox.com wrote:
On Mon, Nov 22, 2010 at 1:03 PM, Nicolas Vervelle <nvervelle@gmail.com
wrote:
Molecular files exist in several formats : pdb, cif, mol, xyz, cml, ... Usually they are detected as simple MIME types (either text/plain or application/xml) by MediaWiki and not as more precise types (even if
this
types exist : chemical/x-pdb, chemical/x-xyz, ...). It seems that to register a Media handler, I have to add an entry to $wgMediaHandlers[] : $wgMediaHandler['text/plain'] = 'MolecularHandler'; Will it be a problem to use such a general MIME type to register the handler ? Especially for files of the same MIME type but that are not molecular files ?
You'd want to make sure the type detection correctly identifies your files so you can associate the handler types, or it's going to make things confusing.
For XML files, you should usually be able to add to the $wgXMLMimeTypes array, which by default recognizes the root elements for HTML, SVG, and Dia vector drawings -- see the entries in DefaultSettings.php as examples. It can recognize XML files by either bare or namespaced root element name, and associates the files with the given MIME type.
Oh, good, that's what I need for file types like CML (Chemical Markup Language). I will start working on the media handler only with this kind of files, easier to begin with them.
I have tried your suggestion with $wgXMLMimeTypes, but it works only partially :
- It works for uploading : when I upload the CML file, MediaWiki detects MIME type chemical/x-cml. - It doesn't seem to work for rendering the page (examplehttp://wiki.jmol.org/index.php/File:Nsc202.cml) : displayed MIME type is unknown/unknown (and MediaWiki looks for a media handler for unknown/unknown).
Have you any on what to do next to detect correctly the MIME type when rendering ?
Here are the log of the upload : MimeMagic::__construct: loading mime types from /public_html/mediawiki-1_16_0/includes/mime.types MimeMagic::__construct: loading mime info from /public_html/mediawiki-1_16_0/includes/mime.info *MimeMagic::guessMimeType: final mime type of /tmp/phpSGMnk9: chemical/x-cml * MediaHandler::getHandler: no handler found for chemical/x-cml. File::getPropsFromPath: /tmp/phpSGMnk9 loaded, 10327 bytes, chemical/x-cml. MacBinary::loadHeader: header bytes 0 and 74 not null MimeMagic::guessMimeType: final mime type of /tmp/phpSGMnk9: chemical/x-cml
mime: <chemical/x-cml> extension: <cml>
UploadBase::verifyExtension: mime type chemical/x-cml matches extension cml, passing file UploadBase::detectScript: checking for embedded scripts and HTML stuff UploadBase::detectScript: no scripts found UploadBase::detectVirus: virus scanner disabled UploadBase::verifyFile: all clear; passing.
\performUpload: sum:[[Category:CML file]] c: [[Category:CML file]] w:FSRepo::publishBatch: wrote tempfile /tmp/phpSGMnk9 to /public_html/mediawiki-1_16_0/images/8/84/Nsc202.cml DatabaseBase::query: Writes done: INSERT IGNORE INTO `image` (img_name,img_size,img_width,img_height,img_bits,img_media_type,img_major_mime,img_minor_mime,img_timestamp,img_description,img_user,img_user_text,img_metadata,img_sha1) VALUES ('Nsc202.cml','10327','0','0','0','UNKNOWN','chemical','x-cml','20101201215518','[[Category:CML file]]','2','NicolasVervelle','','nxeilddfhz427gtfakpu37xljp9ipk1') Class SkinMonobook not found; skipped loading Article::editUpdates: No vary-revision, using prepared edit... Saved in parser cache with key wikijmolorg:pcache:idhash:4233-0!1!0!!en!0 and timestamp 20101201215518 DatabaseBase::query: Writes done: DELETE FROM `objectcache` WHERE keyname = 'wikijmolorg:pcache:idhash:4233-0!1!0!!en!0' BacklinkCache::getLinks: from DB BacklinkCache::partition: got from database BacklinkCache::getLinks: from DB BacklinkCache::getLinks: from DB OutputPage::sendCacheControl: private caching; ** Request ended normally accepts gzip Start request
GET /index.php/File:Nsc202.cml HTTP HEADERS: AUTHORIZATION: HOST: wiki.jmol.org CONNECTION: keep-alive REFERER: http://wiki.jmol.org/index.php/Special:Upload CACHE_CONTROL: max-age=0 ACCEPT: application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 USER_AGENT: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/534.7 (KHTML, like Gecko) Chrome/7.0.517.44 Safari/534.7 ACCEPT_ENCODING: gzip,deflate,sdch ACCEPT_LANGUAGE: fr,en-US;q=0.8,en;q=0.6 ACCEPT_CHARSET: ISO-8859-1,utf-8;q=0.7,*;q=0.3 COOKIE: wikijmolorgUserID=2; wikijmolorgUserName=NicolasVervelle; wikijmolorgToken=ee6361e8e8d8badf3b359b60295d4ae4; wikijmolorg_session=b4ef6699ab15e1cdc6786845d1a2de22 SUEXEC_UID: 2818 SUEXEC_GID: 2818
CACHES: FakeMemCachedClient[main] SqlBagOStuff[message] SqlBagOStuff[parser] session_set_cookie_params: "0", "/", "", "", "1" Unstubbing $wgParser on call of $wgParser::setHook from wfChemFormExtension Fully initialised Unstubbing $wgContLang on call of $wgContLang::checkTitleEncoding from WebRequest::getGPCVal LocalisationCache: using store LCStore_DB Unstubbing $wgOut on call of $wgOut::setTitle from MediaWiki::performRequestForTitle Connecting to 93.184.35.247 wikijmolorg... Connected *MediaHandler::getHandler: no handler found for unknown/unknown.* Unstubbing $wgUser on call of $wgUser::getOption from ImagePage::view Cache miss for user 2 Loading options for user 2 from database. Logged in from session Class SkinMonobook not found; skipped loading Unstubbing $wgMessageCache on call of $wgMessageCache::get from wfMsgGetKey Unstubbing $wgLang on call of $wgLang::getCode from wfGetLangObj Connecting to 93.184.35.247 wikijmolorg... Connected MessageCache::load: Loading en... got from global cache MediaHandler::getHandler: no handler found for unknown/unknown. OutputPage::checkLastModified: client did not send If-Modified-Since header Article::view using parser cache: yes Trying parser cache wikijmolorg:pcache:idhash:4233-0!1!0!!en!0 Found. Article::view: showing parser cache contents DatabaseBase::query: Writes done: UPDATE `page` SET page_counter = page_counter + 1 WHERE page_id = 4233 MediaHandler::getHandler: no handler found for unknown/unknown. OutputPage::sendCacheControl: private caching; Wed, 01 Dec 2010 21:55:23 GMT ** Request ended normally accepts gzip
Nico
wikitech-l@lists.wikimedia.org