mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
Merge branch 'master' of github.com:discourse/discourse
This commit is contained in:
commit
fbb6eba252
222 changed files with 2726 additions and 1141 deletions
|
@ -46,15 +46,18 @@ class Auth::Result
|
|||
}
|
||||
end
|
||||
else
|
||||
{
|
||||
email: email,
|
||||
name: User.suggest_name(name || username || email),
|
||||
username: UserNameSuggester.suggest(username || name || email),
|
||||
# this feels a tad wrong
|
||||
auth_provider: authenticator_name.capitalize,
|
||||
email_valid: !!email_valid,
|
||||
omit_username: !!omit_username
|
||||
}
|
||||
result = { email: email,
|
||||
username: UserNameSuggester.suggest(username || name || email),
|
||||
# this feels a tad wrong
|
||||
auth_provider: authenticator_name.capitalize,
|
||||
email_valid: !!email_valid,
|
||||
omit_username: !!omit_username }
|
||||
|
||||
if SiteSetting.enable_names?
|
||||
result[:name] = User.suggest_name(name || username || email)
|
||||
end
|
||||
|
||||
result
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -68,7 +68,7 @@ module Email
|
|||
html_override.gsub!("%{unsubscribe_link}", unsubscribe_link)
|
||||
end
|
||||
|
||||
styled = Email::Styles.new(html_override)
|
||||
styled = Email::Styles.new(html_override, @opts)
|
||||
styled.format_basic
|
||||
|
||||
if style = @opts[:style]
|
||||
|
|
|
@ -16,11 +16,11 @@ module Email
|
|||
|
||||
def html
|
||||
if @message.html_part
|
||||
style = Email::Styles.new(@message.html_part.body.to_s)
|
||||
style = Email::Styles.new(@message.html_part.body.to_s, @opts)
|
||||
style.format_basic
|
||||
style.format_html
|
||||
else
|
||||
style = Email::Styles.new(PrettyText.cook(text))
|
||||
style = Email::Styles.new(PrettyText.cook(text), @opts)
|
||||
style.format_basic
|
||||
end
|
||||
|
||||
|
|
|
@ -87,12 +87,12 @@ module Email
|
|||
|
||||
# http://www.ietf.org/rfc/rfc2919.txt
|
||||
if topic && topic.category && !topic.category.uncategorized?
|
||||
list_id = "<#{topic.category.name.downcase}.#{host}>"
|
||||
list_id = "<#{topic.category.name.downcase.gsub(' ', '-')}.#{host}>"
|
||||
|
||||
# subcategory case
|
||||
if !topic.category.parent_category_id.nil?
|
||||
parent_category_name = Category.find_by(id: topic.category.parent_category_id).name
|
||||
list_id = "<#{topic.category.name.downcase}.#{parent_category_name.downcase}.#{host}>"
|
||||
list_id = "<#{topic.category.name.downcase.gsub(' ', '-')}.#{parent_category_name.downcase.gsub(' ', '-')}.#{host}>"
|
||||
end
|
||||
else
|
||||
list_id = "<#{host}>"
|
||||
|
|
|
@ -6,8 +6,9 @@ module Email
|
|||
class Styles
|
||||
@@plugin_callbacks = []
|
||||
|
||||
def initialize(html)
|
||||
def initialize(html, opts=nil)
|
||||
@html = html
|
||||
@opts = opts || {}
|
||||
@fragment = Nokogiri::HTML.fragment(@html)
|
||||
end
|
||||
|
||||
|
@ -42,7 +43,6 @@ module Email
|
|||
img['width'] = 'auto'
|
||||
img['height'] = 'auto'
|
||||
end
|
||||
add_styles(img, 'max-width:100%;') if img['style'] !~ /max-width/
|
||||
end
|
||||
|
||||
# ensure all urls are absolute
|
||||
|
@ -92,11 +92,15 @@ module Email
|
|||
|
||||
def onebox_styles
|
||||
# Links to other topics
|
||||
style('aside.quote', 'border-left: 5px solid #bebebe; background-color: #f1f1f1; padding: 12px 25px 2px 12px; margin-bottom: 10px;')
|
||||
style('aside.quote blockquote', 'border: 0px; padding: 0; margin: 7px 0')
|
||||
style('aside.quote', 'border-left: 5px solid #e9e9e9; background-color: #f8f8f8; padding: 12px 25px 2px 12px; margin-bottom: 10px;')
|
||||
style('aside.quote blockquote', 'border: 0px; padding: 0; margin: 7px 0; background-color: clear;')
|
||||
style('aside.quote blockquote > p', 'padding: 0;')
|
||||
style('aside.quote div.info-line', 'color: #666; margin: 10px 0')
|
||||
style('aside.quote .avatar', 'margin-right: 5px; width:20px; height:20px')
|
||||
|
||||
style('blockquote', 'border-left: 5px solid #e9e9e9; background-color: #f8f8f8; margin: 0;')
|
||||
style('blockquote > p', 'padding: 1em;')
|
||||
|
||||
# Oneboxes
|
||||
style('aside.onebox', "padding: 12px 25px 2px 12px; border-left: 5px solid #bebebe; background: #eee; margin-bottom: 10px;")
|
||||
style('aside.onebox img', "max-height: 80%; max-width: 25%; height: auto; float: left; margin-right: 10px; margin-bottom: 10px")
|
||||
|
@ -146,7 +150,7 @@ module Email
|
|||
|
||||
# this method is reserved for styles specific to plugin
|
||||
def plugin_styles
|
||||
@@plugin_callbacks.each { |block| block.call(@fragment) }
|
||||
@@plugin_callbacks.each { |block| block.call(@fragment, @opts) }
|
||||
end
|
||||
|
||||
def to_html
|
||||
|
|
|
@ -1,6 +1,11 @@
|
|||
# A very simple formatter for imported emails
|
||||
|
||||
class EmailCook
|
||||
|
||||
def self.url_regexp
|
||||
/[^\>]*((?:https?:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.])(?:[^\s()<>]+|\([^\s()<>]+\))+(?:\([^\s()<>]+\)|[^`!()\[\]{};:'".,<>?«»\s]))/
|
||||
end
|
||||
|
||||
def initialize(raw)
|
||||
@raw = raw
|
||||
end
|
||||
|
@ -20,6 +25,11 @@ class EmailCook
|
|||
quote_buffer = ""
|
||||
in_quote = false
|
||||
else
|
||||
|
||||
l.scan(EmailCook.url_regexp).each do |m|
|
||||
url = m[0]
|
||||
l.gsub!(url, "<a href='#{url}'>#{url}</a>")
|
||||
end
|
||||
result << l << "<br>"
|
||||
end
|
||||
end
|
||||
|
@ -29,7 +39,6 @@ class EmailCook
|
|||
end
|
||||
|
||||
result.gsub!(/(<br>){3,10}/, '<br><br>')
|
||||
|
||||
result
|
||||
end
|
||||
|
||||
|
|
|
@ -212,7 +212,7 @@ class Guardian
|
|||
|
||||
def can_invite_to?(object, group_ids=nil)
|
||||
return false if ! authenticated?
|
||||
return false unless ( SiteSetting.enable_local_logins && (!SiteSetting.must_approve_users? || is_staff?) )
|
||||
return false unless (!SiteSetting.must_approve_users? || is_staff?)
|
||||
return true if is_admin?
|
||||
return false if (SiteSetting.max_invites_per_day.to_i == 0 && !is_staff?)
|
||||
return false if ! can_see?(object)
|
||||
|
|
|
@ -21,7 +21,8 @@ module MemoryDiagnostics
|
|||
require 'objspace'
|
||||
diff = diff.map do |id|
|
||||
ObjectSpace._id2ref(id) rescue nil
|
||||
end.compact!
|
||||
end
|
||||
diff.compact!
|
||||
|
||||
report = "#{diff.length} objects have leaked\n"
|
||||
|
||||
|
|
|
@ -64,8 +64,13 @@ module Middleware
|
|||
CurrentUser.has_auth_cookie?(@env)
|
||||
end
|
||||
|
||||
def no_cache_bypass
|
||||
request = Rack::Request.new(@env)
|
||||
request.cookies['_bypass_cache'].nil?
|
||||
end
|
||||
|
||||
def cacheable?
|
||||
!!(!has_auth_cookie? && get?)
|
||||
!!(!has_auth_cookie? && get? && no_cache_bypass)
|
||||
end
|
||||
|
||||
def cached
|
||||
|
|
|
@ -189,6 +189,8 @@ module PrettyText
|
|||
end
|
||||
end
|
||||
|
||||
# reset emojis (v8 context is shared amongst multisites)
|
||||
context.eval("Discourse.Dialect.resetEmoji();")
|
||||
# custom emojis
|
||||
Emoji.custom.each do |emoji|
|
||||
context.eval("Discourse.Dialect.registerEmoji('#{emoji.name}', '#{emoji.url}');")
|
||||
|
|
|
@ -379,6 +379,8 @@ class Search
|
|||
end
|
||||
|
||||
def user_search
|
||||
return if SiteSetting.hide_user_profiles_from_public && !@guardian.user
|
||||
|
||||
users = User.includes(:user_search_data)
|
||||
.where("active = true AND user_search_data.search_data @@ #{ts_query("simple")}")
|
||||
.order("CASE WHEN username_lower = '#{@original_term.downcase}' THEN 0 ELSE 1 END")
|
||||
|
|
|
@ -7,6 +7,8 @@ end
|
|||
task 'db:migrate' => ['environment', 'set_locale'] do
|
||||
SeedFu.seed
|
||||
|
||||
SiteSetting.last_vacuum = Time.now.to_i if SiteSetting.last_vacuum == 0
|
||||
|
||||
if SiteSetting.vacuum_db_days > 0 &&
|
||||
SiteSetting.last_vacuum < (Time.now.to_i - SiteSetting.vacuum_db_days.days.to_i)
|
||||
puts "Running VACUUM FULL ANALYZE to reclaim DB space, this may take a while"
|
||||
|
|
|
@ -201,6 +201,7 @@ class TopicQuery
|
|||
|
||||
def latest_results(options={})
|
||||
result = default_results(options)
|
||||
result = remove_muted_topics(result, @user) unless options && options[:state] = "muted".freeze
|
||||
result = remove_muted_categories(result, @user, exclude: options[:category])
|
||||
result
|
||||
end
|
||||
|
@ -215,6 +216,7 @@ class TopicQuery
|
|||
# TODO does this make sense or should it be ordered on created_at
|
||||
# it is ordering on bumped_at now
|
||||
result = TopicQuery.new_filter(default_results(options.reverse_merge(:unordered => true)), @user.treat_as_new_topic_start_date)
|
||||
result = remove_muted_topics(result, @user)
|
||||
result = remove_muted_categories(result, @user, exclude: options[:category])
|
||||
suggested_ordering(result, options)
|
||||
end
|
||||
|
@ -395,6 +397,13 @@ class TopicQuery
|
|||
@guardian.filter_allowed_categories(result)
|
||||
end
|
||||
|
||||
def remove_muted_topics(list, user)
|
||||
if user
|
||||
list = list.where('tu.notification_level <> :muted', muted: TopicUser.notification_levels[:muted])
|
||||
end
|
||||
|
||||
list
|
||||
end
|
||||
def remove_muted_categories(list, user, opts=nil)
|
||||
category_id = get_category_id(opts[:exclude]) if opts
|
||||
|
||||
|
|
|
@ -8,7 +8,7 @@ class TopicsBulkAction
|
|||
end
|
||||
|
||||
def self.operations
|
||||
@operations ||= %w(change_category close archive change_notification_level reset_read dismiss_posts delete)
|
||||
@operations ||= %w(change_category close archive change_notification_level reset_read dismiss_posts delete unlist)
|
||||
end
|
||||
|
||||
def self.register_operation(name, &block)
|
||||
|
@ -66,6 +66,15 @@ class TopicsBulkAction
|
|||
end
|
||||
end
|
||||
|
||||
def unlist
|
||||
topics.each do |t|
|
||||
if guardian.can_moderate?(t)
|
||||
t.update_status('visible', false, @user)
|
||||
@changed_ids << t.id
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def archive
|
||||
topics.each do |t|
|
||||
if guardian.can_moderate?(t)
|
||||
|
|
|
@ -5,7 +5,7 @@ module Discourse
|
|||
MAJOR = 1
|
||||
MINOR = 5
|
||||
TINY = 0
|
||||
PRE = 'beta2'
|
||||
PRE = 'beta3'
|
||||
|
||||
STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue