New menu.
authorRadek Czajka <rczajka@rczajka.pl>
Thu, 8 Sep 2022 14:34:01 +0000 (16:34 +0200)
committerRadek Czajka <rczajka@rczajka.pl>
Thu, 8 Sep 2022 14:34:01 +0000 (16:34 +0200)
16 files changed:
src/catalogue/templates/catalogue/preview_ad.html [new file with mode: 0644]
src/catalogue/templatetags/catalogue_tags.py
src/chunks/admin.py
src/chunks/migrations/0004_menu_menuitem.py [new file with mode: 0644]
src/chunks/models.py
src/chunks/templates/chunks/menu.html [new file with mode: 0644]
src/chunks/templatetags/menu.py [new file with mode: 0644]
src/chunks/translation.py
src/wolnelektury/static/2021/scripts/main.js
src/wolnelektury/static/2022/images/icons/user-staff.svg [new file with mode: 0644]
src/wolnelektury/static/2022/images/icons/user-vip.svg [new file with mode: 0644]
src/wolnelektury/static/2022/images/icons/user.svg [new file with mode: 0644]
src/wolnelektury/static/2022/more.scss
src/wolnelektury/templates/2022/header.html
src/wolnelektury/templates/latest_blog_posts.html
src/wolnelektury/templates/main_page.html

