Ejemplo n.º 1
0
 def add_root_elements(self, handler):
     Rss201rev2Feed.add_root_elements(self, handler)
     handler.startElement(u'image', {})
     handler.addQuickElement(u"url", settings.SITE["logo_url"])
     handler.addQuickElement(u"title", settings.SITE["title"])
     handler.addQuickElement(u"link", settings.SITE["url"])
     handler.endElement(u"image")
Ejemplo n.º 2
0
    def add_root_elements(self, handler):
	Rss201rev2Feed.add_root_elements(self, handler)
	handler.startElement(u"image", self.root_attributes())
	handler.addQuickElement(u"url", "http://holger.outgesourced.org/favicon.ico")
	handler.addQuickElement(u"title", "Share the road")
	handler.addQuickElement(u"link", "http://holger.outgesourced.org/blog/")
	handler.endElement(u"image")
Ejemplo n.º 3
0
def get_favorites_rss(request, user_hash):
    ou = OauthUser.objects.get(user_hash=user_hash)
    favs = favorite_list(request, ou.twitter_name)
    feed = RssFeed(title='%s\'s favorites' % (ou.twitter_name), link='http://savethisfor.me/', description='')
    for f in favs:
        feed.add_item(title='%s - %s' % (f['user']['name'], f['created_at']), 
                      link='http://twitter.com/%s/status/%s' % (f['user']['screen_name'], f['id']),
                      description = f['text'],
                      author_name = f['user']['name'],
                      author_link = 'http://twitter.com/%s' % (f['user']['screen_name'],),
                      pubdate = datetime.datetime.strptime(f['created_at'], '%a %b %d %H:%M:%S +0000 %Y'))
    response = HttpResponse(mimetype='text/rss+xml')
    feed.write(response, 'UTF-8')
    return response
Ejemplo n.º 4
0
 def get(self, request, *args, **kwargs):
     context = self.get_context_data(*args, **kwargs)
     queryset = self.get_queryset()
     link = 'http://%s%s?%s' % (request.get_host(),
                                reverse('bills', args=args, kwargs=kwargs),
                                request.META['QUERY_STRING'])
     feed_url = 'http://%s%s?%s' % (
         request.get_host(), reverse(
             'bills_feed', args=args,
             kwargs=kwargs), request.META['QUERY_STRING'])
     feed = Rss201rev2Feed(title=context['description'],
                           link=link,
                           feed_url=feed_url,
                           ttl=360,
                           description=context['description'] +
                           '\n'.join(context.get('long_description', '')))
     for item in queryset:
         link = 'http://%s%s' % (request.get_host(),
                                 item.get_absolute_url())
         feed.add_item(title=item['bill_id'],
                       link=link,
                       unique_id=link,
                       description=item['title'])
     return HttpResponse(feed.writeString('utf-8'),
                         content_type='application/xml')
Ejemplo n.º 5
0
def rss(request, issue=None):
    issue = Issue.objects.get(is_default=True,
                              is_published=True,
                              language=request.language)
    articles = issue.article_set.filter(is_published=True).all()

    feed = Rss201rev2Feed(title=request.locals['magazine_name'] + u' - ' +
                          issue.title + u' ' + request.locals['number'],
                          link=u'http://' + request.get_host() +
                          request.get_full_path(),
                          description=request.locals['magazine_slogan'])

    #handler = xml.sax.saxutils.XMLGenerator()
    #feed.add_root_elements(handler)
    for article in articles:
        #print article
        intro_text = article.intro_text
        if not intro_text:
            intro_text = ''
        try:
            feed.add_item(title=article.headline,
                          link=u'http://' + request.get_host() +
                          article.get_absolute_url(),
                          description=intro_text,
                          pubdate=article.created_at)
        except Exception, e:
            pass
