Exemple #1
0
 def get_params(self, request, article, **kwargs):
     text = article.text
     if article.topic.article_set.count() == 1:  # new topic
         text = article.topic.subject + '\n' + text
     try:
         openid = article.author.user.scipio_profile.openid
     except ScipioProfile.DoesNotExist:
         openid = ''
     return {
         'blog':
         utils.absolute_url(reverse('cicero_index')),
         'user_ip':
         article.ip,
         'permalink':
         utils.absolute_url(
             reverse(
                 'cicero.views.topic',
                 args=[article.topic.forum.slug, article.topic.id],
             )),
         'comment_type':
         'post',
         'comment_author':
         smart_str(article.from_guest() and article.guest_name
                   or article.author),
         'comment_author_url':
         smart_str(openid),
         'comment_content':
         smart_str(text),
     }
Exemple #2
0
 def ping_external_urls(self):
     '''
     Пингование внешних ссылок через Pingback
     (http://www.hixie.ch/specs/pingback/pingback)
     '''
     index_url = utils.absolute_url(reverse('cicero_index'))
     source_url = utils.absolute_url(reverse('cicero.views.topic', args=(self.topic.forum.slug, self.topic.id)))
     pingdjack.ping_external_urls(source_url, self.html(), index_url)
Exemple #3
0
 def ping_external_urls(self):
     '''
     Пингование внешних ссылок через Pingback
     (http://www.hixie.ch/specs/pingback/pingback)
     '''
     index_url = utils.absolute_url(reverse('cicero_index'))
     source_url = utils.absolute_url(
         reverse('cicero.views.topic',
                 args=(self.topic.forum.slug, self.topic.id)))
     pingdjack.ping_external_urls(source_url, self.html(), index_url)
Exemple #4
0
def index(request):
    if 'application/xrds+xml' in request.META.get('HTTP_ACCEPT', ''):
        return response(request, 'cicero/yadis.xml', {
            'return_to': absolute_url(reverse(auth)),
        }, content_type='application/xrds+xml')
    return response(request, 'cicero/forum_list.html', {
        'object_list': Forum.objects.all(),
        'page_id': 'index',
    })
Exemple #5
0
def index(request):
    if 'application/xrds+xml' in request.META.get('HTTP_ACCEPT', ''):
        return response(request, 'cicero/yadis.xml', {
            'return_to': absolute_url(reverse(auth)),
        }, content_type='application/xrds+xml')
    return response(request, 'cicero/forum_list.html', {
        'object_list': Forum.objects.all(),
        'page_id': 'index',
    })
Exemple #6
0
def articles_list(request, *args, **kwargs):
    if 'application/xrds+xml' in request.META.get('HTTP_ACCEPT', ''):
        return render_to_response(request,
                                  'cicero/yadis.xml', {
                                      'return_to': absolute_url(reverse(auth)),
                                  },
                                  mimetype='application/xrds+xml')

    kwargs['extra_context'] = {'groups': _get_left_side_cont()}

    return object_list(request, *args, **kwargs)
Exemple #7
0
 def get_params(self, request, article, **kwargs):
     text = article.text
     if article.topic.article_set.count() == 1: # new topic
         text = article.topic.subject + '\n' + text
     try:
         openid = article.author.user.scipio_profile.openid
     except ScipioProfile.DoesNotExist:
         openid = ''
     return {
         'blog': utils.absolute_url(reverse('cicero_index')),
         'user_ip': article.ip,
         'permalink': utils.absolute_url(reverse(
             'cicero.views.topic',
             args=[article.topic.forum.slug, article.topic.id],
         )),
         'comment_type': 'post',
         'comment_author': smart_str(article.from_guest() and article.guest_name or article.author),
         'comment_author_url': smart_str(openid),
         'comment_content': smart_str(text),
     }
Exemple #8
0
    def ping_external_links(self):
        '''
        Пингование внешних ссылок через Pingback
        (http://www.hixie.ch/specs/pingback/pingback)
        '''
        domain = Site.objects.get_current().domain
        index_url = reverse('cicero_index')
        topic_url = utils.absolute_url(
            reverse('cicero.views.topic',
                    args=(self.topic.forum.slug, self.topic.id)))

        def is_external(url):
            scheme, server, path, query, fragment = urlsplit(url)
            return server != '' and \
                   (server != domain or not path.startswith(index_url))

        def search_link(content):
            match = re.search(r'<link rel="pingback" href="([^"]+)" ?/?>',
                              content)
            return match and match.group(1)

        soup = BeautifulSoup(self.html())
        links = (a['href'] for a in soup.findAll('a')
                 if is_external(a['href']))
        links = (l.encode('utf-8') for l in links)
        for link in links:
            try:
                f = urlopen(link)
                try:
                    info = f.info()
                    server_url = info.get('X-Pingback', '') or \
                                              search_link(f.read(512 * 1024))
                    if server_url:
                        server = ServerProxy(server_url)
                        server.pingback.ping(topic_url, link)
                finally:
                    f.close()
            except (IOError, Fault, ProtocolError, ResponseError, ExpatError):
                pass