Archive for the ‘Website’ Category

HTACCESS, RewriteRule, and the disappearing images problem

Wednesday, January 6th, 2010

I decided today that I was going to fix my ongoing issues with images and WordPress. Turns out that in this case the blame did not lay with Wordpress, but instead with my hosting provider.

A long time ago I decided to use blog.codeinreview.com as my web address instead of www.codeinreview.com or codeinreview.com.  Since I was originally going to use the ‘www’ address for a different site, I never really thought too much about it.  However, recently my web hosting provider went through some sort of upgrade (in defense of my provider, they did roll out a number of neat features).  As part of this upgrade it would appear that my .htaccess file was rewritten to prevent outside domains from linking to my images.  This worked OK, except it only worked for the main domain, not the blog subdomain I run on.

Fortunately, the fix was pretty simple – just remove the rewrite rule they were using.

Once I did that, and uploaded the new file, it seemed to fix all the wordpress image problems I was having.  Now all I need to do is figure out how to address the issue with posting to the site.

[EDIT]

It appears that the issue with publishing via Windows Live Writer has also been fixed.  As a number of thigns have been changed (including upgrading to a new version of Wordpress), I cannot say for sure, but hopefully I can now focus on writing instead of ensuring that my posts are displayed correctly.

Windows Live Writer vs Wordpress

Tuesday, December 22nd, 2009

A few months ago I switched my blogging platform over from Blogengine.net to Wordpress.  This change was done mostly due to a change in hosting platform that precluded me from running an asp.net website.  My experience with Wordpress has been… less than satisfactory.  The administration pages seem to be incredibly slow to load and use.  It seems to be having issues displaying images, and I have encountered no end of difficulty attempting to upload and link to files.  What may be the final straw for me though is that it is corrupting my posts.  While it appears to have corrupted most of my older posts on its own, the new posts appear to be corrupted when I use Windows Live Writer to upload the posts.

A quick google search appears to absolve Wordpress of any wrongdoing in this area, but it doesn’t help my problem in the least, as I cannot change the relevant libraries on my host.  A further search revealed a possible fix involving a plug-in.  Unfortunately, activating that plug-in still did not solve my issue.  At this point I still have no resolution to this issue.  If I do find a solution, I’ll let you know, but it may involve me changing from the Wordpress platform.

Developing a Usable Website Width

Thursday, December 17th, 2009

When you design a website, most folks try to minimize the amount of scrolling a user has to do.  Studies seem to indicate that while users will scroll, the less scrolling a web page requires, the more usable it will be.  Most websites attempt to limit the scrolling to the vertical direction, while minimizing or eliminating any need to scroll horizontally.

There are basically 2 ways to achieve this with a standard webpage.  The first is to fix the width of the page to a width smaller than the average user’s display width.  This design has the advantage that you can precisely position all the elements on the page because you are basically requiring a certain width.  However, if the user has a smaller window they will have to scroll horizontally to view the entire design.  In addition, this can create a large amount of empty space if the chosen width is too small for the average display width.

The second method would be to have the design “expand” or “shrink” to fill the available width.  This is usually accompanied with a minimum width to prevent the design from becoming unusable.  While this allows the user to size their window as they need to while still presenting as much of the content and design as possible, it can represent a much more complicated layout for the developer.  As I am not a designer, I usually pick this style so I can maximize the amount of actual content being displayed, and minimize the importance of the actual design.

Enter the Style Sheet

In many cases, making your site fill the available width can be as simple as adding a “width: 100%” line to your content class in your style sheet.  This will make the content fill 100% of the available width:

#ContentFull
{
width: 100%;
background-color: #DDDDDD;
float: left;
}

<div id=”ContentFull”>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>

But what happens if you don’t want the content to fill 100% of the width, but only some smaller portion, leaving room for a menu bar or some other content next to it?  If you want the content to fill some reduced percentage, and want the other content to fill a proportional amount of the layout, then the solution is still simple:

#RightContentProportional
{
width: 80%;
background-color: yellow;
float: right;
}

#LeftContentProportional
{
width: 20%;
background-color: #DDDDDD;
float: left;
}

<div id=”LeftContentProportional”>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>

<div id=”RightContentProportional”>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>

So now both columns will adjust their widths in proportion to the percentage allocated to them.  So far, there haven’t been any complicated tricks, and has been pretty straight-forward.  The problem occurs when you have a 2-column layout where one column is a fixed-width and the other column needs to expand to fill the remaining space.

To solve this problem you need to perform a bit of magic using padding and containing elements.  Once you have the general idea, you can adjust it to meet your needs.  The basic setup is as follows:

#ContentWrapper
{
float: left;
width: 100%;
}

#RightContentExpandable
{
margin-left: 160px;
background-color: #DDDDDD;
float: left;
}