diff --git a/src/catalogue/templates/catalogue/preview_ad.html b/src/catalogue/templates/catalogue/preview_ad.html
new file mode 100644 (file)
index 0000000..0494a8b
--- /dev/null
@@ -0,0 +1,24 @@
+{% if book %}
+  <p>
+    <strong>Prapremiera!</strong>
+    Dziękujemy za wsparcie – przeczytaj w prezencie już dzisiaj!
+  </p>
+  <div class="l-navigation__menu__book__info">
+    <a href="{{ book.get_absolute_url }}" tabindex="-1">
+      <img src="{{ book.cover_clean.url }}" alt="{{ book.pretty_title }}">
+    </a>
+    <h3>
+      <a href="{{ book.get_absolute_url }}" tabindex="-1">
+        {% for author in book.authors %}
+          {{ author }}
+        {% endfor %}
+        <strong>
+          {{ book.title }}
+        </strong>
+      </a>
+    </h3>
+    <div>
+      {{ book.description|truncatewords_html:20|safe }}
+    </div>
+  </div>
+{% endif %}
index 93950d7..93b6f1c 100644 (file)
@@ -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()
+    }
index 38ac2b2..90b69ae 100644 (file)
@@ -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 (file)
index 0000000..34c50d8
--- /dev/null
@@ -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',),
+            },
+        ),
+    ]
index f5fdbbf..881cc52 100644 (file)
@@ -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('<hr>')
+        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 (file)
index 0000000..56ccfa2
--- /dev/null
@@ -0,0 +1,13 @@
+{% for item in menu.menuitem_set.all %}
+  <li>
+    {% if item.has_link %}
+      <a href="{{ item.final_link }}" tabindex="-1">
+    {% endif %}
+    {% if item.highlight %}
+    {% endif %}
+    {{ item.final_name }}
+    {% if item.has_link %}
+      </a>
+    {% endif %}
+  </li>
+{% endfor %}
diff --git a/src/chunks/templatetags/menu.py b/src/chunks/templatetags/menu.py
new file mode 100644 (file)
index 0000000..809d204
--- /dev/null
@@ -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,
+    }
index 4338699..64bba5d 100644 (file)
@@ -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)
index 1ffea17..994900a 100644 (file)
@@ -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 (file)
index 0000000..88122b9
--- /dev/null
@@ -0,0 +1,82 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   width="28"
+   height="33"
+   viewBox="0 0 28 33"
+   fill="none"
+   version="1.1"
+   id="svg17"
+   sodipodi:docname="user-staff.svg"
+   inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:svg="http://www.w3.org/2000/svg">
+  <defs
+     id="defs21" />
+  <sodipodi:namedview
+     id="namedview19"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     inkscape:pagecheckerboard="0"
+     showgrid="false"
+     inkscape:zoom="37.118972"
+     inkscape:cx="15.975658"
+     inkscape:cy="9.2540278"
+     inkscape:window-width="1920"
+     inkscape:window-height="1003"
+     inkscape:window-x="0"
+     inkscape:window-y="40"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="g15" />
+  <mask
+     x="0"
+     y="0"
+     width="28"
+     height="33"
+     id="mask0_1809_390"
+     style="mask-type:alpha"
+     maskUnits="userSpaceOnUse">
+    <rect
+       width="28"
+       height="33"
+       fill="#D9D9D9"
+       id="rect2" />
+  </mask>
+  <g
+     mask="url(#mask0_1809_390)"
+     id="g15">
+    <rect
+       x="5"
+       y="3"
+       width="18"
+       height="18"
+       rx="9"
+       fill="#74BDC2"
+       id="rect5" />
+    <rect
+       x="5"
+       y="20"
+       width="18"
+       height="23"
+       rx="9"
+       fill="#74BDC2"
+       id="rect7" />
+    <path
+       d="M14 31.1304C14 31.1304 8.25373 25.8278 0 26.0043V36.6559C7 36.6559 11.7015 39.1761 14 40V31.1304Z"
+       fill="#FBC40F"
+       id="path9" />
+    <path
+       d="M14 31.1304C14 31.1304 19.7463 25.8278 28 26.0043V36.6559C21 36.6559 16.2985 39.1761 14 40V31.1304Z"
+       fill="#E59717"
+       id="path11" />
+    <path
+       d="M 23.801338,11.979863 4.3595814,11.964957 C 4.1133168,11.109508 4.9729499,10.404912 4.9892284,9.8806756 5.0838432,6.8336782 8.3219759,3.638928 11.258254,3.0650433 c 0.431771,-0.084388 -0.373,-1.8984423 3.03031,-1.8928315 3.689802,0.00608 2.661897,1.681716 3.130073,1.8273248 2.479045,0.7710161 5.979222,4.1103072 5.998193,7.2197644 0.0041,0.669689 0.414774,0.219155 0.384508,1.760562 z"
+       fill="#fbc40f"
+       id="path13"
+       sodipodi:nodetypes="ccsssssc" />
+  </g>
+</svg>
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 (file)
index 0000000..b06656f
--- /dev/null
@@ -0,0 +1,12 @@
+<svg width="28" height="33" viewBox="0 0 28 33" fill="none" xmlns="http://www.w3.org/2000/svg">
+<mask id="mask0_1809_390" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="28" height="33">
+<rect width="28" height="33" fill="#D9D9D9"/>
+</mask>
+<g mask="url(#mask0_1809_390)">
+<rect x="5" y="3" width="18" height="18" rx="9" fill="#74BDC2"/>
+<rect x="5" y="20" width="18" height="23" rx="9" fill="#74BDC2"/>
+<path d="M14 31.1304C14 31.1304 8.25373 25.8278 0 26.0043V36.6559C7 36.6559 11.7015 39.1761 14 40V31.1304Z" fill="#FBC40F"/>
+<path d="M14 31.1304C14 31.1304 19.7463 25.8278 28 26.0043V36.6559C21 36.6559 16.2985 39.1761 14 40V31.1304Z" fill="#E59717"/>
+<path d="M23 12H5V0.866682L9 4.00002L14 1.52588e-05L19 4.00002L23 0.433349V12Z" fill="#FBC40F"/>
+</g>
+</svg>
diff --git a/src/wolnelektury/static/2022/images/icons/user.svg b/src/wolnelektury/static/2022/images/icons/user.svg
new file mode 100644 (file)
index 0000000..d67d7c1
--- /dev/null
@@ -0,0 +1,77 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   width="28"
+   height="33"
+   viewBox="0 0 28 33"
+   fill="none"
+   version="1.1"
+   id="svg17"
+   sodipodi:docname="user.svg"
+   inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
+   xmlns="http://www.w3.org/2000/svg"
+   xmlns:svg="http://www.w3.org/2000/svg">
+  <defs
+     id="defs21" />
+  <sodipodi:namedview
+     id="namedview19"
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1.0"
+     inkscape:pageshadow="2"
+     inkscape:pageopacity="0.0"
+     inkscape:pagecheckerboard="0"
+     showgrid="false"
+     inkscape:zoom="9.985336"
+     inkscape:cx="-12.318063"
+     inkscape:cy="15.472689"
+     inkscape:window-width="1920"
+     inkscape:window-height="1003"
+     inkscape:window-x="0"
+     inkscape:window-y="40"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="g15" />
+  <mask
+     x="0"
+     y="0"
+     width="28"
+     height="33"
+     id="mask0_1809_390"
+     style="mask-type:alpha"
+     maskUnits="userSpaceOnUse">
+    <rect
+       width="28"
+       height="33"
+       fill="#D9D9D9"
+       id="rect2" />
+  </mask>
+  <g
+     mask="url(#mask0_1809_390)"
+     id="g15">
+    <rect
+       x="5"
+       y="3"
+       width="18"
+       height="18"
+       rx="9"
+       fill="#74BDC2"
+       id="rect5" />
+    <rect
+       x="5"
+       y="20"
+       width="18"
+       height="23"
+       rx="9"
+       fill="#74BDC2"
+       id="rect7" />
+    <path
+       d="M14 31.1304C14 31.1304 8.25373 25.8278 0 26.0043V36.6559C7 36.6559 11.7015 39.1761 14 40V31.1304Z"
+       fill="#FBC40F"
+       id="path9" />
+    <path
+       d="M14 31.1304C14 31.1304 19.7463 25.8278 28 26.0043V36.6559C21 36.6559 16.2985 39.1761 14 40V31.1304Z"
+       fill="#E59717"
+       id="path11" />
+  </g>
+</svg>
index 8e50810..2b38995 100644 (file)
@@ -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;
 }
