Posted by ljmacphee on June 23, 2008 under cgi, how to, perl, php |
The original TimesToCome site was created in 1997. The web has changed a great deal since then but my scripts hadn’t. I just hacked my blogs to use the PERL scripts. Converting them to work in your blog without using PERL or CGI is actually quite simple.
The first thing to do is convert your old CGI scripts to PHP. Your forms will remain the same except for the name of the script they are calling. ( <form method=”post” action=”new-script-url”> ) I found that User Friendly Forms in PHP, and PHP Form Handling gave me enough information to convert the forms from PERL to PHP. Most of what works in PERL, works in PHP, you’ll find very little needs to be changed. ( ‘PHP Black Book’
is the best book I’ve found so far. )
Once you have a working PHP form you need to incorporate it into your blog. To do this you need to create a page template. The easiest way is to copy an existing page template in your theme. The archives.php page usually works well.
Remove the archives information from the page. I deleted everything after <div id=”content” class=”pages”> down to the matching </div> tag for that division. Your template may be slightly different.
Now copy and paste your PHP form - everything between <body> and </body> into that space between <div id=”content” class=”pages”> and </div>.
Rename the page to something useful, and don’t forget to change the ‘Template Name: xxxx ‘ in the template.
Now log into your Wordpress or other blog. Create a new page, name it something useful. Then go to the templated drop down menu (’Templates’) and select your newly created template from the menu. Save and publish.
If you wish to use multiple pages for your form just create multiple pages. If you wish it to reload the same page when the script runs, call yourself in the action= and place a hidden check that lets you know if this page is being loaded or if the form is filled out and submitted.
Put the hidden check if form submitted in the form:
<input type=”hidden” name=”submit_check” value=”1″ />
The check for it in the part of the form you do your calculations:
if ($_POST['submit_check'] == 1 ) { /*do something*/ }
See example: Calorie calculator
Download example: Calories example php form in a WP blog
Posted by ljmacphee on September 12, 2007 under archives, blogger, perl, wordpress |
I found that lots of people were hunting around the TimesToCome Mobile Blog for posts that weren’t easily findable. You can tell this by looking in your log files. If you see some of your top views are for http://yourblog.com/label/something then people aren’t finding posts.
Make it easier for them. Add in an archive by subject post and make it easy to find.
I haven’t figured out how to fully automate it but in the meantime, I wrote a couple of PERL scripts, one for Wordpress and one for Blogger that fetch your RSS feed, pull out the links, sort them by subject and stick them in an HTML file. You can open the file in any editor and cut and paste it into a post. You’ll want to re-run it once a month or so and update your archive post.
Blogger archive building tool
Wordpress archive building tool
Directions are in each file, it’s pretty painless. In Wordpress you have to temporarily up your feed count. In both you just have to switch the temp url to your RSS url feed.
See also:
Installing PERL Modules
Posted by ljmacphee on August 8, 2007 under blogger, perl, tools |
There are many tools for backing up Blogger blogs to Windows but none I could find for us OSX and Linux users.
Here is a PERL script that will fetch your rss comment feed from your blogger blog. It will grab your blogs comments and save them with the same name as on blogger. Comments are then stored in a separate directory for each post.Posts and images are not downloaded with this script.
backup-blogger-comments.pl
If you have Perl installed on your computer then down load the script.
Chmod 755 backup-blogger-comments.pl to make it executable
On line 38 change the 999s to your blog’s blogger id number
Then run the script../backup-blogger-comments.pl
If you have more than 300 comments change the max=300 to a number larger than the number of posts you have posted.
It’s a very fast script and will have your comments backed up in no time.
If, like me you have numerous blogs write a script to back up all the posts and comments like this:
#!/usr/bin/perl
# perl script to call all back up programs for blogger blogs
print “\nBacking up AI posts”;
system ( “./backupai.pl” );
print “\n Backing up AI comments”;
system ( “./backupai-comments.pl” );
print “\nBacking up Mobile posts”;
system ( “./backupmobile.pl” );
print “\n Backing up Mobile comments”;
system ( “./backupmobile-comments.pl” );
print “\nBacking up Recipes post”;
system ( “./backuprecipes.pl” );
print “\n Backing up Recipe comments”;
system ( “./backuprecipes-comments.pl”);
print “\nBacking up Garden posts”;
system ( “./backupgarden.pl” );
print “\n Backing up Garden comments”;
system ( ” ./backupgarden-comments.pl” );
print “\nBacking up Houseplants posts”;
system ( “./backuphouseplants.pl” );
print “\n Backing up Houseplant comments ” ;
system ( “./backuphouseplants-comments.pl” );
print “\nBacking up Webtools posts”;
system ( “./backupwebtools.pl” );
print “\n Backing up Webtools comments “;
system ( “./backupwebtools-comments.pl ” );
More information:
Download Perl and help to get you started
You may need to install Perl modules; see How to install Perl modules
See also:
Perl script to back up Blogger posts and images
Posted by ljmacphee on August 6, 2007 under blogger, perl, tools |
There are many tools for backing up Blogger blogs to Windows but none I could find for us OSX and Linux users.
Here is a PERL script that will fetch your rss feed from your blogger blog. It will grab your posts and save them with the same name as on blogger. It will then fetch the images from your posts and down load them. Files are stored in a separate directory for each month.
Comments are not downloaded with this script.
BloggerBackup.pl
If you have Perl installed on your computer then down load this file.
Chmod 755 BloggerBackup.pl to make it executable
On line 38 change the 999s to your blog’s blogger id number
Then run the script.
./BloggerBackup.pl
If you have more than 300 posts change the max=300 to a number larger than the number of posts you have posted.
If you have a slow net connection or tons of images it will take a few minutes, be patient. Otherwise it is very fast.
More information:
Download Perl and help to get you started
You may need to install Perl modules; see How to install Perl modules
See also:
Perl Script to back up Blogger comments