Thursday, July 06, 2006

Special Blog Post:
The Coding Hack's Corner, Issue #2

This is the second issue in The Dark Wraith Forums series on tips and helpful advice for bloggers. Issue #1 provided some useful directions on making HTML tags and special character codes. In this issue, a very narrow matter will be addressed: backing up your template. Although the publishing platform called Blogger will be used for the example, the routine can be applied to blogs on just about any service, provided you know how to get to the screen that displays the code for your blog template.

The instructions that follow are for Windows users. Follow them, and even if your template is completely destroyed by accident or by the incompetence of your publishing service (and no specific service will be named here, but Blogger comes to mind as an example, although no specific publishing service will be named here), you'll be able to simply and easily rectify what would otherwise be a total catastrophe. So without further introductory prattle, here's how to back up your template.

◊ Go to the screen where you manage your blog.
Your blog management screen

◊ Find the tab for managing your template and click on it.
Locate the tab to go to your template code management screen

◊ Your template screen should now appear.
Your template code screen

◊ Right-click in the template screen. A drop-down menu will appear; on that menu, click on "Select All."
Right-clicking in the template screen invokes a pop-up menu

◊ The contents of the template screen should all highlight.
All of the code is highlighted

◊ Right-click again. When the drop-down menu appears, click on "Copy."
Choose Copy on the drop-down menu

◊ Now, open the ancient Windows word processor called Notepad. (That's right: Notepad. Don't argue; just do it.)

Start → Programs → Accessories → Notepad.

◊ Once you've launched Notepad, right-click in the blank screen area. When the drop-down menu appears, click on "Paste."
Right-clicking in the Notepad screen invokes the little drop-down menu

◊ Your entire template should appear exactly as it looked in the template management screen from which you just exported it.
Choosing Paste creates an exact copy of your template code in the Notepad screen

◊ Save the file.
Use the Notepad menu bar to save this file

◊ Just type index2006-07-06 or whatever date it is in YYYY-MM-DD format (with thanks to Dr. Bong for suggesting that variation on my own unfortunately backward date naming method). Notepad will put the .txt extension on the file, which is what you want it to do. Writing the file name this way will allow you to go back through and know when you've made back-ups of your template. If you need to recover your blog template from a deletion or from some coding experiment you've done, you'll know exactly what index file version was your last good one.
Name the file appropriately


WARNING: Do NOT under any circumstances use Word or WordPerfect or any other high-end word processor for saving this file. Use plain old Notepad.


You now have a back-up of your template; so no matter what happens to the template on your publishing service, you'll be able to make everything right again in a matter of a few minutes. If you ever do need to publish the back-up, follow these simple steps:

