Saving PDF files with Chickenfoot - chickenfoot

I'm writing a web-crawler using Chickenfoot and need to save PDF files. I can either click the link on the page or grab the PDF's URL and use
go("http://www.whatever.com/file.pdf")
and I get the firefox "Opening file.pdf" dialog box, but can't click the "OK" button to actually save the file.
I've tried using other means to download the files (wget, python's urllib2, twill), but the PDF files are gated so none of those will work.
Any help is appreciated.

This example of how to save a target in the Mozilla developer documents looks like it should do exactly what you want. I've tested a Chickenfoot example that is very similar that gets the temp environment variable, and that worked well for me in Chickenfoot.
https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIWebBrowserPersist#Example
You might have to play with the application associations in Tools, Options, Applications to make sure the action is set to Save File, but those settings might not apply to these functions.
End Answer, begin related grumblings...
I sure wish someone would fix the many bugs in Chickenfoot, and write a nice Cookbook programming guide. I've been using it for years, and there are still many basic things I've not been able to figure out how to do. I finally broke down and subscribed to the mailing list, as the archives have some decent script examples. It takes a lot of searching through the pdf references, blogs, etc. as the web API reference is very sparse.
I love how simple Chickenfoot can make automating some tasks, but it takes me days of searching javascript, DOM, and Firefox documents to find ways to do some of the things it can't, since I'm not really a web programmer. The goal of Chickenfoot seems to be that I shouldn't have to be, but unfortunately few are refining the proof of concept, as MIT has dropped the project.
I tried to do this several ways using only Chickenfoot commands and confirmed they don't work with the latest Firefox 3 and Chickenfoot 1.0.7.
I hope this helps! Good luck. Sorry I only ran across your question yesterday, but found it too interesting to leave alone.

You won't be able to click on Firefox dialogs for the sake of security.
The best way to download the content of a URL is to read then write the content of the URL.
// Chickenfoot 1.0.7 Javascript Code to download the content of a url.
include( "fileio.js" ); // enables the write function.
var url = "http://google.com",
saveFileTo = "c://chickenfoot-google.com";
write( saveFileTo, read( url ) );
You might find it helpful to use jquery with chickenfoot.
http://groups.csail.mit.edu/uid/chickenfoot/scripts/index.php?title=Using_jQuery,_jQuery_UI_and_similar_libraries

This has worked for me to save Excel files from NCES portal.
http://muaz-khan.blogspot.com/2012/10/save-files-on-disk-using-javascript-or.html
I was using Firefox 3.0 and the "old syntax" version of the code. I also stripped code intended for IE and "(window.URL || window.webkitURL).revokeObjectURL(save.href);" which generated an error.

Related

Firefox Addon SDK1.17 Annotator tutorial: widget/button does not appear

