Making online Spin files open in a Prop IDE
Phil Pilgrim (PhiPi)
Posts: 23,514
I have posted Spin programs online for the class I'm teaching. They open in the browser as plain text files, whose contents can be copied and pasted into the Prop Tool. I would prefer to have them open in the Prop Tool (complete with program name in the tab, if possible) -- or in whatever default Spin editor the programmer is using. Is there a way to do this directly in HTML/JS without involving CGI?
Thanks,
-Phil
Thanks,
-Phil
Comments
-Phil
This can be figured in the Apache config file /etc/apache2/mods-available/mime.conf just add a line with "AddType application/x-spin .spin"
Or it can be set in an .htaccess file put into the director holding the spin files. See article here: http://www.hypercosm.com/support/howto6.html
I have tried the former method and it delivered the right header. What I can't figure out is how to associate that header with a propeller IDE in Chrome.
At least you can do this in windows. Not sure about Mac/Linux but I guess they can do that also.
Then you can just double click the spin-file in the Explorer and the PropTool gets started loading the file from drive x.
Enjoy!
Mike
In a similar class setting, for CAD, I prepare download packages, one per lesson, and they work in a local folder, which they also take with them, or Dropbox, etc... when they are done.
But I am a little bit worried about him. His posts are getting short, lately. I am used to scroll them.
Enjoy!
Mike
Props are very likely to land in a few of the automation projects planned. For the first time, I'll have a setup at work, not just hobby stuff. Yippee! A few of us are going to jump into things that will need some easy, capable embedded. There will be some learning all around, maybe contractors or a hire down the road too.
Edit: FWIW, there are two basic business paths associated with automation: One is to automate the people away, and the other is to automate in order to free people to do more and smarter and higher level things. We are doing the latter, and it's being done in the US, so the work stays in the US. This little company can dominate it's niche, despite overseas competitors. I'm very, very excited to be able to be a part of making it work that way. In the first scenario, we all get put on a grind, always seeking new niches, competing hard, race to the bottom. It's brutal. In the second scenario, there remains that seeking, but it's funded, and people can work smart, not hard, in the colloquial sense, not the literal sense. This is good for everybody. Automation can fund growing better people, both ways make better margin. I very strongly believe in the latter, though the former dominates most automation projects today.
Right now, my load is high, but a lot of fun. I've needed it to be that way for a while. Truth is, I have near complete mastery of my former niche of 20 years, but let's just say there are some basic problems that would force me to move somewhere else, deal with crappy financials, or jump ship, and that made the financial ride way more bumpy than I can deal with. Normally, one does that kind of time and learning investment for the reward of a secure career path and solid financials. Didn't happen for me. Smile. Seriously, and if we ever meet up over a beer, I'll tell the tale. It will very likely annoy you. It sure does me. Big.
So... I jumped, and it's a new game! I'm in my first executive / tech role ever! (and there are not many of those out there) That means I get to be involved in and call the shots on a macro / business / operations level, while at the same time, learning a ton to bring some engineering and automation efforts to fruition.
In my life, so far, I've taken each skill set and used it as the basis for moving into a new one, all the way back to the very first job I ever had, so all jobs overlapped in some basic way, allowing for contracting and fall back options if needed, to stay current, let knowledge build, etc... (Another mentor early in life sold me on this idea, and it has played out well for me)
In this one, the industrial robotics (FANUC) are really new. All of us are on the learning path, and enough to make a cell+ are going to hit the dock very soon. Mechanical CAD is fundamental to the engineering efforts, and I'm solid there. My hobby time here brings enough embedded type understanding to build that team and get some stuff done. We are getting some 6 axis arms, vision, and some pick 'n place type robots. The owner of the company has a manufacturing process vision that is very trendy, involves some cool materials, new products, etc... Really cool stuff. Real robots! And I will get to play with them, and do stuff. How cool is that?
A lot of the engineering is new to me too, though I've touched on most of it in the past. I've been mentored into being ready for the management piece, and I can build teams, and or make existing ones run much better. I was asked to take that role, and I thought about it hard for a full week. (nobody had asked before, and I was taken by surprise --my mentor in these things says that is how it happens best, so there you go)
I think I made the right call, because I'm having fun. Scary though. Seriously. If it gets botched, I'm gonna be the guy who has to own that Smile. And there are these spreadsheets with important numbers on them... People might do well, or have no work, or worse based on what that pile of little numbers contains. Sheesh...
My whole life has been technical with a nice mix of soft, people type skills mixed in. Truth is, business is technical, just in a different way, and I've long attacked it, and sales in the same exact way I do tech. One can make standard, MBA type, decisions, and it's probably going to work. But, if one digs deep, sorts out the economics and risks, those decisions are more likely to make it work well. Some of my longer posts here, "speaking MBA" as Heater puts it, highlight some of how that is. (And I would never, ever get an MBA, BTW. I subscribe to a more basic, and older school of business, just FYI)
So all of that is getting put to the test. Good. But don't think for a minute I'm not worried about it all. I am, and I'm told I should be.
All that said, I visit Parallax each day. This is "home" and I've learned and continue to learn a ton here. Honestly, you all are smart, nearly everyone tries really hard to make it work, or get the answer, or sort the issue out, and are fine people, which makes for a great home. I can very easily credit this forum, and the people I've met and learned from as very good influences. And I find that a little strange to write, but it's true. This place is one of the best on the net. Worth every minute. Thanks.
Hey, since Chip is deep into it, one could say I chose this time to get work life sorted out and make some money while waiting for P2. Gotta get that Parallax FPGA board somehow, right?
--->a scroller for you Mike. (up early prepping for a CAD class on contract tomorrow)
Put your files there and share the links to them. I just tried this with Firefox, and I get the "Open With" dialog.
https://www.dropbox.com/s/lvlxu3n9b34xoib/test.spin?dl=0 This is a simple, ".spin" file saved to Dropbox.
Once I browse to the file and pick the Propeller Tool, I can check the "always open" box, and Firefox appears to handle it right from then on.
Edit: I just tried the same link with Chrome, and it opened as a Spin file should in Propeller tool after clicking on that download button.
Seems that service is passing along enough info for the file associations to work as they should.
Awesome. Scary but awesome. I do so wish I could join you for that beer. We could swap career disaster stories. Or not...onward and upward!
Of course I have to add my two cents
I could be wrong, but I do not believe it can be done on the browser side. On the other hand, it could be done quite easily from the IDE side, but that functionality would have to be programmed into each individual IDE, however I could be wrong.
That being said, I believe potatohead has provided some good advice, however I do not know if my approach would be the same as his. For those of us who dabble, HTML can be a wonderful tool, especially when it comes to formatting documentation and linking to additional documentation. In addition to those benefits, HTML can also be a very valuable tool for teaching. As I am sure you are already well aware of these facts, I will get to the point.
When creating content for the internet, most programmers think internet type programming, however HTML can also be a very valuable teaching tool when written to be used locally on an individuals computer. When used locally, on the surface, it appears to be equivalent to internet content, however, in fact it is quite different, because many security measures are bypassed and file associations are well defined by each individual computer. Clicking on a URL with *.SPIN type file association locally will open the file with the executable that has been associated with that extension, which in your case is some sort of Propeller IDE.
Still not to the point
Basically create your internet programming and "lessons", so that all content can be accessed and formatted without accessing the internet. So in other words, you should be able to navigate anywhere within your HTML without being connected to the internet (images, etc..). It will all boil down to "PATHS", both directory and file paths. Any reference to a domain is a no no. When you have finished writing the content, basically all wrapped into one directory, upload it to the internet, as you normally would. This uploaded directory should include all of your desired content. In addition to this upload, take that same directory and ZIP it into an archive and upload that file to your webserver. Now all you have to do is provide a link on your website to that archive, where your students can download it. With that archive now stored locally, your students should be able to view your lessons with their favorite browser and any attempt to activate a URL with a *.SPIN type file association should open that file with the appropriate Propeller IDE.
When I create an html file like so:
I can load into into chrome using "file://....." and I see the link to my Spin file.
However when I click on the link it "downloads" it to my Downloads directory.
Seems to just be the same issue. How to get the browser to open the PropTool or PropellerIDE instead of just downloading?
Place a copy of test.spin on the desktop. Take that HTML source and save it to the desktop as test.htm and then open it, followed by clicking the test.spin link within the browser. An OPEN file dialog should appear at that point, at which point simply click OPEN, and it should open it within the Propeller IDE.
This works for windows, or at least XP, I am unsure about MACs, but I would assume that it should be the same.
However if test.spin and test.htm were uploaded to the internet, test.spin would open in the browser instead.
Also nope IE does not run on my Linux.
If I remember correctly, this works for JavaScripts also. So the HTML can have embedded and externally linked JavaScripts.
Down side is that it gets out of date quickly and the new stuff isn't "just there" as it is on the web.
Upside is you don't need the net of course.
But in the last few years I have realized that I don't keep anything important on a local machine anymore.
Even the smallest bits of code doodling end up in github or some other repo.
Everything else is spread out over and replicated on machines near and far.
If the net stops, I stop.
That still leaves the Phil's problem of opening Spin files from the net into a Spin IDE. Our answer to that is to move the IDE into the browser like so:
http://the.linuxd.org/lab/spine.html
and so
http://the.linuxd.org/lab/editor17/editor17.html
Sadly progress is slow and none of it works well yet.
It has always been my opinion that cross platform compatability is hugest obstacle for any software development. With so many variants and differences of opinion and preference, it is not feasible to create a perfect solution for any particular problem.
If it was me, being Microsoft rooted, I would approach the problem from a different angle. As mentioned, my software is quite outdated, as of Visual Studio 6.0, Microsoft included an Internet Explorer Add-In that you could add to any project, to create a custom web browser, but I do not know if they still offer that. Anyhow with that Add-In, you had access to many methods which provided a fair amount of control over a customized web browser. Out of the box, the Add-In was a fully functional web browser, but with some expertise and creativity, a person could create a very unique browser, with very specific traits. I would assume, that a SPIN aware browser could be created in probably half a days time. To where if a *.SPIN extension was encountered, it could be used to program a Propeller.
Okay half a day is an exaggeration...., but rather quickly, by adding a serial interface to the browser. For instance, turning it around a bit, a browser control could have easily been added to this project.
http://forums.parallax.com/showthread.php/133979-Project-In-Progress-New-Serial-Terminal-Taking-Suggestions
EDIT: Or by combining a customized browser with Propellant
I think you are right. For a long time now if you wanted to build an application you chose your market, Windows, Mac etc and invested your efforts in that. Making something that would run well across all platforms is hard and most don't bother. Today it plays out again in the mobile space, do you write for Android or iOS?
It's kind of depressing. For many decades now you could write a command line program that worked everywhere, at least with little effort. printf and friends are standardized and available all over. But after all those decades there is still no standardized way to write even a simple a GUI app.
Luckily we have things like Qt that make this possible. Notice how SimpleIDE and PropellerIDE work on Windows, Mac and Linux. You can even run Qt Apps on Android!
Java was supposed to be the fix for this "write once run anywhere problem". Sadly that turned out to be a pile of jobby,
I have always wondered about the complaints that when, say, a Windows app is moved to Mac that it does not look "native". Do what? When I write a program I want it to look like how I meant not how the OS thinks it should look.
But this mess is why there are huge efforts going on to make a platform abstraction layer and software delivery mechanism. The web. HTML, CSS, JS, basically web apps. With those you can reach the widest audience and make things very easy for them. No searching for downloads, no installation, just use it wherever you are, whatever OS, PC or mobile.
Turns out you can make an app with a built in web browser in ten lines of code or so using Qt. Totally cross platform, it uses the webkit engine as does Chrome. But that still leaves us with an old fashioned application to install.
One way or another, the audience will be very low for those that want SPIN file support. For those that truly want browser support for SPIN files, I am sure they would download the app.
TIME is everything and we are all only alloted with a certain amount of it. We must all choose our battles and interests. I say to spit out a piece of functional software, if they download it, then they have a piece of software that will do what they want.
I think I understand now, you are gearing towards phone usage as compared to the PC. If that is the case, then perhaps a full blown browser is not a viable option.
The PropellerIDE project at this time does not implement Qt's "QFileOpenEvent" class which would make opening files from a file description or URL simple. As an example, double-clicking a .spin file in Mac OS X's Finder won't open the file in PropellerIDE (or SimpleIDE) AND, it won't display a dialog requesting which app to launch. On my system, it launches SimpleIDE but does not open the selected file (I probably configured my system at one point to think that SimpleIDE was the appropriate app for .spin files in an attempt to test this theory).
I'll create a bug-report/enhancement request in the PropellerIDE issue tracker to implement QFileOpenEvent. A fix for this could solve at least a part of the problem. EDIT: Issue Tracker - https://lamestation.atlassian.net/browse/IDE-73?filter=-2
As far as cross-platform UI tradeoffs and such...
There are a number of OS-bound UI elements that do not cross-over well. Expectations of Windows, Mac OS X & Linux users for UI elements that conform to the unique aspects of each OS is problematic, right? Key bindings differ (Control-X on Windows, Command-Q on Macs, to quit an app, etc...). File creation & saving paradigms offer different results (Mac OS X basically removed "Save As", requiring more of a duplicate and save paradigm...). Find & Replace scenarios vary as well. Lot's of other differences exist as well as menu placement, mouse button requirements, TAB support, container view hierarchy differences, etc...
Qt development does support conditional compile per OS and that can go a long way in providing "comfort" for the user. I know that PropellerIDE's developer, Brett Weir, is making changes in support of these differences. We can help by writing-up enhancement requests at : https://lamestation.atlassian.net/browse/IDE-72?jql=project%20%3D%20IDE
dgately
Conditional compiling is great for software giants, with a wide variety of programming talent, but in my opinion, for small time developers, that is tricky business. Targeting a specific OS requires a well rounded knowledge of the ins and outs of the OS, but targeting numerous OSes, a programmer would really have to know his stuff. The same holds true for cross browser compatability, but on a much simpler basis.
As far as opening the SPIN files on your MAC.... If it were a WINDOWS system, I would say it was a file association problem and VERB problem in the registry, but since it is a MAC..... I don't even know if there is a registry
In WINDOWS, the executing application can be changed through file properties, by right clicking any file with a specific extension, perhaps MACs might have a similar feature.
Quite so.
Conditional compiling is a day to day part of my life. That's how all my compiled code runs on Linux, Mac, Windows, BSD etc. And I'm operating in a very small shops. Admittedly most of that is not cross-platform GUI stuff.
Which brings me to my current projects. Originally written as traditional applications in C++. The powers that be did not want a Windows only, or Mac only app. They did not want the expense of supporting multiple platforms. Turns out that the real-time data visualization that we do can be done just as well in a web browser. A little bit of HTML/CSS and big gobs of webgl all fed by websockets. It's amazing what you can do in a browser now a days. No installation, no fuss, no mess.
Re: Cross browser compatibility - When we started this a couple of years ago I was suspicious of the idea. It's never going to work I thought. There are so many browsers out there. I for one don't have the know how to make things work the same on all of them, never mind just look the same. Quite frankly I don't want to waste one minute of my life messing with cross-browser issues, the web is standardized right? And JavaScript will be too slow and...and....
Turns out it's not an issue. We made a prototype, we went to our customers, we nervously explained they will probably need to use Chrome or perhaps FireFox. To my amazement none of them flinched at that. It was as if it was already understood that IE 6, 7, 8, 9 whatever is not a requirement and a Chrome/Firefox install is only moments away. No problem.
But re: "I think I understand now, you are gearing towards phone usage as compared to the PC"
No, not at all. I take my inspiration for a Spin IDE in the browser from the Espruino project, https://chrome.google.com/webstore/detail/espruino-web-ide/bleoifhkdalbjfbobjackfdifdneehpo?hl=en or from IBM's Orion project: http://eclipse.org/orion/ or Cloud9 https://c9.io/ I want a big screen a proper keyboard and mouse. I have no idea how well any of that stuff works on a tab never mind a phone. Heck, I want a web browser that lights up all four walls of my living room in glorious 3D.
Sounds like you have enough to do without taking time off.
I could not find your email, but there is always P.M. here I guess.
It's not so much the file association (that's there on Mac OS X as well and can be changed as easily as in Windows), but that the app itself is not currently handling the type of system-supplied events that Qt (and XCode) support. I think that Windows (at least, the version that you are using) uses a sort of "puppet strings" method to manipulate the app to open a selected file. Updating PropellerIDE to support QFileOpenEvent will allow more systems to comply with the user's request.
One thing that I did notice in my experiments is that there are other legacy applications that use .spin as a file extension as well. This could be another reason for problems like this.
dgately
Now, when I click on a link to a .spin file in that directory, a dialog box comes up offering to open the file in Propeller Tool.
Problem solved. Thanks, Heater!
-Phil
But wait a minute, that is not exactly what I specified, I guess you had to do some experiments with it.
Do you have such .spin files on the public internet so we can try and see what happens out here?
-Phil