Ejemplo n.º 6
0
def rss_of_group(request, group_id, current_app, type):

    group = TgGroup.objects.plus_get(request.user, id=group_id)
    feed = Rss201rev2Feed(title=group.get_display_name(),
                          link=group.get_url(),
                          description=strip_tags(group.description))
    return rss_of(feed, group)
Ejemplo n.º 7
0
def rss_explore(request, tag_string, s_type=None):
    from apps.plus_lib.redis_lib import redis
    feed_type = 'rss2.0'  # XXX decide how to send this as parameter to link
    key = "feed:" + feed_type + ":" + tag_string
    if redis.exists(key):
        return HttpResponse(redis.get(key), mimetype="application/xhtml+xml")
    else:
        feed = Rss201rev2Feed(
            title=settings.SITE_NAME + " : " + tag_string,
            link='http://' + settings.DOMAIN_NAME +
            reverse('explore_filtered_feed', args=(tag_string, )),
            description=_("Items tagged with %s" % tag_string))
        # XXX decide how to parameterize which feed type, title, description, link

        form = SearchForm(request.GET)
        if form.is_valid():
            search, order = set_search_order(request, form)
        else:
            search = ''
            order = ''

        side_search = side_search_args('', '')

        if s_type:
            search_types = narrow_search_types(s_type)
        else:
            search_types = get_search_types()

        head_title = settings.EXPLORE_NAME
        listing_args_dict = listing_args('explore',
                                         'explore_filtered',
                                         tag_string=tag_string,
                                         search_terms=search,
                                         multitabbed=True,
                                         order=order,
                                         template_base="site_base.html",
                                         search_type_label=head_title)
        search_dict = plus_search(listing_args_dict['tag_filter'], search,
                                  search_types, order)

        for item_ref in search_dict['All']:
            item = item_ref.obj
            item = secure_wrap(item, request.user)

            try:
                feed.add_item(title=item.get_display_name(),
                              link=item.get_url(),
                              description=item.get_description(),
                              author_name=item.get_author_name(),
                              author_copyright=item.get_author_copyright(),
                              pubdate=item.get_created_date(),
                              **(item.get_feed_extras()))
            except PlusPermissionsNoAccessException, e:
                pass

        feed_string = feed.writeString('utf-8')
        # uncomment the following when we start to cache
        #redis.set(key,feed_string)
        #redis.expire(key,60*60*1) # sets expire every 1 hour
        return HttpResponse(feed_string, mimetype="application/xhtml+xml")
Ejemplo n.º 8
0
def rss(request, issue=None):
    try:
        issue = Issue.objects.filter(is_default=True,
            is_published=True).all()[0:1].get()
    except:
        raise Http404
    
    articles = issue.article_set.filter(is_published=True).order_by('order').all()
    
    feed = Rss201rev2Feed(title=request.site.name + u' - ' + issue.title, 
        link=u'http:/www.alqualam.com',
        feed_url=u'http://' + request.get_host() + request.get_full_path(),
        description=request.site.settings.slogan
    )
    
    for article in articles:
        if article.intro_text:
            description = article.intro_text
        else:
            description = article.get_title()
        
        feed.add_item(title=article.get_title(),
            link=u'http://' + request.get_host() + article.get_absolute_url(),
            description=description,
            pubdate=article.created_at
        )
    return HttpResponse(feed.writeString('UTF-8'), mimetype='application/rss+xml')
Ejemplo n.º 9
0
def rssFeed(req):
    """Generates an RSS2 syndication feed for shared searches.
    
    Returns an XML string."""
    ctx = getsearchresults(req)
    feed = Rss201rev2Feed(
        _('Search: ') + ctx['q'], u'/catalog/feed/rss/',
        _('Fac-Back-OPAC Search in RSS2 syndication'))
    return feedCreator(ctx, feed)
