Saturday, April 4, 2009

Blogger: selectively add 'click to read rest of entry' to long entries

Wordpress has a handy feature where long posts can be broken into two parts: when viewing the full blog you only see the first few paragraphs of long items, with a link along the lines of 'full post' or 'click here to read rest of entry'. I assumed it would be as easy as adding a tag [previewBreak] to any blogger post, but blogger does not seem to have this feature built in, so as best I can tell you have to hack it. Read on to learn how.

A technology commonly used for selectively hiding content is CSS. CSS lets you sepearate the content from how it is displayed: and one common display parameter is whether something is hidden or not. CSS lets you change display parameters based on type (table, link) and based on arbitrary tags you have assigned to content within the page.

Basic solution:


A basic solution can be found at here but it has one major drawback: it adds a "click here for rest of entry" link to *every* post. Short posts can be displayed in full on your blog and don't need a "full post" link.

Here is how the basic solution works:

Step 1 adds a definition to your template, so that any part of your post marked 'fullpost' will be hidden on your main blog page, but visible when viewing the full post.

Step 2 adds a definition to your template, adding a 'full post' link to the end of *every* post. This is bad, because short posts don't need a 'full post' link.

Step 3 shows you how to tag each post to determine what part of the post is hidden on main blog page.

I'm sure someone has posted a better solution, but google didn't find it so here is a modified version:

Better solution:


Step 1: rather than pasting in a single style to hide bulk of post, add two styles: one hidden in preview but visible in full post (used for the bulk of long posts), the other style visible in preview but hidden in full post (used for the 'full post' link). You can follow instructions from link above, but paste in the following (note the added 'notfullpost' case):

<style>
<b:if cond='data:blog.pageType == &quot;item&quot;'>
div.fullpost {display:inline;}
div.notfullpost {display:none;}
<b:else/>
div.fullpost {display:none;}
div.notfullpost {display:inline;}
</b:if>
</style>

Save your template!

Skip Step 2: we don't want the link in the template, because we don't want it applied to every post. HOWEVER, do be sure to save your template after Step 1.

Step 3: add the fullscreen div tag within each post where you want the post to break:
<div class="fullpost">

At the bottom of the post, *after* closing the div tag, add a link to the blogger URL for this post, eg instead of
</div>

paste
</div><div class="notfullpost">
<b><a href="http://interfaceoff.blogspot.com/2009/04/blogger-add-click-to-read-rest-of-entry.html">Continue Entry»</a></b>
</div>

Because you are manually adding the link only to posts which you are manually splitting, it won't infect short posts. Because the 'full post' links are tagged 'notfullpost' they won't be visible in the full post.

Notes:


Tips:

* tags like <div> imply newlines; More generally, whitespace will be collapsed unless there are line-level tags within it. If you have extra whitespace in your full post, remove blank links around such tags. Note that in our modified Step 3, the initial closing div and opening div tags are on one line; that is to cut down on unnecessry whitespace.

Shortcomings:

* you have to hard-code the link to full post. It would be better to use 'data:post.url' but I couldn't figure out a way to access that variable from code within blogger's post edit screen. I suspect that if you change the post date, the link might break. However if the canonical link changes any 3rd party links into your blog posts will break as well. Therefore the problem goes far beyond your 'full post' links; it is in blogger's interest to preserve the canoncal link to your post, and in your interest to avoid anything that might cause blogger to change the canonical link to your post. And as expected, changing the title of a post *does not* change the canonical link.

Possible improvements:

* A way to use 'data:post.url' within the code of your post.

* A way to add a link to 'data:post.url' within the template, but set a piece of data withing your post to indicate whether there is a break, and have the link in template only visible when there is a break.

Please comment if you have found a more elegant solution!

Friday, April 3, 2009

Windows - Install, Repair, Authorize

Managing Windows installs can be a hassle. Here are my notes.

FIRST INSTALL

