I spent a little time today trying to get Spotlight to import Tinderbox files correctly. I was initially having problems and knew the latest Tinderbox (2.5) was supposed to be Spotlightable. So what do we know about Tinderbox files?
$ mdls Tinderbox\ release\ notes
Tinderbox release notes -------------
kMDItemAttributeChangeDate = 2005-06-30 11:20:26 -0400
kMDItemContentCreationDate = 2002-03-08 14:21:13 -0500
kMDItemContentModificationDate = 2005-06-27 13:49:50 -0400
kMDItemContentType = "dyn.ah62d4rv4gk8yg3pwqy"
kMDItemContentTypeTree = ("public.data", "public.item")
kMDItemDisplayName = "Tinderbox release notes"
kMDItemFSContentChangeDate = 2005-06-27 13:49:50 -0400
kMDItemFSCreationDate = 2002-03-08 14:21:13 -0500
kMDItemFSCreatorCode = 1130721893
kMDItemFSFinderFlags = 16
kMDItemFSInvisible = 0
kMDItemFSLabel = 0
kMDItemFSName = "Tinderbox release notes"
kMDItemFSNodeCount = 0
kMDItemFSOwnerGroupID = 80
kMDItemFSOwnerUserID = 501
kMDItemFSSize = 646376
kMDItemFSTypeCode = 1130721893
kMDItemID = 2251793
kMDItemKind = "Tinderbox document"
kMDItemLastUsedDate = 2005-06-30 11:19:26 -0400
kMDItemUsedDates = (2005-06-30 11:19:26 -0400, 2005-06-29 20:00:00 -0400)
The important bits for our purpose are the kMDItemContentType and kMDItemContentTypeTree. These are set by the Spotlight importer and are what Spotlight "knows" about the filetype. Here the Tinderbox Release Notes is treated as just plain data and not indexed.
$ mdimport -d1 Tinderbox\ release\ notes
2005-07-01 16:46:21.470 mdimport[13845] Import '/Applications/Productivity/Tinderbox 2.5/Tinderbox release notes' type 'dyn.ah62d4rv4gk8yg3pwqy' no mdimporter
Now, I have a choice -- I can either let Spotlight not index the file, or I can finesse the RichText.mdimporter to handle this type. We'll ignore this for now.
So let's look at another Tinderbox. The original box for this web site was called RoboTHOR. I'd never added a file extension, since I hadn't needed it previously, but obviously raw Tinderboxes don't work ideally. What if I renamed it to RoboTHOR.xml ?
$ mdls RoboTHOR.xml
RoboTHOR.xml -------------
kMDItemAttributeChangeDate = 2005-07-01 16:28:00 -0400
kMDItemContentCreationDate = 2005-04-19 18:48:33 -0400
kMDItemContentModificationDate = 2005-07-01 14:39:31 -0400
kMDItemContentType = "public.xml"
kMDItemContentTypeTree = ("public.xml", "public.text", "public.data", "public.item", "public.content")
kMDItemDisplayName = "RoboTHOR"
...
Certainly better. Now mdimport's output will be a little more pleasant:
$ mdimport -d1 RoboTHOR.xml
2005-07-01 16:48:24.961 mdimport[13852] Import '/Users/mtlong/Sites/robothor/RoboTHOR.xml' type 'public.xml' using 'file://localhost/System/Library/Spotlight/ RichText.mdimporter/'
So now the final test. What about .tbx, the normal extension for Tinderbox documents?
$ mdls RoboTHOR.tbx
RoboTHOR.tbx -------------
kMDItemAttributeChangeDate = 2005-07-01 16:50:00 -0400
kMDItemContentCreationDate = 2005-04-19 18:48:33 -0400
kMDItemContentModificationDate = 2005-07-01 16:33:18 -0400
kMDItemContentType = "com.testgate.tinderbox"
kMDItemContentTypeTree = (
"com.testgate.tinderbox",
"public.xml",
"public.text",
"public.data",
"public.item",
"public.content"
)
...
But now we have stopped getting love from mdimport:
$ mdimport -d1 RoboTHOR.tbx
2005-07-01 16:50:48.586 mdimport[13872] Import '/Users/mtlong/Sites/robothor/RoboTHOR.tbx' type 'com.testgate.tinderbox' no mdimporter
Spotlight will no longer import this file, even though it still knows that it is XML. But there is a solution. We can modify the /System/Library/Spotlight/ RichText.mdimporter/Contents/Info.plist and alter the LSItemContentTypes array as follows:
<key>LSItemContentTypes</key>
<array>
<string>public.rtf</string>
<string>public.html</string>
<string>public.xml</string>
<string>public.plain-text</string>
<string>com.apple.traditional-mac-plain-text</string>
<string>com.apple.rtfd</string>
<string>com.apple.webarchive</string>
<string>com.testgate.tinderbox</string>
<string>dyn.ah62d4rv4gk8yg3pwqy</string>
</array>
We simply added com.testgate.tinderbox and dyn.ah62d4rv4gk8yg3pwqy. Now mdimport
$ mdimport -d2 RoboTHOR.tbx
2005-07-01 16:09:53.020 mdimport[13591] Import '/Users/mtlong/Sites/robothor/RoboTHOR.tbx' type 'com.testgate.tinderbox' using 'file://localhost/System/Library/Spotlight/ RichText.mdimporter/'
$ mdimport -d1 Tinderbox\ release\ notes
2005-07-01 17:35:27.905 mdimport[13901] Import '/Applications/Productivity/Tinderbox 2.5/Tinderbox release notes' type 'dyn.ah62d4rv4gk8yg3pwqy' using 'file://localhost/System/Library/Spotlight/ RichText.mdimporter/'
Now were sitting fat dumb and happy.



