# Path: apps/images/models/db.py
# class Image(ImageAbstractModel):
#     description = models.CharField(max_length=255, blank=True)
#     is_cover = models.BooleanField(default=False)
# 
#     def __str__(self):
#         return self.description
# 
#     class Meta(ImageAbstractModel.Meta):
#         db_table = "generic_image"
# 
#     @cached_property
#     def thumb(self):
#         return self.resize_image()
# 
#     def resize_image(self, size=128):
#         _img_url = f"/upload/{size}/{self.file.name}"
#         if not debug:
#             _img_url = f"https://image.jiaxin.im{_img_url}"
#         return _img_url
# 
# Path: apps/ext/render/md.py



from urllib.parse import urlparse
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
from django.urls import reverse
from django.db import models
from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
from django_extensions.db import fields
from model_utils import Choices
from model_utils.fields import StatusField, MonitorField
from taggit.managers import TaggableManager
from apps.images.models import Image
from apps.ext.render.md import md
        return "jiaxin.im"

    @cached_property
    def domain_link(self):
        if self.origin_link:
            o = urlparse(self.origin_link)
            return f"{o.scheme}://{o.netloc}"
        return "https://jiaxin.im"

    @cached_property
    def cover(self):
        _covers = self.images.filter(is_cover=True)
        if _covers.count() == 0:
            return "https://static.jiaxin.im/dugong/static/img/placeholder.jpg"
        else:
            cover = _covers[0]
        return cover.file.url

    @property
    def created_at_ts(self) -> float:
        return self.created_at.timestamp()

    @property
    def published_at_ts(self) -> float:
        return self.published_at.timestamp()

    @cached_property
    def tag_list(self):
        return [{"id": o.pk, "name": o.name} for o in self.tags.all()]


# Path: apps/images/models/db.py
# class Image(ImageAbstractModel):
#     description = models.CharField(max_length=255, blank=True)
#     is_cover = models.BooleanField(default=False)
# 
#     def __str__(self):
#         return self.description
# 
#     class Meta(ImageAbstractModel.Meta):
#         db_table = "generic_image"
# 
#     @cached_property
#     def thumb(self):
#         return self.resize_image()
# 
#     def resize_image(self, size=128):
#         _img_url = f"/upload/{size}/{self.file.name}"
#         if not debug:
#             _img_url = f"https://image.jiaxin.im{_img_url}"
#         return _img_url
# 
# Path: apps/ext/render/md.py



# Path: apps/tutorials/models.py
from urllib.parse import urlparse
from django.conf import settings
from django.contrib.contenttypes.fields import GenericRelation
from django.urls import reverse
from django.db import models
from django.utils import timezone
from django.utils.functional import cached_property
from django.utils.html import strip_tags
from django.utils.translation import ugettext_lazy as _
from django_extensions.db import fields
from model_utils import Choices
from model_utils.fields import StatusField, MonitorField
from taggit.managers import TaggableManager
from apps.images.models import Image
from apps.ext.render.md import md

        return "jiaxin.im"

    @cached_property
    def domain_link(self):
        if self.origin_link:
            o = urlparse(self.origin_link)
            return f"{o.scheme}://{o.netloc}"
        return "https://jiaxin.im"

    @cached_property
    def cover(self):
        _covers = self.images.filter(is_cover=True)
        if _covers.count() == 0:
            return "https://static.jiaxin.im/dugong/static/img/placeholder.jpg"
        else:
            cover = _covers[0]
        return cover.file.url

    @property
    def created_at_ts(self) -> float:
        return self.created_at.timestamp()

    @property
    def published_at_ts(self) -> float:
        return self.published_at.timestamp()

    @cached_property
    def tag_list(self):
        return [{"id": o.pk, "name": o.name} for o in self.tags.all()]


    def tag_string(self):