Added post anchors and show post.
when a new post is created, the page is now scrolled to is via its anchor created a show post route, and view. added a post number to post view, with link. need to change displayed post number from post id, to reply #
This commit is contained in:
@@ -1,4 +1,7 @@
|
|||||||
class ApplicationController < ActionController::Base
|
class ApplicationController < ActionController::Base
|
||||||
|
|
||||||
|
helper :all
|
||||||
|
|
||||||
protect_from_forgery
|
protect_from_forgery
|
||||||
|
|
||||||
rescue_from CanCan::AccessDenied do |exception|
|
rescue_from CanCan::AccessDenied do |exception|
|
||||||
|
|||||||
@@ -1,9 +1,17 @@
|
|||||||
class PostsController < ApplicationController
|
class PostsController < ApplicationController
|
||||||
|
|
||||||
|
include ApplicationHelper
|
||||||
|
|
||||||
load_and_authorize_resource :topic
|
load_and_authorize_resource :topic
|
||||||
load_and_authorize_resource :post, :through => :topic, :shallow => true
|
load_and_authorize_resource :post, :through => :topic, :shallow => true
|
||||||
|
|
||||||
before_filter :check_for_cancel#, :only[:create, :update]
|
before_filter :check_for_cancel#, :only[:create, :update]
|
||||||
|
|
||||||
|
def show
|
||||||
|
@topic = @post.topic
|
||||||
|
@my_blockquote = block_quote
|
||||||
|
end
|
||||||
|
|
||||||
def new
|
def new
|
||||||
if params[:quote]
|
if params[:quote]
|
||||||
quote_post = Post.find(params[:quote])
|
quote_post = Post.find(params[:quote])
|
||||||
@@ -18,7 +26,7 @@ class PostsController < ApplicationController
|
|||||||
@post.user ||= current_user
|
@post.user ||= current_user
|
||||||
if @post.save
|
if @post.save
|
||||||
flash[:notice] = "Post was successfully created."
|
flash[:notice] = "Post was successfully created."
|
||||||
redirect_to topic_path(@post.topic, :page => @post.topic.posts.page.per(10).num_pages)
|
redirect_to topic_path(@post.topic, :page => @post.topic.posts.page.per(10).num_pages, :anchor => @post.id)
|
||||||
else
|
else
|
||||||
render :action => 'new'
|
render :action => 'new'
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,7 @@
|
|||||||
class TopicsController < ApplicationController
|
class TopicsController < ApplicationController
|
||||||
|
|
||||||
|
include ApplicationHelper
|
||||||
|
|
||||||
load_and_authorize_resource :forum
|
load_and_authorize_resource :forum
|
||||||
load_and_authorize_resource :topic, :through => :forum, :shallow => true
|
load_and_authorize_resource :topic, :through => :forum, :shallow => true
|
||||||
|
|
||||||
@@ -9,15 +12,7 @@ class TopicsController < ApplicationController
|
|||||||
|
|
||||||
@posts = @topic.posts.page(params[:page]).per(10)
|
@posts = @topic.posts.page(params[:page]).per(10)
|
||||||
|
|
||||||
@my_blockquote = {
|
@my_blockquote = block_quote
|
||||||
'Quote' => [
|
|
||||||
/\[quote(:.*)?=(.*?)\](.*?)\[\/quote\1?\]/mi,
|
|
||||||
'<blockquote><cite>\2</cite><span class="a">“</span>\3<span class="b">”</span></blockquote>',
|
|
||||||
'Quote with citation',
|
|
||||||
'[quote=mike]please quote me[/quote]',
|
|
||||||
:quote
|
|
||||||
],
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def create
|
def create
|
||||||
|
|||||||
@@ -5,4 +5,16 @@ module ApplicationHelper
|
|||||||
:confirm => 'Are you sure? Any changes will be lost.'
|
:confirm => 'Are you sure? Any changes will be lost.'
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def block_quote
|
||||||
|
return {
|
||||||
|
'Quote' => [
|
||||||
|
/\[quote(:.*)?=(.*?)\](.*?)\[\/quote\1?\]/mi,
|
||||||
|
'<blockquote><cite>\2</cite><span class="a">“</span>\3<span class="b">”</span></blockquote>',
|
||||||
|
'Quote with citation',
|
||||||
|
'[quote=mike]please quote me[/quote]',
|
||||||
|
:quote
|
||||||
|
],
|
||||||
|
}
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -15,6 +15,7 @@
|
|||||||
<% if !post.user.blank? %>
|
<% if !post.user.blank? %>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="post_author" rowspan="2">
|
<td class="post_author" rowspan="2">
|
||||||
|
<a name="<%= post.id %>"> <%= link_to ("#"+ post.id.to_s ), post %> </a>
|
||||||
<span class="name"><%= post.user.username %></span>
|
<span class="name"><%= post.user.username %></span>
|
||||||
<span class="avatar"><%= image_tag post.user.gravatar_url %></span>
|
<span class="avatar"><%= image_tag post.user.gravatar_url %></span>
|
||||||
<span class="info smaller">
|
<span class="info smaller">
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ Community::Application.routes.draw do
|
|||||||
root :to => 'categories#index', :via => :get
|
root :to => 'categories#index', :via => :get
|
||||||
end
|
end
|
||||||
|
|
||||||
|
resources :posts, :only => :show
|
||||||
|
|
||||||
devise_for :users, :controllers => {:registrations => "registrations"}
|
devise_for :users, :controllers => {:registrations => "registrations"}
|
||||||
|
|
||||||
scope "/admin" do
|
scope "/admin" do
|
||||||
|
|||||||
Reference in New Issue
Block a user