diff --git a/app/helpers/asciicasts_helper.rb b/app/helpers/asciicasts_helper.rb index 4e0fdd8..1ad0ddd 100644 --- a/app/helpers/asciicasts_helper.rb +++ b/app/helpers/asciicasts_helper.rb @@ -19,6 +19,12 @@ module AsciicastsHelper end link_to img + "~#{asciicast.user.nickname}", profile_path(asciicast.user) + else + if asciicast.username.present? + "~#{asciicast.username}" + else + "anonymous" + end end end diff --git a/app/models/asciicast.rb b/app/models/asciicast.rb index 3621b3d..43809fe 100644 --- a/app/models/asciicast.rb +++ b/app/models/asciicast.rb @@ -24,6 +24,7 @@ class Asciicast < ActiveRecord::Base def meta=(file) data = JSON.parse(file.tempfile.read) + self.username = data['username'] self.user_token = data['user_token'] self.duration = data['duration'] self.recorded_at = data['recorded_at'] diff --git a/db/migrate/20120403165915_add_username_to_asciicast.rb b/db/migrate/20120403165915_add_username_to_asciicast.rb new file mode 100644 index 0000000..27afaf5 --- /dev/null +++ b/db/migrate/20120403165915_add_username_to_asciicast.rb @@ -0,0 +1,5 @@ +class AddUsernameToAsciicast < ActiveRecord::Migration + def change + add_column :asciicasts, :username, :string + end +end diff --git a/db/schema.rb b/db/schema.rb index 8c4c465..42b392a 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 20120311142204) do +ActiveRecord::Schema.define(:version => 20120403165915) do create_table "asciicasts", :force => true do |t| t.integer "user_id" @@ -33,6 +33,7 @@ ActiveRecord::Schema.define(:version => 20120311142204) do t.string "user_token" t.text "description" t.boolean "featured", :default => false + t.string "username" end add_index "asciicasts", ["created_at"], :name => "index_asciicasts_on_created_at"