How do you get around this issue? Well, a php based proxy is one solution. You call via AJAX, this php file that then makes the request to the real feed, and sends it back. That didn’t seem like a simple or elegant enough solution.
I found RssToHtml, which is a PHP script that you can use the parse the RSS feed. Using this, you can even use an server side¬†include to get the feed. This¬†didn’t work on my machine¬†that would only¬†run cgi scripts from the include.¬†
Reflection is a very interesting part of Java. It is sometimes considered an advanced topic, but I think it is worth exploring here. There are several practical applications for using reflection, and we will look at a few here.
Reflection is a little like cheating. It allows you to get access to classes and its methods and variables without accessing them the normal way. We don‚Äôt use the new operator to create an instance, and by using reflection we can get access even to private variables and methods. For this reason, we should be careful about using reflection. It is a powerful way of writing programs, but be sure not to overuse it. Continue reading →
Abstract classes are an interesting piece of Java. They can’t be used on their own, and they have a unique place in our code. They are often confused with interfaces, but they provide a great way to prevent code duplication and ensure consistent structures when building an application.
¬†In this tutorial we want to look at what Abstract classes are and when to use them. We will take a look at the previous Interfaces lesson and see how we could refactor our code from that lesson to use an Abstract class. Continue reading →
I am currently creating a continuation of the java series on useing reflection. In one of the examples I was trying to read from a properties file. I completely forgot how to find the resource I was looking for. I found this article on Java World. It’s from 2003, but still relevent.
To start with. The myFile.properties file is in the same package as the class MyClass.
These were my attempts:
// 1. Just get a FileInputStream
InputStream aStream = new FileInputStream("myFile.properties");
// 2. Switched to getResourceAsStream
InputStream aStream = MyClass.class.getClassLoader().getResourceAsStream("my/package/myProps.properties");
// 3. Settled on
InputStream aStream = MyClass.class.getResourceAsStream("myProps.properties");
So, the first attempt was me completely forgetting how to do things. The only way that works is if you are putting in an absolute path from the file system. Never a good idea.
The second one, using the ClassLoader went astray because I forgot to include the “/” at the beginning.
The third times a charm. If you get the resource right from the class, you can also use relative pathing, and I got to drop the path.
Interfaces are a very important part of Java. They can also be quite confusing. In this lesson, we want to take a look at Interfaces, what they are, their relationship to classes, and how and why we use them.
I think of an interface as like a contract. If you want to fulfill a contract, you have certain obligations to fulfill. The same for a Java contract (interface). An interface defines a set of obligations that an implementing class needs to provide. The obligations are nothing more than method signatures. No code, just the signatures. The class that implements the interface provides the code.
The other thing an interface does, is it allows different classes to appear similar, at least in so far as they implement the interface. As you will see, a Bird, a Fish, and a Mammal are not the same, but if they all implement the Animal interface, then we can treat them all like Animals.
Note: lytebox appears to be discontinued by the author. See also Thickbox.
I was recently asked how to use lytebox in a gallery. The instructions at lyteboxes web page has several examples, but I guess they can seem a little overwhelming for some people, so I put together as basic an example as I could think of. It looks like this.
In this example, we are only dealing with useing lytebox with images in gallerys. There are lots of ways to use this library, and you can check his web page for the other options.
First, in order to use this library you need to get some files moved over. There are three things you need:
These files need to be placed in the folder where your html file is going to be. So, for our example, this is what I have :
index.html is the gallery html file that has the thumbnails and pulls everything together. gallery.css is a css file to style our little gallery just a bit. You don’t need this file at all. The pictures folder is where I have all my images. You can organize your images how you would like.
Ok, lets look that what index.html looks like. The first thing you need to do is put some code in the <head> tag. This is to tell the browser where the lytebox css and js files are.
Then you need to create the links in the body of your document. I have chosen to link thumbnails to larger size images. Here is the code to one image:
So, the path to the thumbnail is in the img tag. That is what shows up first. Then, in the a tag, you add the rel attribute. This is not really standard html. Html is not using the rel attribute, so lytebox has decided to use the attribute to signal it that you are linking the image within the href of the a tag through lytebox. This all happens in the background when your document loads, the lytebox.js file scans your document looking for these rel attributes, and adds some code to make it all work.
Also, look at the this: rel=”lytebox[gallery1]”. To make this work, you only need to say rel=”lytebox”. We put “gallery1” inside the  to link all these images together. This way lytebox knows to link these images together with “next” and “previous” buttons when the larger image comes up. In the example that I have here, I have two gallery’s, “gallery1” and “gallery2” so you can see how they work. One gallery per line.
Simple? Ok, so here is all the code in our example. I have here the code for the index.html and the gallery.css file. I have not listed the lytebox code. You can download that here.
The other day I finished the CwExif plugin. I got the idea originaly from posts that Gavin Gough, and Matt Brandon did where they were wishing for some easy way to get the EXIF data displayed.
Gavin today called me a “very nice man.”¬† Also that I¬†was a¬†”geeky Canadian”. We Canadian programmers take that to be the highest compliment. :-)¬†I was quite tickled. It is great when you get to create something that someone really wanted, and doubly when they go out of their way to say thank you.
I am glad that it is what he was looking for. I hope to make some improvements and options for display in the future, but will keep the “title” display¬†that works now.¬†
If you give it a try and have issues or suggestions. Leave a comment on the CwExif plugin page.
I now have a first version of CwExif that can be downloaded. This is a new WordPress plugin that will show exif data for an image uploaded to the wordpress library in the title tag. There is a button on the media admin screen that will take the exif data and put it into the title tag. On hover, the data will be displayed.
This is just the first version. There is much more that I want to do with this plugin, but you have to start somewhere.
I have been working on a plugin for WordPress that will display the EXIF data for an image. It turned out to be harder than I thought. First of all, there are very few working libraries that will access the data in an image. Second, this is my first WordPress plugin, and the documentation is not what I had hopped. So‚Ä¶ to start, and get something out there, I have scaled back abit.
The first iteration of the plugin will simple replace the title of the image (displayed on hover) with the some meta data captured by WordPress. This will be things like f-stop and shutter speed. Eventually I would like more data, but I will have to go outside of WordPress to get it. Second, I will need to beef up the display options. Using the title is not what I wanted. I would like to have a hover give a proper note, or a click with a lightbox effect. I will get to those later.
So, the first release of this plugin will be soon. I have it working within the media library, but when you are adding an image, the admin panel uses a pop-up with a different form. I just need to get it working either way.