Fix more bugs

This commit is contained in:
vas3k
2020-01-07 21:02:30 +01:00
parent 944b2fdc62
commit 945ada51b5
7 changed files with 44 additions and 10 deletions

View File

@@ -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),
),
]

View File

@@ -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)

View File

@@ -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

View File

@@ -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}...")

View File

@@ -42,6 +42,10 @@
padding: 0 20px;
}
.landing-top-title a {
color: var(--text-color);
}
.landing-boards {
display: flex;
flex-wrap: wrap;

View File

@@ -42,13 +42,15 @@
{% if feed.block == block %}
{% for column, articles in feed.articles_by_column %}
<div class="feed {% if column > 1 %}hide-on-iphone{% endif %}">
<div class="feed-title {% if column != 0 %}feed-title-hidden{% endif %}">
{% if feed.icon %}
<img src="{{ feed.icon }}" alt="{{ feed.name }}">
{% endif %}
<a href="{{ feed.url }}" target="_blank">{{ feed.name }}</a><br>
<small>последний пост {{ feed.natural_last_article_at }}</small>
</div>
{% if feed.name %}
<div class="feed-title {% if column != 0 %}feed-title-hidden{% endif %}">
{% if feed.icon %}
<img src="{{ feed.icon }}" alt="{{ feed.name }}">
{% endif %}
<a href="{{ feed.url }}" target="_blank">{{ feed.name }}</a><br>
<small>последний пост {{ feed.natural_last_article_at }}</small>
</div>
{% endif %}
<div class="articles feed-articles">
{% for article in articles %}
<div class="article {% if article.is_fresh %}is-article-fresh{% endif %}">

View File

@@ -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)