2
0
Fork 0
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:
Neil Lalonde 2016-04-25 15:55:15 -04:00
parent 7151c16c79
commit e5918c7d00
93 changed files with 2484 additions and 20 deletions

View file

@ -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