index ed97154..490159c 100644 (file)
@@ -1,17 +1,10 @@
+{% load cache %}
 {% load static %}
+{% load menu %}
+{% load latest_blog_posts from blog %}
+{% load preview_ad from catalogue_tags %}
 
 <nav class="l-navigation">
-  <div class="l-change-pop">
-    <h3>Zmieniamy się!</h3>
-    <p>
-      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ę – <a href='/formularz/ux-strona-ksiazki-T1/' target="_blank">możesz nam ją przesłać tutaj</a>.
-      Jeżeli wolisz klasyczny wygląd - wystarczy, że <a class="quit-experiment" href="#">klikniesz tutaj</a>
-    </p>
-    <!-- button class="l-change-pop__close">
-         <i class="icon icon-close"></i>
-         </button -->
-  </div>
   <div class="l-container">
     <a href="/" class="l-navigation__logo">
       <img src="{% static "2022/images/logo.svg" %}" alt="WolneLektury.pl">
       </form>
     </div>
     <div class="l-navigation__actions">
-      <a href="/ludzie/polka/"><i class="icon icon-liked"></i></a>
-      <!-- button class="l-navigation__button js-menu" aria-label="Menu">
-           <span class="c-hamburger">
-           <span class="bar"></span>
-           </span>
-           </button-->
+      {% if request.user.is_authenticated %}
+        <a href="/ludzie/polka/"><i class="icon icon-liked"></i></a>
+        <a href="{% url 'user_settings' %}" class="user">
+          {% if request.user.is_staff %}
+            <img src="{% static '2022/images/icons/user-staff.svg' %}">
+          {% elif request.user %}
+            <img src="{% static '2022/images/icons/user-vip.svg' %}">
+          {% else %}
+            <img src="{% static '2022/images/icons/user.svg' %}">
+          {% endif %}
+        </a>
+      {% else %}
+        <div class="l-navigation__login">
+          <a href='...'>Zaloguj się</a>
+          /
+          <a href='...'>Załóż konto</a>
+        </div>
+      {% endif %}
+      <button class="l-navigation__button js-menu" aria-label="Menu">
+        <span class="c-hamburger">
+          <span class="bar"></span>
+        </span>
+      </button>
+    </div>
+    <div class="l-navigation__menu">
+      <div class="l-container">
+        <div class="l-navigation__menu__links">
+          <ul>
+            <li><strong>Katalog</strong></li>
+            {% menu 'Katalog' %}
+          </ul>
+          <ul>
+            <li><strong>Włącz się</strong></li>
+            {% menu 'Włącz się' %}
+          </ul>
+          <ul>
+            <li><strong>Aktualności</strong></li>
+            {% cache 1800 latest_blog_posts %}
+              {% latest_blog_posts %}
+            {% endcache %}
+            {% menu 'Aktualności' %}
+          </ul>
+          <ul>
+            <li><strong>Narzędzia</strong></li>
+            {% menu 'Narzędzia' %}
+          </ul>
+          <ul>
+            <li><strong>O nas</strong></li>
+            {% menu 'O nas' %}
+          </ul>
+        </div>
+
+        <div class="l-navigation__menu__info">
+
+          <div class="l-navigation__menu__book">
+            {% preview_ad %}
+          </div>
+
+          <div class="l-navigation__menu__social">
+            <ul>
+              <li>
+                <a href="https://www.facebook.com/wolnelektury/"
+                   title="Facebook" tabindex="-1" target="_blank">
+                  <i class="icon icon-fb" aria-hidden="true"></i>
+                </a>
+              </li>
+              <li>
+                <a href="https://www.youtube.com/c/WolneLekturyYT/"
+                   title="YouTube" tabindex="-1" target="_blank">
+                  <i class="icon icon-yt" aria-hidden="true"></i>
+                </a>
+              </li>
+              <li>
+                <a href="https://www.instagram.com/wolnelektury/"
+                   title="Instagram" tabindex="-1" target="_blank">
+                  <i class="icon icon-ig" aria-hidden="true"></i>
+                </a>
+              </li>
+              <li>
+                <a href="https://twitter.com/wolnelektury"
+                   title="Twitter" tabindex="-1" target="_blank">
+                  <i class="icon icon-tt" aria-hidden="true"></i>
+                </a>
+              </li>
+            </ul>
+          </div>
+        </div>
+      </div>
     </div>
   </div>
 </nav>
