Profile paths: ~sickill

openid
Marcin Kulik 12 years ago
parent 35af4cf9e7
commit 51dfa8474f

@ -1,10 +1,10 @@
<div class="left">
<a href="#"><img src="{{user.avatar_url}}" alt="{{user.nickanme}}" class="avatar" /></a>
<a href="{{profile_path}}"><img src="{{user.avatar_url}}" alt="{{user.nickanme}}" class="avatar" /></a>
</div>
<div class="right">
<div>
<span class="user-name">{{user.nickname}}</span>
<a href="{{profile_path}}"><span class="user-name">{{user.nickname}}</span></a>
<span class="when">{{created}}</span>
</div>
<div class="body">{{body}}</div>

@ -11,9 +11,12 @@ class AsciiIo.Views.CommentEntry extends AsciiIo.Views.Base
@collection = options.collection
render: ->
context = _.extend( @model.toJSON(), {
show_remove_link: @showRemoveLink(),
created: @timeAgo() } )
extra =
show_remove_link: @showRemoveLink()
created: @timeAgo()
profile_path: "/~#{@model.get('user').nickname}"
context = _.extend(@model.toJSON(), extra)
$(@el).html @template(context)
this

@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/

@ -0,0 +1,3 @@
// Place all the styles related to the users controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/

@ -0,0 +1,9 @@
class UsersController < ApplicationController
PER_PAGE = 20
def show
@user = User.find_by_nickname(params[:nickname])
@asciicasts =
@user.asciicasts.order("created_at DESC").page(params[:page]).per(PER_PAGE)
end
end

@ -12,7 +12,8 @@ module AsciicastsHelper
def asciicast_author(asciicast)
if asciicast.user
link_to avatar_img(asciicast.user) + " #{asciicast.user.nickname}", '#'
link_to avatar_img(asciicast.user) + " #{asciicast.user.nickname}",
profile_path(asciicast.user)
end
end

@ -0,0 +1,2 @@
module UsersHelper
end

@ -4,7 +4,8 @@ class User < ActiveRecord::Base
validate :uid, :presence => true
validate :nickname, :presence => true
has_many :user_tokens
has_many :user_tokens, :dependent => :destroy
has_many :asciicasts, :dependent => :destroy
def self.create_with_omniauth(auth)
create! do |user|
@ -16,6 +17,10 @@ class User < ActiveRecord::Base
end
end
def to_param
nickname
end
def add_user_token(token)
user_tokens.find_or_create_by_token(token)
end

@ -1,7 +1,7 @@
<ul id="session-info">
<% if current_user %>
<li>
<%= avatar_img current_user %>
<%= link_to avatar_img(current_user), profile_path(current_user) %>
<%= link_to "Log out", logout_path, :class => "logout" %>
</li>
<% else %>

@ -0,0 +1,14 @@
<div class="user-info">
<p>
<%= avatar_img(@user) %> <%= @user.nickname %>
</p>
<p>
<%= @user.asciicasts.count %> asciicasts
</p>
</div>
<ul class="asciicasts">
<%= render :partial => "asciicasts/preview", :collection => @asciicasts, :as => :asciicast %>
</ul>
<%= paginate @asciicasts %>

@ -2,13 +2,7 @@ AsciiIo::Application.routes.draw do
resources :asciicasts, :path => 'a'
namespace :api do
resources :comments
resources :asciicasts do
resources :comments
end
end
match '/~:nickname' => "users#show", :as => :profile
match "/installation" => "static_pages#show", :page => 'installation'
@ -20,5 +14,13 @@ AsciiIo::Application.routes.draw do
match "/connect/:user_token" => "user_tokens#create"
namespace :api do
resources :comments
resources :asciicasts do
resources :comments
end
end
root :to => 'home#show'
end

@ -0,0 +1,5 @@
require 'spec_helper'
describe UsersController do
end

@ -0,0 +1,15 @@
require 'spec_helper'
# Specs in this file have access to a helper object that includes
# the UsersHelper. For example:
#
# describe UsersHelper do
# describe "string concat" do
# it "concats two strings with spaces" do
# helper.concat_strings("this","that").should == "this that"
# end
# end
# end
describe UsersHelper do
pending "add some examples to (or delete) #{__FILE__}"
end
Loading…
Cancel
Save