--- __init__.py.old Tue Aug 22 09:39:56 2006 +++ __init__.py Tue Aug 22 10:14:07 2006 @@ -69,7 +69,7 @@ DATE_FORMAT = "%B %d, %Y %I:%M %p" NEW_DATE_FORMAT = "%B %d, %Y" ACTIVITY_THRESHOLD = 0 - +MAX_PER_CHANNEL = 10 class stripHtml(sgmllib.SGMLParser): "remove all tags from the data" def __init__(self, data): @@ -187,7 +187,8 @@ "items_per_page", ITEMS_PER_PAGE)) days_per_page = int(tmpl_config_get(config, template_file, "days_per_page", DAYS_PER_PAGE)) - + max_per_channel = int(tmpl_config_get(config, template_file, + "max_per_channel", MAX_PER_CHANNEL)) activity_threshold = int(tmpl_config_get(config, template_file, "activity_threshold", ACTIVITY_THRESHOLD)) @@ -238,7 +239,7 @@ prev_date = [] prev_channel = None for newsitem in self.items(max_items=items_per_page, - max_days=days_per_page): + max_days=days_per_page, max_per_channel=max_per_channel): item_info = template_info(newsitem, date_format) chan_info = channels[newsitem._channel] for k, v in chan_info.items(): @@ -321,7 +322,7 @@ """Unsubscribe the planet from the channel.""" self._channels.remove(channel) - def items(self, hidden=0, sorted=1, max_items=0, max_days=0): + def items(self, hidden=0, sorted=1, max_items=0, max_days=0, max_per_channel=0): """Return an optionally filtered list of items in the channel. The filters are applied in the following order: @@ -355,6 +356,7 @@ items = [] seen_guids = {} for channel in self.channels(hidden=hidden, sorted=0): + channel_items=[] for item in channel._items.values(): if hidden or not item.has_key("hidden"): @@ -395,8 +397,12 @@ if not seen_guids.has_key(item.id): seen_guids[item.id] = 1; - items.append((time.mktime(item.date), item.order, item)) - + channel_items.append((time.mktime(item.date), item.order, item)) + channel_items.sort() + channel_items.reverse() + if len(channel_items) and max_per_channel: + channel_items=channel_items[:max_per_channel] + items=items+channel_items # Sort the list if sorted: items.sort()