Welcome to NeoOffice developer notes and announcements
NeoOffice
Developer notes and announcements
 
 

This website is an archive and is no longer active
NeoOffice announcements have moved to the NeoOffice News website


Support
· Forums
· NeoOffice Support
· NeoWiki


Announcements
· Twitter @NeoOffice


Downloads
· Download NeoOffice


  
NeoOffice :: View topic - [posted] an AppleScript to install help file
[posted] an AppleScript to install help file
 
   NeoOffice Forum Index -> NeoOffice Releases
View previous topic :: View next topic  
Author Message
Max_Barel
Oracle


Joined: May 31, 2003
Posts: 219
Location: French Alps

PostPosted: 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
Back to top
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: 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
Back to top
pluby
The Architect
The Architect


Joined: Jun 16, 2003
Posts: 11949

PostPosted: Tue Mar 08, 2005 10:14 pm    Post subject:

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.

Patrick
Back to top
rays
The Anomaly
(earlier version)


Joined: Sep 23, 2004
Posts: 475
Location: Geneva, Switzerland

PostPosted: 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.

Thanks again.

Ray
Back to top
Max_Barel
Oracle


Joined: May 31, 2003
Posts: 219
Location: French Alps

PostPosted: 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.

Here is the zipped script: click here

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.

Here is the full code; comments below :
Code:
(*
The following two properties are "dictionnary" of UI messages.
Add translation for other languages with the same syntax : the message tags must be the same.
For each new "dictionnary", a new line must be added in the get_mess() function to return the right property from the language code.
*)
property mess_fr : {messNeo:"Sélectionner l'application NeoOffice/J", messaide:"Sélectionner l'archive des fichiers d'aide à installer", messOK:"Installation réussie", messerr:"Erreur: installation non modifiée", messGrave:"Erreur: le dossier d'aide peut être inutilisable"}
property mess_en : {messNeo:"Select the NeoOffice/J application", messaide:"Select the help file archive to install", messOK:"Installation succesful", messerr:"Error: current installation unchanged", messGrave:"Error: the help folder may be unusable"}
--property mess_de : {messNeo:"", messAide:""}
--etc...

property mess : mess_en

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.

Max
Back to top
ovvldc
Captain Naiobi


Joined: Sep 13, 2004
Posts: 2352
Location: Zürich, CH

PostPosted: Wed Mar 09, 2005 10:17 am    Post subject: Re: Here is first draft

Max_Barel wrote:
Here is the zipped script: click here

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
Back to top
Max_Barel
Oracle


Joined: May 31, 2003
Posts: 219
Location: French Alps

PostPosted: 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
Back to top
s_habe
Red Pill


Joined: Feb 23, 2005
Posts: 8
Location: Estonia

PostPosted: 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. Confused

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.... Sad Maybe there are some more dumbusers like me?
Back to top
Max_Barel
Oracle


Joined: May 31, 2003
Posts: 219
Location: French Alps

PostPosted: 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.... Sad

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.

Max
Back to top
s_habe
Red Pill


Joined: Feb 23, 2005
Posts: 8
Location: Estonia

PostPosted: Sat Mar 12, 2005 8:44 am    Post subject:

Thanks, Max, for clarification. I got it now.

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!
Back to top
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: 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 Smile

Smokey

_________________
"[...] whether the duck drinks hot chocolate or coffee is irrelevant." -- ovvldc and sardisson in the NeoWiki
Back to top
pluby
The Architect
The Architect


Joined: Jun 16, 2003
Posts: 11949

PostPosted: Sat Mar 12, 2005 2:45 pm    Post subject:

Max,

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.

Patrick
Back to top
sardisson
Town Crier
Town Crier


Joined: Feb 01, 2004
Posts: 4588

PostPosted: Sat Mar 12, 2005 11:01 pm    Post subject:

pluby wrote:
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.


Since this was an "anybody" question Smile

osacompile -o resulting_applet_name.app sourcefile_name.scpt

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
Back to top
ovvldc
Captain Naiobi


Joined: Sep 13, 2004
Posts: 2352
Location: Zürich, CH

PostPosted: Sun Mar 13, 2005 6:32 am    Post subject: Re: Here is first draft

Max_Barel wrote:
Here is the full code; comments below :
Code:
(*
The following two properties are "dictionnary" of UI messages.
Add translation for other languages with the same syntax : the message tags must be the same.
For each new "dictionnary", a new line must be added in the get_mess() function to return the right property from the language code.
*)
property mess_fr : {messNeo:"Sélectionner l'application NeoOffice/J", messaide:"Sélectionner l'archive des fichiers d'aide à installer", messOK:"Installation réussie", messerr:"Erreur: installation non modifiée", messGrave:"Erreur: le dossier d'aide peut être inutilisable"}
property mess_en : {messNeo:"Select the NeoOffice/J application", messaide:"Select the help file archive to install", messOK:"Installation succesful", messerr:"Error: current installation unchanged", messGrave:"Error: the help folder may be unusable"}
--property mess_de : {messNeo:"", messAide:""}

--etc...


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
Back to top
Max_Barel
Oracle


Joined: May 31, 2003
Posts: 219
Location: French Alps

PostPosted: 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.
Smokey shot first (day off the net for me).

ovvldc wrote:
property mess_nl...
property mess_de...
property mess_es...
Thank you.

I'll update and post the script tomorow.

Max
Back to top
Display posts from previous:   
   NeoOffice Forum Index -> NeoOffice Releases All times are GMT - 7 Hours
Goto page 1, 2  Next
Page 1 of 2

 
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

Powered by phpBB © 2001, 2005 phpBB Group

All logos and trademarks in this site are property of their respective owner. The comments are property of their posters, all the rest © Planamesa Inc.
NeoOffice is a registered trademark of Planamesa Inc. and may not be used without permission.
PHP-Nuke Copyright © 2005 by Francisco Burzi. This is free software, and you may redistribute it under the GPL. PHP-Nuke comes with absolutely no warranty, for details, see the license.