Improving Code

Online Photo Gallery, Payment & Order Fulfillment: Ruby on Rails Tutorial

Friday, September 18th, 2009 | Custom Development, Improving Code, Photography, Portfolio, Programming, Projects, Ruby on Rails, Tutorials, Web Development, Websites | 4 Comments

This post is a follow-up to the post on my personal blog, titled “Ruby on Rails Photo Gallery & Shopping Cart with RESTful Authentication” In that article, I merely showed off what I’d done with Ruby on Rails, but I didn’t show anyone how. Well, I’ve gotten some comments from people asking me to show them how to build it.

That’s what this post is for.

So on to the nitty gritty details.

Start with the RESTful Authentication Tutorial:

Follow the README to install, but READ THIS FIRST to fix the ExceptionLogger error Then follow these instructions to fix the OpenID plugin error Make sure you get your recaptcha keys for the config.yml, otherwise failed login attempts will bust your application. Fill out the config & database.yml files accordingly, run your database create & migrate rakes, fire up the server and make sure it looks good. Cool? Let’s move on: Define the objects Let’s begin by pointing out what, exactly, we’ll be building this application around: Galleries of Photos that Customers can order with a private Account provided to them by an Admin who can manage the galleries and review the Orders, which are also available to their respective customers. I will go through how to set up the following models like so:

  • Galleries
    • has_many :photos
    • belongs_to :customer
    • title
    • acts_as_urlnameable (pretty URLs)
  • Photos
    • belongs_to :gallery
    • paperclip attachment: image
  • Customers
    • username, password, full name
  • Orders
    • has_many :line_items
    • belongs_to :customer
  • Line Items
    • belongs_to :order
    • quantity, size, price

So let’s build the Galleries first:

Then edit the Gallery model:

That’ll be fine for now. Let’s add the Photos model with paperclip image attached:

Now edit the Photo model as such:

You should read all about the paperclip gem if you need more info on this model. Basically, we’re telling it to allow image attachments to the Photo model. Customers can be the RESTful Authentication Tutorial User model, just need to add a couple things here:

Let’s worry about Orders and Line Items later. We’ll have to add a cart, too. I’ll cover it, but it is all derived from Agile Web Development with Ruby on Rails Third Edition

Run your rake db:migrate and confirm all is well. Delete the Galleries layout file so it uses the application layout.

Let’s go see http://localhost:3000/galleries and play around. Add a gallery and then go to edit it. This is where we’ll add SWFUpload. Follow Jim Neath’s advice for this.

You’ll want a photos controller:

The create method I use is:

I had no luck getting Jim Neath’s session fix working, so I put skip_before_filter :verify_authenticity_token in the Photos Controller. Bad? Yea, probably. I haven’t found a better way yet.

Add this code to app/views/galleries/edit.html.erb:

Which leads you to add the following partial: app/views/photos/_image.html.erb

We’ll worry about the destroy link later, let’s integrate swfupload. Download the latest copy of SWFUpload. Copy flash/swfupload.swf to public/flash (make directory first). Copy swfupload.js & upload.js (in Jim Neath’s demo app) to public/javascripts. Copy Jim Neath’s swfupload.css file to public/stylesheets. Copy Jim Neath’s images/icons folder to public/images.

Add this code to app/views/galleries/edit.html.erb:

Yep, a lot is going on there. Reload your galleries/edit page and see if it’s still working :)

Ok, so this gets you to a functioning online photo gallery. Up next will be adding user accounts, a shopping cart, ordering options, customers & paypal integration. Stay tuned!

For now, please find the source here: http://github.com/joemsak/proofs_package

And for help on your project, visit us at http://www.simplifyadvance.com

Tags: , , , ,

SEO for Enliven has been Successful

Monday, October 6th, 2008 | Improving Code, Programming, SEO, Semantic XHTML, Web Development, Websites, Work Stuff, XHTML | 1 Comment

Bunmi told me recently that our sister company, Enliven Software, has been getting regular business and sales through online visitors who did a search on Google.

I’m proud of this, because I wrote the XHTML that’s been helpful in optimizing enlivensoftware.com for robots like googlebot to understand the site and return it high in the rankings for search results lists.

How did I do it?
 
Header tags, Title attributes and Cross-linking, oh my!