#LeftContentFixed
{
margin-right: -100%;
float: left;
width: 150px;
background-color: yellow;
}

<div id=”ContentWrapper”>
<div id=”LeftContentFixed”>
<p>
Fixed Width Content:
</p>
<p>
<ul>
<li>Item1</li>
<li>Item2</li>
</ul>
</p>
</div>

<div id=”RightContentExpandable”>
<p>
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</p>
</div>
</div>

Basically, what this does is create a left column that is fixed at 150 pixels.  It does this by playing with the left and right margins.  The left column has a RIGHT margin of –100%.  Essentially, this makes the right margin of the element the left side of the screen.  This means that when we float a second element, it will be position over the top of the left column.  Since we don’t want the content to overlap, we give the right column a LEFT margin of 150 pixels (in this case, I gave it a left margin of 160 pixels to create a bit of space between the columns).  What this does is cause the right column to start its left edge at 160 pixels from the right margin of the element next to it.  In our case, since we gave the element next to it a right margin all the way on the left, the right column will display an empty space where the fixed column is displayed, giving the impression that the left column is side-by-side with the right column (even though they are technically on top of each other).

So why do we need the wrapper element?  You may notice that the expandable element does not specify a width.  If we had given it a width of 100%, the resulting layout would have been 100% of the screen, plus the 160 pixels for the left column – we would always have to scroll.  To get around this, we size the parent element as 100% of the width, and then allow the right column to fill as needed.

Unfortunately, this means that the right column will only fill as wide as needed to display the content.  If the right column has a different background color from the background color of the containing element, the color will not “fill” the entire right side of the screen.  If this is a problem, you may need to play with different ways of solving the issue.

Open Sample Page

Everythings Broken!

Thursday, June 4th, 2009

I’m slowly working my way through the new site – changing providers and blogging software has proven both easier and more difficult than I had originally planned.  Unfortunately I have also had things made more difficult by an extensive travel schedule for the past few weeks (and extending into next week).

I am hoping to get a chunk of time to address these issues during the next few days and get back to regular posts in a week or so.

Sorry!

Site back online…

Wednesday, May 27th, 2009

… and hopefully most of the content is here somewhere.  I’ll be updating it over the next week to get everything back in order.  I’ll also be working on recreating my template one more time for Wordpress this time.

I’ll write more about my switch over tomorrow.

Working on a new site

Thursday, May 21st, 2009

I will be quiet through Memorial Day as I complete work on a new version of this site.  I hope to get all the content transferred over sometime this weekend, so I can switch over and start up on the new site first thing next week.

How to lose a customer, in 1 easy step

Monday, May 11th, 2009

Finding new customers is hard.  First, you have to identify the people who are interested in what you are selling.  Then you have to find a way to meet those people so you can tell them about what you are selling.  Then you have to convince them that they want what you are selling, and if you manage to do all that, you still have to agree to a price for everything.

Doing that takes time, money, and a whole lot of effort and patience.

On the other hand, if someone is already a customer of yours, things become much easier.  You already know who they are and what they want.  They already know you and (hopefully) trust you and want to purchase your product or service.  So all that’s left is to agree on a price – which should be easy because they already have some expectation based on their previous purchase.

Given that keeping an existing customer is so much easier than finding a new one, you would think that companies would work hard to make sure that their existing customers stay customers.

Sometimes companies keep customers (either intentionally or not) through “lock-in” – they make it so difficult to switch to a competitor that it isn’t worth the cost.  This is essentially why Microsoft dominates the business world.  The cost of switching is too high for most companies – they simply can’t do what they need to do on other platforms (or they don’t know how).  Comcast keeps its customers despite horrible services, prices, and policies because in most cases they are the only option for cable or high speed internet.

So how do you keep a customer if there are low barriers to switching or lots of competition?

You can try to create “brand loyalty”.  By creating a community around the product or company, you can convince people to keep coming back.  This is (more or less) what Apple relies on.  You can also create loyalty through exceptional customer service.  HP support managed this when they promptly and efficiently fixed my out-of-warranty laptop for free.  REI does this through their simple and generous return policy (if it breaks or you don’t like it – return it).

If none of these options are possible, you are left to compete on price, and if you are competing on price you better price yourself accordingly.

Take for example, my webhosting provider.  I use webhost4life.  They have been OK – they have had several service outages and issues with my site, but on the whole I’ve been satisfied with their service over the past year.  Being inherently lazy, I decided to renew my plan, and look into adding a second site for my photography work.  Imagine my shock when I discover that they wanted to charge me for the privilege of renewing my plan.  Since all the work in setting up the hosting plan had already been done, essentially they are trying to charge me for taking my money.  To add insult to injury, if you sign up for a new account with them, they will not charge a setup fee – so it is cheaper to be a new customer than an existing one, yet somehow they expect me to feel some compulsion to continue purchasing their service.

