jME Source Viewer

Well, hello again everyone. :slight_smile: So I got the dreaded "role revoked" email recently and so, ironically enough, it prompted me to do some work for jME. (To be honest, I'll do anything to avoid studying for finals; jME is a welcome reminder of when I had spare time outside of university.) Though the code has been sitting around for months, I cleaned up and jME-ified a Java source viewer.

Check it out using the following links, showing different ways to invoke it:

In addition to its run-of-the-mill pretty printing capabilities, the script generates links on import statements to view the source of other jME classes. For package imports (.*) it links directly to the JavaDocs for the package. The script can read files both from a flat directory structure and zip archives. The examples above are, in fact, grabbing the classes out of a nightly CVS build. Hopefully this will mean that the source viewer can always point to up-to-date code. The script consists of three files: showsrc.php, showsrc_impl.php, and unzip.lib.php. The src directory trickery is accomplished with this .htaccess file.

With a few very minor modifications (nothing more than changing a few URLs to point to the right place) the jME site should be able to link directly to source. For example, all the demos could have source links to show newcomers

Welcome back EricTheRed :)  hope to see You hanging around here some more again.

Welcome back.

Yes welcome, and thanks for the source code viewer. Although, none of the source is kept on the website, I'm not sure how we could make good use of it. Ideas?

Thanks for the warm welcome. :slight_smile: I really would like to contribute again to jME, but university always has a habit of getting in the way. Heh, if nothing else, I’ll have loads of free time come May 2009!

As for using the viewer, I had envisioned linking it to the nightly builds hosted on rather than directly to the repository. That, or perhaps have an archive of the latest stable release to which the viewer points. Another option is for me to host the script on my university account and have cron download the nightly build, well, nightly. Then the viewer would be more of a convenience utility to which people could link on the wiki or forums. Finally, it can always gather digital dust until we find a home for it.

welcome back eric :slight_smile:

comfortably viewing the jme source of the nightly build would be great. sometimes i'd like to take a quick look at the jme code (very useful for answering those troubleshooting threads) but i get online from various places and don't always have the possibility to check out jme from cvs.

You could just reference the head of CVS:

But perhaps that’s too easy. :wink:

Your smarty pants comments just never get old.  :stuck_out_tongue:

Renanse, I do them just because I know you love them. :slight_smile:

Ah, but grabbing the file directly from CVS doesn't have the added awesomeness of configurable line numbering and code colouring and and linkage to other jME stuff! Heh, the reason I wrote this in the first place is I abosolutely loathe reading unformatted source code. So, howsabout throwing it up on

Eric,  I was responding to Mojo asking for ideas about how to make use of your code displayer.  Just have the PHP file remotely load the source from the CVS repository and format it and you'll be golden.

Ah, I missed that (I blame it on exams). Once I'm through this week (i.e., end of term) I'll see about modifying the viewer to grab entries directly from CVS - it should, theoretically, be a simple enough task.

that would be really great (no matter what the frog says :stuck_out_tongue: )

reels from the lingering shock of a brutal set of exams Well, that’s that; I’m officially half way through my academic career Waterloo. Now I have about a week or so of free time before I start working for ATI (or should I say AMD?) for the term. But with the end of exams comes… code! You can now access files directly from CVS via the viewer. Just append a fully qualified class name to and, voila, Instant CVS Viewer! The script now has a hierarchy of where to look for source files: first locally, then remotely, then inside a local or remote zip archive. The source is still available from the links in my first post.

I’m content to host the script on my student account and simply leave it available to anybody who wants to (ab)use it. That said, it might be nice to have a copy hosted on; I think there’s value in having formatted access to CVS source available on demand.

As always, I welcome comments, criticism*, or any feedback you might have.

  • "Stop complainin'! When I was a youngin, we had to write our exams walking uphill both ways!"

i just tried it and it fails to open linked java files:

Warning: fopen(*checkout*/jme/src/showsrc/ failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /u8/eworoshow/public_html/showsrc_impl.php on line 64
Could not load source file

an option for font size would be nice. ;)

The mod_rewrite rule that handles files with a .java extension is, well, kinda screwed right now. It works well if you simply use the class name without the .java suffix. Tonight I'll see what I can do about fixing that. As for changing the font size, that should (theoretically) be easy enough to incorporate.

Right, well I think I've fixed the mod_rewrite voodoo so that it'll accept files with a .java extension. Let me know if it's still broken, but my (admittedly paltry) testing indicates everything is in order. As for changing the font size, I made a bit of progress tonight but it'll be a few days still until I have something usable to show everyone.

And since I seem to love talking to myself, here is yet another small update. As always, check out the new version which now includes a basic mechanism to change the font size. Because the script needs to hit every time it opens a file for formatting, I’ve shudder ajax-ified the controls so that the file need only be retrieved once and then manipulated to your heart’s content.

Changing the font size can be a bit… unpredictable. It seems that at some sizes the line numbers and lines of code no longer line up properly. It looks increasingly likely that I am going to have to embed the line numbers in the code rather than using my current two-column layout should I want everything to work nicely. Bah. For now, however, it is basically functional. :slight_smile:

don't worry eric, you're not talking to yourself :wink:

the font resizing function is really nice. but the imports(the links) still don't work:


Warning: fopen(*checkout*/jme/src/showsrc/ failed to open stream: HTTP request failed! HTTP/1.1 404 Not Found in /u8/eworoshow/public_html/showsrc_impl.php on line 64
Could not load source file

Welllll, it looks like I finally have a release I’m happy to say is Finished. Mostly, heh. It’s feature complete and (hopefully!) bug-free at this point so it’s good for use in whatever capacity it ends up. New to this version is better font resizing capabilities (line numbers scale correctly with size); fixed import links; minor control enhancements (mostly aesthetic); HTML/CSS that validates; much cleaner code (yay maintainability!); additional awesomeness.

Anyhow, check it out and let me know what you think!