Class Annotation
In: app/models/annotation.rb
Parent: ActiveRecord::Base

Annotations function like very short comments inside the text and are meanth as one-liners…

Methods

Attributes

position_ranges  [RW] 

Protected Instance methods

Sets the position_ranges attribute and associates each PositionRange with it‘s position in the un-sorted list.

[Source]

    # File app/models/annotation.rb, line 44
44:   def after_initialize
45:     if self.new_record?
46:       @position_ranges = PositionRange::List.new()
47:     else
48:       @position_ranges = PositionRange::List.from_s(self.position_ranges_string, :annotation => self)
49:     end
50:     return true
51:   end

Logs creation to log.logilogi.org

[Source]

    # File app/models/annotation.rb, line 67
67:   def log_create_to_log_log
68:     if GlobalConfig.use_log_log
69:       m = LogLogMessage.new(
70:           :kind => "Annotation",
71:           :channel_names => ['all', 'annotation',
72:               'for_' + self.logi.creator.unix_name].join(','),
73:           :author => self.user.name,
74:           :title => 'On: ' + self.logi.current_title,
75:           :text => self.message,
76:           :url => GlobalConfig.site_url + self.logi.link.to_s)
77:       m.save
78:     end
79:   end

Does a sanity-check on the position_ranges and turns them into a string for saving.

[Source]

    # File app/models/annotation.rb, line 56
56:   def stringify_position_ranges
57:     if !@position_ranges.below?(self.logi.text_stack.size) # sanity check
58:       raise StandardError, t('defaults.error_end_position_range_bigger') + ' ' +
59:           self.logi.text_stack.size.to_s
60:     end
61:     self.position_ranges_string = @position_ranges.to_s
62:     return true
63:   end

Validation-functions

[Source]

    # File app/models/annotation.rb, line 85
85:   def validate
86:     # length
87:     if GlobalConfig.done_with_basics?
88:       if self.message.size > GlobalConfig.maximum_message_size
89:         self.errors.add(:message, t('m.annotation.error_too_long',
90:             :max => GlobalConfig.maximum_message_size))
91:       end
92:     end
93:     # no html-tags
94:     if self.message =~ Const::LogiVersion::HTML_TAG
95:       self.errors.add(:message, 'm.annotation.html_tags_not_allowed')
96:     end
97:   end

[Validate]