119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
|
# File 'lib/menu_window.rb', line 119
def draw_line(text, item)
if item.is_a?(Entry)
color = case
when item.respond_to?(:flagged) && item.flagged && !@options[:turn_off_flagged_color]
:red
else
nil
end
matches = @matches || @global_matches
search_string = @search_string || @global_search_string
if matches && !matches.empty? && matches.include?( @items.index(item) )
LOGGER.debug("matching line detected : search string #{search_string} : text: #{text}")
text = text.gsub(/(#{search_string})/i, '%%%\1%%%')
text.split(/%%%/).each_with_index do |chunk, index|
if index % 2 == 0
@window.addstr(chunk, color)
else
@window.addstr(chunk, :yellow)
end
end
else
@window.addstr(text, color)
end
if @options[:show_feed_titles] @window.addstr(" #{item.feed.title}", :cyan)
end
item_date = case
when @options[:feed_title] == "All Entries"
item.created_at
when @options[:feed_title] == "Flagged Entries"
item.flagged
else
item.date_published
end
if item_date
item_date = " #{time_ago_in_words(item_date)} ago"
else
item_date = ''
end
@window.addstr(item_date, :magenta)
@window.addstr("\n")
else
color = case
when item.is_a?(VirtualFeed) && text =~ /Flagged Entries/
:red
else
nil
end
@window.addstr(text, color)
if item.is_a?(VirtualFeed) && item.title == "All Entries"
entry = Entry.find(:first, :order => "id desc")
last_updated = entry ? "#{time_ago_in_words(entry.created_at)} ago\n" : "\n"
@window.addstr(" " + last_updated, :magenta)
elsif item.is_a?(VirtualFeed) && item.title == "Flagged Entries"
entry = Entry.find(:first, :conditions => "flagged IS NOT NULL", :order => "flagged desc")
last_updated = entry ? "#{time_ago_in_words(entry.flagged)} ago\n" : "\n"
@window.addstr(" " + last_updated , :magenta)
elsif item.last_updated
most_recent_entry = item.entries.first
last_updated = (most_recent_entry && most_recent_entry.date_published) ?
most_recent_entry.date_published : item.last_updated
if last_updated
last_updated = time_ago_in_words(last_updated) + " ago\n"
else
last_updated = ''
end
@window.addstr(" " + last_updated , :magenta)
else
@window.addstr("\n")
end
end
end
|