Friday, July 31, 2009I Posted My First php ProgramI posted my first php program today. It is just a simple hit counter for my web page: www.thekimerers.com/brian/I downloaded most of it from the net, but then I had to make a change in order to get it to work properly. Here is the complete file:
?php $file = 'counter.txt'; if(!file_exists($file)) { $handle = fopen($file, 'w'); fwrite($handle, 0); fclose($handle); } $count = file_get_contents($file); // Trim the newline of one is there $count = trim($count); $count++; if(is_writable($file)) { $handle = fopen($file, 'w+'); fwrite($handle, $count); fclose($handle); } else { echo 'Could not increment the counter! I had to change my index page from index.shtml to index.php to get it to work. What does this have to do with this blog? Some day I will probably change this blog from .html files to .php files and try to make it a bit smarter. Stay tuned. Wednesday, July 29, 2009I Fixed the Formatting ProblemI fixed my formatting problem. The blog now works better when I shrink it down. The text from the left and the right no longer overlap when I make the browser skinny or show the blog with the RSS frame displayed. Don't try sqeezing it down with your browser now because it does not do that any more. To fix it, I had to edit all the templates plus the style sheet. In the templates I put tables around the "content" part and the "index" part. Those two ID's in the style sheet make up the two main parts of the blog, the left side and the right side. By putting them into tables it is no longer possible to have the text overlap. I put the content part into a table like this: <div id="content"> <div class="blog"> <table align="left" width="65%" border="0"> <tr><td> Then after the <div> is closed, I close the table. </td></tr></table> This table is set up to take up 65% of the width of the browser. That way the content will be arranged to fit in the available space. For the "index" ID (the right hand side of the blog) I made a fixed width table, like this: <table align="right" width="280" border="0"> <tr><td> <!-- sidebar begin --> <div id="links"> And I closed it when the </div> is closed, like this: </td></tr></table> The fixed size table for the right hand side of the blog keeps the browser from wrapping things like the calendar etc. because the table is sized large enough to avoid that effect. In order to keep the visuals inside of the tables, I had to edit the style sheet, styles-site.css, to get rid of some absolute positions and margins. I commented out the positions like this: #content, #container { background-image: url(stripes.png); background-repeat: repeat-x; background-position: bottom left; /* position: absolute;*/ left: 0; } And in the links ID. #links { /*position: absolute;*/ right: 10px; width: 280px; text-align: right; } Then I commented out the right margin of the #content.blog class #content .blog { margin-bottom: 100px; /*margin-right: 290px;*/ } That is it. It took a bit of investigation to figure out what to do, but the fix itself is not too difficult once you know the secret. Tuesday, July 28, 2009Bad Formatting ProblemToday I found a pretty bad formatting problem with the blog. I pulled up the site with a Sage side panel open and the site was jumbled. The right hand side of the contents was overwriting the left hand side of the right column. It was pretty ugly. It was happening because the viewing space had been made more narrow than what I am used to using. You can see the effect if you squeeze your browser down to be tall and skinny. Other blogs don't do that; they throw up a scroll bar. I suppose that this is a side effect of the way the style sheet is specified. I will have to improve this, which will require making a new style sheet. I haven't messed around with style sheets much, but I guess I will have to get into it. Stay tuned.
Friday, July 24, 2009I Built Thingamablog from SourceJust for grins I built Thingamablog from source code. Since it is written in java, the build script is written for "ant". Ant is a program like "make" which accepts an input file that describes the program and how to build it, and then it makes sure that everything gets built properly and stored in the right places. The old makefile's were a nightmare to deal with. Ant uses a file called "build.xml". So first you have to get "ant" from somewhere. You can download it from If you are running on Windows, download the installer and follow the directions. I have done that, but I don't remember the details right now. I am running Thingamablog on Linux here at home, and I installed ant using the package manager. Ant is a small program and will not take long to install. BTW, ant is written in Java as well. Once you have ant installed, download the Thingamablog source file, thingamablog-1.1b6-src.zip, put it into some directory or other and unzip it. That will result in having the directory called thingamablog-1.1b6, which is full of the source code. Open a command window and cd into the directory thingamablog-1.1b6 and you should see a file called build.xml. That is the default build file for ant. Just type in "ant" and wait.
[brian@localhost thingamablog-1.1b6]$ ant Buildfile: build.xml init: [mkdir] Created dir: /home/brian/blogtest/thingamablog-1.1b6/build [mkdir] Created dir: /home/brian/blogtest/thingamablog-1.1b6/build/classes [mkdir] Created dir: /home/brian/blogtest/thingamablog-1.1b6/build/app/thingamablog-1.1b6 [mkdir] Created dir: /home/brian/blogtest/thingamablog-1.1b6/build/dist [echo] Initializing ------- lots of stuff goes by ----------------- BUILD SUCCESSFUL Total time: 5 seconds [brian@localhost thingamablog-1.1b6]$ The zip files with the compiled Thingamablog in them are left in the directory, thingamablog-1.1b6/build/dist. Notice the time.... 5 seconds! That's it. Thursday, July 23, 2009Added the RSS LogoIt was a pretty low key day today. All I did was add the RSS logo to the blog. At least I didn't destroy the format like last time. Wednesday, July 22, 2009Don't Destroy Your Customization Work!I inadvertently destroyed my customization of the templates. I had added a few custom tags to all the templates in order to display an image, some links, etc. Then I fooled around with changing the theme. Bad decision. When you change the theme, the default templates overwrite the ones that are there. I knew that, but I somehow forgot it and did it anyway. So I went back and put the custom tags back in and then immediately copied the restored blog to a backup directory. Thank goodness I had entered the html into the custom tags and not directly into the templates. The tags were still there. I just needed to call them out again in the templates. Some days I just do stupid things. Tuesday, July 21, 2009Creating a Desktop Shortcut on LinuxHere is how I created a desktop shortcut on my Linux platform. When you install Thingamablog on Windows you get a nice shortcut with an icon. But I installed Thingamablog on my Linux computer by unzipping a file and then running the .jar file. No icon; no shortcut. So I made one. I use the KDE desktop, so I don't know if this would work on a Gnome desktop or not.
First, I wrote a bash file to run the program. Here it is: #!/bin/bash # Contains all the switches to run thingamablog cd /home/brian/apps/thingamablog/thingamablog-1.1b6 java -jar thingamablog.jar I put that into a file named "thingamablog" in the directory where the jar file resides. Then I created a shortcut to an application by right clicking on the desktop and choosing "Create New=>Link to Application...". In the dialog box click on the Application tab and browse to the bash file you created. Change the name of the shortcut to whatever you want, and then click on OK to create the shortcut. Double click the shortcut to run the application. It works for me. Unfortunately, it has an ugly gear icon in it. I wanted a nice icon for my shortcut, so I made one. The application icons in Linux are stored (on my system) in the directory /usr/share/icons/hicolor in directories named after their sizes. I created four icons of different sizes with the same image,
The icons must be in .png or .xpm format. Then I copied them into the proper directories as root, like this:
% su % <enter password> % cd /usr/share/icons/hicolor % cp /home/brian/images7/created/thingamablog/thing-logo48.png 48x48/apps/ % cp /home/brian/images7/created/thingamablog/thing-logo32.png 32x32/apps/ % cp /home/brian/images7/created/thingamablog/thing-logo22.png 22x22/apps/ % cp /home/brian/images7/created/thingamablog/thing-logo16.png 16x16/apps/ Change the locations to the directories where you have the images saved. Once the images are saved, right click on the shortcut and select Properties. Then click on the icon in the upper left to post the icon chooser. The thingamablog logos should be in the list. Select the one you want to use (I put the 48x48 on the desktop) and you are done. In case you don't want to create your own, here are mine. Just right click on the images and download them.
That is all there is to it. Monday, July 20, 2009Help Doesn't Hang on WindowsI tried to get Help to hang on my Windows installation at work and it didn't. I guess it is a problem with the java runtime that I have on my Linux computer at home. They are both running flavors of Java 1.6, but there must be differences in the runtime between the two. Saturday, July 18, 2009Hanging on the HelpSometimes Thingamablog will hang when I try to bring up the Help document. Once that happens, the only way I can fix it is to kill the java runtime that was running Thingamablog. I have figured out that this happens only when I try to bring up the Help when I have one of the editors open. As long as no editors are open, the Help works fine. The workaround for this problem is to make sure that all the editors are closed before trying to bring up Help. After that, you can display the editors and everything works fine.
Setting Up the Upload ParametersThingamablog is pretty easy to set up once you know the magic. It is also easy to change the setup since just about everything you put into the setup wizard can be changed later. The most confusing part of the setup for me was specifying the Path and the URL on the very first page of the wizard. I must confess that I got this part wrong a couple of times, and the results were confusing. So here is the straight skinny on what those two things mean. Path: This is the path that the FTP program must follow to find the right directory to put the files into. When you sign up with a company to host your web site you get part of a disk. The server software gives you a chunk of space and assigns it the name "/", which is your "root" directory. That is as far up as you can go as a user on their disk. All of your stuff starts at "/". That space is further broken up into directories for various purposes, for example, /public_ftp and /public_html. There is probably also a folder called "/mail" and one called "/logs". Files that you want to make available to the public for FTP download are put into /public_ftp. Files that you want to make available to the public for access using http are put into /public_html. That is the directory that contains your web site, i.e. all of your .html files. The FTP program needs to know the complete path from your "/" directory all the way down to the directory where you want to store your blog pages. Normally that will include the "public_html" directory. The path on my server for this blog is: /public_html/brian/blogs/TAMB URL: The URL is different. Thingamablog uses it to create the internal links in your blog to its own pages, such as archive pages. Since the URL path goes directly into the web pages, it must look just like a path that an outside user would use to get there. Your web server knows enough to send requests for web pages directly into your /public_html directory, so readers do not have to put that part into the path. The server itself, of course, is addressed using your www address, for example "http://www.thekimerers.com". So when you enter the URL into the wizard, enter the path that you would type into a browser if you were just trying to read the blog from the outside. Most of the path will be the same as the Path entry, but do not put in the "public_html" part. The URL for my setup is http://www.thekimerers.com/brian/blogs/TAMB/ P.S. If you are writing the blog to your local disc, use the complete path from your home folder to the blog for the Path variable, and use the "file://" protocol instead of the "http://" protocol in the URL. In my case, the Path is /home/brian/blogs/TAMB and the URL is file:///home/brian/blogs/TAMB Notice that there are three "/" characters after the "file:" part. Two of them are for the protocol spec. and the third is the "/" for the root directory. On a Windows computer it could be something like: file://C:\blogs\TAMB Friday, July 17, 2009Blogging about BloggingI have recently been thinking of starting a blog and so I went looking for blogging tools. I found one called Thingamablog that surprised me and captured my imagination. Thingamablog is different from other blogging tools because it works entirely on the client side, namely all of the blog data is stored on my local computer instead of on a server. Most of the blog tools out there are installed on the server computer that is hosting your blog. You enter your blogs using some sort of GUI and the entries go across the internet into a MySQL database on the server. When a visitor lands on your blog, the server fetches the information out of the database, converts it into html code, and sends it to the web browser across the internet. This is called a "server side" blog because the formatting work is done on the server. Thingamablog stores the blog entries in its own database on your local computer, and when you post them, the .html pages are formatted locally and sent up to the server via the internet. Then, when a visitor lands on your blog, the server simply sends the plain .html files to the user's browser. This is called a "client side" blog because the formatting work is done on the client, your PC. Thingamablog is a client side blogging tool. While this may seem like a picky deail, it has significant effects on how you use the blogging tool. There are tradeoffs to consider when decicing which tool you use, and here they are: Server Side Benefits:
Client Side Benefits:
Being somewhat of a computer geek and control freak, I really like the idea of having all of my blog located on my own personal PC. That way I can back it up myself and move it around or whatever I want to do with it and not depend on someone else's computer. So I decided to give Thingamablog a try, and I spent some time figuring out how to make the best use of the tool. Then it came to me that the best subject I could do for my first blog was how to use the Thingamablog tool. And that is how this blog came about. I will not repeat the excellent tutorials that are already out there, so for the basics, go to the Thingamablog web site. I plan on describing things that I have discovered myself about how this tool works. Check back later for some tips on using Thingamablog. This site and all of its contents are copyright Brian S. Kimerer 2009 |
I am a software engineer by trade. For fun I build and play banjos and paint pictures. To see some of my work, click on the link that says "My Web Site" in the Links section of this page.
Favorite Links
Archives
August 2010
July 2010 June 2010 May 2010 March 2010 January 2010 November 2009 October 2009 September 2009 August 2009 July 2009 Archive Index Google Site Search
Credits
|