+
+<div class="l-container l-change-pop">
+  <h3>Zmieniamy się!</h3>
+  <p>
+    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ę – <a href='/formularz/ux-strona-ksiazki-T1/' target="_blank">możesz nam ją przesłać tutaj</a>.
+    Jeżeli wolisz klasyczny wygląd - wystarczy, że <a class="quit-experiment" href="#">klikniesz tutaj</a>
+  </p>
+  <!-- button class="l-change-pop__close">
+       <i class="icon icon-close"></i>
+       </button -->
+</div>
index af7d256..5c7d320 100644 (file)
@@ -1,7 +1,5 @@
 {% spaceless %}
-  <ol>
-    {% for post in posts %}
-      <li><a href="{{ post.link }}">{{ post.title }}</a></li>
-    {% endfor %}
-  </ol>
-{% endspaceless %}
\ No newline at end of file
+  {% for post in posts %}
+    <li><a href="{{ post.link }}">{{ post.title }}</a></li>
+  {% endfor %}
+{% endspaceless %}
index a384cb9..de61221 100644 (file)
 
     <section class="infopages-box">
       <h1>{% trans "News" %}</h1>
-      {% cache 1800 latest_blog_posts %}
-        {% latest_blog_posts %}
-      {% endcache %}
+      <ol>
+        {% cache 1800 latest_blog_posts %}
+          {% latest_blog_posts %}
+        {% endcache %}
+      </ol>
     </section>
 
     <section class="infopages-box">