Ejemplo n.º 10
0
def rss_of_everyone(request):
    feed = Rss201rev2Feed(
        title='Hub+',
        link='http://' + settings.DOMAIN_NAME + reverse('home', args=[]),
        description=
        'Hub+ is the network that gives you access to the people, resources and knowledge you need to inspire and make your idea come to life.'
    )
    return rss_from_item_list(
        feed, FeedItem.feed_manager.all_permissioned(request.user))
Ejemplo n.º 11
0
def rss_of_user(request, username):

    profile = Profile.objects.plus_get(request.user, user__username=username)
    profile.get_display_name()  # test permission
    user = profile.user
    feed = Rss201rev2Feed(title=user.get_display_name(),
                          link='http://' + settings.DOMAIN_NAME +
                          reverse('profile_detail', args=(username, )),
                          description=strip_tags(user.get_profile().about))

    return rss_of(feed, user)
Ejemplo n.º 12
0
    def get(self, request, state):
        bills, form = self.get_bills(request, state)
        host = request.get_host()
        link = "https://{}{}?{}".format(
            host,
            reverse("bills", kwargs={"state": state}),
            request.META["QUERY_STRING"],
        )
        feed_url = "https://%s%s?%s" % (
            host,
            reverse("bills_feed", kwargs={"state": state}),
            request.META["QUERY_STRING"],
        )
        description = f"{state.upper()} Bills"
        if form["session"]:
            description += f" ({form['session']})"
        # TODO: improve RSS description
        feed = Rss201rev2Feed(
            title=description,
            link=link,
            feed_url=feed_url,
            ttl=360,
            description=description,
        )
        for item in bills[:100]:
            link = "https://{}{}".format(host, pretty_url(item))
            try:
                description = f"""{item.title}<br />
                          Latest Action: {item.billstatus.latest_action_description}
                          <i>{item.billstatus.latest_action_date}</i>"""
            except Bill.billstatus.RelatedObjectDoesNotExist:
                description = item.title

            feed.add_item(
                title=item.identifier,
                link=link,
                unique_id=link,
                description=description,
            )
        return HttpResponse(feed.writeString("utf-8"),
                            content_type="application/xml")
Ejemplo n.º 13
0
def feed(request, lang_code):
    translation.activate(lang_code)
    advisories = Advisory.objects.filter(publish=True,
                                         language__code=lang_code)[:25]
    site = Site.objects.get_current()

    rss = Rss201rev2Feed(title=unicode(_("Pardus Linux Security Advisories")),
                         link="http://%s/%s/rss/" % (site.domain, lang_code),
                         description=unicode(
                             _("Pardus Linux Security Advisories")),
                         language=lang_code)

    for adv in advisories:
        rss.add_item(title="[PLSA %s] %s" % (adv.plsa_id, adv.title),
                     link="http://%s/%s/%s/" %
                     (site.domain, lang_code, adv.plsa_id),
                     description=adv.summary,
                     pubdate=adv.release_date,
                     unique_id=adv.plsa_id)

    return HttpResponse(rss.writeString("utf-8"))
Ejemplo n.º 14
0
def atomstream(request):
    """provides user feed as rss

    note that if token auth fails, we will not return xml. it's
    probably alright because we couldn't return any useful content
    anyway.

    """

    feed = Rss201rev2Feed(title=settings.SITE_NAME,
                          link=settings.SITE_URL,
                          description=_(u"Search feed for %(username)s") %
                          request.jwt.user.username)
    objects = SubscriptionHit.objects.filter(
        notified_users=request.jwt.user)[:10]
    for item in objects:
        feed.add_item(title=item.subject,
                      link=item.link,
                      description=_(u"No description provided"))

    response = HttpResponse(content_type="application/rss+xml")
    feed.write(response)
    return response
Ejemplo n.º 15
0
 def render_rss2(self, request, context, template_name):
     (title, desc, link) = extractFeedDetails(request)
     feed = Rss201rev2Feed(title, link, desc)
     return self.renderGeneralFeed(request, context, template_name, feed)