Hi Brion and others, On Tue, Nov 23, 2010 at 12:46 AM, Nicolas Vervelle <[email protected]>wrote:
> On Mon, Nov 22, 2010 at 11:57 PM, Brion Vibber <[email protected]> wrote: > >> On Mon, Nov 22, 2010 at 1:03 PM, Nicolas Vervelle <[email protected] >> >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 (example<http://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 mailing list [email protected] https://lists.wikimedia.org/mailman/listinfo/wikitech-l