Use the proper hierarchy of Header tags in your code. On the home page, H1 belongs to your logo and company name. H2 belongs to the main headline of the page and maybe your company’s motto if you have one. H3 and H4 can be headers of sections, like News or Events.

On your subpages, make your logo/company name a regular anchor tag linking back to the home page. Now H1 goes to your page name and H2 becomes a sub-header for dividing content. H3 and H4 can still designate page sections. It helps if your H1 matches your Page Title

Then you should put titles on those tags and on your navigation menu links. Hell, you can even put titles on divs! These titles should differ from the text in the tag itself. For example, you could have a link named “Events” and its corresponding title could be “Calendar of Events at Company ABC”. This is cross-linking and keyword density rolled into one swift move without overloading the user with too much fluff in the words they see.

Also, a good friend of yours can be the ABBR tag. It’s the tag you use to define abbreviations. In a real-world example, here’s the code I used for the logo for the new MHSAA web site we’re working on:

<h1 id=”logo” title=”Michigan High School Athletic Association”><abbr title=”Michigan High School Athletic Association”>MHSAA</abbr></h1>

Now Google and other robots will know what MHSAA means. That should help in future searches. It also helps that their domain is mhsaa.com.< You can submit your sitemap to google and use webmaster tools and google analytics, as well.

So these are simple ways you as a programmer can help your company and clients succeed in SEO. Don’t forget that you should start with a kick-ass writer, too.

DotNetNuke Core Team all up in my Grill

Tuesday, June 3rd, 2008 | CSS, DotNetNuke, Improving Code, Programming, Skinning, Web Development, XHTML | No Comments

Man, I’ve been getting quite a bit of attention from the DNN Core Team the past couple days.

I just wanted to say I appreciate the feedback and I’m interested in the advancements and improvements being considered in upcoming versions of the platform. Thanks for putting up with my candor and overt angst in these past few bitch posts.

I’d be particularly interested in knowing about any plans to move forward with .Net 3.5 and its ability to allow designers to define all the HTML in the controls. I’d like to see DNN reach the point where all rendered HTML is controlled by the front-end engineer, and we can achieve W3C compliance and simpler control over themes and content generation.

DotNetNuke Default.CSS: Seriously??

Monday, June 2nd, 2008 | Artemis Solutions Group, CSS, DotNetNuke, Improving Code, Programming, Ranting, Skinning, Venting, Web Development, Work Stuff | 16 Comments

Here’s another one of the myriad of reasons that I am displeased with DotNetNuke as a web development platform:

The “default.css” included with all installs of DNN has this (and more CSS for other stuff like it) in it:
H1
{
font-family: Tahoma, Arial, Helvetica;
font-size: 20px;
font-weight: normal;
color: #666644;
}

