scriptygoddess

15 May, 2003

Easy printer friendly pages

Posted by: Jennifer In: CSS

Ever want your readers to be able to print your pages cleanly without having to suffer through all your sidebars and graphics? Here's a way to do just that. You need to create a new stylesheet and point your pages to it. Here's how I did it:

First, you need to define the two stylesheets in your document's HEAD:

<link rel="stylesheet" type="text/css" href="<$MTBlogURL$>print.css" media="print" />
<link rel="stylesheet" href="<$MTBlogURL$>styles-site.css" type="text/css" media="screen" />

Your print.css stylesheet should not contain any extraneous items, such as banners or sidebars. Your readers will probably only want to print your posts. Therefore, any element that should not be printed should be dealt with as follows:

.element-name {
display: none;
}

You must define the original stylesheet as media="screen" and the print.css stylesheet as media="print" so that when your page is viewed on the Web, the browser will serve up the screen-based stylesheet. But when the browser's Print or Print Preview button is pressed, the browser will use the print.css stylesheet.

If you have a separate division for your copyright information, as I do, it might be a good idea to leave that in the print stylesheet as well.

There is one "gotcha" involved in printing, and it doesn't matter whether there's a special stylesheet for printing or not. When you are printing pages, such as MT blog pages, that have the "More" (extended text) link (like the "But wait! There's more!" link on these pages), the text in that link is not going to print. If you want the extended text to print, you'll need to go to the individual archive page and expand the link and then print the page(s).

Guest authored by:
Joni Mueller – jonielectric.com

14 May, 2003

Password protect your page

Posted by: Jennifer In: Scripts

I wrote this script to password-protect a page of mine. This has some disadvantages in that you need to implement this on every page you want to password protect, though you can throw it into a header/footer file to cover a set of pages. I use this in MT to password protect a private journal of mine.

First, post this on the VERY FIRST LINE of the code… it has to come before any <HTML> or header tags… It MUST start on the very first line, or it won't work. Change the URLs to the page you want it to go to when you log in, and change USERNAME and PASSWORD to whatever you choose.

<?php
// Set a cookie that expires in one year
if($submitcookie){
if($loginname=="USERNAME" && $loginpassword=="PASSWORD"){
setcookie("login", $loginname, time()+31536000);
header("Location: http://YOURDOMAIN.COM/PATH/TO/PAGE/");
exit;
} else {
$incorrectlogin = true;
}
}
if($deletecookie){
setcookie("login", $loginname, time()-31536000);
header("Location: http://YOURDOMAIN.COM/PATH/TO/PAGE/");
}
?>

Next, paste this right after your BODY tag, before anything you want protected.

<?php
// if LOGGED IN
if (isset($login)){
?>

Somewhere in the page include this link to let you log out. This can be placed anywhere in your design. =)

<a href="<?php echo $PHP_SELF ?>?deletecookie=true">Log Out</a>

And lastly at the very end of the page, before the BODY tag and after everything you want protected, paste this chunk of code. You can format it so it looks nice and fits in with your design, as long as you don't change the mechanics (field names, etc).

<?
// if not logged in
} else {
?>
<table border=0 cellpadding=0 cellspacing=0 align=center>
<tr>
<td>
<?php if($incorrectlogin){ ?>
<div id="entry" align=center style="text-align: center;">
Username/password incorrect.
</div>
<?php } ?>
<form action="<?php echo $PHP_SELF; ?>" name="login">
<div style="font-weight: bold;">Please Log In</div>
<div align=center style="text-align: center; margin-top:8px;">
<table border=0 cellpadding=0 cellspacing=2>
<tr><td> User Name</td>
<td><input type=text size=20 name="loginname" class="forms"></td> </tr>
<tr><td>Password</td>
<td><input type=password size=20 name="loginpassword" class="forms"></td> </tr>
<tr><td colspan=2 align=center>
<input type=submit name="submitcookie" value="Login" class="forms2"> </td></tr>
</table>
</div>
</form>
</td></tr>
</table>
<?php
} // end if/else logged in
?>

So you're basically making a sandwich of your page contents. And that's it!

Guest Authored by:
Natalie – lunardreams.net

14 May, 2003

Color Schemer

Posted by: Jennifer In: Bookmarks

I do not have an eye for color. An online tool that helps tremendously is The Color Schemer. Each color selected will show 15 other web-safe colors that correspond with it.

There is also a shareware version of the program, with more options than the web site, including a non-web-safe color spectrum.

Guest Authored by:
Jennifer – confettifalling.com

12 May, 2003

Site validation

Posted by: Jennifer In: How to's

Mark Pilgrim's recent post (why we won't help you) about using HTML validation as a way to troubleshoot layout problems (among other things) got me wondering if I could validate my own HTML. So I did – here are some tips on how you can too:

Validation means you're bringing your markup into compliance with the standards set by the World Wide Web Consortium; because I was a novice and because my main goal was cross-browser viewing compatibility, I chose to validate to the standards for HTML 4.01 Transitional. HTML is being supplanted by XHTML or eXtensible Hypertext Markup Language; if you want to validate to the most cutting-edge standards, you'll want to read more about it. Among other benefits, validation acts as the ultimate proofreader; it catches mistakes you might not find (and might not even know were mistakes) that cause your site to behave strangely in differnet browsers. If you're considering embarking upon a big site overhaul like skinning, this kind of effort is worth it, because you'll move forward with cleaner code.

The nuts and bolts of validating involve checking for and correcting errors; to do this most effectively while my main site was still live, I moved a copy of my index page to a test blog – no risk of ruining the template because my main site could serve as a backup copy. Another reason to use a test blog? You will always want to validate the source code of a live page; that's what people will see when they view your site. If you try to validate a blogging template before any PHP scripts or template tags have been processed when the page loads, the validator will give you error messages because it won't recognize the tags. When I first ran my page through the W3C HTML Validator, I discovered 103 errors. Let that sink in for a moment. Then I realized that the validator was picking up two kinds of mistakes: 1. errors in the code used for the templates, and 2. errors in the code in the entry text. Every time I corrected an error in the template code, it removed multiple instances of that error on the index page – the number of errors I found started dropping sharply after I figured that out.

In addition to the W3C validator, I used this excellent HTML resource from Ian Graham; which helped me understand what tags could be used where, and what tags were deprecated, or out-of-date. I used HTML Validator Lite to help me interpret the more obscure messages I got from the W3C validator. I didn't know which standard HTMLValidator Lite was using, so I doublechecked the changes it suggested on another test page before implementing them in the final corrected template. Many people recommend using HTML Tidy; my page was so far from valid when I started that Tidy had trouble processing it.

Other good things to be aware of (or "let my mistakes save you time"): Many of the errors I encountered were as a result of the improper handling of special characters in Javascript (like the "Blogroll Me!" link) or HTML (like a link to an item on Amazon.com) in my templates. I used the Hiveware URLCleaner and the CleanURL bookmarklet to give me the ASCII equivalents to characters like the dreaded ampersand. I made sure that each and every page had a DOCTYPE at the top; it's the validator's way of recognizing what kind of text you're about to feed it. I was under the mistaken impression that tables don't validate (this comes from hanging out with people who use and love cascading stylesheets); table tags must appear in the proper order (be properly nested) to ensure that designs with tables validate. Finally, if you do want to skin your website and you want it to be valid, you can; each skin you implement needs to be checked against the output of the validator.

Sound complicated? It's not nearly as complex as trying to ask for help when you're not sure what the problem is ("My site doesn't look like I thought it would in Browser X. Why?") Being able to say "My site validates, and I'm still having problem X" puts you a lot closer to a solution because more people will have an idea of what you're talking about. Don't be intimidated – give it a try. If I can do it without pulling my hair out, anyone can.

Guest authored by:
Donna – deliriouscool.org

12 May, 2003

ASP – (database) connection strings

Posted by: Jennifer In: Bookmarks

An extensive list of connection strings: connectionstrings.com

Comments Off on ASP – (database) connection strings

11 May, 2003

Another way to manage links

Posted by: Jennifer In: Script snippet

Back when I first changed the format of my page so that I had the same list of links down the side of every page, I quickly discovered that it was a pain to have to go through 5 or 6 pages of HTML/PHP adding new links here and there.

I eventually came up with a system that makes it much easier to add/remove links from all my pages in a single go. On every page that has a list of links, I put this at the top:

include "path/to/linkage.inc";

The file linkage.inc contains a series of multidimensional arrays, like so:

$blogsLinkage = array(
0 => array("http://www.snazzykat.com/", "snazzykat"),
1 => array("http://www.scriptygoddess.com/", "Scriptygoddess"),
2 => array("http://www.technoerotica.net/", "technoerotica"),
4 => array("http://www.neuroticfishbowl.com/", "neurotic fishbowl"),
5 => array("http://www.tampatantrum.com/", "aint too proud to blog"),
7 => array("http://troll54.blogspot.com/", "Troll54"),
8 => array("http://timatollah.blogspot.com/", "Timatollah"),
9 => array("http://www.greasypants.org/", "greasypants"),
10 => array("http://www.randomramblings.com/", "Random Ramblings"),
);

$techLinkage = array(
0 => array("http://www.thinkgeek.com/", "ThinkGeek"),
1 => array("http://www.phpbuilder.com/", "PHP Builder"),
2 => array("http://www.scriptygoddess.com/", "scriptygoddess"),
3 => array("http://www.dynamicdrive.com/", "Dynamic Drive"),
);

Then, in each file where the links are to be listed, it's a simple matter of a nice little loop to render the code:

<?php
foreach ($blogsLinkage as $val) {
print "<a href=\"$val[0]\">$val[1]</a><br />";
}
?>
[more HTML code…]
<?php
foreach ($techLinkage as $val) {
print "<a href=\"$val[0]\">$val[1]</a><br />";
}
?>

Then, whenever I need to add a new link, I simply put a new entry into linkage.inc. If I need to remove a link, simply take it out of linkage.inc. This way, all the pages are updated automatically, and it's much easier!

Guest authored by:
Will – silverfisch.net

11 May, 2003

Automated Posting of Deferred MovableType Entries

Posted by: Jennifer In: Bookmarks

Just ran across this script to automatically post drafted entries in Movable Type.

Honestly, I haven't been able to figure it out, but I thought perhaps others might be able to wrap their brains aound it.

(Note by Jennifer: If this works, then this would take care of that whole "pre-post" issue. We had come up with a script that did this, but there were a lot of holes. This one won't even publish the post until the date/time it's supposed to – it looks promising.)

Guest authored by:
Patricia – lunanina.com

Comments Off on Automated Posting of Deferred MovableType Entries

11 May, 2003

Zipped Archives in Unix Shell

Posted by: Jennifer In: How to's

If you're working with scripts, the time will come when you need to work with a Unix archive. Generally, these are .tar files or .tar.gz (zipped). These .tar files are commonly called "tarballs". These are no different than any other archive/backup/zipped files, they just take a little getting used to.

How to decompress a .tar or .tar.gz archive in Windows:
Winzip is my windows-based zip file manager of choice. There are several versions available, included a free "evaluation" version. Winzip can decompress .tar and .tar.gz files locally to your hard drive. Make sure you use the wizard or select "Use Folder Names" from the Classic interface so the file structure will be maintained.

How to decompress a .tar or .tar.gz archive on your webserver:
You need shell access (telnet or ssh). If you don't have shell access, you'll just have to decompress the tarball local (see Windows directions above) and upload via ftp.

1) Assuming you have shell access, upload the tarball to your webserver in binary mode via ftp. (Note: Choose binary mode, not ascii or automatic detect – binary). Most of the time, you'll want to place the tarball one level above where you want the files installed, as the structure of most tarballs begins with a folder.

2) Once the tarball is on your server, log into your shell account (ask your host for directions).

3) Use the following commands to decompress:

.tar files: tar -xvfz filename.tar
.tar.gz files: tar -xvfz filename.tar.gz

4) The files will decompress into it's original uncompressed structure. You can browse the structure using your ftp program or other tools that are more familiar to you.

While we're at it, let's just round out this topic.

How to zip a folder in Unix:
To create an archive from the Unix shell (telnet/ssh), use the following command:

tar -cvzf filename.tar.gz folder-name

So, if I want to create a tarball to backup my "images" folder, I'd use the following command:

tar -cvzf images.tar.gz images

Note the space between the "z" and the name of the folder I am compressing. You can create archives of individual files as well, just replace the "folder-name" in the example with a file name (i.e. "image.jpg").

If you need a good telnet/ssh client for windows, I recommend Putty. For more information on unix shell commands, google "unix shell commands". There are 1,000s of good resources.

Guest authored by:
Kevin Donahue – blog.kevindonahue.com

09 May, 2003

Quickstart your photoblog

Posted by: Jennifer In: Bookmarks

A lot of people would like to have a photoblog, I was one of them. Even though I really like designing and building websites, I really didn?t want to spend too much time on building one. Instead, I wanted to focus on creating the photos.

I came around quite a few sites with photoblogs and tutorials, here are the three most popular I found based on MovableType:

The Moonpost tutorial:
This is an easy, down to earth photoblog how-to, based on the standard MT weblog templates.

Blogstyles Photoblog Tutorial:
Slightly more custom then the Moonpost photoblog. It is also very easy to setup, and it is supplied with all MT templates already!

The Quixotic Photoblog Tutorial:
The most customized photolog of these three, but also drop-dead-easy to setup, complete with templates and stylesheets and stuff! An excellent and beautiful photoblog. I used this one to build my own photoblog (www.sindono.com) At the end of the tutorial are some tips on how to expand your weblog with extra features such as voting and a random image.

Guest authored by:
Arno Jansen – www.sindono.com

09 May, 2003

Doors are now open…

Posted by: Jennifer In: Announcements

I am happy to announce that we are now accepting guest authored posts!

Read the FAQ, then submit your post.

Comments Off on Doors are now open…

Featured Sponsors

Genesis Framework for WordPress

Advertise Here


  • Scott: Just moved changed the site URL as WP's installed in a subfolder. Cookie clearance worked for me. Thanks!
  • Stephen Lareau: Hi great blog thanks. Just thought I would add that it helps to put target = like this:1-800-555-1212 and
  • Cord Blomquist: Jennifer, you may want to check out tp2wp.com, a new service my company just launched that converts TypePad and Movable Type export files into WordPre

About


Advertisements