I am trying to work through https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Annotator with jpm (https://developer.mozilla.org/en-US/Add-ons/SDK/Tools/jpm) rather than cfx, and running into difficulties:=> the button/widget that the addon adds does not appear in my browser. Not even in the Additional Tools and Features section if I go to Customize the browswer appearance.
This is the SDK v1.17, and Firefox v38.0.1 for Linux (openSuSE13.2).
I have created the structure and files with given names and contents, telling jpm to use main.js as the entry point, rather than index.js, in order to match the tutorial (which is cfx-based).
I am also passing jpm the -b PATH-TO-FIREFOX-BINARY flag, because it apparently doesn't follow the symlink at /usr/bin/firefox, but it sounds like that's a known issue.
I am also also passing jpm the -p MY-DEV-PROFILE flag because I found that with the introductory tutorial (https://developer.mozilla.org/en-US/Add-ons/SDK/Tutorials/Getting_Started_%28jpm%29) that was the only way I could get that button to show up.
But that doesn't help here, nor does leaving off that option.
The Addon Manager confirms that the extension is installed.
So I am open to suggestions. Obviously I am new to extension development, and pretty new to javascript in general.
I had also better ask while I am here: What I want to do is modify the behaviour of Firefox's Find (in page); can something like that be done with the SDK, or do I need to use the Overlay method?
Any other suggestions helpful for learning addon development would also be welcome (but should probably be done as comments, rather than Answers; let's save Answers for the original question about this tutorial button).
Thanks!
The widget api was removed in Firefox 38. For most cases you can replace widget with the button apis we introduced in Firefox 29, see this blog post for more information.
Ah, heheh, never mind.
It was just an impedence mismatch between the original cfx instructions and the jpm way of doing things.
While I had told jpm to use main.js instead of index.js, I had failed to tell it that main.js was in the "./lib/" directory instead of the root directory of the extension.
After changing the package.json to say
"main": "./lib/main.js"
it works - as far as that goes. But it turns out that the entire tutorial is no longer valid; see my (Edward's) comment on canuckistani's answer.
My subsidiary questions about whether the SDK will even do what I want (changing some Find behaviour) and any other advice/resources still stand, however.

best HTML code sharing app

I've been searching google for a while to determine the most coder-friendly example boxes.
I'm wanting to share varying forms of ECMA script (JS for example) etc that provides the user with color coding and a simple way of copying the code. I know there are several out there, but I wanted to get some opinions from SOF since you guys probably have good experience with code.
so- What's the code-sharing tool you [would] use?
the solution
I ended up using Gist for complete snippets and am using Syntax Highlighter for *incomplete * code samples. There's a Drupal plugin for the Syntax Highlighter, but I dare say it's more of a pain to figure out the plugin than it is to just do things the old fashioned way (old fashioned being like 5 years ago..)
I use http://jsfiddle.net/
Color coding — check
HTML, CSS, JS — check
Live demo — check
gist has syntax highlighting and users can download the files separately, as a zip archive or using git. You can embed the files easily on other sites.
Additionally, the site tracks changes and other users can add comments or fork a gist to change it themselves.

SugarCRM: Pdf generation

I'm a newbie to SugarCRM development. In my project, I have to generate a pdf for one entity details(say Account details). On details page, I have added "Print PDF" button, upon clicking this button I have one independent script (I mean to say that it was not implemented as per Sugar framework). In this script we are querying database for the required details and building one html string. Using html2pdf library, converting this html string to pdf.
I dont know whether it is an efficient implementation or not, but everything is working fine as per the requirement. But we have one problem when the original string contains some special characters like currency symbols of different countries. We are getting the html fine, but in pdf getting question marks (?) for those special characters.
While trying to fix this issue, when I looked into SugarCRM code, I found some pdf classed inside includes/ directory that creating an impression that Sugar itself has some built-in library to generate pdf's. Is it true?
If that is true, will it solve my problem, i.e. displaying different countries currency symbols in pdf.
Can anybody please help me to in resolving this. Thanks in advance.
-Venkat Nehatha
Venkat, SugarCRM does indeed have its own pdf generation ability. We use it to generate customer orders, quotes, invoices, and statements.
Though I've done some work on the pdf generation myself, I don't think I'm really experienced enough to be able to guide someone else in detail in the use of Sugar's pdf capabilities. I can tell you that we use pdf generation only in our own custom modules, so the files are found in [sugarRoot]/modules/[customModule]/. (You may know that unless you know exactly what you're doing, NEVER modify the main SugarCRM files in the [root]/modules/ folder!) In the previously mentioned custom module folder are two sub-folders, "sugarpdf", which has the code that accesses the modules/database to get the information to write to the pdf, and a "tpls" folder that holds the layout information for the header, body, and footer of the pdf, in HTML format, using the information from the sugarpdf folder's file.
I strongly recommend you visit the SugarCRM developer forums where you will be in touch with many developers much more experienced than me in Sugar.
I hope this helps in some way.

What do I need to know to create Xcode project templates?

I know some of the tutorials for creating Xcode project templates, for example this one here: http://robnapier.net/blog/project-templates-364
This is the best one I could find. All others basically repeat the same info, or are no longer up to date, or worse tell me that even they don't know what they're doing. Possibly useful tools that are linked to here and in other places are no longer available.
I keep running into roadblocks, and would like to gather as much information as possible on the process of creating Xcode project templates. Info that is most importantly up to date (at least it must be relevant for Xcode 3 or higher).
For example, what I'd like to see is:
a description of the
TemplateChooser.plist and similar
plist files and what these options do
(in my case, once I add a
TemplateChooser.plist, my project
disappears from the Xcode project
template list)
how to create a project template that references another .xcodeproj (when I do that, the other .xcodeproj appears in the project template list even though it doesn't use the special naming convention)
processes that can be applied, for example is it possible to run a script during the creating of a project from a template? This would be useful to unzip certain files into the newly created project.
If you have the answer or suggestions to any of the issues above, I'd appreciate that. Otherwise any link to good Xcode project template resources would be highly recommended. Especially if there is an official documentation from Apple - I haven't found one yet which seems to imply that project templates are undocumented.
Have you seen these:
http://www.sodeso.nl/?p=895
http://www.codeproject.com/KB/iPhone/CreatingXcodeProject.aspx
If you say you have searched, I'm pretty sure you've already seen the links but these are the best resources I could find with my 'googlabilities'
You might try contact this guy - http://linkedin.com/in/mottishneor he has some related messages around the web
The links suggested by FX are also not bad at all!
There is indeed little XCode template info out there. What I have found of interest are the following links (I documented myself on the topic, but haven't yet gone any further):
a Google Code search reveals a few examples, but not much
in particular, I found interesting to look at the code provided by Three20; they have some basic examples, like here
referencing another project worked for me, so maybe you could open a specific question about that giving more details?
there is information scattered on the Apple mailing-lists
there is no official documentation from Apple, as is evidenced by the lack of results to this query
I'm sorry if this is not a Enlighting, concise answer. As you said, it's not well documented, and sources are all over the place. I just hope I could highlight some places to find information that your own searches might not have reached :)
I don't have a Mac anymore, so this is as much as I can give you without testing this myself. As far as I can tell, Xcode templates are undocumented by Apple.
This guy has some guides for messing with Xcode templates but the info is pretty sparse. My suggestion for working with templateChooser.plist is to try to only edit that file in the interface builder.
This guide is a good example of how to add a reference to another .xcodeproj. For the reason you were having trouble adding a reference to your project we probably need more information.
If you scroll way down in this doc you can that each template already includes a script called myscript.sh. This script will show up in the scripts menu for projects built with that template. That isn't quite as convenient as running scripts automatically, but it's better than nothing.
In conclusion, Xcode template documentation is a nightmare. It looks like there are a lot of powerful features there, but they are obscured because of lack of user friendlyness and because documentation lags far behind Apples updates of Xcode. It just doesn't seem to be a priority for them. I hope this helps.
And yet another video link http://howtomakeiphoneapps.com/2010/10/how-to-make-custom-xcode-templates-with-video/

BlogEngine.Net Code Formatting Extension that works?

For months now I've been trying to find a code syntax formatting extension that works for BlogEngine.Net. I'm not fond of the behavior of the default formatting extension, and have tried a couple of others (manoli is among them), but they always seem to interact badly with the TinyMCE editor. Does anyone know of an extension that works, or a different approach that will allow me to make code samples pretty on my blog without hacking the crap out of the HTML myself?
Thanks.
I would try using Windows Live Writer along w/ the Paste From Visual Studio plugin. One you go WLW, you'll never go back to that damn TinyMCE interface.
WLW here:
http://get.live.com/writer/overview
Plugin here:
http://gallery.live.com/liveItemDetail.aspx?li=d8835a5e-28da-4242-82eb-e1a006b083b9&l=8
Thanks, Rafe. Thanks to this post that Hanselman put up the day after I asked the question, I downloaded WLW and am now using it. As far as getting prettily formatted code, I'm using cut-and-paste from a little tool developed and available on manoli.net.
Check out SyntaxHighlighter.. Works excellent. For easy integration into BlogEngine have a look at my blog post.

Resources