Dan Watson avatar Dan Watson committed 6e0458a

Lots of config tweaks

Comments (0)

Files changed (18)

leaves/plugins/archive/models.py

 from django.db import models
+from django.utils.translation import ugettext_lazy as _
 from leaves.models import SiteConfig
 
 DATE_ARCHIVE_CHOICES = (
 )
 
 class Config (SiteConfig):
-	enabled = models.BooleanField(default=True)
-	nav_link = models.BooleanField(default=False)
-	nav_dates = models.BooleanField(default=True)
-	archive_type = models.CharField(max_length=5, choices=DATE_ARCHIVE_CHOICES, default='month')
+	show_index = models.BooleanField(default=False, help_text=_('Display a link to the archive index page.'))
+	show_nav = models.BooleanField(default=True, help_text=_('Display archive links in the navigation.'))
+	nav_count = models.IntegerField(default=0, help_text=_('The number of recent archive links to show in the navigation. Enter 0 to display all.'))
+	nav_grouping = models.CharField(max_length=5, choices=DATE_ARCHIVE_CHOICES, default='month', help_text=_('How archives should be broken down in the navigation.'))
+	index_grouping = models.CharField(max_length=5, choices=DATE_ARCHIVE_CHOICES, default='month', help_text=_('How archives should be broken down in the archive index.'))
+	month_format = models.CharField(max_length=30, default='F Y', help_text=_('Date formatting string for monthy archives.'))
+	year_format = models.CharField(max_length=30, default='Y', help_text=_('Date formatting string for yearly archives.'))

leaves/plugins/archive/templates/archive/date_list.html

 {% for d in dates %}
     <li{% ifequal d current %} class="selected"{% endifequal %}>
         {% ifequal group "month" %}
-        <a href="{% url view-archive-month year=d.year month=d.month %}">{{ d|date:"F Y" }}</a>
+        <a href="{% url view-archive-month year=d.year month=d.month %}">{{ d|date:config.archive.month_format }}</a>
         {% else %}
-        <a href="{% url view-archive-year year=d.year %}">{{ d|date:"Y" }}</a>
+        <a href="{% url view-archive-year year=d.year %}">{{ d|date:config.archive.year_format }}</a>
         {% endifequal %}
     </li>
 {% endfor %}

leaves/plugins/archive/templatetags/archive.py

 
 @register.inclusion_tag('archive/date_list.html')
 def archive_dates(current=None):
-	group = config.archive.archive_type
-	dates = [d.date() for d in Leaf.on_site.stream().dates('pub_date', group, order='DESC')]
+	group = config.archive.nav_grouping
+	limit = config.archive.nav_count
+	qs = Leaf.on_site.stream().dates('pub_date', group, order='DESC')
+	if limit > 0:
+		qs = qs[:limit]
 	return {
-		'dates': dates,
+		'dates': [d.date() for d in qs],
 		'group': group,
 		'current': current,
+		'config': config,
 	}

leaves/plugins/archive/views.py

 import datetime
 
 def archive_index(request):
-    archive_type = config.archive.archive_type
+    archive_type = config.archive.index_grouping
     dates = Leaf.on_site.stream().dates('pub_date', archive_type, order='DESC')
     archives = []
     for d in dates:

leaves/plugins/blog/models.py

 from leaves.managers import LeafManager, RequestSiteManager
 
 class Config (SiteConfig):
-	nav_link = models.BooleanField(default=True)
+	show_nav = models.BooleanField(default=True, help_text=_('Display a link to the blog in the navigation.'))
 
 class Category (models.Model, TreeUtilsMixIn, Translatable):
 	sites = models.ManyToManyField(Site, related_name='blog_categories')

leaves/plugins/photos/models.py

 import os
 
 class Config (SiteConfig):
-	enabled = models.BooleanField(default=True)
-	nav_photos = models.BooleanField(default=True)
-	nav_galleries = models.BooleanField(default=True)
+	nav_photostream = models.BooleanField(default=True, help_text=_('Show a link to the photostream in the navigation.'))
+	nav_galleries = models.BooleanField(default=True, help_text=_('Show a link to view all galleries in the navigation.'))
+	photo_thumb_width = models.PositiveIntegerField(default=300, help_text=_('Thumbnail width for single photos in the stream.'))
+	photo_width = models.PositiveIntegerField(default=600, help_text=_('Width when viewing a single photo page.'))
+	gallery_thumb_height = models.PositiveIntegerField(default=100, help_text=_('Thumbnail height for galleries.'))
 
 class Photo (Leaf):
 	image = models.ImageField(upload_to='photos/%Y/%m/%d', max_length=200, height_field='height', width_field='width')

leaves/plugins/twitter/models.py

 from django.db import models
+from django.utils.translation import ugettext_lazy as _
 from leaves.models import SiteConfig
 
 class Config (SiteConfig):
 	enabled = models.BooleanField(default=False)
 	screen_name = models.CharField(max_length=14, blank=True, default='')
-	display_count = models.PositiveIntegerField(default=5)
+	display_count = models.PositiveIntegerField(default=5, help_text=_('Number of tweets to display.'))

leaves/templatetags/leaf.py

 from django import template
+from django.template import RequestContext
 from django.template.loader import select_template, render_to_string
 from django.utils.encoding import force_unicode
 from django.utils.safestring import mark_safe
 from django.utils.importlib import import_module
 from django.conf import settings
 from leaves.models import Leaf, Comment
-from leaves.utils import format_text, get_site
+from leaves.utils import format_text, get_site, config, helpers
 import hashlib
 import urllib
 
 register = template.Library()
 
+def render_with_context(template_name, params):
+	# TODO: this should basically match our context processor, but we don't have a request object.
+	theme_static = settings.STATIC_URL
+	if not theme_static.endswith('/'):
+		theme_static += '/'
+	theme_static += config.theme + '/'
+	all_params = {
+		'leaves': helpers,
+		'config': config,
+		'site': get_site(),
+		'THEME_STATIC_URL': theme_static,
+		'None': None,
+	}
+	all_params.update(params)
+	return render_to_string(template_name, all_params)
+
 @register.simple_tag
 def leaf_summary(leaf):
 	template_name = '%s/%s_summary.html' % (leaf.subclass.app_label, leaf.subclass.model)
