web design – protofusion http://protofusion.org/wordpress Open Hardware and Software Mon, 20 Sep 2010 23:54:07 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.6 11753368 JavaScript “Current Filename” Function http://protofusion.org/wordpress/2010/07/javascript-current-filename-function/ http://protofusion.org/wordpress/2010/07/javascript-current-filename-function/#respond Mon, 26 Jul 2010 16:01:18 +0000 http://protofusion.org/wordpress/?p=621 ]]> I found the need to get the current filename, without the file extension, of a webpage using javascript. I thought there would be an easy way with jQuery, but I found a good way to do it in plain javascript. I made a quick function to take care of this task that might save you some time, the compressed version is shown below. I’ll add a more human-readable version in the near future.This code is very unreadable! Please don’t use it blindly, as it may not work in all cases.

function getCurrentFile() {
  var filename = document.location.href;
  var tail = (filename.indexOf(".", (filename.indexOf(".org")+1)) == -1) ? filename.length : filename.lastIndexOf(".");
  return (filename.lastIndexOf("/") >= (filename.length - 1)) ? (filename.substring( filename.substring(0, filename.length - 2).lastIndexOf("/")+1, filename.lastIndexOf("/"))).toLowerCase() : (filename.substring(filename.lastIndexOf("/")+1, tail)).toLowerCase();
}

This function returns the current filename (minus the file extension) in all lower-case. Feel free to modify it to suit your needs. It also works properly even when a URL does not have a file extension (such as with some asp-based sites), or when there is no filename present (returns the folder name). This function is great for highlighting menu items based on which page the user is currently browsing. If you don’t understand some of the syntax, note that I’m using javascript’s conditional syntax as shorthand for if/else statements.

]]>
http://protofusion.org/wordpress/2010/07/javascript-current-filename-function/feed/ 0 621
Quick and Easy Sites with FOSS http://protofusion.org/wordpress/2009/08/quick-and-easy-sites-with-foss/ http://protofusion.org/wordpress/2009/08/quick-and-easy-sites-with-foss/#comments Sun, 09 Aug 2009 02:30:55 +0000 http://protofusion.org/wordpress/?p=13 ]]>

In this short guide, you can learn how to create an easy yet professional-looking fixed-width website with free open-source software. Before you begin, ensure that you have the Gimp and Inkscape installed, in addition to some form of text or code editor (any variety will do).

This guide provides a basic guideline on creating a site simply and easily using few tools. Feel free to try different techniques, see how it works, and leave some feedback in the comments. Feel free to comment on how to improve this article!

Initial Design

First, open up Inkscape and begin visualizing what you want your design to look like. If you have not used Inkscape before, check out this simple Inkscape tutorial.

Things to keep in mind:

  • Your design should include a header, menu bar, mid-image portion, and footer portion
  • The menu bar portion can have image-mapped links, or you can overlay text links on a background image
  • The middle image portion should be vertically tileable for a fixed-width variable-height site.
  • The footer can include image-based text, or text can be overlayed on a background image

After you visualize your initial design in Inkscape, you should have something similar to the image below. In this tutorial, we will be creating a site with a header, an image-mapped menubar, a tiled text background, and a footer image.

Your initial Inkscape design should look something like this

Your initial Inkscape design should look something like this

Exporting the Design

After you have created your design in Inkscape, you must export it to a raster format so it can be parsed by web browsers. The resulting raster image also needs to be separated into different portions that we will reference in our CSS. The fastest and easiest way to accomplish this is by creating a “chopper” layer above the layer(s) your design is in. Go to [Layer –> Add Layer (select “Above Current”)] and put in whatever name you wish.

In this layer, you will now begin creating squares to mask off various portions of your design. Start out by dragging a square across the header portion of your design. Zoom in and make sure that the edges of your mask are aligned with the edges of your design. After you create the first mask, copy the mask and paste it below. This time, center the block on your design and only adjust the height, not the width. Continue this process until you mask each portion of your site: header, menu bar, middle tile, and footer. I find it easiest to color-code these sections and make them semi-opaque, as shown below.

Your completed theme with different portions in different translucent colors should look something like this

Your completed theme with different portions in different translucent colors should look something like this

Finished? Take a break and check out some of the notes below.

Notes:

  • The footer in this design will have copyright info on the image itself, therefore search engines and visitors printing out your site will not have footer information. You can easily add a text-based footer to your design, but this won’t be covered in this tutorial (yet)
  • Many other items, such as the menubar imagemap, can be substituted with a text-based menu with an image background behind it. This is usually a bit more flexible, and nicer to search engines.

Ready to move on? If you know some CSS, you can probably figure out this part yourself. You can create

tags to hold each image, although an imagemapped menu bar must be embedded in the page with an tag. You can look at the CSS source for ethanzonca.com to get an idea of what you need to do.

]]>
http://protofusion.org/wordpress/2009/08/quick-and-easy-sites-with-foss/feed/ 3 13