mirror of
https://github.com/wahyd4/links.git
synced 2026-08-08 21:04:53 +10:00
Update web content
This commit is contained in:
Binary file not shown.
@@ -7,6 +7,7 @@ case "$1" in
|
||||
docker-compose up -d
|
||||
echo "Services started. Access:"
|
||||
echo "- Web: http://localhost:8000"
|
||||
docker-compose logs -f
|
||||
;;
|
||||
"stop")
|
||||
docker-compose down
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
# Generated by Django 5.1.13 on 2025-11-04 11:02
|
||||
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('links', '0034_post_summary'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.AddField(
|
||||
model_name='page',
|
||||
name='webpage_content',
|
||||
field=models.TextField(blank=True, help_text='Markdown content extracted from Crawl4AI', verbose_name='Webpage Content (Markdown)'),
|
||||
),
|
||||
]
|
||||
@@ -176,7 +176,6 @@ class Page(models.Model):
|
||||
title = models.CharField(_('Title'), max_length=200, blank=True)
|
||||
summary = models.TextField(_('Summary'), blank=True)
|
||||
content = models.TextField(_('Content'), blank=True)
|
||||
webpage_content = models.TextField(_('Webpage Content (Markdown)'), blank=True, help_text=_('Markdown content extracted from Crawl4AI'))
|
||||
created_at = models.DateTimeField(_('Created at'), default=timezone.now)
|
||||
updated_at = models.DateTimeField(_('Updated at'), auto_now=True)
|
||||
tags = models.ManyToManyField('Tag', blank=True, related_name='pages')
|
||||
|
||||
@@ -54,8 +54,7 @@ class SearchView(ListView):
|
||||
Q(url__icontains=query) |
|
||||
Q(title__icontains=query) |
|
||||
Q(summary__icontains=query) |
|
||||
Q(content__icontains=query) |
|
||||
Q(webpage_content__icontains=query)
|
||||
Q(content__icontains=query)
|
||||
).values('id', 'url', 'title', 'summary', 'created_at').annotate(
|
||||
model_type=Value('page', output_field=CharField())
|
||||
)
|
||||
|
||||
@@ -4,9 +4,9 @@ from .models import Page, Post, ImageCollection, Image, Tag
|
||||
class PageSerializer(serializers.ModelSerializer):
|
||||
class Meta:
|
||||
model = Page
|
||||
fields = ['id', 'url', 'title', 'summary', 'content', 'webpage_content', 'screenshot_path',
|
||||
fields = ['id', 'url', 'title', 'summary', 'content', 'screenshot_path',
|
||||
'process_status', 'created_at', 'updated_at']
|
||||
read_only_fields = ['id', 'screenshot_path', 'process_status', 'webpage_content',
|
||||
read_only_fields = ['id', 'screenshot_path', 'process_status',
|
||||
'created_at', 'updated_at']
|
||||
|
||||
class PostSerializer(serializers.ModelSerializer):
|
||||
|
||||
+1
-1
@@ -310,7 +310,7 @@ def fetch_webpage_content_from_crawl4ai(page_id, retry_count=0):
|
||||
markdown_content = data.get('markdown', '')
|
||||
|
||||
if markdown_content:
|
||||
page.webpage_content = markdown_content
|
||||
page.content = markdown_content
|
||||
page.save()
|
||||
logger.info(f"Successfully fetched webpage content for page {page_id}")
|
||||
else:
|
||||
|
||||
@@ -283,43 +283,7 @@
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
<!-- Webpage Content from Crawl4AI -->
|
||||
{% if page.webpage_content %}
|
||||
<div class="mt-8">
|
||||
<div class="mb-6" x-data="{ expanded: false }">
|
||||
<div class="flex items-center justify-between mb-2">
|
||||
<h3 class="text-lg font-medium text-gray-900">{% trans "Full Webpage Content" %}</h3>
|
||||
<button
|
||||
@click="expanded = !expanded"
|
||||
class="inline-flex items-center px-3 py-1 text-sm font-medium text-blue-600 hover:text-blue-800 focus:outline-none">
|
||||
<span x-show="!expanded">{% trans "Expand" %}</span>
|
||||
<span x-show="expanded" x-cloak>{% trans "Collapse" %}</span>
|
||||
<svg class="ml-2 w-4 h-4 transform transition-transform"
|
||||
:class="{ 'rotate-180': expanded }"
|
||||
fill="none" stroke="currentColor" viewBox="0 0 24 24">
|
||||
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M19 9l-7 7-7-7"/>
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
<div x-show="expanded"
|
||||
x-transition:enter="transition ease-out duration-200"
|
||||
x-transition:enter-start="opacity-0 transform scale-95"
|
||||
x-transition:enter-end="opacity-100 transform scale-100"
|
||||
x-transition:leave="transition ease-in duration-150"
|
||||
x-transition:leave-start="opacity-100 transform scale-100"
|
||||
x-transition:leave-end="opacity-0 transform scale-95"
|
||||
class="bg-gray-50 rounded-lg p-6 border border-gray-200">
|
||||
<div class="prose prose-sm sm:prose lg:prose-lg xl:prose-xl max-w-none">
|
||||
{{ page.webpage_content|markdown|safe }}
|
||||
</div>
|
||||
</div>
|
||||
<div x-show="!expanded"
|
||||
class="bg-gray-50 rounded-lg p-4 border border-gray-200">
|
||||
<p class="text-sm text-gray-600 italic">{% trans "Click 'Expand' to view the full webpage content extracted by Crawl4AI" %}</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user