use dots instead of colons for tag scopes
parent
55e0484121
commit
83c2c466fb
|
@ -36,7 +36,7 @@ class Bangtags
|
||||||
end
|
end
|
||||||
|
|
||||||
def process
|
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!")
|
status.text.gsub!('#!!', "#\u200c!")
|
||||||
|
|
||||||
|
@ -218,7 +218,7 @@ class Bangtags
|
||||||
chunk = mentions.join(' ')
|
chunk = mentions.join(' ')
|
||||||
when 'tag'
|
when 'tag'
|
||||||
chunk = nil
|
chunk = nil
|
||||||
tags = cmd[1..-1].map {|t| t.gsub('.', ':')}
|
tags = cmd[1..-1].map {|t| t.gsub(':', '.')}
|
||||||
add_tags(status, *tags)
|
add_tags(status, *tags)
|
||||||
when 'thread'
|
when 'thread'
|
||||||
chunk = nil
|
chunk = nil
|
||||||
|
@ -291,7 +291,7 @@ class Bangtags
|
||||||
when 'tag'
|
when 'tag'
|
||||||
chunk = nil
|
chunk = nil
|
||||||
next unless @parent_status.account.id == @account.id
|
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)
|
add_tags(@parent_status, *tags)
|
||||||
when 'emoji'
|
when 'emoji'
|
||||||
@parent_status.emojis.each do |theirs|
|
@parent_status.emojis.each do |theirs|
|
||||||
|
@ -404,7 +404,7 @@ class Bangtags
|
||||||
status.visibility = :direct
|
status.visibility = :direct
|
||||||
@vore_stack.push('_draft')
|
@vore_stack.push('_draft')
|
||||||
@component_stack.push(:var)
|
@component_stack.push(:var)
|
||||||
add_tags(status, 'self:draft')
|
add_tags(status, 'self.draft')
|
||||||
when 'format', 'type'
|
when 'format', 'type'
|
||||||
chunk = nil
|
chunk = nil
|
||||||
next if cmd[1].nil?
|
next if cmd[1].nil?
|
||||||
|
|
|
@ -19,7 +19,7 @@ class Tag < ApplicationRecord
|
||||||
has_many :featured_tags, dependent: :destroy, inverse_of: :tag
|
has_many :featured_tags, dependent: :destroy, inverse_of: :tag
|
||||||
has_one :account_tag_stat, dependent: :destroy
|
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
|
HASHTAG_RE = /(?:^|[^\/\)\w])#(#{HASHTAG_NAME_RE})/i
|
||||||
|
|
||||||
validates :name, presence: true, uniqueness: true, format: { with: /\A#{HASHTAG_NAME_RE}\z/i }
|
validates :name, presence: true, uniqueness: true, format: { with: /\A#{HASHTAG_NAME_RE}\z/i }
|
||||||
|
|
|
@ -8,9 +8,9 @@ class ProcessHashtagsService < BaseService
|
||||||
records = []
|
records = []
|
||||||
|
|
||||||
tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |name|
|
tags.map { |str| str.mb_chars.downcase }.uniq(&:to_s).each do |name|
|
||||||
name = name.gsub(/::+/, ':')
|
name = name.gsub(/\.\.+/, '.')
|
||||||
next if name.blank?
|
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 << name.size - 1
|
||||||
component_indices.take(6).each_with_index do |i, nest|
|
component_indices.take(6).each_with_index do |i, nest|
|
||||||
frag = (nest != 5) ? name[0..i] : name
|
frag = (nest != 5) ? name[0..i] : name
|
||||||
|
|
|
@ -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
|
Loading…
Reference in New Issue