Class Texy::LinkElement
In: lib/texy/modules/link.rb
Parent: InlineTagElement

Html tag anchor

Methods

Attributes

link  [RW] 

Public Class methods

[Source]

# File lib/texy/modules/link.rb, line 211
        def initialize(texy)
            super
            self.link = Url.new(texy)
        end

Public Instance methods

[Source]

# File lib/texy/modules/link.rb, line 216
        def set_link(url)
            link.set(url, texy.link_module.root)
        end

[Source]

# File lib/texy/modules/link.rb, line 220
        def set_link_raw(link, text = '')
            if link[0] == ?[ && link[1] != ?*
                el_ref = texy.link_module.reference(link[1..-2])

                if el_ref
                    self.modifier = el_ref.modifier.dup
                    link = el_ref.url + el_ref.query
                    link.gsub!('%s', CGI.escape(Texy.wash(text)))
                else
                    set_link(link[1..-2])
                    return
                end
            end

            if link.length > 1 && link[0..1] == '[*'
                el_image = ImageElement.new(texy)
                el_image.set_images_raw(link[2..-3])
                el_image.require_link_image

                self.link = el_image.link_image.dup
                return
            end

            set_link(link)
        end

Protected Instance methods

[Source]

# File lib/texy/modules/link.rb, line 249
            def generate_tags(tags)
                return if link.as_url.empty? # dest URL is required

                attrs = modifier.attrs_of('a')
                texy.summary[:links] << attrs['href'] = link.as_url

                # rel="nofollow"
                nofollow_class = modifier.unfiltered_classes.include?('nofollow')

                if link.absolute? && (texy.link_module.force_no_follow || nofollow_class)
                    attrs['rel'] = attrs['rel'] ? "#{attrs['rel']} nofollow" : 'nofollow'
                end

                attrs['id'] = modifier.id
                attrs['title'] = modifier.title
                attrs['class'] = modifier.classes
                attrs['style'] = modifier.styles

                attrs['class'].delete('nofollow') if nofollow_class

                # popup on click
                if modifier.unfiltered_classes.include?('popup')
                    attrs['class'].delete('popup')
                    attrs['onclick'] = texy.link_module.popup_on_click
                end

                # email on click
                attrs['onclick'] = texy.link_module.email_on_click if link.email?

                # image on click
                attrs['onclick'] = texy.link_module.image_on_click if link.image?

                tags << ['a', attrs]
            end

[Validate]