Sha256: 88bd09128d87d578860ac6ca7843f531aa4039d7e9987d16468b9c3c474c109d

Contents?: true

Size: 1.18 KB

Versions: 30

Compression:

Stored size: 1.18 KB

Contents

module Alula
  class Smilies < Filter
    MAP = {
      angel:       %w{:angel: },
      angry:       %w{:angry: },
      cool:        %w{:cool: },
      badguy:      %w{:badguy: },
      crying:      %w{:crying: ;( ;-( },
      exclamation: %w{:exclamation: },
      idea:        %w{:idea: },
      kiss:        %w{:kiss: :* :-* },
      laugh:       %w{:laugh: :D :-D },
      monkey:      %w{:monkey: },
      plain:       %w{:plain: :| :-| },
      question:    %w{:question: },
      tongue:      %w{:tongue: },
      sad:         %w{:sad: :( :-( },
      grin:        %w{:grin: },
      smile:       %w{:smile: :) :-) ^^ ^_^},
      smirk:       %w{:smirk: },
      point_right: %w{:point_right: },
      surprise:    %w{:surprise: },
      uncertain:   %w{:uncertain: },
      wink:        %w{:wink: ;) ;-) },
      worried:     %w{:worried: },
    }
    SMILIES = Hash[*MAP.collect{|cls, keys| keys.collect{|key| [key, "<span class=\"smilies-#{cls}\">#{key}</span>"]}}.flatten]
    SMILIES_RE = Regexp.new(SMILIES.keys.collect{|k| Regexp.escape(k)}.join("|"))
    
    def process(content, locale)
      content.gsub(SMILIES_RE, SMILIES)
    end
  end
end

Alula::Filter.register :smilies, Alula::Smilies

Version data entries

30 entries across 30 versions & 1 rubygems

Version Path
alula-0.4.27 lib/alula/core_ext/filters/smilies.rb
alula-0.4.26 lib/alula/core_ext/filters/smilies.rb
alula-0.4.25 lib/alula/core_ext/filters/smilies.rb
alula-0.4.24 lib/alula/core_ext/filters/smilies.rb
alula-0.4.23 lib/alula/core_ext/filters/smilies.rb
alula-0.4.22 lib/alula/core_ext/filters/smilies.rb
alula-0.4.21 lib/alula/core_ext/filters/smilies.rb
alula-0.4.20 lib/alula/core_ext/filters/smilies.rb
alula-0.4.19 lib/alula/core_ext/filters/smilies.rb
alula-0.4.18 lib/alula/core_ext/filters/smilies.rb
alula-0.4.17 lib/alula/core_ext/filters/smilies.rb
alula-0.4.16 lib/alula/core_ext/filters/smilies.rb
alula-0.4.15 lib/alula/core_ext/filters/smilies.rb
alula-0.4.14 lib/alula/core_ext/filters/smilies.rb
alula-0.4.13 lib/alula/core_ext/filters/smilies.rb
alula-0.4.12 lib/alula/core_ext/filters/smilies.rb
alula-0.4.11 lib/alula/core_ext/filters/smilies.rb
alula-0.4.11a lib/alula/core_ext/filters/smilies.rb
alula-0.4.10 lib/alula/core_ext/filters/smilies.rb
alula-0.4.9 lib/alula/core_ext/filters/smilies.rb