Giter Club home page Giter Club logo

django-genericsite's People

Contributors

dependabot[bot] avatar helehack avatar veselosky avatar

Watchers

 avatar

django-genericsite's Issues

Model refactor: Schema.org compliance

Refactor the content models to more closely comply with Schema.org types.

  • Rename the base model from AbstractOpenGraph to CreativeWork
  • Rename fields to match the Scema.org CreativeWork type (publish_time -> date_published, etc.)
  • Derive MediaObject from CreativeWork as in Schema.org
  • Add an Author model to hold author profile information and default copyright information.
  • Refactor copyright code to consult the related author for copyright info if available. (Cascade: item, author, site, default).
  • Add a schema method that returns the Schema.org data as a data class or proxy object.
  • Refactor Opengraph to drop the Pydantic dependency.
  • Change the tinymce.HTMLFields to standard TextFields and remove any tinymce-specific Admin changes. Remove the tinyMCE dependency. (Moved to publishing tools.)

Allow Articles to be linked in Series

As an educational blogger, I want to link Articles together in a series so that I can guide readers through complex topics a step at a time.

  • Allow articles optionally to belong to an ArticleSeries (ForeignKey to ArticleSeries model)
  • Add series field to the ArticleAdmin
  • Articles should order_with_respect_to their Series. Article Meta probably should NOT inherit from AbstractCreativeWork.Meta because of this.
  • The ArticleManager should apply an ordering by -date_published to article queries returned by .live() unless a flag is passed to prevent that.
  • When an Article belongs to an ArticleSeries, the ArticlePage should present a menu linking to other entries in the series, and showing this current Article's position within the Series.
  • When an Article belongs to an ArticleSeries, Next and Previous links should be available below the article text to continue reading the series.
  • A series will contribute to the URL of an Article for SEO purposes: <section>/<series>/<article>.html. To satisfy issue 3 below, this pattern should be listed above the <section>/<article>.html pattern in urlpatterns.
  • If <section>/<article>.html matches an Article that belongs to a Series, it should redirect to <section>/<series>/<article>.html.
  • URLs matching <section>/<series>/ with no article slug should redirect to the first article in the series.

ISSUE 1: Should a single article be allowed to belong to multiple ArticleSeries?
RESOLVE: No, this would be confusing and make it difficult to present a UI for a complete ArticleSeries on the ArticlePage.

ISSUE 2: Should an ArticleSeries have its own Page?
RESOLVE: No, the first Article in the series will serve as the series landing page.

ISSUE 3: Should the ArticleSeries contribute a slug to the URL, e.g. <section>/<series>/<article>? Note, series slugs could conflict with article slugs in this case, since the Article pattern is <section>/<article>.
RESOLVE: Technically there should be no conflicts, because the article pattern is actually <section>/<article>.html, and we're treating Series as directories, not leaf pages. Get <section>/<series>/ will redirect to the first article, whereas Get <section>/<series>.html will 404 (unless the series shares a slug with an article, in which case it would return the article).

ISSUE 4: Should Articles in Series be ordered with respect to their Series?
RESOLVE: Django's order_with_respect_to is a useful feature in this context, but it conflicts with the ordering declaration from the parent AbstractCreativeWork. This is not a big deal since Article overrides the parent's Meta anyway to change several other things. Care should be taken to ensure the default ordering by date_published is applied for article lists in general, except when listing articles in a series.

Image list ignores orientation

The current image list view ignores the image's orientation, always providing a landscape version. Instead, it should detect portrait images and use a portrait preset for those.

Custom Filer models not selectable in admin

When selecting a Filer image in the admin, the field does not populate. This is probably because the custom Filer models are declared in the genericsite app, which loads before the filer app. The documentation for filer statesregarding custom image models "The model can be defined in any installed application declared after django-filer".

Move the custom filer media models into their own filer extension app that can load later. This will be better for code organization anyway. Also, consider moving filer and its dependencies above genericsite in INSTALLED_APPS.

RSS Feeds

Add RSS to site so people can follow.

  • Standard description-only RSS feed view that works with any open graph model
  • Full content RSS feed view for Articles (and any open graph model with a body)
  • Default main feed for site
  • Auto-discovery link in site html header
  • Category-specific RSS feeds

Add Sitemap classes

Add Sitemap classes (subclasses of django.contrib.sitemaps.Sitemap) for:

  • All articles site-wide
  • Articles per section
  • Pages site-wide

It's up to the project using GenericSite to add the sitemap view to its urls.py, but it can easily pull in the sitemaps from GenericSite and add them to its own.

Separate the cacheable site content views from (necessarily) dynamic views

When generating static sites (e.g. using django-distill) we want to use a site-specific settings file that does not contain any dynamic apps. The Django admin and associated tools will not be available on static sites, so we don't want their code or static files involved in the static site generation. This probably means creating a separate GenericSitePublisher app to hold the publishing tools.

  • Move the views that are not required for static site generation into a different file (ProfileView, TinyMCEImageListView). The image list view is only needed for publishing, and the ProfileView requires login so only works on dynamic sites. Remove these views in the default urlpatterns.
  • Modify the GenericSite AppConfig for static sites vs dynamic sites (v0.1 includes all the dynamic apps and admin extensions).

Image presets should not crop images

The current image resize presets are cropping images, when they should resize to fit and maintain aspect ratio instead.

The two smallest image sizes ("small" and "medium"), as well as the social-specific sizes, are meant to fit into specific layouts, and can look awkward if they are not the proper aspect ratio. The goal of the image in these spaces is to represent the target link and hint at the content, so losing some content to cropping is acceptable. Those sizes should use "smart" crop mode to pull them to the right aspect ratio by cropping the "least interesting" side.

The larger sizes are intended for individual layouts, like at the top of or within an article. In those cases, the aspect ratio is less important than presenting the full content, so those images should NOT be cropped.

Perhaps in the future we can add a custom cropping feature.

SiteVars makes too many queries

Observed Behavior

Calculating and displaying the copyright notice for a page makes repeated queries to the SiteVars table, both in the template tags and in the models (MediaObject and AbstractOpenGraph).

The get_template_names and get_context_data methods of the views also make repeated SiteVar queries to look up template names.

In list views, the pagination methods make separate queries for site pagination defaults.

Expected Behavior

SiteVars should be cached and the table should be accessed no more than once per request.

Probably the "get_value" should be either removed entirely to prevent temptation, or modified so that it makes no database queries but only accesses the cached values.

It might be convenient if site.vars was subscriptable, allowing you to access a site var as site.vars["base_template"]. Again, this should access the cache and not produce a database query. Unfortunately that would interfere with Django's default queryset slicing. Best not to change Django's default behavior, that would be confusing for users.

Detail block templates are not set correctly

Observed Behavior

The variables precontent_template, content_template, and postcontent_template need to be set separately for detail and list views. Detail views should be the default. You should be able to override these templates by setting SiteVars prefixed with either list_ or detail_. These variables are being added (with prefix) to the template context by the context processor. However, the base template is looking for variables without prefixes.

As a result, setting the detail_* site variables has no effect on page rendering.

OpenGraphListView.get_context_data is currently mapping the prefixed vars to the non-prefixed vars for views that inherit it. However, this will not work for 3rd-party list views.

Expected Behavior

When rendering a detail view (or any view not determined to be a list view), the non-prefixed context vars above should be set to the value of the detail_-prefixed vars, so that rendered pages will reflect the templates designated in the site vars.

Changes to support static generation

To support static site generation using Django-Distill, some of the URL patterns need to change:

  • List pages (HomePage and Section) pagination needs to be done bypath params, not query params
  • RSS feeds need to move to index.rss (set a redirect at feed/)
  • Anything else?

Support Pagefind for search

Pagefind is a tool that adds full text search for static sites. It pre-generates an index and includes search box that loads partial chunks of the index to conduct searches in the browser with JavaScript. Pagefind indexes static HTML files after they are generated. It can be configured by including certain markup in pages.

  • Create an include component with the search UI (see the docs).
  • Create a new header block that includes the search UI
  • Modify the default templates to add the data-pagefind-body attribute to the main content block for articles and pages, and the precontent block for sections and home pages.
  • Add data-pagefind-meta attributes to identify the title, image, image_alt, section (for articles) and updated date.
  • Add data-pagefind-filter attributes to allow filtering by author, tags, and section.

Copyright notice missing from pages served by other apps

The templates provided to pair with views from other apps (django.contrib.auth, django-allauth) don't have much control over the template context. We can't count on there being an OG-compatible object in the context. Create a template tag that can be used to supply the site default copyright notice for these pages.

Headers that include navigation should include skip-to-content links

For accessibility, headers should include a visually hidden skip-to-content link to jump over navigation menus into page content.

As a prerequisite to this, there must be a target that consistently marks the beginning of the main content. Currently the base template has a main tag wrapped only around the content block. Logically, this should wrap precontent, content, and postcontent, and it should have a targetable ID. This would allow skip links to work consistently for home, section, and article pages. Each of those blocks should probably be wrapped in a section tag.

Standard Error Pages

Add handlers and templates for standard error pages, including:

  • 403 Forbidden
  • 404 Not Found
  • 410 Gone
  • 418 I'm a teapot (for kicks)
  • 429 Too Many Requests
  • 451 Unavailable for legal reasons
  • 500 Server Error
  • 502 Bad Gateway
  • 503 Service Unavailable (Down for Maintenance)
  • 504 Gateway Timeout

Media-oriented sites (visual)

UPDATE: Removed Video from scope as there are too many additional concerns. Will add Video under separate issue if needed.

Implement models, templates, and (if necessary) views for sites that feature visual media, i.e. images and video.

  • Template: Article List Album. Features an image and description for each article (as https://getbootstrap.com/docs/5.3/examples/album/)
  • Template: Article Detail Feature Image. Displays an article with a large, prominent feature image, medium-style.
  • Template: Article Detail Feature Video. Displays an article whose primary purpose is to feature a video (article text might be a transcript).
  • Remove the container wrapper elements from the blocks templates so that any block template can be placed in the main content block or in an aside/header/footer/etc. Container wrappers should move to base.html.
  • Basic Image and Video models to store standard metadata for those media objects.
  • Related models so that Articles (and maybe other OpenGraph objects) can be treated as collections of media objects.
  • Image admin page
  • Base stylesheet (for block custom styles)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.