Changeset - fe64a26a72c0
[Not reviewed]
! ! !
Ben Sturmfels (bsturmfels) - 2 months ago 2024-03-21 22:34:20
ben@sturm.com.au
Move the content templates/files into `conservancy/content`

These were previously intermingled with the static content in `conservancy/static`.
76 files changed with 13 insertions and 14 deletions:
0 comments (0 inline, 0 general)
conservancy/content/GiveUpGitHub/index.html
Show inline comments
 
file renamed from conservancy/static/GiveUpGitHub/index.html to conservancy/content/GiveUpGitHub/index.html
conservancy/content/about/board/index.html
Show inline comments
 
file renamed from conservancy/static/about/board/index.html to conservancy/content/about/board/index.html
conservancy/content/about/contact/accounts-taxinfo.asc
Show inline comments
 
file renamed from conservancy/static/about/contact/accounts-taxinfo.asc to conservancy/content/about/contact/accounts-taxinfo.asc
conservancy/content/about/contact/index.html
Show inline comments
 
file renamed from conservancy/static/about/contact/index.html to conservancy/content/about/contact/index.html
conservancy/content/about/eval-committee/index.html
Show inline comments
 
file renamed from conservancy/static/about/eval-committee/index.html to conservancy/content/about/eval-committee/index.html
conservancy/content/about/index.html
Show inline comments
 
file renamed from conservancy/static/about/index.html to conservancy/content/about/index.html
conservancy/content/about/license/index.html
Show inline comments
 
file renamed from conservancy/static/about/license/index.html to conservancy/content/about/license/index.html
conservancy/content/about/outside/index.html
Show inline comments
 
file renamed from conservancy/static/about/outside/index.html to conservancy/content/about/outside/index.html
conservancy/content/about/staff/index.html
Show inline comments
 
file renamed from conservancy/static/about/staff/index.html to conservancy/content/about/staff/index.html
conservancy/content/about/transparency/index.html
Show inline comments
 
file renamed from conservancy/static/about/transparency/index.html to conservancy/content/about/transparency/index.html
conservancy/content/activities/index.html
Show inline comments
 
file renamed from conservancy/static/activities/index.html to conservancy/content/activities/index.html
conservancy/content/copyleft-compliance/about.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/about.html to conservancy/content/copyleft-compliance/about.html
conservancy/content/copyleft-compliance/enforcement-strategy.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/enforcement-strategy.html to conservancy/content/copyleft-compliance/enforcement-strategy.html
conservancy/content/copyleft-compliance/firmware-liberation.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/firmware-liberation.html to conservancy/content/copyleft-compliance/firmware-liberation.html
conservancy/content/copyleft-compliance/glossary.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/glossary.html to conservancy/content/copyleft-compliance/glossary.html
conservancy/content/copyleft-compliance/help.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/help.html to conservancy/content/copyleft-compliance/help.html
conservancy/content/copyleft-compliance/index.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/index.html to conservancy/content/copyleft-compliance/index.html
conservancy/content/copyleft-compliance/linux-vs-vmkernel_de.png
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/linux-vs-vmkernel_de.png to conservancy/content/copyleft-compliance/linux-vs-vmkernel_de.png
Show images
conservancy/content/copyleft-compliance/linux-vs-vmkernel_de.svg
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/linux-vs-vmkernel_de.svg to conservancy/content/copyleft-compliance/linux-vs-vmkernel_de.svg
conservancy/content/copyleft-compliance/linux-vs-vmkernel_en.png
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/linux-vs-vmkernel_en.png to conservancy/content/copyleft-compliance/linux-vs-vmkernel_en.png
Show images
conservancy/content/copyleft-compliance/linux-vs-vmkernel_en.svg
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/linux-vs-vmkernel_en.svg to conservancy/content/copyleft-compliance/linux-vs-vmkernel_en.svg
conservancy/content/copyleft-compliance/linux-vs-vmkernel_en_scaled.png
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/linux-vs-vmkernel_en_scaled.png to conservancy/content/copyleft-compliance/linux-vs-vmkernel_en_scaled.png
Show images
conservancy/content/copyleft-compliance/past-lawsuits.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/past-lawsuits.html to conservancy/content/copyleft-compliance/past-lawsuits.html
conservancy/content/copyleft-compliance/principles.cn.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/principles.cn.html to conservancy/content/copyleft-compliance/principles.cn.html
conservancy/content/copyleft-compliance/principles.cn.pdf
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/principles.cn.pdf to conservancy/content/copyleft-compliance/principles.cn.pdf
conservancy/content/copyleft-compliance/principles.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/principles.html to conservancy/content/copyleft-compliance/principles.html
conservancy/content/copyleft-compliance/principles.kr.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/principles.kr.html to conservancy/content/copyleft-compliance/principles.kr.html
conservancy/content/copyleft-compliance/principles.kr.pdf
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/principles.kr.pdf to conservancy/content/copyleft-compliance/principles.kr.pdf
conservancy/content/copyleft-compliance/vizio-filing-press-release.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/vizio-filing-press-release.html to conservancy/content/copyleft-compliance/vizio-filing-press-release.html
conservancy/content/copyleft-compliance/vizio.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/vizio.html to conservancy/content/copyleft-compliance/vizio.html
conservancy/content/copyleft-compliance/vmware-code-similarity.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/vmware-code-similarity.html to conservancy/content/copyleft-compliance/vmware-code-similarity.html
conservancy/content/copyleft-compliance/vmware-lawsuit-appeal.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/vmware-lawsuit-appeal.html to conservancy/content/copyleft-compliance/vmware-lawsuit-appeal.html
conservancy/content/copyleft-compliance/vmware-lawsuit-faq.html
Show inline comments
 
file renamed from conservancy/static/copyleft-compliance/vmware-lawsuit-faq.html to conservancy/content/copyleft-compliance/vmware-lawsuit-faq.html
conservancy/content/donate/index.html
Show inline comments
 
file renamed from conservancy/static/donate/index.html to conservancy/content/donate/index.html
conservancy/content/fossy/index.html
Show inline comments
 
file renamed from conservancy/static/fossy/index.html to conservancy/content/fossy/index.html
conservancy/content/learn/index.html
Show inline comments
 
file renamed from conservancy/static/learn/index.html to conservancy/content/learn/index.html
conservancy/content/npoacct/index.html
Show inline comments
 
file renamed from conservancy/static/npoacct/index.html to conservancy/content/npoacct/index.html
conservancy/content/press/index.html
Show inline comments
 
file renamed from conservancy/static/press/index.html to conservancy/content/press/index.html
conservancy/content/press/inthenews.html
Show inline comments
 
file renamed from conservancy/static/press/inthenews.html to conservancy/content/press/inthenews.html
conservancy/content/press/kit.html
Show inline comments
 
file renamed from conservancy/static/press/kit.html to conservancy/content/press/kit.html
conservancy/content/press/qanda.html
Show inline comments
 
file renamed from conservancy/static/press/qanda.html to conservancy/content/press/qanda.html
conservancy/content/press/vizio-coverage.html
Show inline comments
 
file renamed from conservancy/static/press/vizio-coverage.html to conservancy/content/press/vizio-coverage.html
conservancy/content/privacy-policy/index.html
Show inline comments
 
file renamed from conservancy/static/privacy-policy/index.html to conservancy/content/privacy-policy/index.html
conservancy/content/projects/apply/ConservancyFSATemplate.pdf
Show inline comments
 
file renamed from conservancy/static/projects/apply/ConservancyFSATemplate.pdf to conservancy/content/projects/apply/ConservancyFSATemplate.pdf
conservancy/content/projects/apply/conservancy-fsa-template.odt
Show inline comments
 
file renamed from conservancy/static/projects/apply/conservancy-fsa-template.odt to conservancy/content/projects/apply/conservancy-fsa-template.odt
conservancy/content/projects/apply/conservancy-fsa-template.tex
Show inline comments
 
file renamed from conservancy/static/projects/apply/conservancy-fsa-template.tex to conservancy/content/projects/apply/conservancy-fsa-template.tex
conservancy/content/projects/apply/index.html
Show inline comments
 
file renamed from conservancy/static/projects/apply/index.html to conservancy/content/projects/apply/index.html
conservancy/content/projects/current/index.html
Show inline comments
 
file renamed from conservancy/static/projects/current/index.html to conservancy/content/projects/current/index.html
conservancy/content/projects/index.html
Show inline comments
 
file renamed from conservancy/static/projects/index.html to conservancy/content/projects/index.html
conservancy/content/projects/policies/conflict-of-interest-policy.9ed5723d4fa0cd23ff52a8945bd8b82d0b80b590.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conflict-of-interest-policy.9ed5723d4fa0cd23ff52a8945bd8b82d0b80b590.html to conservancy/content/projects/policies/conflict-of-interest-policy.9ed5723d4fa0cd23ff52a8945bd8b82d0b80b590.html
conservancy/content/projects/policies/conflict-of-interest-policy.d477e1b02e2093594db118aaa956da8c93129d58.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conflict-of-interest-policy.d477e1b02e2093594db118aaa956da8c93129d58.html to conservancy/content/projects/policies/conflict-of-interest-policy.d477e1b02e2093594db118aaa956da8c93129d58.html
conservancy/content/projects/policies/conflict-of-interest-policy.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conflict-of-interest-policy.html to conservancy/content/projects/policies/conflict-of-interest-policy.html
conservancy/content/projects/policies/conservancy-travel-policy.11ae065865d3a0b78bb5f2d894c5f955e49e4f0f.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.11ae065865d3a0b78bb5f2d894c5f955e49e4f0f.html to conservancy/content/projects/policies/conservancy-travel-policy.11ae065865d3a0b78bb5f2d894c5f955e49e4f0f.html
conservancy/content/projects/policies/conservancy-travel-policy.3b1bc93469c1bb9ceb479f32c29fd7a8ee3521e3.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.3b1bc93469c1bb9ceb479f32c29fd7a8ee3521e3.html to conservancy/content/projects/policies/conservancy-travel-policy.3b1bc93469c1bb9ceb479f32c29fd7a8ee3521e3.html
conservancy/content/projects/policies/conservancy-travel-policy.44cea2c1e51c72e115dcceeede92e755a1d41da6.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.44cea2c1e51c72e115dcceeede92e755a1d41da6.html to conservancy/content/projects/policies/conservancy-travel-policy.44cea2c1e51c72e115dcceeede92e755a1d41da6.html
conservancy/content/projects/policies/conservancy-travel-policy.4b21de38c2eab014dbfb776460c7600716bd6653.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.4b21de38c2eab014dbfb776460c7600716bd6653.html to conservancy/content/projects/policies/conservancy-travel-policy.4b21de38c2eab014dbfb776460c7600716bd6653.html
conservancy/content/projects/policies/conservancy-travel-policy.676ecf976cff8bf611cc045e6f351ce36f1009bb.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.676ecf976cff8bf611cc045e6f351ce36f1009bb.html to conservancy/content/projects/policies/conservancy-travel-policy.676ecf976cff8bf611cc045e6f351ce36f1009bb.html
conservancy/content/projects/policies/conservancy-travel-policy.783dcdd92fc61f3f150e1c65782c0fe527c8ff52.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.783dcdd92fc61f3f150e1c65782c0fe527c8ff52.html to conservancy/content/projects/policies/conservancy-travel-policy.783dcdd92fc61f3f150e1c65782c0fe527c8ff52.html
conservancy/content/projects/policies/conservancy-travel-policy.96a0a68c8e10ab4ea1f68faaf6573c141bbe7614.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.96a0a68c8e10ab4ea1f68faaf6573c141bbe7614.html to conservancy/content/projects/policies/conservancy-travel-policy.96a0a68c8e10ab4ea1f68faaf6573c141bbe7614.html
conservancy/content/projects/policies/conservancy-travel-policy.9ef7fadc65c41438dd5dfeec3544bf80b53e4cea.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.9ef7fadc65c41438dd5dfeec3544bf80b53e4cea.html to conservancy/content/projects/policies/conservancy-travel-policy.9ef7fadc65c41438dd5dfeec3544bf80b53e4cea.html
conservancy/content/projects/policies/conservancy-travel-policy.b78549cbc630463374e2bd50db187eedda9b75bd.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.b78549cbc630463374e2bd50db187eedda9b75bd.html to conservancy/content/projects/policies/conservancy-travel-policy.b78549cbc630463374e2bd50db187eedda9b75bd.html
conservancy/content/projects/policies/conservancy-travel-policy.bfc2754decec9bf4b88c10accd4e44b33e4664e6.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.bfc2754decec9bf4b88c10accd4e44b33e4664e6.html to conservancy/content/projects/policies/conservancy-travel-policy.bfc2754decec9bf4b88c10accd4e44b33e4664e6.html
conservancy/content/projects/policies/conservancy-travel-policy.d3640cc7e0181236b3b5a988328ab2ae82cd7c03.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.d3640cc7e0181236b3b5a988328ab2ae82cd7c03.html to conservancy/content/projects/policies/conservancy-travel-policy.d3640cc7e0181236b3b5a988328ab2ae82cd7c03.html
conservancy/content/projects/policies/conservancy-travel-policy.efb14f1e18273e4f164e3b3a689a086fd511ba26.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.efb14f1e18273e4f164e3b3a689a086fd511ba26.html to conservancy/content/projects/policies/conservancy-travel-policy.efb14f1e18273e4f164e3b3a689a086fd511ba26.html
conservancy/content/projects/policies/conservancy-travel-policy.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/conservancy-travel-policy.html to conservancy/content/projects/policies/conservancy-travel-policy.html
conservancy/content/projects/policies/index.html
Show inline comments
 
file renamed from conservancy/static/projects/policies/index.html to conservancy/content/projects/policies/index.html
conservancy/content/projects/policies/publish-policy.py
Show inline comments
 
file renamed from conservancy/static/projects/policies/publish-policy.py to conservancy/content/projects/policies/publish-policy.py
conservancy/content/projects/services/index.html
Show inline comments
 
file renamed from conservancy/static/projects/services/index.html to conservancy/content/projects/services/index.html
conservancy/content/sustainer/event.html
Show inline comments
 
file renamed from conservancy/static/sustainer/event.html to conservancy/content/sustainer/event.html
conservancy/content/sustainer/original-supporter-appeal.html
Show inline comments
 
file renamed from conservancy/static/sustainer/original-supporter-appeal.html to conservancy/content/sustainer/original-supporter-appeal.html
conservancy/content/sustainer/thank-you-event.html
Show inline comments
 
file renamed from conservancy/static/sustainer/thank-you-event.html to conservancy/content/sustainer/thank-you-event.html
conservancy/content/sustainer/thank-you.html
Show inline comments
 
file renamed from conservancy/static/sustainer/thank-you.html to conservancy/content/sustainer/thank-you.html
conservancy/settings/base.py
Show inline comments
...
 
@@ -90,25 +90,24 @@ INSTALLED_APPS = [
 
    'conservancy.podjango',
 
    'conservancy.usethesource.apps.UseTheSourceConfig',
 
]
 

	
 
DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
 

	
 
BASE_DIR = Path(__file__).resolve().parent.parent
 
TEMPLATES = [
 
    {
 
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
 
        'DIRS': [
 
            BASE_DIR / 'templates',
 
            BASE_DIR / 'static',
 
        ],
 
        'APP_DIRS': True,
 
        'OPTIONS': {
 
            'context_processors': [
 
                'django.template.context_processors.debug',
 
                'django.template.context_processors.request',
 
                'django.contrib.auth.context_processors.auth',
 
                'django.contrib.messages.context_processors.messages',
 
                'conservancy.local_context_processors.host_url',
 
                'conservancy.local_context_processors.sitefundraiser',
 
            ]
 
        }
conservancy/supporter/urls.py
Show inline comments
 
from django.urls import path, re_path
 
from django.urls import path
 
from django.views.generic import TemplateView
 

	
 
from . import views as supp_views
 
from .. import views as static_views
 

	
 
urlpatterns = [
 
    path('', supp_views.index),
 
    path('banner/', TemplateView.as_view(template_name='supporter/banners.html')),
 
    path('banners/', TemplateView.as_view(template_name='supporter/banners.html')),
 
    re_path(r'', static_views.index),
 
]
conservancy/urls.py
Show inline comments
...
 
@@ -43,17 +43,18 @@ urlpatterns = [
 
    path('sustainer/', include('conservancy.supporter.urls')),
 
    path('usethesource/', include('conservancy.usethesource.urls')),
 

	
 
    # Directories of templates and files
 
    re_path(r'^about/', static_views.index),
 
    re_path(r'^activities/', static_views.index),
 
    re_path(r'^copyleft-compliance/', static_views.index, {'fundraiser_sought': 'vmware-match-0'}),
 
    re_path(r'^donate/', static_views.index),
 
    path('fossy/', static_views.index),
 
    re_path(r'^GiveUpGitHub/', static_views.index),
 
    re_path(r'^learn/', static_views.index),
 
    re_path(r'^npoacct/', static_views.index, {'fundraiser_sought': 'npoacct'}),
 
    re_path(r'^overview/', static_views.index),
 
    re_path(r'^overview/', static_views.index),  # Unused?
 
    re_path(r'^press/', static_views.index),
 
    re_path(r'^privacy-policy/', static_views.index),
 
    re_path(r'^projects/', static_views.index),
 
    re_path(r'^sustainer/', static_views.index),
 
]
conservancy/views.py
Show inline comments
 
import mimetypes
 

	
 
from django.conf import settings
 
from django.http import FileResponse, Http404, HttpResponseRedirect
 
from django.template.response import TemplateResponse
 
from django.http import FileResponse, Http404, HttpResponse, HttpResponseRedirect
 
from django.template import RequestContext, Template
 

	
 
from .local_context_processors import fundgoal_lookup
 

	
 
def index(request, *args, **kwargs):
 
    """Faux CMS: bulk website content stored in templates and document files.
 

	
 
    Rationale: Many websites have a CMS and store the majority of their website
 
    content in a relational database eg. WordPress or Wagtail. That's useful
 
    because various people can easily be given access to edit the website. The
 
    downside is that is application complexity - the management of who change
 
    what, when it changed and what changed becomes an application concern. At
 
    the other end of the spectrum, we have files that are checked into a Git
 
    repository - we get the precise who/what/when out of the box with Git, but
 
    require you to have some technical knowledge and appropriate access to
 
    commit. Since you're committing to a code repository, this also opens up the
 
    possibility to break things you couldn't break via a CMS.
 

	
 
    This view serves most of the textual pages and documents on
 
    sfconservancy.org. It works a little like Apache serving mixed PHP/static
 
    files - it looks at the URL and tries to find a matching file on the
 
    filesystem. If it finds a template, it renders it via Django's template
 
    infrastructure. If it finds a file but it's not a template, it will serve
 
    the file as-is.
 
    """
 
    # The name "static" has no connection to Django staticfiles.
 
    base_path = settings.BASE_DIR / 'static'
 
    base_path = settings.BASE_DIR / 'content'
 
    path = request.path.lstrip('/')
 
    if path.endswith('/'):
 
        path += 'index.html'
 
    full_path = (base_path / path).resolve()
 
    safe_from_path_traversal = full_path.is_relative_to(base_path)
 
    if full_path.is_dir():
 
        # Should have been accessed with a trailing slash.
 
        return HttpResponseRedirect(request.path + '/')
 
    elif not full_path.exists() or not safe_from_path_traversal:
 
        raise Http404()
 
    is_template = mimetypes.guess_type(full_path)[0] == 'text/html'
 
    if not is_template:
 
        return FileResponse(open(full_path, 'rb'))
 
    else:
 
        context = kwargs.copy()
 
        try:
 
            context['fundgoal'] = fundgoal_lookup(kwargs['fundraiser_sought'])
 
            kwargs['fundgoal'] = fundgoal_lookup(kwargs['fundraiser_sought'])
 
        except KeyError:
 
            pass
 
        # Maybe this should open() the template file directly so that these
 
        # don't have to be included in the global template TEMPLATES.DIRS?
 
        return TemplateResponse(request, path, context)
 
        # These template are intentionally not in the template loader path, so
 
        # we open them directly, rather than using the template loader.
 
        with open(full_path) as t:
 
            template = Template(t.read())
 
        context = RequestContext(request, kwargs)
 
        return HttpResponse(template.render(context))
0 comments (0 inline, 0 general)