mirror of
https://github.com/codeninjasllc/discourse.git
synced 2025-02-17 04:01:29 -05:00
couple of bugfixes identified while importing from VB
This commit is contained in:
parent
7670598658
commit
f25bcc5067
5 changed files with 15 additions and 11 deletions
|
@ -51,9 +51,9 @@ class Post < ActiveRecord::Base
|
||||||
scope :public_posts, -> { joins(:topic).where('topics.archetype <> ?', Archetype.private_message) }
|
scope :public_posts, -> { joins(:topic).where('topics.archetype <> ?', Archetype.private_message) }
|
||||||
scope :private_posts, -> { joins(:topic).where('topics.archetype = ?', Archetype.private_message) }
|
scope :private_posts, -> { joins(:topic).where('topics.archetype = ?', Archetype.private_message) }
|
||||||
scope :with_topic_subtype, ->(subtype) { joins(:topic).where('topics.subtype = ?', subtype) }
|
scope :with_topic_subtype, ->(subtype) { joins(:topic).where('topics.subtype = ?', subtype) }
|
||||||
|
|
||||||
delegate :username, to: :user
|
delegate :username, to: :user
|
||||||
|
|
||||||
def self.hidden_reasons
|
def self.hidden_reasons
|
||||||
@hidden_reasons ||= Enum.new(:flag_threshold_reached, :flag_threshold_reached_again, :new_user_spam_threshold_reached)
|
@hidden_reasons ||= Enum.new(:flag_threshold_reached, :flag_threshold_reached_again, :new_user_spam_threshold_reached)
|
||||||
end
|
end
|
||||||
|
|
|
@ -75,7 +75,7 @@ class PostAnalyzer
|
||||||
begin
|
begin
|
||||||
uri = URI.parse(u)
|
uri = URI.parse(u)
|
||||||
host = uri.host
|
host = uri.host
|
||||||
@linked_hosts[host] ||= 1
|
@linked_hosts[host] ||= 1 unless host.nil?
|
||||||
rescue URI::InvalidURIError
|
rescue URI::InvalidURIError
|
||||||
# An invalid URI does not count as a raw link.
|
# An invalid URI does not count as a raw link.
|
||||||
next
|
next
|
||||||
|
@ -90,10 +90,10 @@ class PostAnalyzer
|
||||||
return [] unless @raw.present?
|
return [] unless @raw.present?
|
||||||
return @raw_links if @raw_links.present?
|
return @raw_links if @raw_links.present?
|
||||||
|
|
||||||
# Don't include @mentions in the link count
|
|
||||||
@raw_links = []
|
@raw_links = []
|
||||||
|
|
||||||
cooked_document.search("a").each do |l|
|
cooked_document.search("a").each do |l|
|
||||||
|
# Don't include @mentions in the link count
|
||||||
next if l.attributes['href'].nil? || link_is_a_mention?(l)
|
next if l.attributes['href'].nil? || link_is_a_mention?(l)
|
||||||
url = l.attributes['href'].to_s
|
url = l.attributes['href'].to_s
|
||||||
@raw_links << url
|
@raw_links << url
|
||||||
|
|
|
@ -192,7 +192,7 @@ module PrettyText
|
||||||
else
|
else
|
||||||
l["rel"] = "nofollow"
|
l["rel"] = "nofollow"
|
||||||
end
|
end
|
||||||
rescue URI::InvalidURIError
|
rescue URI::InvalidURIError, URI::InvalidComponentError
|
||||||
# add a nofollow anyway
|
# add a nofollow anyway
|
||||||
l["rel"] = "nofollow"
|
l["rel"] = "nofollow"
|
||||||
end
|
end
|
||||||
|
|
|
@ -55,7 +55,7 @@ class TopicCreator
|
||||||
|
|
||||||
category = find_category
|
category = find_category
|
||||||
|
|
||||||
@guardian.ensure_can_create!(Topic,category)
|
@guardian.ensure_can_create!(Topic, category)
|
||||||
|
|
||||||
topic_params[:category_id] = category.id if category.present?
|
topic_params[:category_id] = category.id if category.present?
|
||||||
|
|
||||||
|
|
14
vendor/assets/javascripts/better_markdown.js
vendored
14
vendor/assets/javascripts/better_markdown.js
vendored
|
@ -437,11 +437,15 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
function escapeHTML( text ) {
|
function escapeHTML( text ) {
|
||||||
return text.replace( /&/g, "&" )
|
if (text && text.length > 0) {
|
||||||
.replace( /</g, "<" )
|
return text.replace( /&/g, "&" )
|
||||||
.replace( />/g, ">" )
|
.replace( /</g, "<" )
|
||||||
.replace( /"/g, """ )
|
.replace( />/g, ">" )
|
||||||
.replace( /'/g, "'" );
|
.replace( /"/g, """ )
|
||||||
|
.replace( /'/g, "'" );
|
||||||
|
} else {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function render_tree( jsonml ) {
|
function render_tree( jsonml ) {
|
||||||
|
|
Loading…
Reference in a new issue