mirror of
https://github.com/discourse/discourse.git
synced 2025-09-05 08:59:27 +08:00
FEATURE: Merge tagging plugin into core
This commit is contained in:
parent
7151c16c79
commit
e5918c7d00
93 changed files with 2484 additions and 20 deletions
|
@ -67,6 +67,23 @@ module PrettyText
|
|||
}
|
||||
end
|
||||
end
|
||||
|
||||
def category_tag_hashtag_lookup(text)
|
||||
tag_postfix = '::tag'
|
||||
is_tag = text =~ /#{tag_postfix}$/
|
||||
|
||||
if !is_tag && category = Category.query_from_hashtag_slug(text)
|
||||
[category.url_with_id, text]
|
||||
elsif is_tag && tag = TopicCustomField.find_by(name: TAGS_FIELD_NAME, value: text.gsub!("#{tag_postfix}", ''))
|
||||
["#{Discourse.base_url}/tags/#{tag.value}", text]
|
||||
else
|
||||
nil
|
||||
end
|
||||
end
|
||||
|
||||
DiscourseEvent.on(:markdown_context) do |context|
|
||||
context.eval('opts["categoryHashtagLookup"] = function(c){return helpers.category_tag_hashtag_lookup(c);}')
|
||||
end
|
||||
end
|
||||
|
||||
@mutex = Mutex.new
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue