Forums / General / using mac's spotlight for .tpl and .php

using mac's spotlight for .tpl and .php

Author Message

*- pike

Sunday 21 October 2007 4:52:12 am

Hi

I had to do much textchanges throughout a ezp site. I was using BBEdit's "find in files", but it took ages for each string. So I wanted to use Mac's "spotlight" - which does content indexing. Alas, it didn't index php and tpl files. Now it does, and here's what I did:

I read these:
http://www.macosxhints.com/article.php?story=20050514182520714
http://www.macosxhints.com/article.php?story=2005052015041510
And set to work.

For PHP first.

check if php is a recognized extension. open a terminal and type

mdimport -n -d1 myfile.php

where myfile.php actually exists. This returns something like

Import 'myfile.php' type 'public.php-script' no mdimporter

This says two things:
- the extension "php" is mapped to "public.php-script"
- there is nothing indexing "public.php-script"

To fix the second thing, let's add public.php-script to

/System/Library/Spotlight/RichText.mdimporter

if you've installed Apples Developer Tools, you'd better add it to

/Library/Spotlight/SourceCode.mdimporter

Find that file, rightclick, "show package contents". Open "info.plist",
and to the LSItemContentTypes, add one entry for "public.php-script".
Save it. In the terminal, type

mdimport -r /System/Library/Spotlight/RichText.mdimporter

which will return with

Asking the server to index files of type: ....

Now perform a spotlight search for "print" and watch php files roll in.

---

Now for tpl. Check if tpl is a recognized extension. open a terminal and type

 mdimport -n -d1 myfile.tpl

where myfile. tpl actually exists. This returns something like

Import 'myfile. tpl' type 'dyn.456fhj8679fhgjhdf' no mdimporter

This says two things:
- the extension "tpl" is mapped to "dyn.456fhj8679fhgjhdf"
- there is nothing indexing "dyn.456fhj8679fhgjhdf"

To fix the first thing, we have to add a UTI for extension ".tpl"
To do this, I downloaded http://www.lexa.ru/andyt/MyUTIs.bundle.zip,
unzipped it, rightclicked, "show package contents". Open "info.plist",
and added one entry for extension ".tpl", mapping it to "no.ez.template".

Then, I put the bundle in my Applications folder and rebooted.
After rebooting, I opened a terminal and typed

mdimport -n -d1 myfile.tpl

This returns something like

Import 'myfile. tpl' type 'no.ez.template' no mdimporter

This says two things:
- the extension "tpl" is now mapped to "no.ez.template"
- there is nothing indexing "no.ez.template" yet

As with the php example, I edited

/System/Library/Spotlight/RichText.mdimporter

I opened "info.plist", and to the LSItemContentTypes, added one entry for "no.ez.template". Then I went to the terminal and typed

mdimport -r /System/Library/Spotlight/RichText.mdimporter

And in spotlight, I did a search for

i18n(-php)

.. and waited for the templates to roll in ..

wow :-)
*-pike

---------------
The class eZContentObjectTreeNode does.

Ole Morten Halvorsen

Monday 22 October 2007 2:44:08 am

Cool! Thanks for the tip. Spotlight is supposedly faster in Leopard so this will be even more useful in the a week or so :)

Ole M.

Senior Software Engineer - Vision with Technology

http://www.visionwt.com
http://www.omh.cc
http://www.twitter.com/omh

eZ Certified Developer
http://ez.no/certification/verify/358441
http://ez.no/certification/verify/272578

eZ debug

Timing: Jan 19 2025 11:50:28
Script start
Timing: Jan 19 2025 11:50:28
Module start 'content'
Timing: Jan 19 2025 11:50:28
Module end 'content'
Timing: Jan 19 2025 11:50:28
Script end

Main resources:

Total runtime0.2210 sec
Peak memory usage2,048.0000 KB
Database Queries141

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0069 588.9688180.8359
Module start 'content' 0.00690.0070 769.804797.8672
Module end 'content' 0.01390.2070 867.6719533.3281
Script end 0.2210  1,401.0000 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00411.8365200.0002
Check MTime0.00150.6756200.0001
Mysql Total
Database connection0.00110.484110.0011
Mysqli_queries0.166875.44221410.0012
Looping result0.00210.96251390.0000
Template Total0.206693.510.2066
Template load0.00080.363710.0008
Template processing0.205893.122010.2058
Override
Cache load0.00060.256610.0006
Sytem overhead
Fetch class attribute can translate value0.00100.466010.0010
XML
Image XML parsing0.00030.129010.0003
General
dbfile0.00552.5038200.0003
String conversion0.00000.002730.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0002 secs