make forum post quoting regexp nongreedy
This commit is contained in:
@@ -9,9 +9,19 @@ class ApplicationController < ActionController::Base
|
||||
layout "default"
|
||||
|
||||
rescue_from User::PrivilegeError, :with => :access_denied
|
||||
rescue_from Danbooru::Paginator::PaginationError, :with => :render_pagination_limit
|
||||
|
||||
protected
|
||||
|
||||
def rescue_exception(exception)
|
||||
@exception = exception
|
||||
render :action => "static/error", :status => 500
|
||||
end
|
||||
|
||||
def render_pagination_limit
|
||||
@error_message = "You can view up to 1,000 pages. Please narrow your search terms."
|
||||
render :action => "static/error", :status => 410
|
||||
end
|
||||
|
||||
def access_denied
|
||||
previous_url = params[:url] || request.fullpath
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
class LegacyController < ApplicationController
|
||||
before_filter :member_only, :only => [:create_post]
|
||||
rescue_from PostSets::SearchError, :with => :error
|
||||
|
||||
def posts
|
||||
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit])
|
||||
@@ -30,6 +31,9 @@ class LegacyController < ApplicationController
|
||||
def unavailable
|
||||
render :text => "this resource is no longer available", :status => 410
|
||||
end
|
||||
|
||||
def error
|
||||
end
|
||||
|
||||
private
|
||||
def tag_query
|
||||
|
||||
@@ -2,9 +2,8 @@ class PostsController < ApplicationController
|
||||
before_filter :member_only, :except => [:show, :index]
|
||||
after_filter :save_recent_tags, :only => [:update]
|
||||
respond_to :html, :xml, :json
|
||||
rescue_from PostSets::SearchError, :with => :search_error
|
||||
rescue_from Post::SearchError, :with => :search_error
|
||||
rescue_from Danbooru::Paginator::PaginationError, :with => :search_error
|
||||
rescue_from PostSets::SearchError, :with => :rescue_exception
|
||||
rescue_from Post::SearchError, :with => :rescue_exception
|
||||
|
||||
def index
|
||||
@post_set = PostSets::Post.new(tag_query, params[:page], params[:limit])
|
||||
@@ -55,16 +54,8 @@ class PostsController < ApplicationController
|
||||
format.js
|
||||
end
|
||||
end
|
||||
|
||||
def error
|
||||
end
|
||||
|
||||
private
|
||||
def search_error(exception)
|
||||
@exception = exception
|
||||
render :action => "error"
|
||||
end
|
||||
|
||||
def tag_query
|
||||
params[:tags] || (params[:post] && params[:post][:tags])
|
||||
end
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class UploadsController < ApplicationController
|
||||
before_filter :member_only
|
||||
respond_to :html, :xml, :json, :js
|
||||
rescue_from Upload::Error, :with => :rescue_exception
|
||||
|
||||
def new
|
||||
@upload = Upload.new(:rating => "q")
|
||||
|
||||
@@ -38,7 +38,7 @@ class Cache
|
||||
def self.get(key, expiry = 0)
|
||||
begin
|
||||
start_time = Time.now
|
||||
value = MEMCACHE.get key
|
||||
value = MEMCACHE.get key.slice(0, 200)
|
||||
elapsed = Time.now - start_time
|
||||
ActiveRecord::Base.logger.debug('MemCache Get (%0.6f) %s' % [elapsed, key])
|
||||
if value.nil? and block_given? then
|
||||
|
||||
@@ -110,7 +110,7 @@ class ForumPost < ActiveRecord::Base
|
||||
end
|
||||
|
||||
def quoted_response
|
||||
stripped_body = body.gsub(/\[quote\](?:.|\n|\r)+\[\/quote\][\n\r]*/m, "")
|
||||
stripped_body = body.gsub(/\[quote\](?:.|\n|\r)+?\[\/quote\][\n\r]*/m, "")
|
||||
"[quote]\n#{creator_name} said:\n\n#{stripped_body}\n[/quote]\n\n"
|
||||
end
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ class Upload < ActiveRecord::Base
|
||||
module ValidationMethods
|
||||
def uploader_is_not_limited
|
||||
if !uploader.can_upload?
|
||||
raise "uploader has reached their daily limit"
|
||||
raise Error.new("uploader has reached their daily limit")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
<%= note_version.updater_ip_addr %>
|
||||
<% end %>
|
||||
</td>
|
||||
<td><%= link_to note_version.updater.name, user_path(note_version.updater) %></td>
|
||||
<td><%= link_to note_version.updater.try(:name), user_path(note_version.updater) %></td>
|
||||
<td><%= compact_time note_version.updated_at %></td>
|
||||
<td>
|
||||
<% if CurrentUser.is_member? %>
|
||||
|
||||
@@ -198,13 +198,16 @@ Danbooru::Application.routes.draw do
|
||||
match "/artist" => redirect {|params, req| "/artists?page=#{req.params[:page]}"}
|
||||
match "/artist/index" => redirect {|params, req| "/artists?page=#{req.params[:page]}"}
|
||||
match "/artist/show/:id" => redirect("/artists/%{id}")
|
||||
match "/artist/show" => redirect {|params, req| "/artists?name=#{req.params[:name]}"}
|
||||
match "/artist/show" => redirect {|params, req| "/artists?name=#{CGI::escape(req.params[:name])}"}
|
||||
match "/artist/history/:id" => redirect("/artist_versions?search[artist_id]=%{id}")
|
||||
match "/artist/update/:id" => redirect("/artists/%{id}")
|
||||
match "/artist/recent_changes" => redirect("/artist_versions")
|
||||
|
||||
match "/comment" => redirect {|params, req| "/comments?page=#{req.params[:page]}"}
|
||||
match "/comment/index" => redirect {|params, req| "/comments?page=#{req.params[:page]}"}
|
||||
match "/comment/show/:id" => redirect("/comments/%{id}")
|
||||
match "/comment/new" => redirect("/comments")
|
||||
match "/comment/search" => redirect("/comments/search")
|
||||
|
||||
match "/favorite" => redirect {|params, req| "/favorites?page=#{req.params[:page]}"}
|
||||
match "/favorite/index" => redirect {|params, req| "/favorites?page=#{req.params[:page]}"}
|
||||
@@ -214,6 +217,7 @@ Danbooru::Application.routes.draw do
|
||||
match "/forum/index" => redirect {|params, req| "/forum_topics?page=#{req.params[:page]}"}
|
||||
match "/forum/show/:id" => redirect("/forum_posts/%{id}")
|
||||
match "/forum/search" => redirect("/forum_posts/search")
|
||||
match "/forum/new" => redirect("/forum_posts/new")
|
||||
match "/forum/edit/:id" => redirect("/forum_posts/%{id}/edit")
|
||||
|
||||
match "/note" => redirect {|params, req| "/notes?page=#{req.params[:page]}"}
|
||||
@@ -243,6 +247,7 @@ Danbooru::Application.routes.draw do
|
||||
match "/post/show/:id" => redirect("/posts/%{id}")
|
||||
match "/post/view/:id/:tag_title" => redirect("/posts/%{id}")
|
||||
match "/post/view/:id" => redirect("/posts/%{id}")
|
||||
match "/post/flag/:id" => redirect("/posts/%{id}")
|
||||
|
||||
match "/post_tag_history" => redirect {|params, req| "/post_versions?page=#{req.params[:page]}"}
|
||||
match "/post_tag_history/index" => redirect {|params, req| "/post_versions?page=#{req.params[:page]}"}
|
||||
@@ -261,6 +266,8 @@ Danbooru::Application.routes.draw do
|
||||
|
||||
match "/wiki" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"}
|
||||
match "/wiki/index" => redirect {|params, req| "/wiki_pages?page=#{req.params[:page]}"}
|
||||
match "/wiki/revert" => redirect("/wiki_pages")
|
||||
match "/wiki/rename" => redirect("/wiki_pages")
|
||||
match "/wiki/show" => redirect {|params, req| "/wiki_pages?title=#{CGI::escape(req.params[:title].to_s)}"}
|
||||
match "/wiki/recent_changes" => redirect("/wiki_page_versions")
|
||||
match "/wiki/history/:title" => redirect("/wiki_page_versions?title=%{title}")
|
||||
|
||||
@@ -59,7 +59,11 @@ module Danbooru
|
||||
|
||||
limit(records_per_page).offset((page - 1) * records_per_page).tap do |obj|
|
||||
obj.extend(NumberedCollectionExtension)
|
||||
obj.total_pages = (obj.total_count.to_f / records_per_page).ceil
|
||||
if records_per_page > 0
|
||||
obj.total_pages = (obj.total_count.to_f / records_per_page).ceil
|
||||
else
|
||||
obj.total_pages = 1
|
||||
end
|
||||
obj.current_page = page
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user