-	return render_to_string((template_name, 'leaf_summary.html'), {
+	return render_with_context((template_name, 'leaf_summary.html'), {
 		'leaf': leaf.resolve(),
 	})
 
 @register.simple_tag
 def leaf_detail(leaf):
 	template_name = '%s/%s_detail.html' % (leaf.subclass.app_label, leaf.subclass.model)
-	return render_to_string((template_name, 'leaf_detail.html'), {
+	return render_with_context((template_name, 'leaf_detail.html'), {
 		'leaf': leaf.resolve(),
 	})
 
 	nav_html = ''
 	try:
 		template_name = '%s/navigation.html' % app
-		nav_html += render_to_string(template_name, {})
+		nav_html += render_with_context(template_name, {})
 	except Exception, ex:
 		pass
 	return nav_html

leaves/themes/stream/static/stream/css/style.css

 div.archive {
     width: 300px;
     float: left;
+/*
     background: -webkit-gradient(linear, left top, left bottom, from(#FEFEFE), to(#F2F5F5));
     background: -webkit-linear-gradient(top, #FEFEFE, #F2F5F5);
     background: -moz-linear-gradient(top, #FEFEFE, #F2F5F5);
     border: 1px solid #d5d5d5;
     border-radius: 3px;
     padding: 10px 15px;
-    margin-right: 15px;
-    margin-bottom: 15px;
+*/
+    margin-right: 25px;
+    margin-bottom: 25px;
 }
 div.archive ul {
     list-style-type: none;

leaves/themes/stream/templates/archive/index.html

 {% extends "base.html" %}
 
 {% block section %}archive{% endblock %}
+{% block title %}{{ site.name }} - Archives{% endblock %}
 
 {% block content %}
 <h1>Browse the Archives</h1>
 <div class="archive">
     <h2>
         {% ifequal archive_type "month" %}
-        <a href="{% url view-archive-month year=a.date.year month=a.date.month %}">{{ a.date|date:"F Y" }}</a>
+        <a href="{% url view-archive-month year=a.date.year month=a.date.month %}">{{ a.date|date:config.archive.month_format }}</a>
         {% else %}
-        <a href="{% url view-archive-year year=a.date.year %}">{{ a.date|date:"Y" }}</a>
+        <a href="{% url view-archive-year year=a.date.year %}">{{ a.date|date:config.archive.year_format }}</a>
         {% endifequal %}
     </h2>
     <ul>
-    {% for leaf in a.leaves %}
+    	{% for leaf in a.leaves %}
         <li><span class="date">{% ifchanged leaf.pub_date.date %}{{ leaf.pub_date|date:"M j" }}{% endifchanged %}</span><a href="{{ leaf.resolve.get_url }}">{{ leaf.title_trans }}</a></li>
-    {% endfor %}
+    	{% endfor %}
     </ul>
 </div>
 {% cycle '' '<div style="clear:both;"></div>' %}

leaves/themes/stream/templates/archive/stream.html

 {% extends "index.html" %}
 {% load archive %}
-{% block title %}{{ site.name }} - Posted in {% ifequal archive_type "month" %}{{ current_date|date:"F Y" }}{% else %}{{ current_date|date:"Y" }}{% endifequal %}{% endblock %}
+{% block title %}{{ site.name }} - Posted in {% ifequal archive_type "month" %}{{ current_date|date:config.archive.month_format }}{% else %}{{ current_date|date:config.archive.year_format }}{% endifequal %}{% endblock %}
 {% block section %}archive{% endblock %}
-{% block content-header %}<h1 class="tag">Posted in {% ifequal archive_type "month" %}{{ current_date|date:"F Y" }}{% else %}{{ current_date|date:"Y" }}{% endifequal %}</h1>{% endblock %}
+{% block content-header %}<h1 class="tag">Posted in {% ifequal archive_type "month" %}{{ current_date|date:config.archive.month_format }}{% else %}{{ current_date|date:config.archive.year_format }}{% endifequal %}</h1>{% endblock %}
 {% block datenav %}
     <div class="box">
         <div class="title">Archive</div>

leaves/themes/stream/templates/base.html

 	<div class="container">
 		<a class="title stroked" href="{% url homepage %}">{{ site.name }}</a>
 		<ul class="page-list">
+			{% if config.archive.show_index %}
 			<li class="archive"><a href="{% url archive-index %}">Archive</a></li>
+			{% endif %}
 			{% for p in leaves.pages.navigable_pages %}
 			<li{% ifequal p leaf %} class="selected"{% endifequal %}><a href="{{ p.get_url }}">{{ p }}</a></li>
 			{% endfor %}
 			{% navigation "blog" %}
 		</div>
 	{% endblock %}
-	{% block photonav %}
+	{% if config.photos.nav_photostream or config.photos.nav_galleries %}
 		<div class="box">
 			<div class="title">Photos</div>
 			{% navigation "photos" %}
 		</div>
-	{% endblock %}
+	{% endif %}
 	{% block datenav %}
-	{% if config.archive.enabled and config.archive.nav_dates %}
+	{% if config.archive.show_nav %}
 	   <div class="box">
 		   <div class="title">Archive</div>
 		   {% load archive %}
 	{% endblock %}
 	{% if config.twitter.enabled %}
 		<div class="box">
-			<div class="title">Twitter</div>
+			<div class="title"><a href="http://twitter.com/{{ config.twitter.screen_name }}">@{{ config.twitter.screen_name }}</a></div>
 			{% load twitter %}
 			{% twitter_feed %}
 		</div>
 {% if config.analytics_id %}
 <script type="text/javascript">
   var _gaq = _gaq || [];
-  _gaq.push(['_setAccount', 'UA-10897395-2']);
+  _gaq.push(['_setAccount', '{{ config.analytics_id }}']);
   _gaq.push(['_trackPageview']);
   (function() {
 	var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

leaves/themes/stream/templates/photos/gallery_detail.html

     {% leaf_summarize leaf %}
 	<div class="photos">
 		{% for p in leaf.photos.all %}
-		<a href="{{ p.get_url }}" title="{{ p.title_trans }}"><img src="{% url photo-thumbnail p.pk %}?height=100" alt="{{ p.title_trans }}" /></a>
+		<a href="{{ p.get_url }}" title="{{ p.title_trans }}"><img src="{% url photo-thumbnail p.pk %}?height={{ config.photos.gallery_thumb_height }}" alt="{{ p.title_trans }}" /></a>
 		{% endfor %}
 	</div>
 </div>

leaves/themes/stream/templates/photos/gallery_summary.html

     {% leaf_summarize leaf %}
 	<div class="photos">
 		{% for p in leaf.photos.all %}
-		<a href="{{ p.get_url }}" title="{{ p.title_trans }}"><img src="{% url photo-thumbnail p.pk %}?height=100" alt="{{ p.title_trans }}" /></a>
+		<a href="{{ p.get_url }}" title="{{ p.title_trans }}"><img src="{% url photo-thumbnail p.pk %}?height={{ config.photos.gallery_thumb_height }}" alt="{{ p.title_trans }}" /></a>
 		{% endfor %}
 	</div>
 </div>

leaves/themes/stream/templates/photos/navigation.html

 <ul>
-	<li class="photostream"><a href="{% url photo-stream %}">Photo Stream</a></li>
-	<li class="galleries"><a href="{% url photo-galleries %}">Galleries</a></li>
+	{% if config.photos.nav_photostream %}<li class="photostream"><a href="{% url photo-stream %}">Photo Stream</a></li>{% endif %}
+	{% if config.photos.nav_galleries %}<li class="galleries"><a href="{% url photo-galleries %}">Galleries</a></li>{% endif %}
 </ul>

leaves/themes/stream/templates/photos/photo_detail.html

 <div class="leaf-content {{ leaf.subclass }}-content detail">
     {% leaf_content leaf %}
 	<div class="photo">
-		<a href="{{ leaf.get_original_url }}" title="{{ leaf.title_trans }}"><img src="{% url photo-thumbnail leaf.pk %}?width=600" alt="{{ leaf.title_trans }}" /></a>
+		<a href="{{ leaf.get_original_url }}" title="{{ leaf.title_trans }}"><img src="{% url photo-thumbnail leaf.pk %}?width={{ config.photos.photo_width }}" alt="{{ leaf.title_trans }}" /></a>
 	</div>
 	<p><a href="{{ leaf.get_original_url }}">View Original</a></p>
 </div>

leaves/themes/stream/templates/photos/photo_summary.html

 <div class="leaf-content {{ leaf.subclass }}-content summary">
     {% leaf_summarize leaf %}
 	<div class="photo">
-		<a href="{{ leaf.get_url }}" title="{{ leaf.title_trans }}"><img src="{% url photo-thumbnail leaf.pk %}?width=300" alt="{{ leaf.title_trans }}" /></a>
+		<a href="{{ leaf.get_url }}" title="{{ leaf.title_trans }}"><img src="{% url photo-thumbnail leaf.pk %}?width={{ config.photos.photo_thumb_width }}" alt="{{ leaf.title_trans }}" /></a>
 	</div>
 </div>
 {% include "leaf_footer.html" with selector="summary" %}
 				raise AttributeError('No config found for %s' % name)
 		else:
 			if site.leaves_config:
-				return getattr(site.leaves_config, name)
+				return getattr(site.leaves_config, name, None)
 			else:
 				from leaves.models import Preferences
 				prefs = Preferences.objects.create(site=site)
-				return getattr(prefs, name)
+				return getattr(prefs, name, None)
 
 helpers = HelperProxy()
 config = ConfigProxy()
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.