diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb
index 25edeccc2..baecafd1a 100644
--- a/app/controllers/posts_controller.rb
+++ b/app/controllers/posts_controller.rb
@@ -8,29 +8,6 @@ class PostsController < ApplicationController
skip_before_filter :which_action_and_user
skip_before_filter :set_grammatical_gender
- def index
- if current_user
- @posts = StatusMessage.joins(:aspects).where(:pending => false
- ).where(Aspect.arel_table[:user_id].eq(current_user.id).or(StatusMessage.arel_table[:public].eq(true))
- ).select('DISTINCT `posts`.*')
- else
- @posts = StatusMessage.where(:public => true, :pending => false)
- end
-
- params[:tag] ||= 'partytimeexcellent'
-
- @posts = @posts.tagged_with(params[:tag])
- @posts = @posts.includes(:comments, :photos).paginate(:page => params[:page], :per_page => 15, :order => 'created_at DESC')
-
- profiles = Profile.tagged_with(params[:tag]).where(:searchable => true).select('profiles.id, profiles.person_id')
- @people = Person.where(:id => profiles.map{|p| p.person_id}).limit(15)
- @people_count = Person.where(:id => profiles.map{|p| p.person_id}).count
-
- @fakes = PostsFake.new(@posts)
- @commenting_disabled = true
- @pod_url = AppConfig[:pod_uri].host
- end
-
def show
@post = Post.where(:id => params[:id], :public => true).includes(:author, :comments => :author).first
diff --git a/app/controllers/tags_controller.rb b/app/controllers/tags_controller.rb
new file mode 100644
index 000000000..8df259e1d
--- /dev/null
+++ b/app/controllers/tags_controller.rb
@@ -0,0 +1,30 @@
+# Copyright (c) 2010, Diaspora Inc. This file is
+# licensed under the Affero General Public License version 3 or later. See
+# the COPYRIGHT file.
+
+class TagsController < ApplicationController
+ skip_before_filter :count_requests
+ skip_before_filter :set_invites
+ skip_before_filter :which_action_and_user
+ skip_before_filter :set_grammatical_gender
+
+ def show
+ if current_user
+ @posts = StatusMessage.joins(:aspects).where(:pending => false
+ ).where(Aspect.arel_table[:user_id].eq(current_user.id).or(StatusMessage.arel_table[:public].eq(true))
+ ).select('DISTINCT `posts`.*')
+ else
+ @posts = StatusMessage.where(:public => true, :pending => false)
+ end
+
+ @posts = @posts.tagged_with(params[:name])
+ @posts = @posts.includes(:comments, :photos).paginate(:page => params[:page], :per_page => 15, :order => 'created_at DESC')
+
+ profiles = Profile.tagged_with(params[:name]).where(:searchable => true).select('profiles.id, profiles.person_id')
+ @people = Person.where(:id => profiles.map{|p| p.person_id}).limit(15)
+ @people_count = Person.where(:id => profiles.map{|p| p.person_id}).count
+
+ @fakes = PostsFake.new(@posts)
+ @commenting_disabled = true
+ end
+end
diff --git a/app/views/posts/index.html.haml b/app/views/tags/show.html.haml
similarity index 87%
rename from app/views/posts/index.html.haml
rename to app/views/tags/show.html.haml
index a2ac65a90..c2749bf5b 100644
--- a/app/views/posts/index.html.haml
+++ b/app/views/tags/show.html.haml
@@ -4,8 +4,8 @@
- content_for :page_title do
- - if params[:tag]
- = "##{params[:tag]}"
+ - if params[:name]
+ = "##{params[:name]}"
- else
= t('.whatup', :pod => @pod_url)
@@ -15,7 +15,7 @@
.span-24.last
%h1.tag
- = "##{params[:tag]}"
+ = "##{params[:name]}"
.span-15
#main_stream.stream
@@ -24,7 +24,7 @@
%a.paginate
= t("more")
- else
- = t('.nobody_talking', :tag => "##{params[:tag]}")
+ = t('.nobody_talking', :tag => "##{params[:name]}")
= will_paginate @posts
.prepend-2.span-7.last
diff --git a/config/locales/diaspora/en.yml b/config/locales/diaspora/en.yml
index 0d7ef4c32..8c10aaeba 100644
--- a/config/locales/diaspora/en.yml
+++ b/config/locales/diaspora/en.yml
@@ -405,8 +405,9 @@ en:
posts:
doesnt_exist: "that post does not exist!"
- index:
- whatup: "What's happening on %{pod}"
+
+ tags:
+ show:
posts_tagged_with: "Posts tagged with #%{tag}"
nobody_talking: "Nobody is talking about %{tag} yet."
people_tagged_with: "People tagged with %{tag}"
diff --git a/config/routes.rb b/config/routes.rb
index 7efea6eb3..ad70d3e23 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -3,12 +3,13 @@
# the COPYRIGHT file.
Diaspora::Application.routes.draw do
-
-
resources :status_messages, :only => [:new, :create, :destroy, :show]
resources :comments, :only => [:create]
resources :requests, :only => [:destroy, :create]
+ match 'tags/:name' => 'tags#show'
+ resources :tags, :only => [:show]
+
resource :profile
match 'services/inviter/:provider' => 'services#inviter', :as => 'service_inviter'
match 'services/finder/:provider' => 'services#finder', :as => 'friend_finder'
@@ -19,7 +20,7 @@ Diaspora::Application.routes.draw do
match 'notifications/read_all' => 'notifications#read_all'
resources :notifications, :only => [:index, :update]
- resources :posts, :only => [:show, :index], :path => '/p/'
+ resources :posts, :only => [:show], :path => '/p/'
resources :contacts
resources :aspect_memberships, :only => [:destroy, :create]
diff --git a/lib/diaspora/taggable.rb b/lib/diaspora/taggable.rb
index 999da53be..9704681ed 100644
--- a/lib/diaspora/taggable.rb
+++ b/lib/diaspora/taggable.rb
@@ -38,7 +38,7 @@ module Diaspora
return text if opts[:plain_text]
regex = /(^|\s)#(\w+)/
form_message = text.gsub(regex) do |matched_string|
- "#{$~[1]}##{$~[2]}"
+ "#{$~[1]}##{$~[2]}"
end
form_message.html_safe
end
diff --git a/spec/controllers/posts_controller_spec.rb b/spec/controllers/posts_controller_spec.rb
index 41d558880..4479070a1 100644
--- a/spec/controllers/posts_controller_spec.rb
+++ b/spec/controllers/posts_controller_spec.rb
@@ -10,70 +10,6 @@ describe PostsController do
before do
@user = alice
end
- describe '#index' do
- context 'signed in' do
- before do
- sign_in :user, @user
- end
- it 'works' do
- get :index
- response.status.should == 200
- end
- it "shows the signed in user's posts" do
- pending
- posts = []
- 2.times do
- posts << @user.post(:status_message, :text => "#what", :to => 'all')
- end
- eve.post(:status_message, :text => "#what", :to => 'all')
-
- get :index
- assigns[:posts].should =~ posts
- end
- it "shows any posts that the user can see" do
- pending
- posts = []
- 2.times do
- posts << bob.post(:status_message, :text => "#what", :to => 'all')
- end
- eve.post(:status_message, :text => "#what", :to => 'all')
-
- get :index
- assigns[:posts].should =~ posts
- end
- end
- it 'restricts the posts by tag' do
- posts = []
- 2.times do
- posts << @user.post(:status_message, :text => "#what", :public => true, :to => 'all')
- end
- 2.times do
- @user.post(:status_message, :text => "#hello", :public => true, :to => 'all')
- end
-
- get :index, :tag => 'what'
- assigns[:posts].should =~ posts
-
- end
- it 'shows the most recent public posts' do
- pending
- posts = []
- 3.times do
- posts << @user.post(:status_message, :text => "hello", :public => true, :to => 'all')
- end
- get :index
- assigns[:posts].should =~ posts
- end
- it' shows only local posts' do
- pending
- 3.times do
- @user.post(:status_message, :text => "hello", :public => true, :to => 'all')
- end
- @user.person.update_attributes(:owner_id => nil)
- get :index
- assigns[:posts].should == []
- end
- end
describe '#show' do
it 'shows a public post' do
status = @user.post(:status_message, :text => "hello", :public => true, :to => 'all')
diff --git a/spec/controllers/tags_controller_spec.rb b/spec/controllers/tags_controller_spec.rb
new file mode 100644
index 000000000..93290d0ed
--- /dev/null
+++ b/spec/controllers/tags_controller_spec.rb
@@ -0,0 +1,37 @@
+# Copyright (c) 2010, Diaspora Inc. This file is
+# licensed under the Affero General Public License version 3 or later. See
+# the COPYRIGHT file.
+
+require 'spec_helper'
+
+describe TagsController do
+ render_views
+
+ before do
+ @user = alice
+ end
+ describe '#show' do
+ context 'signed in' do
+ before do
+ sign_in :user, @user
+ end
+ it 'works' do
+ get :show, :name => 'testing'
+ response.status.should == 200
+ end
+ end
+
+ it 'restricts the posts by tag' do
+ posts = []
+ 2.times do
+ posts << @user.post(:status_message, :text => "#what", :public => true, :to => 'all')
+ end
+ 2.times do
+ @user.post(:status_message, :text => "#hello", :public => true, :to => 'all')
+ end
+
+ get :show, :name => 'what'
+ assigns[:posts].should =~ posts
+ end
+ end
+end
diff --git a/spec/shared_behaviors/taggable.rb b/spec/shared_behaviors/taggable.rb
index c1b48a9b1..b408e14d8 100644
--- a/spec/shared_behaviors/taggable.rb
+++ b/spec/shared_behaviors/taggable.rb
@@ -19,7 +19,7 @@ describe Diaspora::Taggable do
@object.save!
end
it 'links the tag to /p' do
- link = link_to('#what', posts_path(:tag => 'what'), :class => 'tag')
+ link = link_to('#what', '/tags/what', :class => 'tag')
@object.format_tags(@str).should include(link)
end
it 'responds to plain_text' do