def get_feed_info(id): bucket = NewsBucket.get(id, ctx) if bucket is None: abort(404) feed = Dibject() feed.id = id feed.title = bucket.title feed.timestamp = bucket.last_modification_date or datetime.utcnow() try: limit = int(request.params.get('limit', DEFAULT_FEED_SIZE)) except: limit = DEFAULT_FEED_SIZE limit = min(limit, MAX_FEED_SIZE) feed.entries = _bucket_latest_entries_batch(bucket, limit=limit) return feed
def item_trace(e): """ produces a compact subset of the information in a news item suitable for summary or preview. html is stripped and long fields are trimmed. """ trace = Dibject() trace.timestamp = find_best_timestamp(e) or datetime.utcnow() trace.title = stripped_content(e.get('title_detail', None), 128) trace.author = trimmed(find_author_name(e), 128) trace.link = find_best_permalink(e) source = e.get('source', {}) trace.source_url = find_source_url(source) trace.source_title = stripped_content(source.get('title_detail', None), 128) content = e.get('content', [None])[0] if content is None: content = e.get('summary_detail', None) trace.summary = stripped_content(content, 256) return trace