<commit_before>from django import template
from django.core.urlresolvers import reverse
from django.template.loader import get_template
from django.template import Context
from django.utils.translation import ugettext as _

from storybase_user.models import Project

register = template.Library()

# TODO: Actually wire in featured image for project
def _mock_image_html(width):
    from django.conf import settings
    import random
    image_url = "%scss/images/image%d.jpg" % (settings.STATIC_URL,
                                              random.randrange(1, 9))
    return "<img src=\"%s\" />" % (image_url)

@register.simple_tag
def featured_projects(count=4, img_width=335):
    # Put project attributes into a "normalized" dictionary format
    objects = []
    qs =  Project.objects.on_homepage().order_by('-last_edited')[:count]
    for obj in qs:
        objects.append({ 
            "title": obj.name,
            #"author": "<NAME>", 
            "date": obj.last_edited,
            # TODO: Wire in featured image for Project
            "image_html": _mock_image_html(width=img_width),
            "excerpt": obj.description, 
            "url": obj.get_absolute_url(),<commit_msg>Wire in featured asset for projects on homepage<commit_after>from django import template
from django.core.urlresolvers import reverse
from django.template.loader import get_template
from django.template import Context
from django.utils.translation import ugettext as _

from storybase_user.models import Project

register = template.Library()

# TODO: Actually wire in featured image for project
def _mock_image_html(width):
    from django.conf import settings
    import random
    image_url = "%scss/images/image%d.jpg" % (settings.STATIC_URL,
                                              random.randrange(1, 9))
    return "<img src=\"%s\" />" % (image_url)

@register.simple_tag
def featured_projects(count=4, img_width=335):
    # Put project attributes into a "normalized" dictionary format
    objects = []
    qs =  Project.objects.on_homepage().order_by('-last_edited')[:count]
    for obj in qs:
        objects.append({ 
            "title": obj.name,
            #"author": "<NAME>", 
            "date": obj.last_edited,
            "image_html": obj.render_featured_asset(width=img_width),
            "excerpt": obj.description, 
            "url": obj.get_absolute_url(),
{'fraction_non_alphanumeric': 0.10334728033472804, 'fraction_numerical': 0.00502092050209205, 'mean_word_length': 2.9520661157024795, 'pattern_counts': {'":': 12, '<': 7, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5991101', 'n_tokens_mistral': 681, 'n_tokens_neox': 656, 'n_words': 181}