Commits

Sergio Berlotto  committed 2ca9b60

Nova versao do site

  • Participants
  • Parent commits 9421dae

Comments (0)

Files changed (560)

File __init__.pyc

Binary file added.

File berlotto.db

Binary file added.

File django_yaba/__init__.py

+import os
+from django.conf import settings
+
+PROJECT_DIR = os.path.dirname(__file__)
+if settings.MEDIA_ROOT is None:
+    settings.MEDIA_ROOT = os.path.join(PROJECT_DIR, "media")
+
+settings.TEMPLATE_DIRS += (
+    os.path.join(PROJECT_DIR, "templates"),
+    )

File django_yaba/__init__.pyc

Binary file added.

File django_yaba/admin.py

+from django.contrib import admin
+from django_yaba import forms
+from django_yaba.models import *
+
+class PhotoInline(admin.StackedInline):
+    model = Photo
+    extra = 10
+
+class ItemAdmin(admin.ModelAdmin):
+    inlines = [PhotoInline]
+
+class ThemeAdmin(admin.ModelAdmin):
+    prepopulated_fields = {'slug': ('title',)}
+
+class ConfigurationAdmin(admin.ModelAdmin):
+    prepopulated_fields = {'slug': ('title',)}
+
+class GalleryAdmin(admin.ModelAdmin):
+    prepopulated_fields = {'slug': ('title',)}
+    inlines = [PhotoInline]
+    form = forms.GalleryAdminForm
+
+class CategoryAdmin(admin.ModelAdmin):
+    prepopulated_fields = {'slug': ('label',)}
+
+class LinksAdmin(admin.ModelAdmin):
+    prepopulated_fields = {'slug': ('label',)}
+    list_filter = ('label', 'site_link')
+    search_fields = ('label', 'site_link')
+
+class StoryAdmin(admin.ModelAdmin):
+    list_display = ('title', 'owner', 'status', 'created', 'modified')
+    search_fields = ('title', 'content')
+    list_filter = ('status', 'owner', 'created', 'modified')
+    prepopulated_fields = {'slug': ('title',)}
+    form = forms.StoryAdminForm
+
+    class Media:
+        js = ('/static/tiny_mce/tiny_mce.js','/static/js/textareas_admin.js')
+
+class ArticleAdmin(admin.ModelAdmin):
+    list_display = ('title', 'owner', 'status', 'created', 'modified')
+    search_fields = ('title', 'content')
+    list_filter = ('status', 'owner', 'created', 'modified')
+    prepopulated_fields = {'slug': ('title',)}
+    form = forms.ArticleAdminForm
+
+    class Media:
+        js = ('/static/tiny_mce/tiny_mce.js','/static/js/textareas_admin.js')
+
+#admin.site.register(Story, StoryAdmin)
+admin.site.register(Category, CategoryAdmin)
+admin.site.register(Links, LinksAdmin)
+admin.site.register(Article, ArticleAdmin)
+admin.site.register(Gallery, GalleryAdmin)
+#admin.site.register(Theme, ThemeAdmin)
+admin.site.register(Configuration, ConfigurationAdmin)

File django_yaba/admin.pyc

Binary file added.

File django_yaba/feeds.py

+from django.conf import settings
+from django.contrib.syndication.feeds import Feed
+from django_yaba.models import Story, Article
+from django_yaba.multiquery import MultiQuerySet
+from website.models import News
+
+class RSSFeed(Feed):
+    title = settings.BLOG_NAME
+    description = "Recent Posts and News"
+    link = settings.ROOT_BLOG_URL
+
+    item_author_name='Sérgio Berlotto'
+    item_author_email='sergio.berlotto@gmail.com'
+    item_author_link=link
+
+    def items(self):
+        articles = Article.objects.all().order_by('-created')[:10]
+        stories = Story.objects.all().order_by('-created')[:10]
+        news = News.objects.all().order_by('-datetime')[:10]
+        its = MultiQuerySet(stories, articles, news)
+        return its
+    

File django_yaba/feeds.pyc

Binary file added.

File django_yaba/fields.py

+from django.db.models.fields.files import ImageField, ImageFieldFile
+from PIL import Image
+import os
+
+def _add_thumb(s):
+    """
+    Modifies a sting containing an image filename to insert .thumb before the extension
+    """
+    parts = s.split(".")
+    parts.insert(-1, "thumb")
+    if parts[-1].lower() not in ['jpeg', 'jpg']:
+        parts[-1] = 'jpg'
+
+    return ".".join(parts)
+
+class ThumbnailImageFieldFile(ImageFieldFile):
+    def _get_thumb_path(self):
+        return _add_thumb(self.path)
+    thumb_path = property(_get_thumb_path)
+
+    def _get_thumb_url(self):
+        return _add_thumb(self.url)
+    thumb_url = property(_get_thumb_url)
+
+    def save(self, name, content, save=True):
+        super(ThumbnailImageFieldFile, self).save(name, content, save)
+        img = Image.open(self.path)
+        img.thumbnail(
+            (self.field.thumb_width, self.field.thumb_height),
+            Image.ANTIALIAS
+        )
+        img.save(self.thumb_path, 'JPEG')
+
+    def delete(self, save=True):
+        if os.path.exists(self.thumb_path):
+            os.remove(self.thumb_path)
+        super(ThumbnailImageFieldFile, self).delete(save)
+
+class ThumbnailImageField(ImageField):
+    attr_class = ThumbnailImageFieldFile
+
+    def __init__(self, thumb_width=128, thumb_height=128, *args, **kwargs):
+        self.thumb_width = thumb_width
+        self.thumb_height = thumb_height
+        super(ThumbnailImageField, self).__init__(*args, **kwargs)
+

