# Path: pagelets/conf.py
# CONTENT_AREAS = getattr(settings, "PAGELET_CONTENT_AREAS", (("main", "Main"),))
# CONTENT_AREA_DEFAULT = getattr(settings, "PAGELET_CONTENT_AREA_DEFAULT", "main")
# CONTENT_TYPES = (
#     getattr(
#         settings,
#         "PAGELET_CONTENT_TYPES",
#         (
#             (
#                 "html",
#                 "HTML",
#                 (),
#                 {},
#             ),
#             (
#                 "markdown",
#                 "Markdown",
#                 (),
#                 {},
#             ),
#             (
#                 "wymeditor",
#                 "WYMeditor",
#                 ("wymeditor/jquery.wymeditor.js",),
#                 {},
#             ),
#             (
#                 "textile",
#                 "Textile",
#                 (),
#                 {},
#             ),
#         ),
#     )
#     + getattr(settings, "PAGELET_CONTENT_TYPES_EXTRA", ())
# )
# CONTENT_TYPE_CHOICES = tuple((c[0], c[1]) for c in CONTENT_TYPES)
# CONTENT_TYPE_DEFAULT = getattr(settings, "PAGELET_CONTENT_TYPE_DEFAULT", "html")
#     ATTACHMENT_PATH = settings.PAGELET_ATTACHMENT_PATH
#     ATTACHMENT_PATH = getattr(settings, "PAGE_ATTACHMENT_PATH", "attachments/pages/")
# AUTO_LOAD_TEMPLATE_TAGS = "{%% load %s %%}" % " ".join(tags)
# BASE_TEMPLATES = getattr(settings, "PAGELET_BASE_TEMPLATES", [])
# BASE_TEMPLATE_DEFAULT = getattr(settings, "PAGELET_BASE_TEMPLATE_DEFAULT", None)
# INLINE_PAGELET_EXTRA = getattr(settings, "PAGELET_INLINE_PAGELET_EXTRA", 0)
# INLINE_SHARED_EXTRA = getattr(settings, "PAGELET_INLINE_SHARED_EXTRA", 0)
# INLINE_ATTACHMENT_EXTRA = getattr(settings, "PAGELET_INLINE_ATTACHMENT_EXTRA", 0)
# 
# Path: pagelets/validators.py
# PAGE_SLUG_RE = r"[-\w/\.~]+"
# def validate_url_chars(value):
# def validate_leading_slash(value):
# def validate_trailing_slash(value):
# 
# Path: pagelets/utils.py
# def truncate_html_words(value, num_words):
#     """Truncate 'value' to num_words words, ignoring HTML tags."""
#     return Truncator(value).words(num_words, html=True)


from datetime import datetime
from django.conf import settings
from django.db import models
from django.template import Template, TemplateSyntaxError
from django.urls import reverse
from django.utils.html import strip_tags
from django.utils.translation import gettext_lazy as _
from taggit.managers import TaggableManager
from pagelets import conf, validators
from pagelets.utils import truncate_html_words
                from textile import textile
                from markdown import markdown
    def _get_content(self):
        return self.pagelet.content

    def _set_content(self, content):
        self.__pagelet_dirty = True
        self.pagelet.content = content

    content = property(_get_content, _set_content)

    # a property that consistently gives you access to the real "Pagelet"
    # instance for Pagelets, InlinePagelets, and SharedPagelets
    real = property(lambda self: self.pagelet)

    def render(self, *args, **kwargs):
        return self.pagelet.render(*args, **kwargs)

    def save(self, *args, **kwargs):
        if self.__pagelet_dirty:
            self.pagelet.save()
            self.__pagelet_dirty = False
        return super(SharedPagelet, self).save(*args, **kwargs)

    class Meta:
        unique_together = (("pagelet", "page"),)
        ordering = ("order",)


class PageAttachment(models.Model):
    page = models.ForeignKey(Page, related_name="attachments", on_delete=models.CASCADE)
    name = models.CharField(max_length=255)

# Path: pagelets/conf.py
# CONTENT_AREAS = getattr(settings, "PAGELET_CONTENT_AREAS", (("main", "Main"),))
# CONTENT_AREA_DEFAULT = getattr(settings, "PAGELET_CONTENT_AREA_DEFAULT", "main")
# CONTENT_TYPES = (
#     getattr(
#         settings,
#         "PAGELET_CONTENT_TYPES",
#         (
#             (
#                 "html",
#                 "HTML",
#                 (),
#                 {},
#             ),
#             (
#                 "markdown",
#                 "Markdown",
#                 (),
#                 {},
#             ),
#             (
#                 "wymeditor",
#                 "WYMeditor",
#                 ("wymeditor/jquery.wymeditor.js",),
#                 {},
#             ),
#             (
#                 "textile",
#                 "Textile",
#                 (),
#                 {},
#             ),
#         ),
#     )
#     + getattr(settings, "PAGELET_CONTENT_TYPES_EXTRA", ())
# )
# CONTENT_TYPE_CHOICES = tuple((c[0], c[1]) for c in CONTENT_TYPES)
# CONTENT_TYPE_DEFAULT = getattr(settings, "PAGELET_CONTENT_TYPE_DEFAULT", "html")
#     ATTACHMENT_PATH = settings.PAGELET_ATTACHMENT_PATH
#     ATTACHMENT_PATH = getattr(settings, "PAGE_ATTACHMENT_PATH", "attachments/pages/")
# AUTO_LOAD_TEMPLATE_TAGS = "{%% load %s %%}" % " ".join(tags)
# BASE_TEMPLATES = getattr(settings, "PAGELET_BASE_TEMPLATES", [])
# BASE_TEMPLATE_DEFAULT = getattr(settings, "PAGELET_BASE_TEMPLATE_DEFAULT", None)
# INLINE_PAGELET_EXTRA = getattr(settings, "PAGELET_INLINE_PAGELET_EXTRA", 0)
# INLINE_SHARED_EXTRA = getattr(settings, "PAGELET_INLINE_SHARED_EXTRA", 0)
# INLINE_ATTACHMENT_EXTRA = getattr(settings, "PAGELET_INLINE_ATTACHMENT_EXTRA", 0)
# 
# Path: pagelets/validators.py
# PAGE_SLUG_RE = r"[-\w/\.~]+"
# def validate_url_chars(value):
# def validate_leading_slash(value):
# def validate_trailing_slash(value):
# 
# Path: pagelets/utils.py
# def truncate_html_words(value, num_words):
#     """Truncate 'value' to num_words words, ignoring HTML tags."""
#     return Truncator(value).words(num_words, html=True)


# Path: pagelets/models.py
from datetime import datetime
from django.conf import settings
from django.db import models
from django.template import Template, TemplateSyntaxError
from django.urls import reverse
from django.utils.html import strip_tags
from django.utils.translation import gettext_lazy as _
from taggit.managers import TaggableManager
from pagelets import conf, validators
from pagelets.utils import truncate_html_words
                from textile import textile
                from markdown import markdown

    def _get_content(self):
        return self.pagelet.content

    def _set_content(self, content):
        self.__pagelet_dirty = True
        self.pagelet.content = content

    content = property(_get_content, _set_content)

    # a property that consistently gives you access to the real "Pagelet"
    # instance for Pagelets, InlinePagelets, and SharedPagelets
    real = property(lambda self: self.pagelet)

    def render(self, *args, **kwargs):
        return self.pagelet.render(*args, **kwargs)

    def save(self, *args, **kwargs):
        if self.__pagelet_dirty:
            self.pagelet.save()
            self.__pagelet_dirty = False
        return super(SharedPagelet, self).save(*args, **kwargs)

    class Meta:
        unique_together = (("pagelet", "page"),)
        ordering = ("order",)


class PageAttachment(models.Model):
    page = models.ForeignKey(Page, related_name="attachments", on_delete=models.CASCADE)
    name = models.CharField(max_length=255)

    file = models.FileField(upload_to=conf.ATTACHMENT_PATH)