Skip navigation
This discussion is archived

script to install/update files

362 Views 5 Replies Latest reply: Jun 1, 2007 8:57 AM by James Nierodzik RSS
MacPro.ButNOWebPro Level 4 Level 4 (1,940 points)
Currently Being Moderated
Jun 1, 2007 4:10 AM
i am using package maker to install templates into iweb. i have managed to set the installer up to install the files into the correct locations - but i still need to be able to do one thing.

in order for the templates to work they need to update a templates.plist file. the only way i can see package maker to do is this by giving it a script.

how can i create a script that will update the file by adding certain plist lines into alphabetical orderded lists (in the plist file)?

i cannot replace the existing file because they might all have different templates installed! it sort of needs to merge the files as in file-merger!

another sidenote - i basically have no knowledge of applescript, so dont be to hard on me

thanks,

max
iWeb Help & New Templates at my Site:, http://karreth.com/
  • James Nierodzik Calculating status...
    Currently Being Moderated
    Jun 1, 2007 7:46 AM (in response to MacPro.ButNOWebPro)
    Typically I would say using the shell command defaults is the way to go, but after looking at the file I don't think that will work. I don't have any templates to test this with, but this should work. It does make up a back up of your templates file to the desktop though just in case.

    Currently it only works with one template, but by making the theme name variable a list and throwing the main logic block in a repeat through that list it would be easy to accomodate multiple files.

    -- This works for a single file. Assuming though Multple files
    -- it wouldn't be hard to make a list

    (* ======== Change These For Your Theme ======== *)
    set _themeName to "TESTING" -- Your Templates Name
    set _themeVersion to "1.1" -- Some sort of version or compatability indicator??


    (* === Nothing here down should need to be changed === *)

    set _keys to {"About Me", "Blog", "Movie", "Photos", "Podcast", "Blank", "Welcome"}

    set _deskPath to path to desktop as Unicode text
    set _backupFolder to "iWeb Backup"
    set _backupPath to _deskPath & _backupFolder
    set _appPath to path to application "iWeb" as Unicode text
    set _plistPath to _appPath & "Contents:Resources:English.lproj:Templates:TemplatesInfo.plist"

    tell application "Finder"
    if not (exists folder _backupPath) then
    make new folder at _deskPath with properties {name:_backupFolder}
    end if
    tell application "Finder" to duplicate _plistPath to _backupPath
    end tell

    set _data to (read file _plistPath)

    (* ====================== MAIN LOGIC BLOCK ======================*)
    repeat with _keyValue in _keys
    set _osString to ¬
    " <key>" & _keyValue & "</key>
    <dict>
    <key>BLCategory</key>
    <string>" & _keyValue & "</string>
    <key>BLEntries</key>
    <dict>"
    set _insertString to ¬
    " <key>" & _themeName & "</key>
    <dict>
    <key>displayName</key>
    <string>" & _keyValue & "</string>
    <key>fileName</key>
    <string>" & _themeName & space & _keyValue & ".webtemplate</string>
    </dict>"
    set _theOffset to offset of _osString in _data
    set _top to text 1 through (_theOffset + (count _osString)) of _data
    set _bottom to text (_theOffset + (count _osString) + 1) through -1 of _data
    set _data to _top & _insertString & (ASCII character 10) & _bottom
    end repeat

    set _osString to ¬
    " <key>sortedThemes</key>
    <array>"
    set _insertString to ¬
    " <dict>
    <key>displayName</key>
    <string>" & _themeName & "</string>
    <key>keyName</key>
    <string>" & _themeName & "</string>
    <key>version</key>
    <string>" & _themeVersion & " Themes</string>
    </dict>"
    set _theOffset to offset of _osString in _data
    set _top to text 1 through (_theOffset + (count _osString)) of _data
    set _bottom to text (_theOffset + (count _osString) + 1) through -1 of _data
    set _data to _top & _insertString & (ASCII character 10) & _bottom
    (* ==================== CLOSE MAIN LOGIC BLOCK ====================*)

    try
    close access file _plistPath
    end try

    set _fileRef to open for access _plistPath with write permission
    set eof _fileRef to 0
    write _data to _fileRef
    close access _fileRef
    17" MacBook Pro , Mac OS X (10.4.9), Scripts written with Script Debugger 4 / PreFab UI Browser
  • James Nierodzik Level 3 Level 3 (535 points)
    Currently Being Moderated
    Jun 1, 2007 8:30 AM (in response to MacPro.ButNOWebPro)
    ::answer::

    Let me know how if it works out btw, it was fun tearing into the iWeb XML on the train this morning LOL
    17" MacBook Pro , Mac OS X (10.4.9), Scripts written with Script Debugger 4 / PreFab UI Browser
  • James Nierodzik Level 3 Level 3 (535 points)
    Currently Being Moderated
    Jun 1, 2007 8:57 AM (in response to MacPro.ButNOWebPro)
    Hmm interesting it's not doing that with me. What version of iWeb are you running?

    Would it be possible to mail me a copy of your original Template file?

    jnierodzikATfirestarcomDOTcom
    17" MacBook Pro , Mac OS X (10.4.9), Scripts written with Script Debugger 4 / PreFab UI Browser

Actions

More Like This

  • Retrieving data ...

Bookmarked By (0)

Legend

  • This solved my question - 10 points
  • This helped me - 5 points
This site contains user submitted content, comments and opinions and is for informational purposes only. Apple disclaims any and all liability for the acts, omissions and conduct of any third parties in connection with or related to your use of the site. All postings and use of the content on this site are subject to the Apple Support Communities Terms of Use.