Not going to happen.

They are competing on price, and there is a lot of competition out there.  The cost of switching is roughly one hours worth of work – most of which doesn’t even require my attention (uploading and downloading the site).  They are a company that didn’t realize how they were competing, and as a result lost customer.

Blogengine.net Contact Page Problems

Saturday, March 14th, 2009

So I've been having issues with the contact page on this site.? After looking around, I tracked the problem to the Send button handler code.? It would apparently only send email if there was an attached file.? Since my contact form has no ability to attach files, it didn't send emails.

That sucks.

A broken contact page is the worst problem you can have with a website (short of the site going offline), because your visitors can't even tell that it is broken.? Even worse, if the page indicates success but doesn't send it, your visitors won't even know there is a problem, and neither will you.? Yet another good reason to run through and test your sites functionality every once in a while.? That is also why I include my email address (brian@codeinreview.com) on each page, which is apparently what folks have been using to get in touch with me.? So for everyone that tried the Contact page, I'm sorry.

Fortunately the fix was easy, I just commented that check out of the button handler code in the contact page and we were back up and running.?

? private void btnSend_Click(object sender, EventArgs e)
? {
??? if (IsCaptchaValid && Page.IsValid)// && txtAttachment.HasFile)
??? {
????? bool success = SendEmail(txtEmail.Text, txtName.Text, txtSubject.Text, txtMessage.Text);
????? divForm.Visible = !success;
????? lblStatus.Visible = !success;
????? divThank.Visible = success;
????? SetCookie();
??? }
? }

I'm not really certain why that check was in there in the first place, I couldn't see any reason for it.? It would also be nice if there was some feedback as to what failed here – but for now that will need to wait until I better understand what is going on.

In looking into this fix, I also discovered that several other people have had issues with the contact form in blogengine.net.? If my hack doesn't fix the problem for you, check out these changes.? Maybe they will do the trick…

Good luck…

Download Tracker v1.0

Thursday, February 26th, 2009

I’ve been meaning to learn how to write extensions and widgets for BlogEngine.Net for a while now.? I’ve been using this website as an excuse to play around with web-development, which is part of the reason why

  1. The site is often broken.
  2. The site is often changed for no apparent reason.

In this case, the widget and extension I wrote covers functionality already built elsewhere, but let’s face it, what’s the fun in using their code?? Besides, implementing this gave me a chance to look at how other folks wrote their extension, and served as a good learning experience.

Essentially there are 3 parts to this widget/extension.? The first part is the extension.? This is required in order for the widget to work, and tracks the number of times a file is served via the FileHandler service.? It uses the settings provider and saves a count of the number of times the file was served.? No information about who, what, why, where the person came from is recorded, because frankly I don’t really care.? All I am really interested in is which files are popular and which aren’t.? The second part is the DownloadList control.? This simply renders an unordered list of the files and their download counts.? This control can be used anywhere if you have a pressing desire to do so.? The final part is the widget “Download Tracker”.? This hosts the DownloadList control as a widget.? The widget is only displayed to authenticated users.?

Eventually, I might throw together a “most-popular” widget that would display the top five most popular downloads or something like that, but for now I just wanted a way to count the number of times a file is downloaded.

I have 2 other widgets/extensions I plan to implement (in addition to my Trailhead Estimate development).? The first is an AddToAny widget to add the control and customize it.? The second is a “most-popular post” type widget, to help direct visitors to the posts most enjoyed by everyone else.

As always, visit the Download Page to grab the extension/widget.? It is organized according to the directory structure the files should be placed in:

  • The “Download Tracker” folder and its contents should be saved to the “widget” directory.
  • The “DownloadTracker.cs” file should be saved in “App_Code\Extensions”.
  • The “DownloadList.cs” file should be saved in “App_Code\Controls”.

That is all you need to do to install it.? From there, you should see “DownloadTracker” in the extensions, just enable that and add the “Download Tracker” widget to the widget collection and you are done.

Integrating AddToAny in Website Theme

Wednesday, February 11th, 2009

It took a bit of effort and some experimenting, but I have successfully integrated the AddToAny widget into my website theme (v1.2.1).? The hardest part was figuring how to pass the information around so it would display how I wanted it to.? I also fixed the issue I was having with website titles (apparently you need to pass the title of the page in the URL back to AddToAny, setting it in script will not cause it to be displayed correctly).

The widget also has a nice feature that allows you to add service to it, so I added the Dotnet Kicks (Kick it!) service.? This has (I think) cleaned up the posts very nicely.? As it turns out, I really like the customizability.? I might even have to customize it further, there are some neat things other folks are doing with the menu and display that I may need to investigate further to get the site just the way I want it.