Commits

Sergio Berlotto committed 3b57505

Correcao link categorias

  • Participants
  • Parent commits ce622fc

Comments (0)

Files changed (11)

File berlotto.db

Binary file modified.
 photos = flickr.photos_search(user_id='51882400@N00', per_page=2)
 
 for photo in photos[0]:
-	print photo.attrib['title']
-	photoSizes = flickr.photos_getSizes(photo_id=photo.attrib['id'])
-	
-	print 'Thumb'
-	print photoSizes[0][2].attrib['source']
-	print photoSizes[0][2].attrib['url']
-	print photoSizes[0][2].attrib['height']
-	
-	print 'Maior'
-	print photoSizes[0][-1:][0].attrib['source']
-	print photoSizes[0][-1:][0].attrib['url']
-	print photoSizes[0][-1:][0].attrib['height']
-	
-	print 
+        
+        print photo.attrib['title']
+        photoSizes = flickr.photos_getSizes(photo_id=photo.attrib['id'])
+        
+        print 'Thumb'
+        print photoSizes[0][2].attrib['source']
+        print photoSizes[0][2].attrib['url']
+        print photoSizes[0][2].attrib['height']
+        
+        print 'Maior'
+        print photoSizes[0][-1:][0].attrib['source']
+        print photoSizes[0][-1:][0].attrib['url']
+        print photoSizes[0][-1:][0].attrib['height']
+        
+        print 
+
+
 
 
 #Lista todas as galerias do Flickr
 sets = flickr.photosets_getList(user_id='51882400@N00', per_page=2)
 
 for galeria in sets[0]:
-	#imprime o titulo e descricao da galeria
-	for i in galeria:
-		print i.text
-	#imprime o link da galeria
-	print "http://www.flickr.com/photos/%s/sets/%s/" % (flickr_username, galeria.get('id'))
-	#busca a foto que é a capa da galeria
-	lista = flickr.photosets_getPhotos(photoset_id=galeria.get('id'))
-	for p in lista[0]:
-		if p.get('isprimary') == "1":
-			print ' Capa: ' + p.get('title')
-			sizes = flickr.photos_getSizes(photo_id=p.get('id'))
-			print sizes[0][2].attrib['source']
-		
-	print
-	
-	
+    #imprime o titulo e descricao da galeria
+    for i in galeria:
+        print i.text
+    #imprime o link da galeria
+    print "http://www.flickr.com/photos/%s/sets/%s/" % (flickr_username, galeria.get('id'))
+    #busca a foto que é a capa da galeria
+    lista = flickr.photosets_getPhotos(photoset_id=galeria.get('id'))
+    for p in lista[0]:
+        if p.get('isprimary') == "1":
+            print ' Capa: ' + p.get('title')
+            sizes = flickr.photos_getSizes(photo_id=p.get('id'))
+            print sizes[0][2].attrib['source']
+        
+    print
+    
+    
 TWITTER_USERNAME = 'berlottocdd'
 TWITTER_PASSWORD = "j8716u71"
 
+FLICKR_API_KEY = '57cea56064891f6d58219f6505710454'
+FLICKR_USERNAME = 'berlotto'
+FLICKR_USER_ID = '51882400@N00'
+
 # Blog Name
 BLOG_NAME = 'berlotto.net'
 

File settings.pyc

Binary file modified.

File templates/_base.html

     <script type="text/javascript" src="/static/fancy/helpers/jquery.fancybox-buttons.js?v=2.0.5"></script>
     <link rel="stylesheet" media="print" type="text/css" href="/static/fancy/helpers/jquery.fancybox-buttons.css?v=2.0.5" />
 
-
-    <!-- sharethis -->
-    <script type="text/javascript">var switchTo5x=true;</script>
-    <script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
-    <script type="text/javascript" src="http://s.sharethis.com/loader.js"></script>
-    <!-- sharethis -->
-
     <script type="text/javascript" src="/static/megamenu/jquery.megamenu.js"></script>
 
     <script type="text/javascript">
   </script>
   {% block script_footer %}{% endblock %}
 
-<!-- sharethis -->
-<script>
-var options={ "publisher": "bb630386-23a2-412f-a837-6d8b4eaf39f3", "position": "left", "ad": { "visible": false, "openDelay": 5, "closeDelay": 0}, "chicklets": { "items": ["googleplus", "facebook", "twitter", "identi", "linkedin", "digg", "pinterest", "email"]}};
-var st_hover_widget = new sharethis.widgets.hoverbuttons(options);
-</script>
-<!-- sharethis -->
-
 <div id="banner_right">
 {% include "banner_right.html"%}
 </div>

File templates/menubar.html

 <li><a href="/">Início</a></li>
 <li><a href="/blog">Blog</a> 
-<li><a href="/blog/gallery/list">Fotos</a></li> 
+<li><a href="/fotos">Fotos</a></li>
+<li><a href="/blog/gallery/list">Fotoss</a></li> 
 <li>
  <a href="/livro">Livro</a>
  <div style="width: 250px;">

File templates/sidebar.html

             <h3> Categorias</h3>
             <ul class='cetegorias'> 
               {% for cat in categories %}
-              <li><a href="{{ ROOT_URL }}/{{ cat.get_absolute_url }}">{{ cat }}</a></li>
+              <li><a href="/{{ cat.get_absolute_url }}">{{ cat }}</a></li>
               {% endfor %}
             </ul>
             <hr />

File website/urls.py

 from django.conf.urls.defaults import *
 
 urlpatterns = patterns('',
-    
-    (r'^$','website.views.index'),
-    (r'^livro/$','website.views.livro'),
-    (r'^leia/$','website.views.leia'),
-    (r'^contatos/$','website.views.contatos'),
-    (r'^feed/$','website.views.feed'),
-    
+
+    (r'^$', 'website.views.index'),
+    (r'^livro/$', 'website.views.livro'),
+    (r'^leia/$', 'website.views.leia'),
+    (r'^contatos/$', 'website.views.contatos'),
+    (r'^feed/$', 'website.views.feed'),
+    (r'^fotos/$', 'website.views.fotos'),
+    (r'^fotos/(?P<galeriaid>[-\w]+)/$', 'website.views.fotos_galeria'),
+
 )

File website/urls.pyc

Binary file modified.

File website/views.py

-# Create your views here.
+# -*- coding: utf-8 -*-
 from django.http import HttpResponse
 from django.shortcuts import render_to_response
 from django.template import RequestContext
+from django.conf import settings
+import flickrapi
 
 from models import News
 
+
 def index(request):
     if 'allnews' in request.GET:
         noticias = News.objects.all().order_by('-datetime')
     else:
         noticias = News.objects.all().order_by('-datetime')[:6]
 
-    return render_to_response('website/index.html',{'entries':noticias},context_instance=RequestContext(request))
-    
+    return render_to_response('website/index.html',{'entries':noticias}, 
+    context_instance=RequestContext(request))
+
+
 def livro(request):
     #noticias = News.objects.filter(categoria='LIVRO').order_by('-datetime')
-    return render_to_response('website/livro.html',context_instance=RequestContext(request))
+    return render_to_response('website/livro.html', 
+        context_instance=RequestContext(request))
+
 
 def leia(request):
-    return render_to_response('website/leia.html',context_instance=RequestContext(request))
+    return render_to_response('website/leia.html',
+        context_instance=RequestContext(request))
+
 
 def contatos(request):
-    return render_to_response('website/contatos.html',context_instance=RequestContext(request))
+    return render_to_response('website/contatos.html',
+        context_instance=RequestContext(request))
+
 
 def feed(request):
-    return render_to_response('website/feed.html',context_instance=RequestContext(request))
+    return render_to_response('website/feed.html',
+        context_instance=RequestContext(request))
+
+
+def fotos(request):
+    flickr = flickrapi.FlickrAPI(settings.FLICKR_API_KEY, cache=True)
+
+    #Lista todas as galerias do Flickr
+    sets = flickr.photosets_getList(user_id=settings.FLICKR_USER_ID)
+
+    galerias = []
+    for galeria in sets[0]:
+        obj = {}
+        #imprime o titulo e descricao da galeria
+        #for i in galeria:
+        #    print i.text
+        #imprime o link da galeria
+        #obj['link'] = "http://www.flickr.com/photos/%s/sets/%s/" % 
+        #      (settings.FLICKR_USERNAME, galeria.get('id'))
+        obj['link'] = '/fotos/%s/' % galeria.get('id')
+        #busca a foto que é a capa da galeria
+        obj['id'] = galeria.get('id')
+        #lista = flickr.photosets_getPhotos(photoset_id=galeria.get('id'))
+        capa = {}
+        obj['title'] = galeria[0].text
+        obj['description'] = galeria[1].text
+
+        sizes = flickr.photos_getSizes(photo_id=galeria.get('primary'))
+        obj['capa_src'] = sizes[0][2].attrib['source']
+
+        #print galeria.keys()
+        galerias.append(obj)
+    return render_to_response('website/gallery_list.html', {'galerias': galerias},
+                              context_instance=RequestContext(request))
+
+
+def fotos_galeria(request, galeriaid):
+    fotos = []
+    flickr = flickrapi.FlickrAPI(settings.FLICKR_API_KEY, cache=True)
+    # sets = flickrapi.photosets.photosets_getPhotos(api_key=settings.FLICKR_API_KEY, photoset_id=galeriaid)
+    galeria = flickr.photosets_getInfo(api_key=settings.FLICKR_API_KEY,photoset_id=galeriaid)
+    gal = {}
+    gal['title'] = galeria[0][0].text
+    gal['description'] = galeria[0][1].text
+    gal['photos'] = galeria[0].get('count_photos')
+    gal['videos'] = galeria[0].get('count_videos')
+    for foto in flickr.walk_set(galeriaid):
+        f = {}
+        f['id'] = foto.get('id')
+        f['title'] = foto.get('title')
+        sizes = flickr.photos_getSizes(photo_id=foto.get('id'))
+        for size in sizes[0]:
+            print size.get('label')
+            if size.get('label') == 'Large':
+                f['normal'] = size.attrib['source']
+            if size.get('label') == 'Thumbnail':
+                f['thumb'] = size.attrib['source']
+        fotos.append(f)
+    return render_to_response('website/gallery_list.html', {'fotos': fotos, 'galeria':gal},
+                              context_instance=RequestContext(request))

File website/views.pyc

Binary file modified.