- Robert
I have actually taken a slightly different approach, in that I used
Fluid.app <http://fluidapp.com/> to create a site specific browser
that also starts Sage. This means that Sage is a "real application"
that I can Cmd-Tab between etc. Can Platypus does this? If not it
probably could (I may look into it). Frankly, I hate using Sage in a
browser, because it is mixed in with all my other browser windows.
For me a separate application is the only acceptable long-term solution.
There are a few problems with my Fluid-based app currently. One is
that Fluid tacks on '.com' to the URL for local addresses. That
certainly means it's not ready to be released to end users. There is
also a certificate issue, but I assumed that was my fault for running
the sage server wrong. There is also a potential licensing issue.
Fluid is closed source, and I don't know how applications built with
it can be distributed.
If you are interested I would be more that happy to tell you more/send
you what I have. It's at a very early stage and I haven't worked out
the problems, but since you brought it up, I thought I would mention
what I have done.
> The drawback is that the script needs to know the path to my sage
> installation. I think that the workaround to this is to actually put
> the entire Sage installation in the folder that Platypus creates for
> the application. OS X applications on the Mac are actually folders
> (unix directories).
That's the solution that I was considering as well. We could just
distribute binary versions as regular applications. The only
(potential) problem that I see it that notebooks should be stored in
some place that will be saved across upgrades/new installs. This
shouldn't be hard to fix though.
> Does this sound like it would be useful to the Sage community if I
> could get it working?
+1
-Ivan Andrus
> I'm certainly not a mac expert. However, I got Sage working through a
> mac-like icon using the Platypus program (http://www.sveinbjorn.org/
> platypus).
I'm not sure what Platypus is (I haven't clicked on the link), but
here is what I've got set up.
I created the following Apple Script; I bundled it as a .app; changed
the icon to the sage logo from sagemath.org; tossed it into my sage
directory. I'll attach the files, and there are some notes below.
tell application "Finder"
open document file "sage" of folder of (path to me) using application
file "Terminal.app" of folder "Utilities" of folder "Applications" of
startup disk
end tell
Notes:
1. This does NOT depend on the location of the sage directory on the
hard drive. (It does depend on the location of Terminal.app, but
that's standard on Mac OS X.)
2. It just starts sage in the terminal, not the notebook. The use
needs to use notebook(). But this is what I preferred. The Apple
Script can point to a secondary sage-notebook bash script that checks
for a running sage notebook instance or starts one if it doesn't
exist.
Take care,
Franco
--
Create an application (hereafter referred to as Sage.app) pointing to
https://localhost:8000/
or
http://localhost:8000/
I don't know if there is a problem running in non-secure mode on your
own machine, but if you run in secure mode there may be an issue in
which the Fluid app appears to do nothing. This is probably due to a
certificate issue, but if you tell Safari to always accept it, it
seems to work ok.
Then find Sage.app in the Finder. Ctrl-click and "Show Package
Contents"
Goto Contents/MacOS.
Rename FluidInstance to FluidInstance.bin
Create a file called FluidInstance which contains the following script
#!/bin/bash
#path to sage
SAGE_EXE=/Users/gvol/Desktop/sage-2.9.2/sage
# check if sage is running on port 8000
curl localhost:8000 > /dev/null 2> /dev/null
if [ $? != 52 -o $? != 0 ]; then
# start sage if we need to. This could be made to run in non-secure
mode etc.
$SAGE_EXE -notebook 2>&1 > sage.log &
fi
# execute the 'real' Fluid application
exec $BASH_SOURCE.bin
# end script
Set the permissions to be executable. I'm not sure how to do this in
the Finder, but it can be done from the Terminal by
chmod +x /path/to/FluidInstance
You can get the path by dragging the file from the Finder to a
Terminal window.
You will of course have to substitute the path to sage in the script.
This is the script that I used, so I know it works, but I think I
prefer something a little more like rpmuller used would be
preferable. For one thing, I never stop the server (though this is
what I prefer).
It seems like sometimes, if the server isn't already started, then it
opens the window too soon, and can't connect. If it can't connect
then it gives up trying ever again until I quit and restart. So it's
far from perfect.
I would also be willing to put together an all-in-one version that
contains the sage tree within Sage.app. This would be extremely
simple to create for each new build in an automated way.
I also am planning to look into adding an HTML window to Platypus
since I think that would be preferable in many ways, and feels less
hackish to me.
HTH,
Ivan