One strategy is to keep your windows install partion(s) minimal size, and create a partition in the rest of the disk to keep your bulk data (eg music and video files, bulky games, etc). This forces you to distinguish between your windows system and your data, and makes it easier to transfer system files and settings between installs. The danger is that you'll run out of space.... resizing is no simple matter. So if you install apps which come with bulk data (games, soft synths) install the app or at least the data onto a data partition.

Consider making 2 or 3 primary partitions of identical size - install Windows in the first, you can clone to partition 2 for a bootable backup, and have partition 3 free in case you need to do a fresh install (this allows you to keep the old system partition intact, in case you ever need to recover files or settings from it.) Rest of space is used for a data partition.

In my case I chose 20GB for the windows partitions... plenty for a 4GB swap files, windows install, all my apps, and GB's of extra space for downloads. It does fill up now and then, but I just take all the media files littering my Desktop and Documents folder and sort them into the appropriate place on a data partition. With drives so cheap you could easily choose a larger size, but beware of allowing it to bloat with data - backups, defragmentation, and virus scans will take that much longer. A smaller size is also more convenient to backup up to iso images or incremental backups... you can keep backups stretching far into the past if your system is small and you aren't moving media files through it. Even at 20GB, when exporting my files and settings most of the data is bulk data such as WAV files from recording sessions and movies that i dumped on my Desktop at some point.

An appealing option is to install to a spacious USB thumb drive - then you can shutdown and take all your system data with you. However in practice people report slow boot times and app startup, and theoretically flash memory has a limited number of rewrites, so eg windows swap file could go bad relatively soon.



ONGOING MAINTAINENCE

Backup backup backup. Clone partitions if you are comfortable with that. Use the backup software that came with your hard drive. Use Windows Restore Points and any other backup service that is part of the operation system. Backup before installing software. Clone system partitions or make ISO's from them before deleting them - you never know when you'll need to figure out what settings you were using back when something worked for you.

Backup any time you are going to travel. If you are travelling with a system and it is important that it works, make 2 backups: a bootable/portable backup you take with you, and a 2nd backup (perhaps an ISO of your system partition on a big data drive) you leave at home.

Keep a backup at a different location. Should you be unfortunate enough to lose your physical belonging to fire or flood, at least your digital belongings can be copied ad infinitum and preserved.

Put a sticker on each computer/external drive that you need to backup, use it to keep a log of the dates and destinations of every backup you do. This will help you recognize when it's been too long since you last backed up, and help you find the backup should something die.

Keep the installers for drivers and software you've installed in a directory called "stuff i installed" - if you need to recreate your system this will help. Of course, consider finding the latest drivers if appropriate, but in some cases you won't have net access or need to install a specific older version you used in the past.



ONGOING MAINTAINENCE

Backup backup backup. Clone partitions if you are comfortable with that. Use the backup software that came with your hard drive. Use Windows Restore Points and any other backup service that is part of the operation system. Backup before installing software. Clone system partitions or make ISO's from them before deleting them - you never know when you'll need to figure out what settings you were using back when something worked for you.

Backup any time you are going to travel. If you are travelling with a system and it is important that it works, make 2 backups: a bootable/portable backup you take with you, and a 2nd backup (perhaps an ISO of your system partition on a big data drive) you leave at home.

Keep a backup at a different location. Should you be unfortunate enough to lose your physical belonging to fire or flood, at least your digital belongings can be copied ad infinitum and preserved.

Put a sticker on each computer/external drive that you need to backup, use it to keep a log of the dates and destinations of every backup you do. This will help you recognize when it's been too long since you last backed up, and help you find the backup should something die.

Keep the installers for drivers and software you've installed in a directory called "stuff i installed" - if you need to recreate your system this will help. Of course, consider finding the latest drivers if appropriate, but in some cases you won't have net access or need to install a specific older version you used in the past.




MOVING TO A FRESH WINDOWS INSTALL

If your old system cannot be rescued or you choose to make a fresh install, consider a strategy for migration BEFORE you overwrite any existing install.

