Commit 85e5fb62 authored by Will LaShell's avatar Will LaShell
Browse files

Merge branch 'release/3.0.1'

parents 51420879 61de6991
......@@ -15,4 +15,6 @@ recursive-include lyrical/site_news/templates *
recursive-include lyrical/site_news/static *
recursive-include lyrical/site_calendar/templates *
recursive-include lyrical/site_calendar/static *
recursive-include lyrical/site_gallery/templatetags *
recursive-include lyrical/site_gallery/templates *
prune build
__version__ = '3.0.0'
from django.template.base import get_library
_libs = {}
_libs_lookup = {}
def template_tag_library_lookup(func_name):
""" Find the name of the template tag library containing the given
function name. """
if not _libs_lookup:
for name, lib in _libs.items():
for v in lib.tags.keys():
_libs_lookup[v] = name
return _libs_lookup.get(func_name, None)
def register_template_tag_library(name):
""" Register the given template tag library for automatic loading. """
_libs[name] = get_library(name)
......@@ -4,6 +4,9 @@ from django.db import models
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.fields.related import SingleRelatedObjectDescriptor
from django.db.models.query import QuerySet
from django.template.base import Template, Context
from lyrical.site_content import template_tag_library_lookup
import re
class InheritanceQuerySet(QuerySet):
......@@ -54,6 +57,8 @@ class SitePageTemplateSelection(models.Model):
def __unicode__(self):
return u'%s' % self.label
def subclass(self):
return self.__class__
class SitePage(models.Model):
site = models.ForeignKey(Site)
......@@ -76,6 +81,19 @@ class SitePage(models.Model):
def __unicode__(self):
return u'%s' % (self.url)
def rendered_content(self):
""" Render the content as a template and return it. """
content = self.content
libs = set()
for m in re.finditer(r'{% *(\S+).*?%}', content):
tag = m.group(1)
lib = template_tag_library_lookup(tag)
if lib:
libs.add(lib)
content = '{{% load {0} %}}\n{1}'.format(' '.join(list(libs)), content)
t = Template(content)
return t.render(Context({}))
def save(self, force_insert=False, force_update=False):
if self.is_index:
for sitepage in SitePage.objects.filter(site=self.site):
......
......@@ -8,6 +8,7 @@ from lyrical.site_content.models import SitePage
class SitePageView(TemplateView):
template_name = 'site_content/site_page.html'
def get_sitepage(self, url):
if url == '/':
try:
......@@ -71,7 +72,7 @@ class SitePageView(TemplateView):
elif self.sitepage.template:
template_path = self.sitepage.template.template_path
else:
template_path = 'site_content/site_page.html'
template_path = self.template_name
# FIXME: This should evaluated for better handling
return [template_path]
from django.contrib import admin
from django.conf import settings
from django import forms
from django.db import models as django_models
import models
from lyrical.site_content.settings import ENABLE_BUILTIN_MEDIA, RTE_CONFIG_URI
class SiteGalleryImageInline(admin.TabularInline):
model = models.SiteGalleryImageItem
formfield_overrides = {
django_models.TextField: {'widget': forms.TextInput},
}
class SiteGalleryVideoInline(admin.TabularInline):
model = models.SiteGalleryVideoItem
formfield_overrides = {
django_models.TextField: {'widget': forms.TextInput},
}
class SiteGalleryYoutubeVideoInline(admin.TabularInline):
model = models.SiteGalleryYoutubeItem
formfield_overrides = {
django_models.TextField: {'widget': forms.TextInput},
}
class SiteGalleryAdmin(admin.ModelAdmin):
inlines = [SiteGalleryImageInline, SiteGalleryVideoInline,
SiteGalleryYoutubeVideoInline]
readonly_fields = ['embed_code']
list_display = ('__str__', 'embed_code')
if ENABLE_BUILTIN_MEDIA:
class Media:
css = {'all': ('site_content/css/grappelli-tinymce.css',)}
js = (getattr(settings, 'STATIC_URL', '') + 'grappelli/tinymce/jscripts/tiny_mce/tiny_mce.js', RTE_CONFIG_URI)
admin.site.register(models.SiteGallery, SiteGalleryAdmin)
from django.conf import settings
from django.contrib.sites.models import Site
from django.db import models
from django.utils.safestring import mark_safe
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.fields.related import SingleRelatedObjectDescriptor
from django.db.models.query import QuerySet
from filebrowser.fields import FileBrowseField
from lyrical.site_content.models import InheritanceQuerySet
from lyrical.site_content import register_template_tag_library
class SiteGallery(models.Model):
code = models.CharField(max_length=255, unique=True)
title = models.CharField(max_length=255, unique=True)
description = models.TextField(blank=True)
custom_template = models.CharField(max_length=255, blank=True, null=True)
css_class = models.CharField(max_length=255, blank=True, null=True)
@property
def items(self):
return InheritanceQuerySet(SiteGalleryItem).filter(gallery=self).select_subclasses()
@property
def embed_code(self):
if not self.code:
return ''
return "{{% site_gallery '{0}' %}}".format(self.code)
def __unicode__(self):
return u'%s' % (self.title)
class Meta:
verbose_name_plural = 'Site Galleries'
class SiteGalleryItem(models.Model):
gallery = models.ForeignKey(SiteGallery)
title = models.CharField(max_length=255, blank=True)
caption = models.TextField(blank=True)
order = models.IntegerField(default=0)
class Meta:
ordering = ('order',)
def html_tag(self):
return ''
def item_type(self):
return self.__class__.__name__
def __unicode__(self):
return u'%s' % (self.caption)
class SiteGalleryImageItem(SiteGalleryItem):
image = FileBrowseField(format='image', max_length=255)
thumbnail = FileBrowseField(format='image', max_length=255, blank=True)
def save(self, *args, **kwargs):
if not self.thumbnail:
self.thumbnail = self.image
return super(SiteGalleryImageItem, self).save(*args, **kwargs)
@property
def img_src(self):
return self.image.url
@property
def html_tag(self):
return '<img src="{0}">'.format(self.image.url)
def __unicode__(self):
return u'%s' % (self.image)
class SiteGalleryYoutubeItem(SiteGalleryItem):
video_id = models.CharField(max_length=200, blank=False)
thumbnail = FileBrowseField(format='image', max_length=255, blank=True)
def html_tag(self):
return self.video_id
def __unicode__(self):
return u'%s' % (self.video_id)
class SiteGalleryVideoItem(SiteGalleryItem):
video = models.TextField(blank=True)
thumbnail = FileBrowseField(format='image', max_length=255, blank=True)
def html_tag(self):
return self.video
def __unicode__(self):
return u'%s' % (self.video)
register_template_tag_library('site_gallery')
from django.conf import settings
THUMBNAIL_SIZE = getattr(settings, 'SITE_GALLERY_THUMBNAIL_SIZE', None)
{% if gallery %}
{% for item in gallery.items %}
{{ item.html_tag|safe }}
{% endfor %}
{% endif %}
from django import template
from django.template import loader
from django.conf import settings
from lyrical.site_gallery.models import SiteGallery
register = template.Library()
@register.simple_tag(takes_context=True)
def site_gallery(context, code):
template_name = 'site_gallery/tag_site_gallery.html'
try:
gallery = SiteGallery.objects.get(code=code)
if gallery.custom_template:
template_name = gallery.custom_template
except SiteGallery.DoesNotExist:
gallery = None
return loader.render_to_string(template_name, { 'gallery': gallery})
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import datetime
from django.conf import settings
class Migration(migrations.Migration):
dependencies = [
('sites', '0001_initial'),
migrations.swappable_dependency(settings.AUTH_USER_MODEL),
]
operations = [
migrations.CreateModel(
name='SiteNewsArticle',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('url', models.SlugField(max_length=255)),
('title', models.CharField(max_length=255)),
('summary', models.CharField(max_length=255, null=True, blank=True)),
('content', models.TextField(null=True, blank=True)),
('create_date', models.DateTimeField(default=datetime.datetime.now)),
('modify_date', models.DateTimeField(auto_now=True)),
('publish_date', models.DateTimeField(null=True, blank=True)),
('published', models.BooleanField(default=False)),
('author', models.ForeignKey(to=settings.AUTH_USER_MODEL)),
],
options={
'ordering': ('-publish_date',),
},
bases=(models.Model,),
),
migrations.CreateModel(
name='SiteNewsCategory',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('code', models.CharField(unique=True, max_length=255)),
('url', models.SlugField(unique=True, max_length=255)),
('label', models.CharField(max_length=255)),
('content', models.TextField(null=True, blank=True)),
('site', models.ForeignKey(to='sites.Site')),
],
options={
'verbose_name_plural': 'site news categories',
},
bases=(models.Model,),
),
migrations.AddField(
model_name='sitenewsarticle',
name='sitenewscategory',
field=models.ForeignKey(to='site_news.SiteNewsCategory'),
preserve_default=True,
),
migrations.AlterUniqueTogether(
name='sitenewsarticle',
unique_together=set([('sitenewscategory', 'url')]),
),
]
......@@ -38,7 +38,7 @@ class SiteSeoMiddleware(object):
'seo_description': siteurl.page_description}
def process_response(self, request, response):
if response.status_code == 404 and COLLECT_404 and 'site_content' not in settings.INSTALLED_APPS:
if response.status_code == 404 and COLLECT_404 and 'lyrical.site_content' not in settings.INSTALLED_APPS:
add_404_url(request)
return response
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
import filebrowser.fields
class Migration(migrations.Migration):
dependencies = [
]
operations = [
migrations.CreateModel(
name='Slider',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('label', models.CharField(max_length=255)),
('code', models.CharField(unique=True, max_length=255)),
('css_class', models.CharField(max_length=255, null=True, blank=True)),
('template', models.CharField(help_text=b'Default template path is site_slider/slider.html', max_length=255, null=True, blank=True)),
],
options={
'ordering': ('label',),
},
bases=(models.Model,),
),
migrations.CreateModel(
name='SliderSlide',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('weight', models.IntegerField(default=0)),
('image', filebrowser.fields.FileBrowseField(max_length=255, null=True, blank=True)),
('image_css_class', models.CharField(max_length=255, null=True, blank=True)),
('content', models.TextField(null=True, blank=True)),
('content_css_class', models.CharField(max_length=255, null=True, blank=True)),
('template', models.CharField(help_text=b'Default template path is site_slider/slide.html', max_length=255, null=True, blank=True)),
('slider', models.ForeignKey(to='site_slider.Slider')),
],
options={
'ordering': ('weight',),
},
bases=(models.Model,),
),
]
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('site_slider', '0001_initial'),
]
operations = [
migrations.AddField(
model_name='sliderslide',
name='link_url',
field=models.CharField(default=None, max_length=255, null=True, blank=True),
preserve_default=True,
),
]
......@@ -19,6 +19,8 @@ class Slider(models.Model):
class SliderSlide(models.Model):
slider = models.ForeignKey(Slider)
weight = models.IntegerField(default=0)
link_url = models.CharField(max_length=255, null=True, blank=True,
default=None)
image = FileBrowseField(directory='slides', max_length=255, null=True, blank=True)
image_css_class = models.CharField(max_length=255, blank=True, null=True)
content = models.TextField(blank=True, null=True)
......
<div class="slide slide{{ idx }}">
{% if slide.link_url %}<a href="{{ slide.link_url }}">{% endif %}
{% if slide.content %}<div class="slide-content">{{ slide.content|safe }}</div>{% endif %}
{% if slide.image %}<img class="slide-image" src="{{ slide.image.url }}">{% endif %}
{% if slide.link_url %}</a>{% endif %}
</div>
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('sites', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='TrackingCode',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('tracking_type', models.IntegerField(choices=[(0, b'Google Analytics')])),
('code', models.CharField(max_length=255)),
('site', models.ForeignKey(to='sites.Site')),
],
options={
},
bases=(models.Model,),
),
migrations.CreateModel(
name='VerificationCode',
fields=[
('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)),
('verification_type', models.IntegerField(choices=[(0, b'Google Webmaster Tools'), (1, b'Bing Webmaster Tools'), (2, b'Yahoo Site Explorer')])),
('code', models.CharField(max_length=255)),
('site', models.ForeignKey(to='sites.Site')),
],
options={
},
bases=(models.Model,),
),
]
......@@ -9,7 +9,7 @@ os.chdir(os.path.normpath(os.path.join(os.path.abspath(__file__), os.pardir)))
setup(
name='lyrical_page',
version='3.0.0',
version='3.0.1',
description='Website content system based on a mashup of ideas from the Django contrib flatpage appp, joomla!, and many years of systems development..',
author='Will LaShell',
author_email='wlashell@lyrical.net',
......@@ -18,6 +18,8 @@ setup(
url='http://www.lyrical.net/projects/lyrical_page/',
packages=find_packages(),
include_package_data=True,
install_requires = ['Django>=1.7', 'django-grappelli>=2.5.3',
'pytz>=2014.10'],
zip_safe=False,
classifiers=[
'Development Status :: 5 - Production/Stable',
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment