Initial commit.
12 files changed, 372 insertions(+), 0 deletions(-)

A => .hgignore
A => LICENSE
A => MANIFEST.in
A => README.md
A => README.rst
A => nofloc/__init__.py
A => nofloc/apps.py
A => nofloc/middleware.py
A => nofloc/models.py
A => nofloc/views.py
A => pyproject.toml
A => setup.py
A => .hgignore +11 -0
@@ 0,0 1,11 @@ 
+syntax:glob
+.hgsvn
+.*.swp
+**.pyc
+*.*~
+*.egg
+
+# virtualenv
+syntax:regexp
+^build/lib$
+^nofloc.egg-info$

          
A => LICENSE +32 -0
@@ 0,0 1,32 @@ 
+Copyright (c) 2020, Netlandish Inc. <https://www.netlandish.com>
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or 
+without modification, are permitted provided that the 
+following conditions are met:
+
+ * Redistributions of source code must retain the above 
+   copyright notice, this list of conditions and the 
+   following disclaimer.
+
+ * Redistributions in binary form must reproduce the above 
+   copyright notice, this list of conditions and the following 
+   disclaimer in the documentation and/or other materials 
+   provided with the distribution.
+
+ * Neither the name of Netlandish Inc. nor the names of project
+   contributors may be used to endorse or promote products 
+   derived from this software without specific prior written 
+   permission.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
+"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
+LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
+A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
+HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
+SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 
+TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 
+PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 
+LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 
+NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

          
A => MANIFEST.in +3 -0
@@ 0,0 1,3 @@ 
+include LICENSE
+include README.rst
+include README.md

          
A => README.md +100 -0
@@ 0,0 1,100 @@ 
+# django-nofloc [![nlshield](https://img.shields.io/badge/100%25-Netlandish-blue.svg?style=square-flat)](http://www.netlandish.com)
+
+django-nofloc is a simple Django app that provides a middleware to let Google
+Chrome know that your website should not be included in the Google FLoC
+program. Essentially you're opting out of this privacy invading program that is
+default for all Chrome users.
+
+**Version:** 0.1.0
+
+**Project Links:** [Mailing List][pinbox] - [Contributing](#contributing)
+
+**Author:** Peter Sanchez (<https://netlandish.com>)
+
+Because this is a simple middleware we have no issue tracker for it. If there
+are any issues please send an email to the [mailing list][pinbox].
+
+[pinbox]: https://lists.code.netlandish.com/~netlandish/public-inbox
+
+## Python / Django Support
+
+-   Python 3.6+ for Django versions 2.2+
+
+# Installation
+
+PIP:
+
+    pip install django-nofloc
+
+Basic Manual Install:
+
+    $ python setup.py build
+    $ sudo python setup.py install
+
+Then just add the `nofloc.middleware.NoFLoCMiddleware` to your `MIDDLEWARE`
+setting. The placement order shouldn't matter.
+
+    MIDDLEWARE = [
+        'django.middleware.security.SecurityMiddleware',
+        'django.contrib.sessions.middleware.SessionMiddleware',
+        'django.middleware.common.CommonMiddleware',
+        'django.middleware.csrf.CsrfViewMiddleware',
+        'django.contrib.auth.middleware.AuthenticationMiddleware',
+        'django.contrib.messages.middleware.MessageMiddleware',
+        'django.middleware.clickjacking.XFrameOptionsMiddleware',
+	    'nofloc.middleware.NoFLoCMiddleware',
+    ]
+
+This will set the `Permissions-Policy` header to a value of
+`interest-cohort=()` for every request served by Django.
+
+If you need to alter this header within a view or some other case, this app may
+not be a good tool for you to use in it's current state. It's set specifically
+to disable FLoC. Review your use case before installing this app. You can also
+submit a patch to make this more configurable if you'd like :)
+
+## Why?
+
+Because we're tired of big tech spying on us. For more info see:
+
+https://plausible.io/blog/google-floc
+
+# Contributing
+
+We accept patches submitted via `hg email` which is the `patchbomb` extension
+included with Mercurial.
+
+The mailing list where you submit your patches is
+`~netlandish/public-inbox@lists.code.netlandish.com`. You can also view the
+archives on the web here:
+
+https://lists.code.netlandish.com/~netlandish/public-inbox
+
+To quickly setup your clone of `django-nofloc` to submit to the mailing
+list just edit your `.hg/hgrc` file and add the following:
+
+    [email]
+    to = ~netlandish/public-inbox@lists.code.netlandish.com
+
+    [patchbomb]
+    flagtemplate = "django-nofloc"
+
+    [diff]
+    git = 1
+
+We have more information on the topic here:
+
+- [Contributing][cdoc]
+- [Using email with Mercurial][hgemail]
+- [Mailing list etiquette][etiquette]
+
+[etiquette]: https://man.code.netlandish.com/lists/etiquette.md
+[hgemail]: https://man.code.netlandish.com/hg/email.md
+[cdoc]: https://man.code.netlandish.com/contributing.md
+
+# Copyright & Warranty
+
+All documentation, libraries, and sample code are Copyright 2021 Netlandish
+Inc. &lt;<hello@netlandish.com>&gt;. The library and sample code
+are made available to you under the terms of the BSD license which is
+contained in the included file, LICENSE.

          
A => README.rst +117 -0
@@ 0,0 1,117 @@ 
+django-nofloc |nlshield|
+========================
+
+django-nofloc is a simple Django app that provides a middleware to let
+Google Chrome know that your website should not be included in the
+Google FLoC program. Essentially you're opting out of this privacy
+invading program that is default for all Chrome users.
+
+**Version:** 0.1.0
+
+**Project Links:** `Mailing
+List <https://lists.code.netlandish.com/~netlandish/public-inbox>`__ -
+`Contributing <#contributing>`__
+
+**Author:** Peter Sanchez (https://netlandish.com)
+
+Because this is a simple middleware we have no issue tracker for it. If
+there are any issues please send an email to the `mailing
+list <https://lists.code.netlandish.com/~netlandish/public-inbox>`__.
+
+Python / Django Support
+-----------------------
+
+-  Python 3.6+ for Django versions 2.2+
+
+Installation
+============
+
+PIP:
+
+::
+
+   pip install django-nofloc
+
+Basic Manual Install:
+
+::
+
+   $ python setup.py build
+   $ sudo python setup.py install
+
+Then just add the ``nofloc.middleware.NoFLoCMiddleware`` to your
+``MIDDLEWARE`` setting. The placement order shouldn't matter.
+
+::
+
+   MIDDLEWARE = [
+       'django.middleware.security.SecurityMiddleware',
+       'django.contrib.sessions.middleware.SessionMiddleware',
+       'django.middleware.common.CommonMiddleware',
+       'django.middleware.csrf.CsrfViewMiddleware',
+       'django.contrib.auth.middleware.AuthenticationMiddleware',
+       'django.contrib.messages.middleware.MessageMiddleware',
+       'django.middleware.clickjacking.XFrameOptionsMiddleware',
+       'nofloc.middleware.NoFLoCMiddleware',
+   ]
+
+This will set the ``Permissions-Policy`` header to a value of
+``interest-cohort=()`` for every request served by Django.
+
+If you need to alter this header within a view or some other case, this
+app may not be a good tool for you to use in it's current state. It's
+set specifically to disable FLoC. Review your use case before installing
+this app. You can also submit a patch to make this more configurable if
+you'd like :)
+
+Why?
+----
+
+Because we're tired of big tech spying on us. For more info see:
+
+https://plausible.io/blog/google-floc
+
+Contributing
+============
+
+We accept patches submitted via ``hg email`` which is the ``patchbomb``
+extension included with Mercurial.
+
+The mailing list where you submit your patches is
+``~netlandish/public-inbox@lists.code.netlandish.com``. You can also
+view the archives on the web here:
+
+https://lists.code.netlandish.com/~netlandish/public-inbox
+
+To quickly setup your clone of ``django-nofloc`` to submit to the
+mailing list just edit your ``.hg/hgrc`` file and add the following:
+
+::
+
+   [email]
+   to = ~netlandish/public-inbox@lists.code.netlandish.com
+
+   [patchbomb]
+   flagtemplate = "django-nofloc"
+
+   [diff]
+   git = 1
+
+We have more information on the topic here:
+
+-  `Contributing <https://man.code.netlandish.com/contributing.md>`__
+-  `Using email with
+   Mercurial <https://man.code.netlandish.com/hg/email.md>`__
+-  `Mailing list
+   etiquette <https://man.code.netlandish.com/lists/etiquette.md>`__
+
+Copyright & Warranty
+====================
+
+All documentation, libraries, and sample code are Copyright 2021
+Netlandish Inc. <hello@netlandish.com>. The library and sample code are
+made available to you under the terms of the BSD license which is
+contained in the included file, LICENSE.
+
+.. |nlshield| image:: https://img.shields.io/badge/100%25-Netlandish-blue.svg?style=square-flat
+   :target: http://www.netlandish.com

          
A => nofloc/__init__.py +24 -0
@@ 0,0 1,24 @@ 
+# -*- coding: utf-8 -*-
+default_app_config = "nofloc.apps.NoFLoCConfig"
+VERSION = (0, 1, 0, "final", 0)
+
+
+def get_version():
+    "Returns a PEP 386-compliant version number from VERSION."
+    assert len(VERSION) == 5
+    assert VERSION[3] in ("alpha", "beta", "rc", "final")
+
+    # Now build the two parts of the version number:
+    # main = X.Y[.Z]
+    # sub = .devN - for pre-alpha releases
+    #     | {a|b|c}N - for alpha, beta and rc releases
+
+    parts = 2 if VERSION[2] == 0 else 3
+    main = ".".join(str(x) for x in VERSION[:parts])
+
+    sub = ""
+    if VERSION[3] != "final":
+        mapping = {"alpha": "a", "beta": "b", "rc": "c"}
+        sub = mapping[VERSION[3]] + str(VERSION[4])
+
+    return str(main + sub)

          
A => nofloc/apps.py +5 -0
@@ 0,0 1,5 @@ 
+from django.apps import AppConfig
+
+
+class NoFLoCConfig(AppConfig):
+    name = "nofloc"

          
A => nofloc/middleware.py +8 -0
@@ 0,0 1,8 @@ 
+class NoFLoCMiddleware:
+    def __init__(self, get_response):
+        self.get_response = get_response
+
+    def __call__(self, request):
+        response = self.get_response(request)
+        response.headers["Permissions-Policy"] = "interest-cohort=()"
+        return response

          
A => nofloc/models.py +1 -0
@@ 0,0 1,1 @@ 
+# No models

          
A => nofloc/views.py +1 -0
@@ 0,0 1,1 @@ 
+# no views

          
A => pyproject.toml +29 -0
@@ 0,0 1,29 @@ 
+[tool.black]
+line-length = 79
+target-version = ['py37', 'py38']
+include = '\.pyi?$'
+exclude = '''
+
+(
+  /(
+      \.eggs         # exclude a few common directories in the
+    | \.git          # root of the project
+    | \.hg
+    | \.mypy_cache
+    | \.tox
+    | \.venv
+    | env
+    | _build
+    | buck-out
+    | build
+    | dist
+  )/
+  | foo.py           # also separately exclude a file named foo.py in
+                     # the root of the project
+)
+'''
+
+[tool.isort]
+line_length=79
+multi_line_output=5
+include_trailing_comma=true

          
A => setup.py +41 -0
@@ 0,0 1,41 @@ 
+import os
+
+from setuptools import find_packages, setup
+
+project_name = "nofloc"
+
+if os.path.exists("README.rst"):
+    long_description = open("README.rst").read()
+else:
+    long_description = (
+        "See https://hg.code.netlandish.com/~netlandish/django-nofloc"
+    )
+
+
+setup(
+    name=project_name,
+    version=__import__(project_name).get_version(),
+    package_dir={project_name: project_name},
+    packages=find_packages(),
+    description=("Opt out of the privacy invading Google FLoC program."),
+    author="Netlandish Inc.",
+    author_email="hello@netlandish.com",
+    license="BSD License",
+    url="https://hg.code.netlandish.com/~netlandish/django-nofloc",
+    long_description=long_description,
+    platforms=["any"],
+    classifiers=[
+        "Development Status :: 4 - Beta",
+        "Intended Audience :: Developers",
+        "License :: OSI Approved :: BSD License",
+        "Natural Language :: English",
+        "Operating System :: OS Independent",
+        "Programming Language :: Python",
+        "Environment :: Web Environment",
+        "Programming Language :: Python",
+        "Programming Language :: Python :: 3 :: Only",
+        "Programming Language :: Python :: 3.6",
+        "Programming Language :: Python :: 3.7",
+        "Programming Language :: Python :: 3.8",
+    ],
+)