feat: extract text preview
This commit is contained in:
parent
cf32c03039
commit
88143da955
@ -65,6 +65,7 @@ services:
|
|||||||
POSTGRES_PASSWORD: later42
|
POSTGRES_PASSWORD: later42
|
||||||
POSTGRES_DB: later42
|
POSTGRES_DB: later42
|
||||||
POSTGRES_HOST_AUTH_METHOD: trust
|
POSTGRES_HOST_AUTH_METHOD: trust
|
||||||
|
READABILITY_HOST: http://ureadability:8080/
|
||||||
volumes:
|
volumes:
|
||||||
- /opt/docker/later42/db:/var/lib/postgresql/data
|
- /opt/docker/later42/db:/var/lib/postgresql/data
|
||||||
logging:
|
logging:
|
||||||
@ -72,3 +73,37 @@ services:
|
|||||||
options:
|
options:
|
||||||
max-size: "10m"
|
max-size: "10m"
|
||||||
max-file: "5"
|
max-file: "5"
|
||||||
|
|
||||||
|
ureadability:
|
||||||
|
image: umputun/ukeeper-readability:latest
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "5"
|
||||||
|
hostname: ureadability
|
||||||
|
restart: always
|
||||||
|
container_name: ureadability
|
||||||
|
links:
|
||||||
|
- mongo
|
||||||
|
environment:
|
||||||
|
- MONGO_URI=mongodb://root:aldbhvaygvavASDVSDFVQFQgfwvsav@mongo:27017
|
||||||
|
- MONGO_DELAY=10s
|
||||||
|
- CREDS=test:l4!AzQVW1dSN0T^7IJGn&Kr!kwRSF2P1
|
||||||
|
|
||||||
|
mongo:
|
||||||
|
image: mongo:5.0
|
||||||
|
logging:
|
||||||
|
driver: json-file
|
||||||
|
options:
|
||||||
|
max-size: "10m"
|
||||||
|
max-file: "5"
|
||||||
|
hostname: mongo
|
||||||
|
restart: always
|
||||||
|
container_name: ureadability-mongo
|
||||||
|
environment:
|
||||||
|
- MONGO_INITDB_DATABASE=admin
|
||||||
|
- MONGO_INITDB_ROOT_USERNAME=root
|
||||||
|
- MONGO_INITDB_ROOT_PASSWORD=aldbhvaygvavASDVSDFVQFQgfwvsav
|
||||||
|
volumes:
|
||||||
|
- /opt/docker/mongodb:/data/db
|
18
later42/migrations/0003_url_content.py
Normal file
18
later42/migrations/0003_url_content.py
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
# Generated by Django 4.1.2 on 2022-10-25 08:05
|
||||||
|
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
|
||||||
|
dependencies = [
|
||||||
|
('later42', '0002_url_archived'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddField(
|
||||||
|
model_name='url',
|
||||||
|
name='content',
|
||||||
|
field=models.TextField(blank=True, null=True),
|
||||||
|
),
|
||||||
|
]
|
@ -8,3 +8,4 @@ class URL(models.Model):
|
|||||||
url = models.CharField(max_length=2000)
|
url = models.CharField(max_length=2000)
|
||||||
title = models.CharField(max_length=2000)
|
title = models.CharField(max_length=2000)
|
||||||
archived = models.BooleanField(default=False)
|
archived = models.BooleanField(default=False)
|
||||||
|
content = models.TextField(blank=True, null=True)
|
||||||
|
@ -159,3 +159,4 @@ REST_FRAMEWORK = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
URLS_PER_PAGE = 20
|
URLS_PER_PAGE = 20
|
||||||
|
READABILITY_HOST = os.getenv('READABILITY_HOST', None)
|
||||||
|
@ -16,6 +16,11 @@
|
|||||||
<a href="/delete/{{ url.id }}"><span class="fa-solid fa-trash"></span></a>
|
<a href="/delete/{{ url.id }}"><span class="fa-solid fa-trash"></span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if url.content %}
|
||||||
|
<p class="post-meta">
|
||||||
|
{{ url.content }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
<p class="post-meta">
|
<p class="post-meta">
|
||||||
{{ url.url }}
|
{{ url.url }}
|
||||||
</p>
|
</p>
|
||||||
|
@ -13,6 +13,11 @@
|
|||||||
<a href="/archive/{{ url.id }}"><span class="fa-solid fa-trash"></span></a>
|
<a href="/archive/{{ url.id }}"><span class="fa-solid fa-trash"></span></a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
{% if url.content %}
|
||||||
|
<p class="post-meta">
|
||||||
|
{{ url.content }}
|
||||||
|
</p>
|
||||||
|
{% endif %}
|
||||||
<p class="post-meta">
|
<p class="post-meta">
|
||||||
{{ url.url }}
|
{{ url.url }}
|
||||||
</p>
|
</p>
|
||||||
|
@ -4,6 +4,7 @@ from rest_framework.response import Response
|
|||||||
from rest_framework.views import APIView
|
from rest_framework.views import APIView
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
from later42.models.urls import URL as URLModel
|
from later42.models.urls import URL as URLModel
|
||||||
|
from django.conf import settings
|
||||||
|
|
||||||
|
|
||||||
class URL(APIView):
|
class URL(APIView):
|
||||||
@ -22,7 +23,13 @@ class URL(APIView):
|
|||||||
title = self.get_title(url)
|
title = self.get_title(url)
|
||||||
if title is None:
|
if title is None:
|
||||||
title = url
|
title = url
|
||||||
url = URLModel(url=url, title=title, user=request.user)
|
|
||||||
|
content = None
|
||||||
|
if settings.READABILITY_HOST:
|
||||||
|
content = self.get_content(url)
|
||||||
|
|
||||||
|
url = URLModel(url=url, user=request.user,
|
||||||
|
title=title, content=content)
|
||||||
url.save()
|
url.save()
|
||||||
return Response({'status': 'success'})
|
return Response({'status': 'success'})
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user