H2
{
font-family: Tahoma, Arial, Helvetica;
font-size: 20px;
...

(I think you get the point)

Excuse me, DotNetNuke core team, but isn’t stuff like this up to the Designers and Developers? Why are you including a default stylesheet with definitions for HTML elements that would be used by Web developers? I can’t tell you how many times default.css has left me absolutely baffled about the smallest details not being quite right according to our design specs because it has these random “defaults” in it. It’s not up to DNN Core team to define my font families, sizes, and colors. And seriously, stop using pixel font sizing.

It’s becoming clearer to me almost on a daily basis, that DNN is not the right CMS for a professional Web shop to be using. They probably have this default.css for people who don’t make skins or know anything about Web development. And if you remove default.css, it completely hoses all the Admin pages and Control Panel. It takes way too much time and effort to figure out what’s removable and what’s not, and you always end up surprised when some random element isn’t positioned or styled correctly later on down the road.

It’s time for us to move on to a CMS that gives the developer full control over the theme, and not put a bunch of defaults in it that you can’t get rid of. 

Why DotNetNuke is Terrible

Wednesday, April 23rd, 2008 | Design, DotNetNuke, Improving Code, Programming, Ranting, Usability, Venting, Web Development | 4 Comments

I really could go on and on about this, but just a few notes.

1. Forced Registration to Download their Software
When you go to DNN’s web site and sister sites, like the new DNN Events site, the first thing you have to do before you can download anything is register an account. Now, it’s not all bad because it’s free and I guess they just want to track popularity (ever heard of Google Analytics?), but the registration process takes too long. I registered an account to download the new Events Module beta about 10 minutes ago and still haven’t received my “verify your account” email. Sorry, DNN team, I’ve now lost all interest in your beta.

Not only that, but it’s not clearly obvious you have to register. They bury the instruction to register in their rather long and boring content. If I go to wordpress or drupal’s site, I see big freakin links to download (no registration required of course). It wouldn’t be so bad if they had a big link that said “Register and Download” but no, of course they don’t.

Which leads to my next point,

2. They really don’t support or discuss usability and accessibility
DNN modules and the DNN platform itself are so hard to use. Their website is hard to navigate, most of the icons don’t make sense, and the forums are cluttered and don’t work in all browsers. You can’t make a post in their forums in Safari. Sorry, Safari users, outta luck. Get firefox, I guess. No one seriously talks about how to make the admin screens and layouts of their modules more functional, faster, and easier to understand.

Most of the modules we have to buy (another point) are riddled with awful and outdated front-end code, and have the absolute worst Admin screens.

3. You have to pay for most of the modules
Now this isn’t that bad. I mean, a software developer’s gotta make money, and some people run their business solely off of DNN modules, right? Ok, but step up your game and make a module worth paying for. Refer to point #2.

More later, I have to get back to work.

Cheap Web Companies are Ruining the Web

Tuesday, December 4th, 2007 | Clients, Computers, Design, Feedback, Improving Code, Life, Programming, Ranting, Usability, Venting, Web Development, Websites | 1 Comment

This is completely opinion and I didn’t do any research but I’m probably right in most cases. This is really me venting because I’ve been having more than enough run-ins with external companies who under-price our clients for “services” such as consulting or even developing systems that they can’t afford for us to do. › Continue reading

DotNetNuke and Search Usability

Sunday, November 18th, 2007 | DotNetNuke, Improving Code, Programming, Search Engines, Search Modules, Search Results, Usability, Web Development, Websites | No Comments

DotNetNuke recently added what they call a “feature” to their implementation of a search bar: the ability to search the web or search your web site.

This poses a couple problems:

  1. It can confuse users with unnecessary options
  2. It’s pretty meaningless.

› Continue reading

Login Usability: Am I in or out?

Wednesday, August 1st, 2007 | CSS, Code, Design, Feedback, Improving Code, Javascript, Programming, Usability, Web Development, Websites | No Comments

UPDATE: After making this post, and refreshing the parallels forums page, I was presented with “Welcome, Joseph Sak” instead of a login prompt. So maybe I got it wrong, or they did, but this post still stands!

The Parallels Forums recently got some redesign and information restructure, which all looks good and is organized quite well. But they’ve missed a couple really easy issues with their login functionality.

› Continue reading

Semantic XHTML – More than Table-less layouts

Wednesday, July 18th, 2007 | CSS, Improving Code, Life, Programming, Semantic XHTML, Web Development, Work Stuff, XHTML | No Comments

OK so I have a confession to make. I didn’t know that semantic XHTML is different from standards-compliant XHTML.

I formally apologize to the entire web development community. My terrible practice over the last seven years has finally caught up with me and put me in my place!

I am deeply ashamed and will be making every effort to step up my game and read all about the wonderful world of semantic web development.

Modifying DotNetNuke Search and Improving the Results

Saturday, July 14th, 2007 | Artemis Solutions Group, Custom Development, DotNetNuke, Improving Code, Open Source, SEO, Search Engines, Search Modules, Search Results, Stored Procedure Improvement, Usability, Web Development, Websites, Work Stuff | 8 Comments

Recently, I modified the Stored Procedure named “GetSearchResults” to improve the results pages in DotNetNuke web sites. Here is my explanation from the DNN forums.

› Continue reading

Search

Social Media

About the Author

I'm a Front-End Web Developer from Chicago, IL. I like XHTML, CSS, JavaScript, last.fm, 37signals, flickr, Getting Real, dogs, bikes, social life, ROWE, speaking my mind, UX/UI engineering & design, dinner dates, dancing, movies, indie rock music, hipsters, scene kids, bars, food co-ops, drums, writing, books, organic food, eco-friendly, progressive thinkers, the secret message of Jesus, and lots of other things.