diff --git a/boards/migrations/0004_auto_20200107_1904.py b/boards/migrations/0004_auto_20200107_1904.py new file mode 100644 index 0000000..a167787 --- /dev/null +++ b/boards/migrations/0004_auto_20200107_1904.py @@ -0,0 +1,22 @@ +# Generated by Django 2.2.8 on 2020-01-07 19:04 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('boards', '0003_auto_20200106_2228'), + ] + + operations = [ + migrations.AlterModelOptions( + name='board', + options={'ordering': ['index', 'name']}, + ), + migrations.AlterField( + model_name='boardfeed', + name='name', + field=models.CharField(max_length=512, null=True), + ), + ] diff --git a/boards/models.py b/boards/models.py index 13bc21c..ffab1f9 100644 --- a/boards/models.py +++ b/boards/models.py @@ -86,7 +86,7 @@ class BoardFeed(models.Model): id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False) board = models.ForeignKey(Board, related_name="feeds", on_delete=models.CASCADE, db_index=True) block = models.ForeignKey(BoardBlock, related_name="feeds", on_delete=models.CASCADE, db_index=True) - name = models.CharField(max_length=512) + name = models.CharField(max_length=512, null=True) comment = models.TextField(null=True) url = models.URLField(max_length=512) icon = models.URLField(max_length=512, null=True) diff --git a/etc/crontab b/etc/crontab index 807200a..14cf59f 100644 --- a/etc/crontab +++ b/etc/crontab @@ -1 +1,2 @@ 0 * * * * cd /home/vas3k/infomate.club/scripts && python3 update.py >/dev/null 2>&1 +0 4 * * * cd /home/vas3k/infomate.club/scripts && python3 cleanup.py >/dev/null 2>&1 diff --git a/scripts/initialize.py b/scripts/initialize.py index bad30c1..1ede462 100644 --- a/scripts/initialize.py +++ b/scripts/initialize.py @@ -95,7 +95,7 @@ def initialize(config, board_slug, upload_favicons): continue for feed_index, feed_config in enumerate(block_config.get("feeds") or []): - feed_name = feed_config.get("name") or "" + feed_name = feed_config.get("name") feed_url = feed_config["url"] print(f"Creating or updating feed: {feed_name}...") diff --git a/static/css/components.css b/static/css/components.css index 3580f32..1033d43 100644 --- a/static/css/components.css +++ b/static/css/components.css @@ -42,6 +42,10 @@ padding: 0 20px; } + .landing-top-title a { + color: var(--text-color); + } + .landing-boards { display: flex; flex-wrap: wrap; diff --git a/templates/board.html b/templates/board.html index de165d5..03a6daa 100644 --- a/templates/board.html +++ b/templates/board.html @@ -42,13 +42,15 @@ {% if feed.block == block %} {% for column, articles in feed.articles_by_column %}
-
- {% if feed.icon %} - {{ feed.name }} - {% endif %} - {{ feed.name }}
- последний пост {{ feed.natural_last_article_at }} -
+ {% if feed.name %} +
+ {% if feed.icon %} + {{ feed.name }} + {% endif %} + {{ feed.name }}
+ последний пост {{ feed.natural_last_article_at }} +
+ {% endif %}
{% for article in articles %}
diff --git a/utils/images.py b/utils/images.py index a933b0f..14a1d09 100644 --- a/utils/images.py +++ b/utils/images.py @@ -24,7 +24,12 @@ def upload_image_from_url(url, resize=(192, 192), convert_format="PNG"): return None if resize: - image = Image.open(image_data) + try: + image = Image.open(image_data) + except OSError: + log.error(f"Broken image file: {url}") + return None + image.thumbnail(resize) saved_image = io.BytesIO() image.save(saved_image, format=convert_format, optimize=True)