Get Off My Lawn

Adventures of a Curmudgeon

Personal Project Continued

I’ve started to put some of the technology pieces together, but I’m still, very much in a prototype-, spike-mode. Per usual, I’m kind of stuck on the visuals for the website. I know what I want; I’m just not sure how to get there from here.

InK - Interface Kit

I don’t remember where/when I found it, but I’m going to be using InK for my presentation layer. It includes a lot of nice things out-of-the-box, but the main one is the “responsive” design.

And while it does Grids differently, possibly easier and more straight forward, I think my presentation is at most two columns. The initial iterations will only use a single column.

I probably need a UX/Data design person to help me layout all of the information I plan on presenting; it’s going to be dense. While there’s a lot of data to present I don”t want the UI to feel cluttered.

Soldier Images

Naturally, since this website/application is going to be focused on Battlefield3, I’m in need of some military-type images.

I have found some I plan on using; I also want to select one for the site’s background. However, from a suggestion, I was able to find quite a few interesting pictures on DeviantArt.

Padrino

Ok, the interesting bits; sadly I haven’t dug too deep yet into padrino and the functionality is brings to the project. I’ve generated my skeleton application. I’ve read the docs. I even implemented a PagesController:

app/controller/pages.rb
1
2
3
4
5
6
7
8
9
10
11
Bf3Squad.controllers :pages do

  get :index, :map => '/' do
    render 'pages/home'
  end

  get :show, :map => '/pages/:id' do
    render "pages/#{params[:id].to_s.downcase}"
  end

end

I’m using Sequel as my ORM. The connection configuration was new:

config/database.rb
1
2
3
4
5
6
7
Sequel::Model.plugin(:schema)
Sequel::Model.raise_on_save_failure = false # Do not throw exceptions on failure
Sequel::Model.db = case Padrino.env
  when :development then Sequel.connect("postgres://bf3squad:bf3quad@localhost:5432/bf3_squad_development", :loggers => [logger])
  when :production  then Sequel.connect("postgres://bf3squad:bf3quad@localhost:5432/bf3_squad_development", :loggers => [logger])
  when :test        then Sequel.connect("postgres://bf3squad:bf3quad@localhost:5432/bf3_squad_test",        :loggers => [logger])
end

I had to create a PostgreSQL Login Role, password protected, of course. I had to manually add that to the connection information. And, while I didn’t try without, I did add the port information to the connection string.

Sequel also implements migrations:

db/migrate/001_create_players.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Sequel.migration do
  up do
    create_table :players do
      primary_key :id
      String :platform
      String :name
      Text :data
      index [:platform, :name], :name => 'index_players_on_bf3stats_key'
    end
  end

  down do
    drop_table :players
  end
end
models/player.rb
1
2
3
class Player < Sequel::Model

end

If you’ve used ActiveRecord then nothing should jump out at you, just the syntactical differences. And I’m not sure how I feel about the (apparent) sequential numbering of migrations.

And the Model doesn’t implement any behavior over and above what Sequel provides. Padrino also allows you to put your models in several different locations, depending on your needs. It seems this models directory allows models to be shared across implemented, mounted applications.

There are several different files that got generated but I’m not listing them here because I haven’t changed them.

Here are the Specs that got generated when I generated my controller and model:

spec/app/controllers/pages_controller_spec.rb
1
2
3
4
5
6
7
8
9
10
11
require 'spec_helper'

describe "PagesController" do
  before do
    get "/"
  end

  it "returns hello world" do
    last_response.body.should =~ /Hello World/
  end
end
spec/models/player_spec.rb
1
2
3
4
5
6
7
8
require 'spec_helper'

describe "Player Model" do
  let(:player) { Player.new }
  it 'can be created' do
    player.should_not be_nil
  end
end

Again, very vanilla because I haven’t added any extra behavior. One note, though, I did change the controller spec from == "Hello World" to =~ /Hello World/ because I started to implement my InK-inspired layout.

Up Next

I have quite a few things to do before I can create Version 0.0.0. I still need to implement the mechanism to call the BF3 Stats API. I need to learn more about Sequel in order to know what can and can’t be done via the ORM. I need to implement authentication; I’m leaning towards OmniAuth Identity and support for Twitter, Facebook, and Google+ OAuth.

I guess I should develop some kind of Product Road Map; would probably help me stay on task.

Cheers

Comments