◊ Open that back-up index file you created in Notepad.
◊ Right-click in the Notepad screen where all the text of the template is displayed.
◊ On the drop-down menu that pops up, choose "Select All."
◊ Right-click again.
◊ On the drop-down menu that pops up, select "Copy."
◊ Go into your template management screen.
◊ Remove any vestiges of the corrupted template code that might still be there.
◊ Right-click anywhere in template screen area (which, again, should have no old code still there because you've removed it).
◊ On the drop-down menu that appears, choose "Paste."
◊ Your back-up code should appear in the screen, and you can now republish the template.


That's it for this edition of "The Coding Hacker's Corner." Click here for a printable pdf version of this article.

More issues in this series will follow in the future. Until then, always keep this in mind: It's Bill Gates's universe; we're all just hackers in it.


The Dark Wraith wants to help folks be good hackers in it.

<< 19 Comments Total
 Anonymous blogged...

Good morning, Dark Wraith... Dr. Bong here, frequent lurker and first time commenter. One thing I would suggest regarding the format of the file name of your back-up file is using the "yyyy-mm-dd" so the most recent file is always on top.

Carry on
Dr. Bong

Thu Jul 06, 12:59:25 PM EDT  
 Dark Wraith blogged...

Good morning, Dr. Bong.

Ouch. I am so used to my own file naming system—quirky as it is—that I didn't think about that. You're right: my system would make the files for different years list in an odd order if the files were displayed in the normal way, which is by name.

I shall go back and fix that.


The Dark Wraith does appreciate it when someone points out that his own preferences are starting to interfere with normal human and computer thinking.

Thu Jul 06, 01:21:35 PM EDT  
 Debra blogged...

Your directions will also work for a Mac, but you save it in TextEdit without rich text editing. Are we all using Firefox?

I'm going to have to change my filing system also.

Thu Jul 06, 01:35:59 PM EDT  
 Dark Wraith blogged...

Good morning, Debra.

Thank you for letting me know about the Mac protocol. Although I use Macs to see what my Websites look like in the native browser, I don't work at all with them otherwise.

As far as Windows browsers are concerned, I have recent releases of Firefox, Netscape, and Opera all at the ready so I can ensure that renderings of pages look as close to identical as possible across browsers, but I use Internet Explorer as the default browser, and I deliberately do not work completely within the W3C framework, even though I ensure that my Websites look pretty good in Mozilla browsers. I am especially averse to holding strict adherence to W3C standards as some of them are now starting to take shape. Attribute this oddity to my Luddite streak or to my extensive state of paranoia these days. However, the instructions I gave are pretty much browser-independent under the Windows (pseudo-)operating system.

(Sorry, I still haven't gotten over losing my real DOS prompt to a GUI.)

Anyway, thank you for letting me know that the instructions I gave in the article are actually adaptable to Macs. That was a concern I had with publishing this article: it seemed like I was being rather narrower than necessary in the audience I was addressing.


The Dark Wraith tries to give everyone something to chew on.

Thu Jul 06, 01:49:58 PM EDT  
 Debra blogged...

Try not to shudder too much, but I very rarely back up anything. My brother goes nuts every time he hears that.

I just make sure I don't crash my puter and I created a blogger template that I can mess with, but I usually forget and just do it on the fly.

Me bad. And very lucky. Of course, I do have that Ipod thing. Hmmm.

Thu Jul 06, 02:28:22 PM EDT  
 Dark Wraith blogged...

Arghh! The handhelds! Another layer of CSS I have to get coded in.


The Dark Wraith longs for the days when they did PowerPoints on stone tablets.

Thu Jul 06, 02:33:47 PM EDT  
 SB Gypsy blogged...

Good Afternoon Dark Wraith,

More mind candy - yumm! can't wait 'till I get some time to do it justice.

Thu Jul 06, 04:51:48 PM EDT  
 Gary blogged...

Good Evening Sir!

I have just returned from my Blogger adventure. Needless to say, it was no fun at all!

I have backed up my new template (twice) per your more than adequate directions.

I have also linked this post for all to see.

I pray none go through this exercise.

Thank you much for your help and encouragement. I am now ready to lead a meeting.

"Hi...My name is Gary...And I am a Blogger user."

Until such time as I change.

Thanks again!

Thu Jul 06, 05:53:07 PM EDT  
 Dark Wraith blogged...

Good evening, Gary.

You got me motivated to finally think about writing this article, and then when I read Patricia telling about what happened to her template, that sent me over the edge.

It was good therapy. I've been simulating the transfer of this blog to Movable Type for several days now, so this gave me a break from that all-too-frustrating task.

I'm still trying to figure out how best to muddle that stupid rdf file, but at least the thing is exposed and vulnerable in Movable Type. I suppose I'm going to have to expose myself one of these days to some pretty virulent criticism when I publish a post explaining where W3C is leading. I'm not looking forward to that, but I'm not going to sit back and watch millions of blogs turn into nothing more than data feeds into some enormous snooping database.

Fortunately for me, that's another day's battle.

Anyway, your blog looks pretty good right now.

Strangely, although I do dearly love darkly themed blogs, yours looks really nice in the clean, white motif. I don't know why that is. Maybe I'm just getting old and more flexible in my aesthetic range.

God, I hope not.


The Dark Wraith would have to shoot himself if he were to start wearing any color other than black.

Thu Jul 06, 07:01:46 PM EDT  
 konagod blogged...

Of course I used Word to back up my template. Will take corrective action tomorrow. I cannot begin to tell you how pissed I'd be if I had needed to restore and something went horribly wrong.

Thu Jul 06, 08:53:03 PM EDT  
 Eric A Hopp blogged...

Good Afternoon Dark Wraith:

I had to smile at your little posting on how to save out your blog template from Blogger. Lordy, how many times have I saved out my own blog template into Notepad, to be converted into html so it can be opened into Front Page and worked on, to be saved out into a txt file that I can reopen into Notepad and replace the old Blogger template with my new Blogger template. I will say I do like the filename standard with the date--I'll have to remember that.

And theoretically, Dark Wraith, you could use Word to save our your template file. The key thing you have to remember is to use the "Save As" button and save it out as a plain txt file with no formatting instructions. If you use the "Save" button on Word, you end up saving it as a Word doc, with the .doc extension, and that would certainly mess up your day. Of course, I'll admit that it is a pain in the ass to remember all these infuriatingly little steps that could drive you to tear your hear out while screaming obscenities at MicroBloat's Word. You're certainly better off using Notepad instead.

Ah, to reminisce about going back to the good ole days of the DOS command prompt....

Thu Jul 06, 10:01:37 PM EDT  
 Dark Wraith blogged...

Good evening, Eric.

Believe it or not, I still maintain a DOS partition. Novell DOS 7.0, the inheritor of Digital Research's DR DOS.

Unfortunately, I must spend most of my time in the Windows environment, seeing as how I teach a number of business computing courses. I can't do much even with *nix these days; but when I have some time to myself, I do return to DOS and have some good fun with old-time skills that aren't very useful to anyone else. I even still have the last release of WordPerfect for DOS. It's amazingly powerful with the muscle of modern machines. I still have my Lotus 1-2-3, too. Ditto for dBase IV. I also have my FORTRAN compiler ready to go, too. Ah, but the good old days are over forever, I fear.

You never know, though. Once in a while, a civilization comes apart at the seams, and all that remains are old technologies abandoned decades or even centuries before the collapse.


The Dark Wraith bawls out, "DOS will rise again!"

Thu Jul 06, 11:12:12 PM EDT  
 Dark Wraith blogged...

Good evening, konagod.

As Eric Hopp pointed out above, you actually can make Word save the file properly; but honestly, it's a whole lot easier to simply save it in plain old Notepad.

Of course, I write just about all of my Web page coding in Notepad, too. That's a bit too primitive for most people's tastes.

But it really is good to be comfortable with clean text formatting: that's what browsers want to see when they open a Web page file to render it for end users. As with many things in the ultra-modern world, the plumbing still looks like it did when our forefathers were doing their Web pages back in the Revolutionary War days.

In fact, I've been meaning to see if a Google search would turn up Ben Franklin's Website. I'll bet it would be cool, what with all the graphics created back when Photoshop did vector graphics on woodblocks.


The Dark Wraith does love the occasional rustic experience on the Internet.

Thu Jul 06, 11:21:52 PM EDT  
 Eric A Hopp blogged...

Dark Wraith: I can do one below you--I've got DOS 3.2 with RamDrive on a 5 1/4 diskette, of which I used as the operating system for an old IBM PC Junior--sometimes I wish I had kept the old Junior computer. At one time I had 4 PC Junior computers sitting in my computer room. In fact, I still have a slew of 5 1/4 disks with old DOS programs--we're talking DOS games, IBM Writing Assistant, Harvard Graphics, Word Perfect, MultiMate, and I think even WordStar! I even have the 5 1/4 half-height disk drives, but they're not even installed on any of my computers. So when civilisation does come apart at its seams, I'll be ready with all my old DOS software! ;)

Fri Jul 07, 12:53:08 AM EDT  
 Mark blogged...

Spoilsport!

Spell checking your template (especially when your language settings are set to something OTHER than American-English) can lead to some interesting results ;)

