Joined: May 31, 2003 Posts: 219 Location: French Alps
Posted: Tue Mar 08, 2005 5:12 pm Post subject: [posted] an AppleScript to install help file
As we get more and more request about this topic, I just wrote a straightforward AppleScript to allow anyone to install help file without using Terminal. It prompts for admin password, let you select the NeoJ install and either select or drop help archive. It gess the language code from the file name.
It works with no problem.
I need to add some international setting and error checking. Will probably be ready tomorow (it's 1 AM here)
So where should I post it. For the drag&drop ability the script must be saved as an Application and downloaded by the user.
Since the source is very short I can also post it there and Patrick grab it to add on this download page; or will it go to the wiki; or on one of my own site with some links toward?
?
Max
Last edited by Max_Barel on Wed Mar 09, 2005 9:59 am; edited 1 time in total
Posted: Tue Mar 08, 2005 8:31 pm Post subject: Re: [coming] an AppleScript to install help file
Max_Barel wrote:
As we get more and more request about this topic, I just wrote a straightforward AppleScript to allow anyone to install help file without using Terminal. It prompts for admin password, let you select the NeoJ install and either select or drop help archive. It gess the language code from the file name.
Cool! I was just thinking about this again the other day....
Max_Barel wrote:
So where should I post it. For the drag&drop ability the script must be saved as an Application and downloaded by the user.
Since the source is very short I can also post it there and Patrick grab it to add on this download page; or will it go to the wiki; or on one of my own site with some links toward?
In order to make it visible (and therefore cut down the number of questions about installing Help in the forums, which is one of the goals), the app really needs to be linked from the official Neo/J download page(s).
As to where the app (.dmg/.sit) physically resides, I think in terms of upgrading/fixing/maintianing it, hosting it on your own space would provide you the most flexibility and save time and effort for both you and Patrick. ...Unless Jake can/will turn on uploading for you, which would provide the miniscule advantage of the file appearing at a semi-official-looking URL.
Smokey _________________ "[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Posted: Wed Mar 09, 2005 12:04 am Post subject: Re: [coming] an AppleScript to install help file
Max_Barel wrote:
So where should I post it. For the drag&drop ability the script must be saved as an Application and downloaded by the user.
Since the source is very short I can also post it there and Patrick grab it to add on this download page; or will it go to the wiki; or on one of my own site with some links toward?
?
Max
Thanks, in advance, for your work Max. I look forward to being able to download your script as I have multilingual installations to contend with. Anything that simplifies these extra installation processes are welcome.
I hope you will make the source script available as I, for one, would want to learn from your superior knowledge of AppleScript.
Joined: May 31, 2003 Posts: 219 Location: French Alps
Posted: Wed Mar 09, 2005 9:51 am Post subject: Here is first draft
pluby wrote:
Would it be possible for me to just put it in with the Neo/J patches? I don't know where you need this AppleScript file to reside.
Definitely, the best place is on your own download or patches page.
This script can be run from anywhere. As it is one-shot for most users, I presume they will download it on the Desktop, use it once and discard.
There are two way to use it :
1) Launch it by double-clicking on its icon; two step selection; enter password; done.
2) Drag and drop the help file archive onto the script icon; one step selection; enter password; done.
on get_mess()
repeat with ui_lang in get_ui_lang()
if ui_lang as text = "fr" then return mess_fr
--if ui_lang as text = "de" then return mess_de
--etc...
end repeat
return mess_en --default to English
end get_mess
on run
--script launched from finder
set mess to get_mess() --set UI message "dictionnary"
choose file with prompt mess's messaide without invisibles -- get help file archive
set aide to POSIX path of result
traite(aide)
end run
on open help_alias
--help archive drag&droped onto the script
set aide to (POSIX path of help_alias)
set mess to get_mess() --set UI message "dictionnary"
traite(aide)
end open
on traite(aide)
--processing
set code_l to code_lang(aide) --get help language code
if code_l is false then
display dialog mess's messerr --invalid help archive
else
choose application with prompt mess's messNeo as alias --select NeoOffice/J
set neoj_h to (POSIX path of result) & "Contents/help"
try
folder of (info for (neoj_h as POSIX file)) --check for help directory
on error
display dialog mess's messerr --invalide application selected
return
end try
--command line construction
set shell_c to "sudo /bin/sh -e -c 'cd \"" & neoj_h & "\" ; rm -Rf " & code_l & " ; mkdir " & code_l & " ; cd " & code_l & " ; gunzip -q < \"" & aide & "\" | tar xvf - --no-same-owner ; for i in *.zip ; do jar xvf \"$i\" ; rm \"$i\"; done'"
--display dialog shell_c --uncomment to allow check the command before processing
--the true action is there
try
do shell script shell_c with administrator privileges
display dialog mess's messOK --success
on error
display dialog mess's messGrave --this error might be serious...
return
end try
end if
end traite
on code_lang(aide)
--guess the language code from the country number embeded in the file name
set code to text -11 through -10 of aide
if code = "33" then return "fr"
if code = "34" then return "es"
if code = "39" then return "it"
if code = "46" then return "sv"
if code = "49" then return "de"
if code = "55" then return "pt-BR"
if code = "81" then return "ja"
if code = "82" then return "ko"
if code = "86" then return "zh-CN"
if code = "88" then return "zh-TW"
if code = "90" then return "tr"
return false --unknow code or invalid file name
end code_lang
--return list of languages from user's preferences
on get_ui_lang()
set AppleScript's text item delimiters to ", "
try
do shell script "defaults read 'Apple Global Domain' AppleLanguages"
set retour to text items of text 2 through -2 of result
on error
set retour to {"en"}
end try
set AppleScript's text item delimiters to ""
return retour
end get_ui_lang
Remarks :
- As usual, most of the code is glue to check for error and select the UI language. The active part is very short, as was the test version.
- I modified slightly the shell command: the useless zip files under the newly created help folder are removed to save space; added a tar option to ensure all files are created as root:admin ownership; added quotes to be safer with special (space...) char in pathnames. There is still error floating around if a " is embeded in pathname!
- This first draft has no version number yet, it's alpha.
- The script is aware of the default system language of the user and try to select messages accordingly.
- Those few message displayed in dialogs are currently available in English and French only. Please post translations for other langages so we can add them. That's easy to do, see comment in the source. I can do it if I host the script.
- You can copy and paste the code in a new AppleScript Editor window if you like. This is redundant since the application code is editable.
There are two way to use it :
1) Launch it by double-clicking on its icon; two step selection; enter password; done.
2) Drag and drop the help file archive onto the script icon; one step selection; enter password; done.
...
- The script is aware of the default system language of the user and try to select messages accordingly.
- Those few message displayed in dialogs are currently available in English and French only. Please post translations for other langages so we can add them. That's easy to do, see comment in the source. I can do it if I host the script.
- You can copy and paste the code in a new AppleScript Editor window if you like. This is redundant since the application code is editable.
Neat!
One question: There is a list of language code guesses. Is this final, or do you need more? Ideally, you have those the have language packs available for them as well.
Thanks again,
Oscar _________________ "What do you think of Western Civilization?"
"I think it would be a good idea!"
- Mohandas Karamchand Gandhi
Joined: May 31, 2003 Posts: 219 Location: French Alps
Posted: Wed Mar 09, 2005 10:37 am Post subject: Re: Here is first draft
ovvldc wrote:
One question: There is a list of language code guesses. Is this final, or do you need more? Ideally, you have those the have language packs available for them as well.
To clarify : there are two language notions in this script : UI language and help file language. Most of the time they will be the same but are processed independently.
For the UI language there is no limitation and we can add all contributed translations.
Edit: Yes, I need more translations of the script messages to add them in the source.
For the help languages the current list is limited to thoses files listed on Planamesa, which refers to the help archives repository at OpenOffice.org.
I'm not aware of other help files.
If there are, we could add them to the list (if the file name convention isn't the same, I'd have to modify the guessing function).
Max
Last edited by Max_Barel on Sat Mar 12, 2005 8:05 am; edited 1 time in total
Posted: Sat Mar 12, 2005 2:09 am Post subject: Re: [posted] an AppleScript to install help file
Max_Barel wrote:
... a straightforward AppleScript to allow anyone to install help file without using Terminal.
I'm sorry, but could anyone please explain how is this help file different from the one that is included in NeoJ install package? I already have one help.
Is it just to use different localisations, i.e. help in other languages? Or something else. Somewhat more explicit installation guidelines would also be helpful. Maybe it's my bad english and only small technical knowledge, but I really did not understand the two possibilities of installation.... Maybe there are some more dumbusers like me?
Joined: May 31, 2003 Posts: 219 Location: French Alps
Posted: Sat Mar 12, 2005 7:59 am Post subject: Re: [posted] an AppleScript to install help file
s_habe wrote:
I'm sorry, but could anyone please explain how is this help file different from the one that is included in NeoJ install package? I already have one help. Is it just to use different localisations, i.e. help in other languages?
Yes. This script is to help folks install help in oher languages. It's just a wrapper for commmand lines listed on NeoOffice/J site at this download page.
s_habe wrote:
Somewhat more explicit installation guidelines would also be helpful. Maybe it's my bad english and only small technical knowledge, but I really did not understand the two possibilities of installation....
This thread was for annoucing the script availability.
Hopefully it will be referenced from the previous page, with a few words of usage.
In short (for forthcoming searching readers):
1) download the script and unzip it (e.g. on the Desktop).
2) download the help archive you wish to install.
3) drag& drop the archive on the script icon.
4) select the NeoOffice/J application from the pop-up dialog, enter you (admin) password, wait for the completion message.
BTW: Only a few days, but there not much comments, a couple of download, no contributed translation... I wonder if it was a worthwile attempt (I was wondering before I did it anyway).
For sure, until Patrick add it to the download page, there will be few users aware of this thing.
BTW, one reason for not having many translations is that people are used to english programs and don't like to change the habits and partly even learn the use of program as new again, while swiching languages. Well, I'm one of such people. Tried my native language localisation in different programs a couple of times and changed it quickly back to the english version I'm used to.
Then again, for many users it is certainly helpful and thanks guys for helping them!
Posted: Sat Mar 12, 2005 10:32 am Post subject: Re: [posted] an AppleScript to install help file
Max_Barel wrote:
BTW: Only a few days, but there not much comments, a couple of download, no contributed translation... I wonder if it was a worthwile attempt (I was wondering before I did it anyway).
For sure, until Patrick add it to the download page, there will be few users aware of this thing.
The requests for help with installing help do seem to come in spurts, and we just had a spurt of francophone requests right before you posted the script. Plus, as you said, it's not yet referenced on the download pages. I am surprised, however, that you haven't gotten any translations yet, at least for the other supported European languages....
(That was a cool trick, by the way, how you did the localisation; I figured one would have to resort to AppleScript Studio in XCode to make an AppleScript localized).
I do hope you don't consider the script a wasted effort; I think it will be very useful when the next spurt of requests come (if it's not on the download page by then), and I certainly found looking at your code very educational
Smokey _________________ "[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
So I opened script editor, saved your script as an application, and ran the script on my Jaguar machine. I like the script a lot and since it's compiled size is so small, hosting it on the Neo/J download site is no problem.
1. Remove the "--no-same-owner" from tar. This argument is not supported on Jaguar.
2. Is it possible to hide ".*" files in the file dialog? If you wanted to be really fancy, it would be cool if you only showed "*.tgz" files.
3. Is it possible to splice my patch installer shell script commands to just find all Neo/J installations in the /Applications directories of all local volumes? My script looks for the existence of "/Applications/*.app/Contents/MacOS/bootstraprc" and "/Volumes/*/Applications/*.app/Contents/MacOS/bootstraprc" files to locate Neo/J installations. Then I grep the file to ensure that the following regular expression is matched to determine if it is a Neo/J 1.1 compatible installation: "^ProductKey=NeoOffice/J 1.1".
4. Can you add a GPL compatible copyright statement to the beginning of your file? If you do that, then I can check the file into the Neo/J cvs repository. Having the license in the file ensures that the copyright holder (i.e. you) is permanently recorded in the file.
5. Apparently, in order to run an AppleScript, it needs to have executable permissions. So, I think we might want to package this script into a *.dmg file as most browsers do not save files with executable permissions. I can do that for you once we take care of items 1 through 4.
6. Can you provide updated text for the "installing help files" section of the English and French download.php pages? I can then send the HTML files and your script to the other translators for localization.
7. Last question. Does anybody know how to open a script source file and invoke Save As -> Application using AppleScript? I ask because if I can automate this step, I can put creation of the *.dmg file into the Neo/J build.
7. Last question. Does anybody know how to open a script source file and invoke Save As -> Application using AppleScript? I ask because if I can automate this step, I can put creation of the *.dmg file into the Neo/J build.
The sourcefile name can really be any plaintext file, e.g. source.txt, but the .scpt extension makes its purpose more clearly evident. The resulting file must be given the .app extension here to generate an applet.
Smokey _________________ "[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
property mess_nl : {messNeo:"Selecteer de NeoOffice/J applicatie", messaide:"Selecteer het helpbestand om te installeren", messOK:"Installatie is gelukt", messerr:"Fout: de huidige installatie is ongewijzigd", messGrave:"Fout: het helpbestand is mogekijk onbruikbaar"}
property mess_de : {messNeo:" Bitte wahlen sie das NeoOffice/J Anwendungsprogramm", messaide:"Bitte wahlen sie die Hilfefile um ein zu fürhen", messOK:"Einführung ist gelungen", messerr:"Fehler: die laufende Einführung ist unverändert", messGrave:"Fehler: die Hilfefile ist vielleicht nicht benutzbar"}
property mess_es : {messNeo:"Por favor elega la aplicación NeoOffice/J", messaide:"Por favor elega el archivo de ayuda por installar", messOK:"Instalación exitiso", messerr:"Error: La instalción corriente est inalterado", messGrave:"Error: El archivo de ayuda tal vez no est utilizable"}
Please take care: Dutch is my native language, but I had to use the dictionary at http://www.ultralingua.net/ for the German and Spanish translations. So some words might be a bit off.
BTW, If I am not mistaken, the language number for Dutch is 31. _________________ "What do you think of Western Civilization?"
"I think it would be a good idea!"
- Mohandas Karamchand Gandhi
Joined: May 31, 2003 Posts: 219 Location: French Alps
Posted: Sun Mar 13, 2005 4:37 pm Post subject:
pluby wrote:
1. Remove the "--no-same-owner" from tar. This argument is not supported on Jaguar.
Would you mind if I then add "chown -R root:admin *" to the script? I don't like to let files owned by random id user. As I remove the intermediate zip files, there is only the license.txt remaining (from the French archive) but it's sort of a rule.
Quote:
2. Is it possible to hide ".*" files in the file dialog? If you wanted to be really fancy, it would be cool if you only showed "*.tgz" files.
? "without invisible" in the source should hide "point" files.
Restricting selection in AppleScript is based on HFS file type which is not set for help archive files.
Quote:
3. Is it possible to splice my patch installer shell script commands to just find all Neo/J installations in the /Applications directories of all local volumes? My script looks for the existence of "/Applications/*.app/Contents/MacOS/bootstraprc" and "/Volumes/*/Applications/*.app/Contents/MacOS/bootstraprc" files to locate Neo/J installations. Then I grep the file to ensure that the following regular expression is matched to determine if it is a Neo/J 1.1 compatible installation: "^ProductKey=NeoOffice/J 1.1".
The "choose application" standard dialog is, iMO, the way to go and does not provide subselecting option. Anyway, I can easily splice your code in a function to narrow the check.
Quote:
4. Can you add a GPL compatible copyright statement to the beginning of your file? If you do that, then I can check the file into the Neo/J cvs repository. Having the license in the file ensures that the copyright holder (i.e. you) is permanently recorded in the file.
Please, do it for me, before commiting the script. I got lost in the license jungle for long now.
Quote:
5. Apparently, in order to run an AppleScript, it needs to have executable permissions. So, I think we might want to package this script into a *.dmg file as most browsers do not save files with executable permissions. I can do that for you once we take care of items 1 through 4.
A simple zip or sit file do the trick as well, but it's up to you.
Quote:
6. Can you provide updated text for the "installing help files" section of the English and French download.php pages? I can then send the HTML files and your script to the other translators for localization.
Ok, coming soon, probably tomorow with the updated script.
Quote:
7. Last question. Does anybody know how to open a script source file and invoke Save As -> Application using AppleScript? I ask because if I can automate this step, I can put creation of the *.dmg file into the Neo/J build.
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You cannot attach files in this forum You cannot download files in this forum