Windows "File and Settings Transfer Wizard" can transfer things like the files on Desktop and My Documents, your preferences, desktop settings, application data such as your browser bookmarks, etc. Assuming you don't install things to wierd locations, it should cover just about everything. HOWEVER you have to be running the old system to export data - the tool can't just be pointed at a windows partition on any old drive. If you can boot in Safe Mode, that's good enough.

If you are moving to a new install on the same hardware, something like "driver genius" or the tools on multipurpose boot cd's such as "hiren boot cd" will export all the drivers you installed to eg improve video card performance or get certain USB devices working.

If you want to transplant your old hard drive into a new computer, you may have problems that A) windows won't boot and B) windows will require re-authorization (even something as minor as upgrading a video card could cause windows to require re-authorization.) For A) you might try repairing your install using a retail Windows install CD.




AUTHORIZATION


I've paid for various versions of Windows plenty of times - eg a 2-install license for every laptop I've bought. But I don't have all those product keys or install cd's around anymore, the ones i do don't match the flavor of XP i run. And anyhow I'm running hacked up TinyXP install for speed and reliability, and those types of systems mess with the registration and authorization. Sometimes when a virus corrupts the install, a crash causes data corruption, or the system somehow gets in a bad state, I struggle with Windows copy protections schemes.

When you pay for a license, keep the product key. Copy onto stickers, put em inside and outside your computer case. Email it to yourself. While you're at it make a couple copies of the install CD and write the key on them. Always note exactly what type of system/windows the install CD is for, as product keys might work only with certain flavors of windows or even certain install CD's.

Note that a Product Key you acquire through shady means or off a hacked CD might be valid enough to get you through install, but might be blacklisted on the server and invalid for authorization.

If you have an install CD, either retail or hacked, search the CD for a file with "unattend" or "UNATTEND" in the name. Open in text editor, the product key will be in there.

If you have a bootable windows install, there are tools to find the product key it is registered with. HOWEVER i've read that for certain OEM installs the key returned is a "bulk" key rather than your personal one, and might not work for repair or reinstall.



If you have a windows install that won't boot or just some recovered files, it is probably possible to extract the product key using whatever strategy the tools above employ. However at first glance the common tools only work on a running system, you can't point it at a different drive or folder. Some time with google should yield an answer.

If you can't log on to windows because it insists on activation (and you don't have a proper key handy you can use to activate - or if some bug prevents activation from working) you should still be able to boot in safe mode. There is a strategy WHICH DID NOT WORK FOR ME of modifying the windows installation to prevent it from prompting for activation before log-in. From http://au.answers.yahoo.com/question/index?qid=20071108113517AA1fMxA

1. Restart in Safe Mode (F8)
2. Go to Windows/System32/ and delete wgatray.exe & Go to /dllcache/ if it exists and delete the same .exe If not don't worry about the second.
3. Go to Start => Run => regedit
4. Browse HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Winlogon\Notify
5. Delete WgaLogon folder
6. Reboot.



If you can't install updates or microsoftware due to Windows Genuine Advantage, there several workarounds which are at least temporary.

MuBlinder software lets you install without activation.

You can get a brief reprieve by running the authorize app -> by phone -> change product key -> entering a different product key -> ok / remind later / you might have to try different strategies to complete the process... see http://www.p2plife.com/forums/index.php?showtopic=344&st=0

A fix to fool windows into thinking it is authorized at http://antiwpa.blogspot.com/



MY CASE

In my case, I was running tinyXP and a hard drive crash dumped a bunch of dll files and important-looking folders into found.000/ dir. I was able to boot it once or twice, but it would blue screen or throw errors and before long i couldn't even boot it. Because the hacked install like tinyXP can only be installed cleanly, I repaired my system by running retail XP install disk, *not* using the repair console, but selecting my existing install at the next step. If done correctly this will copy all the core Windows files into their proper places, but preserve your software and settings. However after install completed, reboot gave me an error that i couldn't log in until XP was authorized - no way to get around it. Safe mode works, and i tried duping wgatray and modifying registry, but after reboot same problem. However safe mode should be enough to let me use the "file and settings transfer wizard" onto a fresh install on another partition.