momo: make it possible to specify an extra CSS file

This commit is contained in:
Frédéric Péters 2015-10-28 10:55:14 +01:00
parent 289632669c
commit 1f0d7e42eb
3 changed files with 25 additions and 0 deletions

View File

@ -0,0 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models, migrations
class Migration(migrations.Migration):
dependencies = [
('momo', '0005_momoiconcell_embed_page'),
]
operations = [
migrations.AddField(
model_name='momooptions',
name='extra_css',
field=models.CharField(max_length=100, null=True, verbose_name='Extra CSS', blank=True),
preserve_default=True,
),
]

View File

@ -31,6 +31,7 @@ class MomoOptions(models.Model):
default=86400, null=True)
icons_on_homepage = models.BooleanField(
_('Use icons on the homepage'), default=False)
extra_css = models.CharField(_('Extra CSS'), max_length=100, blank=True, null=True)
def save(self, *args, **kwargs):
self.id = 1

View File

@ -146,8 +146,12 @@ def generate(request, **kwargs):
'updateFreq': options.update_freq or 86400,
'manifestUrl': request.build_absolute_uri(default_storage.url('index.json')),
'assetsUrl': request.build_absolute_uri(default_storage.url('assets.zip')),
'stylesheets': ["assets/index.css"],
}
if options.extra_css:
manifest['meta']['stylesheets'].append('assets/%s' % options.extra_css)
if options.icons_on_homepage:
manifest['display'] = 'icons'