Friday, 22 December 2006

PayPal helldesk

I like text-only emails. It's a great way to avoid link-jack phishing spam, virii and annoying flashing ads. It's also a great way to get your email through an ssh connection. However, dealing with long URLs can sometimes be annoying. It doesn't seem to matter that I've set all of my settings to *not* use wrap-characters. When a link comes through it will, more-often-than-not, have a '+' sign squidged into it when it breaks onto a newline.

This is not a big problem. I've grown accustomed to copy/pasting (ok, highlight and middle-clicking) into my browser window, searching for the <CR> and a spurious '+' and removing it before hitting "Go".

This does not work for PayPal URLs

PayPal text-based email is that hideous abomination that comes sprinkled with MicoSoft proprietary characters. Lines end in '=' and there is a smattering of '?', "=20" and other random wierdness, just to make life more challenging...

I spent hours yesterday morning trying to get back into an old paypal account of mine. I did the "forgotten password email" thing. I clicked on the URL. I removed the <CR> and the clearly spurious '=' wrap-character - no go. I tried it while leaving in the '=' - no go. I tried copy/pasting the inidividual halves of the URL into my browser - no go.

I then spent an hour or more on the phone with their help-desk trying to be polite while they went through their script:
"Hi there, I'm having trouble with the forgotten-password URL. I have tried copy/pasting it into my browser, I removed the line-wrap symbol and the carriage-return, and it still doesn't work."
"Have you gone to the forgotten password page and clicked the link to send you a reminder email?"
"Yes, I've done that - I've got the email, I've clicked on the link and it doesn't work. I tried to copy the link into my browser, but that doesn't work either."
"Have you tried to copy/paste the URL into your browser?"
<sigh> <<find me somebody that understands linux... or at least somebody that knows how to *listen*!>>.

Finally he agreed that it really wasn't working for me! But their technical desk had gone home by that stage so all they could do was open a trouble-ticket with me and I would need to call them tomorrow.

I played a wild-card and tried creating an account with the email for my old company. I was coming in for some final work this morning. I used Evolution there so I could look at the URL and compare. I wasn't sure if it'd help - but figured it was a better shot than fretting about the next level of helldesk support.

Example URL from Evolution: https://developer.paypal.com/devscr?cmd=_signup-el&ac=Uqht43A9suP7A-qEw=
Wi6tvquhPE8gVgEPX5Rr7vBWrMTj8uOWmJ2eh6wavzjhIQWjjkrfCT8x4rJvA

Example from mutt: https://developer.paypal.com/devscr?cmd=3D_signup-el&ac=3DKiXOj6ebBnR5sJZhj=
xP1NKTMTbq6pyy7COF6tQRj-BkZjbnAvkAjAwLMiTalSVT94OmHniMPIMI9Iw

Note the "3D" after each of the (real) '=' signs. I have no idea what character PayPal's text-email generator thinks they are supposed to represent - or why Evolution seems to gloss over them, but removing them makes it all work.

Tuesday, 12 December 2006

So I finally ditched dry_scaffold after a few too many annoying little things. There's apparently a new version coming out that fixes a lot of these minor annoyances... but it's not stable enough to use just yet - and my life is moving on without it.

The most annoying to me were:
1) Not allowing me to use apostrophes in generated form fields. It didn't just escape them out before saving. It silently removed them from your field as you typed it. :P
2) No proper support for modules. This becomes annoying when most of your sites have both a publically-accessible view of your Thingies and an Admin::ThingyController to do your thingy CRUD. dry_scaffold would look at this and expect your model to be kept in app/models/admin/thingy.rb, so you'd have to have a copy in your base model directory and a symlink in that directory if you wanted to have just one model file for two controllers to access... not exactly DRY in my book.

Tuesday, 5 December 2006

Moist file upload

Cool, so I just figured out how to integrate file-upload with moist scaffold. If you can already do this while standing on your head - well, why are you reading my blog? ;) Otherwise, here are the basic steps:

Generate a moist scaffold

This can be done as per my previous post. You have to generate it using less_dry so that you can extend the create/update actions in the controller. Also - make sure your model has a string column to hold the filename - I'll assume that this is called "thumbnail" from now on.

Configure the column

In your model file you need to update the filename-column's has_column details to something similar to this:

  has_column "thumbnail",{
    :in_list => true,
    :sortable => false,
    :filterable => false,
    :type => :custom
  }

The important bit being being the :type => :custom. This tells dry_scaffold to go look in the helper for methods that generate the edit-field and list-display. If we were to filter on this column, we could also specify a filter-function, but I haven't done this. I've turned off filtering and sorting for this column - though I could have done a filter/sort on the filename.

Put list/edit methods into the helper

module ThingyHelper
    def thumbnail_edit(one_row, column)
        file_field "thingy", "thumbfile"
    end
    def thumbnail_list(one_row)
        image_tag "/images/thumbnails/#{one_row.thumbnail}", :size => "64x64"
    end
end

These are the methods I mentioned above. The edit method creates a file upload field that is named *differently* to the column that will store the eventual URL. If you want to store the whole image file into the db - go ahead, but I figured it'd be nicer to put them into an images directory.

The list method just displays the file squished into 64x64. It'd be nicer to work some RMagick, but I didn't bother for this example. Note: the reference to one_row is a hack - this is how dry_scaffold refers to the current row of the list. To access other values out of the row, you have to use it - but it seems brittle to me.

Update controller+model to manipulate image

When the user does a browse/upload on a file - it passes the StringIO object through to the controller. This file needs to be saved into the images directory - and just the URL put into the db.

Other sites have covered this already (in a variety of forms): read the rails article here (you may need to go back to a non-spam version). Pick a favourite way and you're done.

Monday, 4 December 2006

Moist scaffold

I've just discovered dry_scaffold and it's lots of fun. It does exactly what a scaffold was originally intended for: ie to hold the basic shape of the CRUD bits of a rails application while you get around to replacing the bits that need replacing.

This is as opposed to the rails-standard script/generate scaffold, which generates tons of files that you may not be ready to (or may not ever) change. IMO the standard scaffold-generator is less like a scaffold, and more like a rough-shaped mud-hut slapped quickly together that you can modify.

Unfortunately, if you need more than one of these, you get several nearly-identical rough mud-huts piled randomly about the place. They each begin with their own complete set of infrastructure which you can (try) to modify to be more DRY, but tends to end up with some residual wetness that is just really hard to get rid of without a lot of effort.

By contrast, dry_scaffold adds new model objects like storeys in a high-rise (with shared ventilation and lifts and... ok, I'm going too far now). The basic infrastructure is shared because it's all contained in the engine. Much DRYer.

All this being said, it's still quite new and so has its issues. The main one that I see is the spotty documentation. So here's a rough guide for where to go looking:

  • To get the basic dry_scaffold up and running, use the standard dry_scaffold page, but use your own model (obviously) and ignore where it says to update layouts/admin.rhtml.
  • If you need to only slightly adjust how the fields are added/listed or filtered, you have a range of options available to you. The data are stored in your model object as a set of columns with configuration options. Check out the has_column rDoc to see all the options available. The rDoc is available here, and has_column is listed in the frame at top-right.
  • If you need to do some serious readjustment of the code, or plan on using dry_scaffold simply as the stop-gap while you replace the structure, then you really need a "moist" scaffold. You will need to run the generate command with the following form: script/generate dry_scaffold ModelName ControllerName less_dry. This will generate a minimal controller that allows you to override/extend any actions you need; while continuing to be extremely slim-line. AFAIK there is no documentation on this, but from general mucking about it seems straight-forward.
  • If you have more questions, there is a forum available here.

Sunday, 3 December 2006

Kill the ugly duckling!

For years, now, I've had a "tradesman's website"... you know, how the tradesman comes home and doesn't want to do *more* work, so they let their own house go. That's what my website has been like now for a while. I've suffered brief bouts of inspiration, followed by a flurry of new stuff - only to get caught up in what I was doing at work and not want to do any web-development once I got home :P

But that's gotta change - and the old styling is really not cutting it for me. So the first thing I've done is to get some graphic desgin done... I'll be getting the first look at the result on Monday and have been really looking forward to it!

I've never had to brand myself before, and that's essentially what I'm doing. I've worked with branding for products, companies and services, events and concepts - but never for myself. I had a chance to chat about what I like, how I see myself being portrayed and even a few of my favourite hobbies (eg calligraphy) and now I'm really looking forward to the results.