use dots instead of colons for tag scopes

staging
multiple creatures 2019-05-21 01:55:03 -05:00
parent 55e0484121
commit 83c2c466fb
4 changed files with 16 additions and 7 deletions

View File

@ -36,7 +36,7 @@ class Bangtags
end
def process
return unless status.text&.present? && status.text.include?('#!')
return unless !@vars['_bangtags:disable'] && status.text&.present? && status.text.include?('#!')
status.text.gsub!('#!!', "#\u200c!")
@ -218,7 +218,7 @@ class Bangtags
chunk = mentions.join(' ')
when 'tag'
chunk = nil
tags = cmd[1..-1].map {|t| t.gsub('.', ':')}
tags = cmd[1..-1].map {|t| t.gsub(':', '.')}
add_tags(status, *tags)
when 'thread'
chunk = nil
@ -291,7 +291,7 @@ class Bangtags
when 'tag'
chunk = nil
next unless @parent_status.account.id == @account.id
tags = cmd[2..-1].map {|t| t.gsub('.', ':')}
tags = cmd[2..-1].map {|t| t.gsub(':', '.')}
add_tags(@parent_status, *tags)
when 'emoji'
@parent_status.emojis.each do |theirs|
@ -404,7 +404,7 @@ class Bangtags
status.visibility = :direct
@vore_stack.push('_draft')
@component_stack.push(:var)
add_tags(status, 'self:draft')
add_tags(status, 'self.draft')
when 'format', 'type'
chunk = nil
next if cmd[1].nil?

View File

@ -19,7 +19,7 @@ class Tag < ApplicationRecord
has_many :featured_tags, dependent: :destroy, inverse_of: :tag
has_one :account_tag_stat, dependent: :destroy
HASHTAG_NAME_RE = '[[:word:]:_\-]*[[:alpha:]:_·\-][[:word:]:_\-]*'
HASHTAG_NAME_RE = '[[:word:]._\-]*[[:alpha:]._·\-][[:word:]._\-]*'
HASHTAG_RE = /(?:^|[^\/\)\w])#(#{HASHTAG_NAME_RE})/i
validates :name, presence: true, uniqueness: true, format: { with: /\A#{HASHTAG_NAME_RE}\z/i }

View File

@ -8,9 +8,9 @@ class ProcessHashtagsService < BaseService
records = []
tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |name|
name = name.gsub(/::+/, ':')
name = name.gsub(/\.\.+/, '.')
next if name.blank?
component_indices = name.size.times.select {|i| name[i] == ':'}
component_indices = name.size.times.select {|i| name[i] == '.'}
component_indices << name.size - 1
component_indices.take(6).each_with_index do |i, nest|
frag = (nest != 5) ? name[0..i] : name

View File

@ -0,0 +1,9 @@
class RewriteScopedTagDelims < ActiveRecord::Migration[5.2]
disable_ddl_transaction!
def up
Tag.where("tags.name LIKE '%:%'").find_each do |tag|
tag.name.gsub!(':', '.')
tag.save
end
end
end