Fri Jul 07, 11:08:14 AM EDT  
 Dark Wraith blogged...

Good morning, Mark.

I got a big grin out of that comment.

In a related vein, it's sort of interesting that Word doesn't have a setting to spell check a Web document or to prep it for the Web. The spell-checker just has a fit about HTML tags. Worse is that Word does those cutesy little things like curly quotes and ellipses, which look nice but cause interesting and unfortunate effects when some browsers try to render them, especially because they have no HTML special character code equivalents. This has become more of an issue with the use of Word to write documents for Blogger blogs, and it's really getting interesting with the proliferation of RSS feeds and handhelds pulling blog content. Some can render the strange characters, and some can't. I actually had to build a macro to run through blogScream headers to strip out those characters and replace them with ASCII stuff; and you know what?—writing the routine wasn't as easy as it might seem: because those Word characters have no equivalents in ASCII, how do you write a routine to go find them so they can be replaced? I worked it out, but it wasn't the slam-dunk I thought it would be when I sat down to write it.

Life was so much easier in the old days, Mark. I'll tell you: we didn't have all these fancy characters. Heck, I tell my students we didn't even have so darned many nice, modern numbers: all we had was binary, and that was good enough. Gracious, when times were lean, sometimes we didn't even have the ones, but we got by anyway: you can do a lot with zeroes. That's what I tell me students.

My students just stare at me when I say things like that.


The Dark Wraith thinks young programmers have it too easy these days.

Fri Jul 07, 11:44:24 AM EDT  
 Chuck blogged...

Hi Dark Wraith.

OK, you've got my curiosity up. :)

Why only notepad? I've used .rtf since the beginning and have never had a problem.

TIA!

Sat Jul 08, 12:10:50 AM EDT  
 Dark Wraith blogged...

Good evening, Chuck.

Browsers read, interpret, and render pure ASCII text. That's what Notepad deals in. When you go to the Blogger "Template" screen, what you see in that big box area is essentially nothing more than a Notepad window. What Blogger pulls up and displays is nothing but a plain, flat, text file for you to look at, modify, save, and then publish. That last phase, publishing, is really nothing more than uploading to a server the same file, but with the extension written as .htm or .html, and that's the case with any "HTML editor": the manipulation is done on a text file, but with the .htm* extension.

And that's what browsers want: if they see .txt, they render the file flat; if they see .htm, .html, .xml, .js, or several other extension they know about, they render that very same text based upon codes they find.

High-end word processors embed codes for their own purposes and to create effects for the rendering of printable documents. Word processors are really nothing more than computer programs that take the text you write and add lots of codes in the background where you can't see them. If you're familiar with the old WordPerfect, it used to have a wonderful command called "Reveal Codes" that allowed you to see all the background stuff.

But Heaven forbid you would want a browser trying to interpret high-end word processor code: generally speaking, it would have no idea in the world what that file was talking about.

The codes that browsers need are not the same at all as what word processors create and use. Browsers use what we call "mark-up," and those mark-ups are right there as nothing but ASCII text, themselves; but because they have "<" and ">" symbols around them, browsers know that they're not to be displayed, but rather to be used for formatting purposes during the process of rendering the page for an end user to see. (In fact, by the way, the "mark-up" today's browsers want to see is merely a somewhat more rigorous version of the mark-up that editors have used on printed "galley proofs" for ages and ages. The mark-ups inserted by the editors was used by the printer folks to put the pretty finishing touches like italics and bolds on the paged version of the documents that would be printed for publication, binding, and distribution.)

Saving files as .rtf will work provided you put in pure ASCII text because there's no "rich text" to save in the file. That's fine unless, somehow, something that's not simple ASCII makes it into the document. Then things would get ugly. It's better to use Notepad because there's no way ASCII going in can be altered into something other than ASCII coming out. (Actually, there's an old, old trick for making characters in primitive word processors that browsers might not know how to render, but fortunately, hardly anyone knows how to do that anymore.)

The truth of the matter is, Chuck, I write just about all my Web page coding (even javascripts and some xml) in Notepad. That way, I have no possible chance of getting something interpreted by the word processor as anything other than exactly what I've written.

In your case, you're okay with saving .rtf, but I would not recommend this for backing up anything that's Web coding. It's sort of like turning on a computer and launching Excel to multiply 524 and 367. Yes, Excel can do it, and you'll get the right answer as long as you don't use any special commands that might turn the answer into something you don't intend (like, for example, if the cell were formatted for dates); but why go to the trouble of using something beyond what is necessary to the task?

Your end users' browsers and your server all want ASCII, and that's what Notepad does. In fact, it's the only thing Notepad does. That makes it the perfect place into which you can put text that's Web coding.

Think about it like this, Chuck. I'm betting you're old enough to remember the famous Pepsi Challenge, right? Okay, suppose you were told you had to take that Pepsi Challenge. Once you knew you were going to do that, would you go out and run five miles a day, spend a couple hours at the library studying, and maybe start purifying your system by abstaining from sex and fatty foods?

No, of course not: you'd just drink the fool pop and see if you could tell if it was Pepsi or Coke.

There you go. The analogy is clear, and I'm sure you'll now see why Notepad is right for you.




The Dark Wraith, himself, is not sure exactly how that Pepsi Challenge analogy thing works in, but somehow it just does.
[GOD! but I need to lay off the excessive prattling that goes on until I'm blithering.]

Sat Jul 08, 02:28:28 AM EDT  
 Chuck blogged...

HA!HA! "The Pepsi Challenge". Yep. Heck, I'm old enough to remember "The Pepsi Generation".

Thanks DW for that explanation. I certainly didn't know all of that. It now makes sense & I'll be changing to regular old notepad.

I learn something every time I stop by.

Appreciated!

Sat Jul 08, 10:45:11 PM EDT