File django_yaba/fields.pyc

Binary file added.

File django_yaba/forms.py

+from django import forms
+from django.db.models import get_model
+from django_yaba import widgets
+
+class StoryAdminForm(forms.ModelForm):
+    body=forms.CharField(widget=widgets.TinyMCEWidget())
+
+    class Meta:
+        model = get_model('django_yaba', 'story')
+
+class ArticleAdminForm(forms.ModelForm):
+    body=forms.CharField(widget=widgets.TinyMCEWidget())
+
+    class Meta:
+        model = get_model('django_yaba', 'article')
+
+class GalleryAdminForm(forms.ModelForm):
+    body=forms.CharField(widget=widgets.TinyMCEWidget())
+
+    class Meta:
+        model = get_model('django_yaba', 'gallery')
+

File django_yaba/forms.pyc

Binary file added.

File django_yaba/models.py

+import datetime, urllib, re, twitter
+from tagging.fields import TagField
+from tagging.models import Tag
+from django.contrib.comments.moderation import CommentModerator, moderator
+from django.conf import settings
+from django.db.models.signals import post_save, pre_save
+from django.db.models import permalink
+from django_yaba.fields import ThumbnailImageField
+from django.contrib.auth.models import User
+from django.db import models
+
+VIEWABLE_STATUS = [3, 4]
+
+class ViewableManager(models.Manager):
+    def get_query_set(self):
+        default_queryset = super(ViewableManager, self).get_query_set()
+        return default_queryset.filter(status__in=VIEWABLE_STATUS)
+
+class Theme(models.Model):
+    """
+    Users will currently need to upload their own themes to /media/themes/ 
+    and then add them via the admin panel
+    """
+    title = models.CharField(max_length=50)
+    slug = models.SlugField()
+     
+    class Meta:
+        ordering = ['title']
+
+    def __unicode__(self):
+        return self.title
+
+class Configuration(models.Model):
+    """
+    General configuration stuff via the admin panel. Currently just handles 
+    themes
+    """
+    title = models.CharField(max_length=50, default="Main Site")
+    slug = models.SlugField(default="main-site")
+    theme = models.ForeignKey(Theme)
+
+    def __unicode__(self):
+        return self.title
+
+class Category(models.Model):
+    """
+    Categories for the Content that is Submitted
+    """
+    label = models.CharField(blank=True, max_length=50)
+    slug = models.SlugField()
+
+    class Meta:
+        ordering = ['label']
+        verbose_name_plural = "categories"
+
+    def __unicode__(self):
+        return self.label
+  
+    @permalink
+    def get_absolute_url(self):
+        return ("blog-category", (), {'slug' : self.slug})
+
+class Links(models.Model):
+    """
+    A model for links to other sites
+    """
+    label = models.CharField(max_length=100)
+    site_link = models.CharField(max_length=300)
+    slug = models.SlugField()
+
+    class Meta:
+        ordering = ['label']
+        verbose_name_plural = "links"
+
+    def __unicode__(self):
+        return self.label
+
+
+class Story(models.Model):
+    """
+    Status Choices dictate whether or not an article can be seen by the general
+    public. Only Published and Archived will be displayed.
+    """
+
+    STATUS_CHOICES = (
+        (1, "Needs Edit"),
+        (2, "Needs Approval"),
+        (3, "Published"),
+        (4, "Archived"),
+    )
+
+    title = models.CharField(max_length=50)
+    slug = models.SlugField()
+    category = models.ManyToManyField(Category)
+    body = models.TextField()
+    owner = models.ForeignKey(User)
+    status = models.IntegerField(choices=STATUS_CHOICES, default=1)
+    created = models.DateTimeField(default=datetime.datetime.now)
+    modified = models.DateTimeField(default=datetime.datetime.now)
+    tweet_this = models.BooleanField()
+    enable_comments = models.BooleanField(default=True)
+    tags = TagField()
+
+    def set_tags(self, tags):
+        Tag.objects.update_tags(self, tags)
+
+    def get_tags(self):
+        return Tag.objects.get_for_object(self) 
+
+    class Meta:
+        ordering = ['-modified']
+        verbose_name_plural = "stories"
+
+    def __unicode__(self):
+        return self.title
+
+    @permalink
+    def get_absolute_url(self):
+        return ("blog-story", (), {'slug' : self.slug})
+
+    admin_objects = models.Manager()
+    objects = ViewableManager()
+
+class Article(models.Model):
+    """ 
+    Articles are a bit different from Stories. These are 'extra' content 
+    pieces. For instance items that don't belong as news, maybe like a 
+    projects page of sorts. 
+
+    By setting 'buttoned' to true in the admin panel, the buttons on the top 
+    nav bar will link to this page, and the text will be the title of this page
+    """
+
+    STATUS_CHOICES = (
+        (1, "Needs Edit"),
+        (2, "Needs Approval"),
+        (3, "Published"),
+        (4, "Archived"),
+    )
+
+    title = models.CharField(blank=True, max_length=50)
+    slug = models.SlugField()
+    category = models.ManyToManyField(Category)
+    body = models.TextField()
+    owner = models.ForeignKey(User)
+    status = models.IntegerField(choices=STATUS_CHOICES, default=1)
+    buttoned = models.BooleanField()
+    created = models.DateTimeField(default=datetime.datetime.now)
+    modified = models.DateTimeField(default=datetime.datetime.now)
+    tweet_this = models.BooleanField()
+    enable_comments = models.BooleanField(default=True)
+    tags = TagField()
+
+    def set_tags(self, tags):
+        Tag.objects.update_tags(self, tags)
+
+    def get_tags(self):
+        return Tag.objects.get_for_object(self)
+
+    class Meta:
+        ordering = ['modified']
+        verbose_name_plural = "articles"
+
+    def __unicode__(self):
+        return self.title
+
+    @permalink
+    def get_absolute_url(self):
+        return ("blog-article", (), {'slug' : self.slug})
+
+    admin_objects = models.Manager()
+    objects = ViewableManager()
+
+class Gallery(models.Model):
+    title = models.CharField(max_length=250)
+    slug = models.SlugField()
+    created = models.DateTimeField(default=datetime.datetime.now)
+    modified = models.DateTimeField(default=datetime.datetime.now)
+    body = models.TextField()
+    owner = models.ForeignKey(User)
+    category = models.ManyToManyField(Category)
+    enable_comments = models.BooleanField(default=True)
+    tags = TagField()
+
+    def set_tags(self, tags):
+        Tag.objects.update_tags(self, tags)
+
+    def get_tags(self):
+        return Tag.objects.get_for_object(self)
+
+    class Meta:
+        ordering = ["created"]
+        verbose_name_plural = "galleries"
+
+    def __unicode__(self):
+        return self.title
+
+    @permalink
+    def get_absolute_url(self):
+        return ("blog-gallery", (), {'slug': self.slug})
+
+class Item(models.Model):
+    name = models.CharField(max_length=250)
+    description = models.TextField()
+
+    class Meta:
+        ordering = ['name']
+
+    def __unicode__(self):
+        return self.name
+
+    @permalink
+    def get_absolute_url(self):
+        return ('item_detail', None, {'object_id' : self.id})
+
+class Photo(models.Model):
+    gallery = models.ForeignKey(Gallery)
+    title = models.CharField(max_length=100)
+    image = ThumbnailImageField(upload_to='gallery/photos')
+    caption = models.CharField(max_length=250, blank=True)
+
+    class Meta:
+        ordering = ['title']
+
+    def __unicode__(self):
+        return self.title
+
+    @permalink
+    def get_absolute_url(self):
+        return ('photo_detail', None, {'object_id' : self.id})
+
+def tiny_url(url):
+    apiurl = "http://tinyurl.com/api-create.php?url="
+    tinyurl = urllib.urlopen(apiurl + url).read()
+    return tinyurl
+
+def content_tiny_url(content):
+
+    regex_url = r'http:\/\/([\w.]+\/?)\S*'
+    for match in re.finditer(regex_url, content):
+        url = match.group(0)
+        content = content.replace(url,tiny_url(url))
+
+    return content
+
+def post_tweet(sender, instance, created, **kwargs):
+    if created:
+        if instance.tweet_this:
+            try:
+                if settings.TWITTER_USERNAME and settings.TWITTER_PASSWORD:
+                    url = content_tiny_url("%s/%s" % (settings.ROOT_BLOG_URL,
+                        instance.get_absolute_url()))
+                    api = twitter.Api(username = settings.TWITTER_USERNAME, 
+                        password = settings.TWITTER_PASSWORD)
+                    api.PostUpdate("New blog post - %s" % url)
+            except:
+                pass
+
+def config_name(sender, instance, created, **kwargs):
+    if created:
+        temp = Configuration.objects.all()
+        if temp.count() > 2:
+            raise Exception(
+                "There can only be one configuration entry, \
+                thus only one theme. Sorry!")     
+
+class PostModerator(CommentModerator):
+    email_notification = True
+    enable_field = 'enable_comments'
+
+try:
+    moderator.register(Story, PostModerator)
+    moderator.register(Article, PostModerator)
+    moderator.register(Gallery, PostModerator)
+
+    post_save.connect(config_name, sender=Configuration)
+    post_save.connect(post_tweet, sender=Article)
+    post_save.connect(post_tweet, sender=Story)
+except:
+    pass

File django_yaba/models.pyc

Binary file added.

File django_yaba/multiquery.py

+class MultiQuerySet(object):
+    def __init__(self, *args, **kwargs):
+        self.querysets = args
+        self._count = None
+    
+    def _clone(self):
+        querysets = [qs._clone() for qs in self.querysets]
+        return MultiQuerySet(*querysets)
+    
+    def __repr__(self):
+        return repr(list(self.querysets))
+                
+    def count(self):
+        if not self._count:
+            self._count = sum([qs.count() for qs in self.querysets])
+        return self._count
+    
+    def __len__(self):
+        return self.count()
+    
+    def __iter__(self):
+        for qs in self.querysets:
+            for item in qs.all():
+                yield item
+
+    def __getitem__(self, item):
+        indices = (offset, stop, step) = item.indices(self.count())
+        items = []
+        total_len = stop - offset
+        for qs in self.querysets:
+            if len(qs) < offset:
+                offset -= len(qs)
+            else:
+                items += list(qs[offset:stop])
+                if len(items) >= total_len:
+                    return items
+                else:
+                    offset = 0
+                    stop = total_len - len(items)
+                    continue
+

File django_yaba/multiquery.pyc

Binary file added.

File django_yaba/templates/blog/REM_story_detail.html

+{% extends "_base.html" %}
+<!-- start main content -->
+{% block content %}
+<div class="postbox">
+<div id="story-title-{{ posts.id }}" class="span-6 first">
+  <h2>{{ posts.title }}</h2>
+</div>
+<div id="story-body-{{ posts.id }}" class="span-18 last">
+  {{ posts.body|safe }}
+  <hr />
+  <p class="small">Updated {{ posts.modified|date:"m/d/y @ h:iA T" }} by {{ posts.owner }}</p>
+  <p class="story_cat"><u>Categories</u>:
+   {% for x in posts.category.all %}<a href="{{ x.get_absolute_url }}">{{ x }}</a> {% endfor %}
+    </p>
+    <!-- start tags -->
+     <p><u>Tags</u>: {% for tag in posts.get_tags %}
+     <a href="/tags/{{ tag }}">{{ tag }}</a>
+  {% endfor %}</p>
+  <!-- end tags -->
+  <hr />
+         <!-- start social media -->
+         <div class="social">
+           <span>Compartilhe:</span>
+           <a href="http://www.facebook.com/sharer.php?u={{ ROOT_URL }}{{ post.get_absolute_url }}" target="_blank"><img src="{{ MEDIA_URL }}images/facebook.png" alt="Facebook" title="Compartilhar no facebook" ></img></a>
+           <a href="http://twitter.com/share?url={{ ROOT_URL }}{{ post.get_absolute_url }}&amp;ang=pt&amp;text={{ post.title|urlencode }}" target="_blank"><img src="{{ MEDIA_URL }}images/twitter.png" alt="Twitter" title="Twitt this!" ></img></a>
+           <a href="http://reddit.com/submit?url={{ ROOT_URL }}{{ post.get_absolute_url }}&amp;title={{ post.title|urlencode }}"><img src="{{ MEDIA_URL }}images/reddit.gif" alt="Reddit" ></img></a>
+           <a href="http://digg.com/submit?phase=2amp;url={{ ROOT_URL }}{{ post.get_absolute_url }}"><img src="{{ MEDIA_URL }}images/digg.gif" alt="Digg it!" ></img></a>
+           <a href="http://www.stumbleupon.com/submit?url={{ ROOT_URL }}{{ post.get_absolute_url }}&amp;title={{ post.title|urlencode }}"><img src="{{ MEDIA_URL }}images/stumble-upon.jpg" alt="StumbleUpon" ></img></a>
+           <a href="http://del.icio.us/post?url={{ ROOT_URL }}{{ post.get_absolute_url }}&amp;title={{ post.title|urlencode }}"><img src="{{ MEDIA_URL }}images/delicious.gif" alt="Delicious!" ></img></a>
+         </div>
+         <!-- stop social media -->
+  <!-- start comments -->
+{% if posts.enable_comments %}
+</div>
+</div>
+{% load get_setting %}
+{% get_setting "DJANGO_COMMENTS" "django_comments" %}
+  {% if django_comments %}
+    {% load comments %}
+    {% get_comment_list for posts as post_comments %}
+    {% for comment in post_comments %}
+      {{ comment }}
+    {% endfor %}
+    {% render_comment_form for posts %} 
+  {% else %}
+    {% load disqus_tags %}
+    {% disqus_show_comments %}
+  {% endif %}
+{% endif %}
+  <!-- end comments -->
+{% endblock %}
+<!-- end main content -->

File django_yaba/templates/blog/REM_story_search.html

+{% extends "_base.html" %}
+<!-- start main content -->
+{% block content %}
+    {% if heading %}
+        <h1>{{ heading }}</h1>
+    {% else %}
+    {% endif %}
+<!-- start blog posts results -->
+{% if posts %}
+    {% for post in posts.object_list %}
+<div class="postbox postlistaitem">
+   <div id="story-title-{{ post.id }}" class="span-6">
+        <h2><a href="{{ post.get_absolute_url }}">{{ post.title }} {{post.name }}</a></h2>
+          <div class="small">
+           Autor:{{ post.owner }}, em {{ post.modified|date:"d/m/y" }}, as {{ post.modified|date:"H:i" }}, em 
+           {% for x in post.category.all %}<a href="{{ x.get_absolute_url }}">{{ x }}</a> {% endfor %}
+          </div>
+       </div>
+       <div id="story-body-{{ post.id }}" class="span-18">
+         <div class="small">Updated {{ post.modified|date:"m/d/y @ h:iA T" }} by {{post.owner}}</div>
+         <div class="story_cat"><u>Categories</u>: 
+         {% for x in post.category.all %}<a href="{{ x.get_absolute_url }}">{{ x }}</a> {% endfor %}
+         </div>
+         <!-- start tags -->
+         <div><u>Tags</u>: {% for tag in post.get_tags %}
+         <a href="/tags/{{ tag }}">{{ tag }}</a>
+         {% endfor %}</div>
+         <!-- end tags -->
+       </div>
+       <hr />
+<!-- stop blog post results -->
+    {% endfor %}
+    <!-- start pagination -->
+    <div class="pagination">
+        <span class="step-links">
+        {% if posts.has_previous %}<a href="?page={{ posts.previous_page_number }}" class="util-link">previous</a>{% endif %}
+        {% if posts.has_next %}<a href="?page={{ posts.next_page_number }}" class="util-link">next</a>{% endif %}
+        </span>
+             <h2>Page {{ posts.number }} of {{ posts.paginator.num_pages }}</h2>
+    <!-- end pagination -->
+    </div>
+</div>
+{% else %}
+	<p>N&Atilde;o existem resultados para o crit&eacude;io.</p>
+{% endif %}
+
+{% endblock %}
+<!-- end main content -->

File django_yaba/templates/blog/article_detail.html

+{% extends "_base.html" %}
+<!-- start main content -->
+{% block content %}
+{% if posts %}
+ <div class="postbox postlistaitem">
+       <div id="story-title-{{ forloop.counter }}" class="span-6">
+        <h2><a href="{{ posts.get_absolute_url }}">{{ posts.title }}</a></h2>
+          <div class="small">
+           Autor:{{ posts.owner.get_full_name }}, em {{ posts.modified|date:"d/m/y" }}, as {{ posts.modified|date:"H:i" }}, em
+           {% for x in posts.category.all %}<a href="{{ x.get_absolute_url }}">{{ x }}</a> {% endfor %}
+          </div>
+       </div>
+       <div id="story-body-{{ forloop.counter }}" class="span-18">
+         <div class='postbody'>
+         {{ posts.body|safe }}
+         </div>
+         <!-- start tags -->
+         {% if posts.get_tags|length > 0 %}
+             <div class="tags"><u>Tags</u>:
+           {% for tag in posts.get_tags %}
+             <a href="/tags/{{ tag }}">{{ tag }}</a>
+           {% endfor %}
+             </div>
+         {% endif %}
+         <!-- end tags -->
+      </div>
+      </div>
+  <!-- start comments -->
+{% if posts.enable_comments %}
+{% load get_setting %}
+{% get_setting "DJANGO_COMMENTS" "django_comments" %}
+  {% if django_comments %}
+    {% load comments %}
+    {% get_comment_list for posts as post_comments %}
+    {% for comment in post_comments %}
+      {{ comment }}
+    {% endfor %}
+    {% render_comment_form for posts %} 
+  {% else %}
+    {% load disqus_tags %}
+    {% disqus_show_comments %}
+  {% endif %}
+{% endif %}
+  <!-- end comments -->
+{% else %}
+<p> Sorry, nothing seems to exist here. Please try one of the many other links instead</p>
+{% endif %}
+{% endblock %}
+<!-- end main content -->
+

File django_yaba/templates/blog/gallery.html

+{% extends "_base.html" %}
+<!-- start main content -->
+{% block content %}
+{% if gallery %}
+<div class="postbox">
+<div id="story-name-{{ gallery.id }}" class="span-6 first">
+  <p class="story_name"><h2>{{ gallery.title }}</h2></p>
+  <hr />
+</div>
+<div id="story-body-{{ gallery.id }}" class="span-18 last">
+  {{ gallery.body|safe }}
+  <br>
+  <br>
+       {% for photo in gallery.photo_set.all %}
+       
+       <a href="{{ MEDIA_URL }}{{ photo.image }}" class='fancybox' rel='grupo{{ gallery.id }}' title='{{ photo.title }}'> 
+       <img src="{{ photo.image.thumb_url }}" alt="" title="{{ photo.title }}" />
+       <span class='photo_desc'>{{photo.caption}}</span>
+       </a>
+       
+       {% if forloop.last %}
+        </p>
+       {% endif %}
+     {% endfor %}
+  <hr />
+  <div class="small">Created {{ gallery.created|date:"m/d/y @ h:iA T" }} by {{ gallery.owner }}</div>
+  <div class="story_cat"><u>Categories</u>:
+   {% for x in gallery.category.all %}<a href="{{ x.get_absolute_url }}">{{ x }}</a> {% endfor %}
+  </div>
+  <!-- start tags -->
+  <div class="tags"><u>Tags</u>: {% for tag in gallery.get_tags %}
+   <a href="/tags/{{ tag }}">{{ tag }}</a>
+  {% endfor %}</div>
+  <!-- end tags -->
+  <hr />
+  <!-- start comments -->
+{% if gallery.enable_comments %}
+</div>
+</div>
+{% load get_setting %}
+{% get_setting "DJANGO_COMMENTS" "django_comments" %}
+  {% if django_comments %}
+    {% load comments %}
+    {% get_comment_list for gallery as post_comments %}
+    {% for comment in post_comments %}
+      {{ comment }}
+    {% endfor %}
+    {% render_comment_form for posts %} 
+  {% else %}
+    {% load disqus_tags %}
+    {% disqus_show_comments %}
+  {% endif %}
+{% endif %}
+  <!-- end comments -->
+<script type="text/javascript">
+	$(document).ready(function() {
+$(".fancybox").fancybox({
+    closeBtn        : false,
+        buttons : {
+            position: 'top'
+            },
+    helpers:  {
+        title : {
+            type : 'float'
+        },
+        overlay : {
+            css : {
+                'background-color' : '#fff'
+            }
+        }
+    }
+});
+	});
+</script>
+{% endif %}
+{% endblock %}
+<!-- end main content -->
+

File django_yaba/templates/blog/gallery_list.html

+{% extends "_base.html" %}
+{% load navbar %}
+<!-- start main content -->
+{% block content %}
+<div id="main-blog">
+    <h1>Galeria de Fotos {{ heading }}</h1>
+    {% for post in gallery.object_list %}
+
+		 <div class="gallery-img">
+            {% for photo in post.photo_set.all|slice:"1" %}
+                   <a href="{{ post.get_absolute_url }}" rel='grupo{{ post.id  }}' ><img src="{{ photo.image.thumb_url }}" alt="" title='Foto {{ post.id }}' /></a>
+            {% endfor %}
+                  <div class='gallery-img-desc'>{{ post.title|safe }}</div>
+		 </div>
+		 
+    {% endfor %}
+    <!-- start pagination -->
+</div>
+{% endblock %}
+<!-- end main content -->
+
+{% block side %}
+<div id="sidebar-blog">
+	{% sidebar %}
+</div>
+{% endblock %}

File django_yaba/templates/blog/gallery_list_bkp.html

+{% extends "_base.html" %}
+{% load navbar %}
+<!-- start main content -->
+{% block content %}
+<div id="main-blog">
+    {% if heading %}
+        <h1>{{ heading }}</h1>
+    {% endif %}
+    {% for post in gallery.object_list %}
+     <div class="postbox postlistaitem">
+       <div id="story-title-{{ post.id }}" class="span-6">
+        <h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
+		<div class="small"><strong>Data:</strong>{{ post.modified|date:"d/m/y" }} <strong>Hora:</strong>{{ post.modified|date:"H:i" }} <strong>Autor:</strong>{{post.owner}}</div>
+        <hr />
+       </div>
+       <div id="story-body-{{ post.id }}" class="span-18">
+		 <div class="gallery-index">
+            {% for photo in post.photo_set.all|slice:"1" %}
+                   <a href="{{ post.get_absolute_url }}" class='fancybox' rel='grupo{{ post.id  }}' ><img src="{{ photo.image.thumb_url }}" alt="" title='Foto {{ post.id }}' /></a>
+            {% endfor %}
+                  <p class='gallery-body'>{{ post.body|safe }}</p>
+		 </div>
+         <hr />
+         <div class="story_cat"><u>Categorias</u>: 
+         {% for x in post.category.all %}<a href="{{ x.get_absolute_url }}">{{ x }}</a> {% endfor %}
+         </div>
+
+         <!-- start comments -->
+         {% if post.enable_comments %}
+         <div class="comments">
+         {% load get_setting %}
+         {% get_setting "DJANGO_COMMENTS" "django_comments" %}
+         {% if django_comments %}
+           {% load comments %}
+           {% get_comment_count for post as post_count %}
+           <a href="{{ post.get_absolute_url }}">{{ post_count }} Comments</a>
+         {% else %}
+           {% load disqus_tags %}
+             <a href="{{ post.get_absolute_url }}#disqus_thread">View Comments</a>
+             {% disqus_num_replies %}
+         {% endif %}
+		 </div>
+         {% endif %}
+         <!-- end comments -->
+		 
+         <!-- start tags -->
+         <div class="tags"><u>Tags</u>: {% for tag in post.get_tags %}
+         <a href="/tags/{{ tag }}">{{ tag }}</a>
+         {% endfor %}</div>
+         <!-- end tags -->
+         <hr />
+         <!-- start social media -->
+         <div class="social">
+           <span>Compartilhe:</span>
+           <a href="http://www.facebook.com/sharer.php?u={{ ROOT_URL }}{{ post.get_absolute_url }}" target="_blank"><img src="{{ MEDIA_URL }}images/facebook.png" alt="Facebook" title="Compartilhar no facebook" ></img></a>
+           <a href="http://twitter.com/share?url={{ ROOT_URL }}{{ post.get_absolute_url }}&amp;ang=pt&amp;text={{ post.title|urlencode }}" target="_blank"><img src="{{ MEDIA_URL }}images/twitter.png" alt="Twitter" title="Twitt this!" ></img></a>
+           <a href="http://reddit.com/submit?url={{ ROOT_URL }}{{ post.get_absolute_url }}&amp;title={{ post.title|urlencode }}"><img src="{{ MEDIA_URL }}images/reddit.gif" alt="Reddit" ></img></a>
+           <a href="http://digg.com/submit?phase=2amp;url={{ ROOT_URL }}{{ post.get_absolute_url }}"><img src="{{ MEDIA_URL }}images/digg.gif" alt="Digg it!" ></img></a>
+           <a href="http://www.stumbleupon.com/submit?url={{ ROOT_URL }}{{ post.get_absolute_url }}&amp;title={{ post.title|urlencode }}"><img src="{{ MEDIA_URL }}images/stumble-upon.jpg" alt="StumbleUpon" ></img></a>
+           <a href="http://del.icio.us/post?url={{ ROOT_URL }}{{ post.get_absolute_url }}&amp;title={{ post.title|urlencode }}"><img src="{{ MEDIA_URL }}images/delicious.gif" alt="Delicious!" ></img></a>
+         </div>
+         <!-- stop social media -->
+       </div>
+       <hr />
+	</div>
+    {% endfor %}
+    <!-- start pagination -->
+    <div class="pagination">
+        <span class="step-links">
+        {% if gallery.has_previous %}<a href="?page={{ gallery.previous_page_number }}" class="util-link">previous</a>{% endif %}
+        {% if gallery.has_next %}<a href="?page={{ gallery.next_page_number }}" class="util-link">next</a>{% endif %}
+        </span>
+             <h3>Page {{ gallery.number }} of {{ gallery.paginator.num_pages }}</h3>
+    <!-- end pagination -->
+    </div>
+    <script type="text/javascript">
+	$(document).ready(function() {
+		$(".fancybox").fancybox();
+	});
+    </script>
+</div>
+{% endblock %}
+<!-- end main content -->
+
+{% block side %}
+<div id="sidebar-blog">
+	{% sidebar %}
+</div>
+{% endblock %}

File django_yaba/templates/blog/story_list.html

+{% extends "_base.html" %}
+
+<!-- start main content -->
+{% block content %}
+
+    {% if heading %}
+        <h1>{{ heading }}</h1>
+    {% endif %}
+    {% for post in posts.object_list %}
+      <div class="postbox postlistaitem">
+       <div id="story-title-{{ forloop.counter }}" class="span-6">
+        <h2><a href="{{ post.get_absolute_url }}">{{ post.title }}</a></h2>
+          <div class="small">
+           Autor:{{ post.owner.get_full_name }}, em {{ post.modified|date:"d/m/y" }}, as {{ post.modified|date:"H:i" }}, em 
+           {% for x in post.category.all %}<a href="{{ x.get_absolute_url }}">{{ x }}</a> {% endfor %}
+          </div>
+       </div>
+       <div id="story-body-{{ forloop.counter }}" class="span-18">
+         <div class='postbody'>
+         {{ post.body|safe|truncatewords_html:15 }}
+         </div>
+         <a href="{{ post.get_absolute_url }}"><img src="/static/icones/read_more.jpg" title='Leia o artigo completo' alt='Leia Mais' style="float: right"></a>
+         <!-- start comments -->
+         {% if post.enable_comments %}
+         <span class="comments">
+	      {% load get_setting %}
+	      {% get_setting "DJANGO_COMMENTS" "django_comments" %}
+	      {% if django_comments %}
+		{% load comments %}
+		{% get_comment_count for post as post_count %}
+		<a href="{{ post.get_absolute_url }}">{{ post_count }} Comments</a>
+	      {% else %}
+		{% load disqus_tags %}
+		  <a href="{{ post.get_absolute_url }}#disqus_thread">View Comments</a>
+		  {% disqus_num_replies %}
+	      {% endif %}
+         </span>
+         {% endif %}
+         <!-- end comments -->
+         <!-- start tags -->
+         {% if post.get_tags|length > 0 %}
+             <div class="tags"><u>Tags</u>: 
+           {% for tag in post.get_tags %}
+             <a href="/tags/{{ tag }}">{{ tag }}</a>
+           {% endfor %}
+             </div>
+         {% endif %}
+         <!-- end tags -->
+      </div>
+      </div>
+    {% endfor %}
+    <!-- start pagination -->
+    <div class="pagination">
+        <span class="step-links">
+        {% if posts.has_previous %}<a href="?page={{ posts.previous_page_number }}" class="util-link">previous</a>{% endif %}
+        {% if posts.has_next %}<a href="?page={{ posts.next_page_number }}" class="util-link">next</a>{% endif %}
+        </span>
+             <h3>Page {{ posts.number }} of {{ posts.paginator.num_pages }}</h3>
+    <!-- end pagination -->
+    </div>
+{% endblock %}
+<!-- end main content -->

File django_yaba/templates/comments/posted.html

+{% extends "blog_base.html" %}
+{% load i18n %}
+
+{% block title %}{% trans "Thanks for commenting" %}.{% endblock %}
+
+{% block content %}
+  <h1>{% trans "Thank you for your comment" %}.</h1>
+  <p><a href="/view/{{ comment.object_pk }}/">Return to the original post</a></p>
+{% endblock %}
+

File django_yaba/templates/feeds/rss_description.html

+{{ obj.body|truncatewords_html:"50"|safe }}

File django_yaba/templates/feeds/rss_title.html

+{{ obj.title }}

File django_yaba/templatetags/__init__.py

Empty file added.

File django_yaba/templatetags/__init__.pyc

Binary file added.

File django_yaba/templatetags/get_setting.py

+from django import template
+from django.conf import settings
+
+register = template.Library()
+
+class SettingObjectNode(template.Node):
+    """
+    TODO: Documentation
+    """
+    def __init__(self, setting_name, var_name):
+        self.setting_name = setting_name
+        self.var_name = var_name
+
+    def render(self, context):
+        try:
+            setting = getattr(settings, self.setting_name)
+        except:
+            raise TemplateSyntaxError, "Setting doesn't exist"
+
+        if self.var_name is None:
+            self.var_name = setting_name
+        context.update({self.var_name: setting})
+        return ''
+
+@register.tag
+def get_setting(parser, token):
+    """
+    USAGE:
+    "variable name" is optional
+    {% load get_setting %}
+      {% get_setting "SETTING_NAME" "variable_name" %}
+
+    EXAMPLE:
+    {% load get_setting %}
+      {% get_setting "LOGIN_URL" "login_path" %}
+        {{ login_path }}
+    """
+    try:
+        tag_name, setting_name, var_name = token.split_contents()
+    except ValueError:
+        if var_name is None and setting_name is not None:
+            var_name = setting_name
+        else:
+            raise template.TemplateSyntaxError("Setting Tag requires 1 variables")
+
+    return SettingObjectNode(setting_name[1:-1], var_name[1:-1])

File django_yaba/templatetags/get_setting.pyc

Binary file added.

File django_yaba/templatetags/navbar.py

+import feedparser
+import datetime
+from django_yaba.models import *
+from django.conf import settings
+from django import template
+
+register = template.Library()
+
+def parse_github():
+    if settings.GITHUB_USERNAME:
+        """ Grab latest commits from GitHub """
+        d = feedparser.parse("http://github.com/%s.atom" % settings.GITHUB_USERNAME)
+        e = d.entries[:5]
+        commit = "<ul>"
+        for x in e:
+            link = x['link']
+            link = link.lstrip("http://github.com/")
+            link = "http://github.com/%s" % link
+            commit += "<li>"
+            commit += '<a href="%s">' % link
+            commit += x['title_detail']['value']
+            commit += "</a>\n@ %s" % x['updated']
+            commit += "</li>"
+        commit += "</ul>"
+        return commit
+    else:
+        commit = False
+        return commit
+
+def theme():
+    theme = Configuration.objects.all()[0].theme.slug
+    theme = theme.rstrip()
+    return {'theme': theme}
+
+def sitename():
+    sitename = settings.BLOG_NAME
+    return {'sitename': sitename}
+
+def archives():
+    """ 
+    Creating Archives navigation for the side bar. We start by grabbing all 
+    the content, which needs to be made more effecient. Then we parse out 
+    the year date times, then the month date times.
+    """ 
+    stories = Story.objects.all()
+    galleries = Gallery.objects.all()
+    articles = Article.objects.all()
+    created = datetime.datetime(2000, 1, 1)
+    
+    year_range = []
+    for x in stories.dates('created', 'year'):
+        if x not in year_range:
+            year_range.append(x)
+    for x in galleries.dates('created', 'year'):
+        if x not in year_range:
+            year_range.append(x)
+    for x in articles.dates('created', 'year'):
+        if x not in year_range:
+            year_range.append(x)
+        
+    year_range.sort()
+    
+    month_range = []
+    for x in stories.dates('created', 'month'):
+        if x not in month_range:
+            month_range.append(x)
+    for x in galleries.dates('created', 'month'):
+        if x not in month_range:
+            month_range.append(x)
+    for x in articles.dates('created', 'month'):
+        if x not in month_range:
+            month_range.append(x)
+    
+    month_range.sort()
+    
+    return year_range, month_range
+
+def sidebar():
+    categories = Category.objects.all()
+    link_list = Links.objects.all()
+    commit = parse_github()
+    sitename = settings.BLOG_NAME
+    year_range, month_range = archives()
+    if settings.TWITTER_USERNAME or settings.TWITTER_PASSWORD:
+        tweet = True
+    else:
+        tweet = False
+    last_posts =  Article.objects.order_by('-created')[0:settings.BLOG_LATEST_POSTS_MAX]
+
+    return {'link_list': link_list, 'commit': commit, 'sitename': sitename, 
+        'categories': categories, 'tweet_it': tweet, 
+        'tweet_user': settings.TWITTER_USERNAME, 'year_range': year_range, 
+        'month_range': month_range, 'latest': last_posts}
+
+def main_nav():
+    articles = Article.objects.all()
+    return {'articles': articles}
+
+register.inclusion_tag('sidebar.html')(sidebar)
+register.inclusion_tag('main_nav.html')(main_nav)
+register.inclusion_tag('sitename.html')(sitename)
+register.inclusion_tag('theme.html')(theme)

File django_yaba/templatetags/navbar.pyc

Binary file added.

File django_yaba/templatetags/tweet.py

+from django.template import Library, Node, TemplateSyntaxError
+from django.core.cache import cache
+from django.conf import settings
+from datetime import datetime
+from time import mktime, strptime
+import urllib
+import simplejson
+
+register = Library()
+
+class CachedNode(Node):
+    """
+    Cached template node.
+
+    Subclasses should define the methods ``get_cache_key()`` and
+    ``get_content()`` instead of the standard render() method. Subclasses may
+    also define the class attribute ``cache_timeout`` to override the default
+    cache timeout of ten minutes.
+    """
+
+    cache_timeout = 600
+
+    def render(self, context):
+        if settings.DEBUG:
+            return self.get_content(context)
+        key = self.get_cache_key(context)
+        content = cache.get(key)
+        if not content:
+            content = self.get_content(context)
+            cache.set(key, content, self.cache_timeout)
+        return content
+
+    def get_cache_key(self, context):
+        raise NotImplementedError()
+
+    def get_content(self, context):
+        raise NotImplementedError()
+
+class ContextUpdatingNode(Node):
+    """
+    Node that updates the context with certain values.
+
+    Subclasses should define ``get_content()``, which should return a dictionary
+    to be added to the context.
+    """
+
+    def render(self, context):
+        context.update(self.get_content(context))
+        return ''
+
+class CachedContextUpdatingNode(CachedNode, ContextUpdatingNode):
+    """
+    Node that updates the context, and is cached. Subclasses need to define
+    ``get_cache_key()`` and ``get_content()``.
+    """
+
+    def render(self, context):
+        context.update(CachedNode.render(self, context))
+        return ''
+
+class TwitterNode(CachedContextUpdatingNode):
+    """
+    Node that gets the twitter public user timeline
+    """
+
+    cache_timeout = 1800 # 30 Minutes, maybe you want to change this
+
+    def __init__(self, username, varname):
+        self.username = settings.TWITTER_USERNAME
+        self.varname = varname
+
+    def make_datetime(self, created_at):
+        return datetime.fromtimestamp(mktime(strptime(created_at, '%a %b %d %H:%M:%S +0000 %Y')))
+
+    def get_cache_key(self, context):
+        return 'twitter_user_timeline_cache'
+
+    def get_content(self, context):
+        try:
+            response = urllib.urlopen('http://twitter.com/statuses/user_timeline/%s.json' % self.username).read()
+            json = simplejson.loads(response)[:5]
+        except:
+            return {self.varname : None}
+        for i in range(len(json)):
+            json[i]['created_at'] = self.make_datetime(json[i]['created_at'])
+        return {self.varname : json}
+
+@register.tag
+def twitter_user_timeline(parser, token):
+    """
+    Usage:
+    {% twitter_user_timeline username as twitter_entries %}
+    {% if twitter_entries %}{% for entry in twitter_entries %}
+    <p>{{ entry.created_at|date:"d M Y H:i" }} - {{ entry.text }}</p>
+    {% endfor %}{% endif %}
+    """
+    bits = token.contents.split()