From: Radek Czajka Date: Thu, 8 Sep 2022 14:34:01 +0000 (+0200) Subject: New menu. X-Git-Url: https://git.mdrn.pl/wolnelektury.git/commitdiff_plain/b8c235267a6345ebe3891f49c16ad3fc5f1d3f25?ds=sidebyside New menu. --- diff --git a/src/catalogue/templates/catalogue/preview_ad.html b/src/catalogue/templates/catalogue/preview_ad.html new file mode 100644 index 000000000..0494a8b6e --- /dev/null +++ b/src/catalogue/templates/catalogue/preview_ad.html @@ -0,0 +1,24 @@ +{% if book %} +

+ Prapremiera! + Dziękujemy za wsparcie – przeczytaj w prezencie już dzisiaj! +

+ +{% endif %} diff --git a/src/catalogue/templatetags/catalogue_tags.py b/src/catalogue/templatetags/catalogue_tags.py index 93950d73c..93b6f1c42 100644 --- a/src/catalogue/templatetags/catalogue_tags.py +++ b/src/catalogue/templatetags/catalogue_tags.py @@ -528,3 +528,10 @@ def content_warning(book): return { "warnings": warnings } + + +@register.inclusion_tag('catalogue/preview_ad.html') +def preview_ad(): + return { + 'book': Book.objects.filter(preview=True).first() + } diff --git a/src/chunks/admin.py b/src/chunks/admin.py index 38ac2b284..90b69ae7d 100644 --- a/src/chunks/admin.py +++ b/src/chunks/admin.py @@ -2,19 +2,30 @@ # Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information. # from django.contrib import admin - -from chunks.models import Chunk, Attachment +from django import forms +from chunks import models +from modeltranslation.admin import TranslationStackedInline class ChunkAdmin(admin.ModelAdmin): list_display = ('key', 'description',) search_fields = ('key', 'content',) -admin.site.register(Chunk, ChunkAdmin) +admin.site.register(models.Chunk, ChunkAdmin) class AttachmentAdmin(admin.ModelAdmin): list_display = ('key',) search_fields = ('key',) -admin.site.register(Attachment, AttachmentAdmin) +admin.site.register(models.Attachment, AttachmentAdmin) + + +class MenuItemInline(TranslationStackedInline): + model = models.MenuItem + extra = 1 + + +@admin.register(models.Menu) +class MenuAdmin(admin.ModelAdmin): + inlines = [MenuItemInline] diff --git a/src/chunks/migrations/0004_menu_menuitem.py b/src/chunks/migrations/0004_menu_menuitem.py new file mode 100644 index 000000000..34c50d82a --- /dev/null +++ b/src/chunks/migrations/0004_menu_menuitem.py @@ -0,0 +1,46 @@ +# Generated by Django 2.2.27 on 2022-09-08 10:31 + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('infopages', '0002_auto_20151221_1225'), + ('chunks', '0003_auto_20151221_1225'), + ] + + operations = [ + migrations.CreateModel( + name='Menu', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('identifier', models.CharField(max_length=255, unique=True)), + ], + ), + migrations.CreateModel( + name='MenuItem', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('order', models.SmallIntegerField()), + ('name', models.CharField(blank=True, max_length=255)), + ('name_de', models.CharField(blank=True, max_length=255, null=True)), + ('name_en', models.CharField(blank=True, max_length=255, null=True)), + ('name_es', models.CharField(blank=True, max_length=255, null=True)), + ('name_fr', models.CharField(blank=True, max_length=255, null=True)), + ('name_it', models.CharField(blank=True, max_length=255, null=True)), + ('name_lt', models.CharField(blank=True, max_length=255, null=True)), + ('name_pl', models.CharField(blank=True, max_length=255, null=True)), + ('name_ru', models.CharField(blank=True, max_length=255, null=True)), + ('name_uk', models.CharField(blank=True, max_length=255, null=True)), + ('url', models.CharField(blank=True, max_length=255)), + ('highlight', models.BooleanField()), + ('infopage', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, to='infopages.InfoPage')), + ('menu', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='chunks.Menu')), + ], + options={ + 'ordering': ('order',), + }, + ), + ] diff --git a/src/chunks/models.py b/src/chunks/models.py index f5fdbbf77..881cc529f 100644 --- a/src/chunks/models.py +++ b/src/chunks/models.py @@ -5,6 +5,7 @@ from django.conf import settings from django.core.cache import cache from django.db import models from django.urls import reverse +from django.utils.safestring import mark_safe from django.utils.translation import ugettext_lazy as _ @@ -46,3 +47,43 @@ class Attachment(models.Model): def get_absolute_url(self): return reverse('chunks_attachment', args=[self.key, self.attachment.name.rsplit('.', 1)[-1]]) + + +class Menu(models.Model): + identifier = models.CharField(max_length=255, unique=True) + + def __str__(self): + return self.identifier + + +class MenuItem(models.Model): + menu = models.ForeignKey(Menu, models.CASCADE) + order = models.SmallIntegerField() + highlight = models.BooleanField() + infopage = models.ForeignKey( + 'infopages.InfoPage', models.PROTECT, null=True, blank=True) + url = models.CharField(max_length=255, blank=True) + name = models.CharField(max_length=255, blank=True) + + class Meta: + ordering = ('order',) + + @property + def final_name(self): + if self.name == '-': + return mark_safe('
') + if self.name: + return self.name + if self.infopage: + return self.infopage.title + return '' + + @property + def final_link(self): + if self.infopage: + return self.infopage.get_absolute_url() + return self.url + + @property + def has_link(self): + return self.url or self.infopage diff --git a/src/chunks/templates/chunks/menu.html b/src/chunks/templates/chunks/menu.html new file mode 100644 index 000000000..56ccfa258 --- /dev/null +++ b/src/chunks/templates/chunks/menu.html @@ -0,0 +1,13 @@ +{% for item in menu.menuitem_set.all %} +
  • + {% if item.has_link %} + + {% endif %} + {% if item.highlight %} + {% endif %} + {{ item.final_name }} + {% if item.has_link %} + + {% endif %} +
  • +{% endfor %} diff --git a/src/chunks/templatetags/menu.py b/src/chunks/templatetags/menu.py new file mode 100644 index 000000000..809d2048e --- /dev/null +++ b/src/chunks/templatetags/menu.py @@ -0,0 +1,14 @@ +from django.template import Library +from ..models import Menu + + +register = Library() + + +@register.inclusion_tag('chunks/menu.html') +def menu(identifier): + menu, created = Menu.objects.get_or_create(identifier=identifier) + + return { + 'menu': menu, + } diff --git a/src/chunks/translation.py b/src/chunks/translation.py index 4338699ae..64bba5dd7 100644 --- a/src/chunks/translation.py +++ b/src/chunks/translation.py @@ -3,10 +3,16 @@ # from modeltranslation.translator import translator, TranslationOptions -from chunks.models import Chunk +from chunks.models import Chunk, MenuItem class ChunkTranslationOptions(TranslationOptions): fields = ('content',) translator.register(Chunk, ChunkTranslationOptions) + + +class MenuItemTranslationOptions(TranslationOptions): + fields = ('name',) + +translator.register(MenuItem, MenuItemTranslationOptions) diff --git a/src/wolnelektury/static/2021/scripts/main.js b/src/wolnelektury/static/2021/scripts/main.js index 1ffea17c8..994900a96 100644 --- a/src/wolnelektury/static/2021/scripts/main.js +++ b/src/wolnelektury/static/2021/scripts/main.js @@ -8,11 +8,13 @@ if(!$(this).hasClass('is-active')) { $(this).addClass('is-active'); menu.addClass('is-open'); + $('body').addClass('is-open'); button.find('.bar').addClass('animate'); menuLinks.attr('tabindex', 0); } else { $(this).removeClass('is-active'); menu.removeClass('is-open'); + $('body').removeClass('is-open'); button.find('.bar').removeClass('animate'); menuLinks.attr('tabindex', -1); } @@ -22,6 +24,7 @@ if (e.keyCode === 27) { button.removeClass('is-active'); menu.removeClass('is-open'); + $('body').removeClass('is-open'); button.find('.bar').removeClass('animate'); menuLinks.attr('tabindex', -1); } diff --git a/src/wolnelektury/static/2022/images/icons/user-staff.svg b/src/wolnelektury/static/2022/images/icons/user-staff.svg new file mode 100644 index 000000000..88122b900 --- /dev/null +++ b/src/wolnelektury/static/2022/images/icons/user-staff.svg @@ -0,0 +1,82 @@ + + + + + + + + + + + + + + + diff --git a/src/wolnelektury/static/2022/images/icons/user-vip.svg b/src/wolnelektury/static/2022/images/icons/user-vip.svg new file mode 100644 index 000000000..b06656fb8 --- /dev/null +++ b/src/wolnelektury/static/2022/images/icons/user-vip.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + + diff --git a/src/wolnelektury/static/2022/images/icons/user.svg b/src/wolnelektury/static/2022/images/icons/user.svg new file mode 100644 index 000000000..d67d7c1c6 --- /dev/null +++ b/src/wolnelektury/static/2022/images/icons/user.svg @@ -0,0 +1,77 @@ + + + + + + + + + + + + + + diff --git a/src/wolnelektury/static/2022/more.scss b/src/wolnelektury/static/2022/more.scss index 8e50810cc..2b3899520 100644 --- a/src/wolnelektury/static/2022/more.scss +++ b/src/wolnelektury/static/2022/more.scss @@ -1,3 +1,45 @@ +.is-open { + height: 100%; + overflow-y: hidden; +} + +.l-change-pop { + margin-top: 18px; +} +.is-open .l-change-pop { + height: auto; + margin-top: 18px; + padding: 10px 50px; +} + +.l-navigation { + //opacity: .5; +} + +.l-navigation__menu { + overflow-y: scroll; +} +.l-navigation__menu__book__info { + img { + width: 42px; + height: 60px; + } +} +.l-navigation__login { + color: #74BDC2; + margin-right: 20px; + + a { + color: white; + } +} +.l-navigation__actions { + .user { + margin-right: 25px; + } +} + + .l-books { margin-right: -17px; } diff --git a/src/wolnelektury/templates/2022/header.html b/src/wolnelektury/templates/2022/header.html index ed971540b..490159c9b 100644 --- a/src/wolnelektury/templates/2022/header.html +++ b/src/wolnelektury/templates/2022/header.html @@ -1,17 +1,10 @@ +{% load cache %} {% load static %} +{% load menu %} +{% load latest_blog_posts from blog %} +{% load preview_ad from catalogue_tags %} + +
    +

    Zmieniamy się!

    +

    + Jeżeli to czytasz jesteś jedną z osób, której prezentujemy nowy wygląd części stron. + Będziemy bardzo! wdzięczni za Twoją opinię – możesz nam ją przesłać tutaj. + Jeżeli wolisz klasyczny wygląd - wystarczy, że klikniesz tutaj +

    + +
    diff --git a/src/wolnelektury/templates/latest_blog_posts.html b/src/wolnelektury/templates/latest_blog_posts.html index af7d256c5..5c7d320f6 100644 --- a/src/wolnelektury/templates/latest_blog_posts.html +++ b/src/wolnelektury/templates/latest_blog_posts.html @@ -1,7 +1,5 @@ {% spaceless %} -
      - {% for post in posts %} -
    1. {{ post.title }}
    2. - {% endfor %} -
    -{% endspaceless %} \ No newline at end of file + {% for post in posts %} +
  • {{ post.title }}
  • + {% endfor %} +{% endspaceless %} diff --git a/src/wolnelektury/templates/main_page.html b/src/wolnelektury/templates/main_page.html index a384cb9ff..de612210a 100644 --- a/src/wolnelektury/templates/main_page.html +++ b/src/wolnelektury/templates/main_page.html @@ -84,9 +84,11 @@

    {% trans "News" %}

    - {% cache 1800 latest_blog_posts %} - {% latest_blog_posts %} - {% endcache %} +
      + {% cache 1800 latest_blog_posts %} + {% latest_blog_posts %} + {% endcache %} +