veselosky / django-genericsite Goto Github PK
View Code? Open in Web Editor NEWThe 80% solution to bootstrapping a new Django site: models, views, templates for basic publishing
License: Apache License 2.0
The 80% solution to bootstrapping a new Django site: models, views, templates for basic publishing
License: Apache License 2.0
Header blocks automatically use the slug "main-nav" for the header navigation. Add help to the Menu Admin so user can see this when adding a menu.
Refactor the content models to more closely comply with Schema.org types.
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.
order_with_respect_to
their Series. Article Meta probably should NOT inherit from AbstractCreativeWork.Meta because of this.-date_published
to article queries returned by .live()
unless a flag is passed to prevent that.<section>/<series>/<article>.html
. To satisfy issue 3 below, this pattern should be listed above the <section>/<article>.html
pattern in urlpatterns
.<section>/<article>.html
matches an Article that belongs to a Series, it should redirect to <section>/<series>/<article>.html
.<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.
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.
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.
The stock middleware that comes with the Django redirects app responds with a 301 Permanent status code. To use a 302 Temporary status instead, you must subclass the existing middleware and set the response_redirect_class to django.http.HttpResponseRedirect.
Add RSS to site so people can follow.
Override the default SiteAdmin to add SiteVars inline. That's the logical place to look for them.
Add Sitemap classes (subclasses of django.contrib.sitemaps.Sitemap
) for:
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.
paginate_by
in views a configurable value per site.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.
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.
Enabling ArticleSeries caused use to lose the default ordering, and the hack used to get it back apparently does not work (and was not properly tested).
Ensure that ArticleList views sort by date_published descending.
We shipped a urls.py
but the README still says there is not one and has that marked as TODO.
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.
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 Unfortunately that would interfere with Django's default queryset slicing. Best not to change Django's default behavior, that would be confusing for users.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.
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.
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.
To support static site generation using Django-Distill, some of the URL patterns need to change:
index.rss
(set a redirect at feed/
)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.
data-pagefind-body
attribute to the main content block for articles and pages, and the precontent block for sections and home pages.data-pagefind-meta
attributes to identify the title, image, image_alt, section (for articles) and updated date.data-pagefind-filter
attributes to allow filtering by author, tags, and section.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.
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.
Add handlers and templates for standard error pages, including:
Remove the easy-thumbnails aliases from apps.GenericSiteConfig and turn them into ImageSpecFields on the Image model. Refactor the templates to use the appropriate ImageKit tags.
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.