pelican-nginx-alias-map


Namepelican-nginx-alias-map JSON
Version 2.0.0 PyPI version JSON
download
home_pagehttps://github.com/gaige/nginx_alias_map
SummaryThis Pelican plugin creates an nginx-compatible map between the final page locations and prior locations, defined in the `Alias` attribute for any article or page.
upload_time2024-04-09 18:51:43
maintainerNone
docs_urlNone
authorGaige B. Paulsen
requires_python<4.0,>=3.8
licenseMIT
keywords pelican plugin
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            nginx_alias_map: A Plugin for Pelican
====================================================

[![Build Status](https://img.shields.io/github/workflow/status/gaige/nginx_alias_map/build)](https://github.com/gaige/nginx_alias_map/actions)
[![PyPI Version](https://img.shields.io/pypi/v/pelican-nginx-alias-map)](https://pypi.org/project/pelican-nginx-alias-map/)
![License](https://img.shields.io/pypi/l/pelican-nginx-alias-map?color=blue)


This Pelican plugin creates an nginx-compatible map between the final page locations
and prior locations, defined in the "Alias" attribute for any article or page.

Loosely based on [pelican-alias](https://github.com/Nitron/pelican-alias) by Chris Williams,
which itself was inspired by jekyll_alias_generator.

Installation
------------

This plugin can be installed via:

    python -m pip install pelican-nginx-alias-map

Usage
-----

Add the directory to the base plugins directory to `PLUGIN_PATHS` in
`pelicanconf.py`, and then add `nginx_alias_map` to the `PLUGINS` list. For example,

    PLUGIN_PATHS = ["plugins"]
    PLUGINS = ['nginx_alias_map']

Definable parameters (with defaults in brackets) allow some configuration of the output
of the plugin.

There are two definable parameters, one from Chris's code (`ALIAS_DELIMITER`), which
defines the delimiter for multiple aliases for the same item; and `ALIAS_FILE`, which
defines the final name of the output file containing the map; and

    ALIAS_DELIMITER : Delimeter between multiple aliases for the same item [","]
    ALIAS_FILE : Name of map file to be placed in `output` ['alias_map.txt']
    ALIAS_MAP : Name of the map used in the alias file ['redirect_uri']
    ALIAS_MAP_TEMP: Name of the map used in the alias file when 2-stage lookup is needed ['redirect_uri_1']

### Support for URLs with query strings

In the event that you need to redirect a URI that contains a query string, a separate
map block will be created to map the `$request_uri` against an re.escaped version of your
alias that contains the `?` character. Otherwise, when no query string is present, the
test is made against `$uri`, which has much more processing done with it (query string
removal, removal of unnecessary '/'s, and so forth).

### NGINX configuration

The resulting file (stored in `output/$(ALIAS_FILE)`) is ready to be included into
your nginx configuration file (in an http stanza). Once the map is created, use the
`ALIAS_MAP` variable in your processing.

    include /opt/web/output/alias_map.txt;

    server {
      listen       *:80 ssl;
      server_name  example.server;


        # Redirection logic
        if ( $redirect_uri ) {
            return 301 $redirect_uri;
        }

        location / {
            alias /opt/web/output;
        }
    }

This configuration uses the evil `if` statement, but it's concise.  If you have a better
approach, please create a pull request, and I'll add it to this doc (or replace it if it
makes more sense).

I've chosen to use a 301 redirect here, because I'm confident of the permanency.  During
testing, you may want to use a 302.

Contributing
------------

Contributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on [existing issues][].

To start contributing to this plugin, review the [Contributing to Pelican][] documentation, beginning with the **Contributing Code** section.

[existing issues]: https://github.com/gaige/nginx_alias_map/issues
[Contributing to Pelican]: https://docs.getpelican.com/en/latest/contribute.html

License
-------

This project is licensed under the MIT license.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/gaige/nginx_alias_map",
    "name": "pelican-nginx-alias-map",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.8",
    "maintainer_email": null,
    "keywords": "pelican, plugin",
    "author": "Gaige B. Paulsen",
    "author_email": "gaige@cluetrust.com",
    "download_url": "https://files.pythonhosted.org/packages/67/a3/c7464e71994d7da4da468e7ee034cd861bc296bf054a9b306b295a29c40a/pelican_nginx_alias_map-2.0.0.tar.gz",
    "platform": null,
    "description": "nginx_alias_map: A Plugin for Pelican\n====================================================\n\n[![Build Status](https://img.shields.io/github/workflow/status/gaige/nginx_alias_map/build)](https://github.com/gaige/nginx_alias_map/actions)\n[![PyPI Version](https://img.shields.io/pypi/v/pelican-nginx-alias-map)](https://pypi.org/project/pelican-nginx-alias-map/)\n![License](https://img.shields.io/pypi/l/pelican-nginx-alias-map?color=blue)\n\n\nThis Pelican plugin creates an nginx-compatible map between the final page locations\nand prior locations, defined in the \"Alias\" attribute for any article or page.\n\nLoosely based on [pelican-alias](https://github.com/Nitron/pelican-alias) by Chris Williams,\nwhich itself was inspired by jekyll_alias_generator.\n\nInstallation\n------------\n\nThis plugin can be installed via:\n\n    python -m pip install pelican-nginx-alias-map\n\nUsage\n-----\n\nAdd the directory to the base plugins directory to `PLUGIN_PATHS` in\n`pelicanconf.py`, and then add `nginx_alias_map` to the `PLUGINS` list. For example,\n\n    PLUGIN_PATHS = [\"plugins\"]\n    PLUGINS = ['nginx_alias_map']\n\nDefinable parameters (with defaults in brackets) allow some configuration of the output\nof the plugin.\n\nThere are two definable parameters, one from Chris's code (`ALIAS_DELIMITER`), which\ndefines the delimiter for multiple aliases for the same item; and `ALIAS_FILE`, which\ndefines the final name of the output file containing the map; and\n\n    ALIAS_DELIMITER : Delimeter between multiple aliases for the same item [\",\"]\n    ALIAS_FILE : Name of map file to be placed in `output` ['alias_map.txt']\n    ALIAS_MAP : Name of the map used in the alias file ['redirect_uri']\n    ALIAS_MAP_TEMP: Name of the map used in the alias file when 2-stage lookup is needed ['redirect_uri_1']\n\n### Support for URLs with query strings\n\nIn the event that you need to redirect a URI that contains a query string, a separate\nmap block will be created to map the `$request_uri` against an re.escaped version of your\nalias that contains the `?` character. Otherwise, when no query string is present, the\ntest is made against `$uri`, which has much more processing done with it (query string\nremoval, removal of unnecessary '/'s, and so forth).\n\n### NGINX configuration\n\nThe resulting file (stored in `output/$(ALIAS_FILE)`) is ready to be included into\nyour nginx configuration file (in an http stanza). Once the map is created, use the\n`ALIAS_MAP` variable in your processing.\n\n    include /opt/web/output/alias_map.txt;\n\n    server {\n      listen       *:80 ssl;\n      server_name  example.server;\n\n\n        # Redirection logic\n        if ( $redirect_uri ) {\n            return 301 $redirect_uri;\n        }\n\n        location / {\n            alias /opt/web/output;\n        }\n    }\n\nThis configuration uses the evil `if` statement, but it's concise.  If you have a better\napproach, please create a pull request, and I'll add it to this doc (or replace it if it\nmakes more sense).\n\nI've chosen to use a 301 redirect here, because I'm confident of the permanency.  During\ntesting, you may want to use a 302.\n\nContributing\n------------\n\nContributions are welcome and much appreciated. Every little bit helps. You can contribute by improving the documentation, adding missing features, and fixing bugs. You can also help out by reviewing and commenting on [existing issues][].\n\nTo start contributing to this plugin, review the [Contributing to Pelican][] documentation, beginning with the **Contributing Code** section.\n\n[existing issues]: https://github.com/gaige/nginx_alias_map/issues\n[Contributing to Pelican]: https://docs.getpelican.com/en/latest/contribute.html\n\nLicense\n-------\n\nThis project is licensed under the MIT license.\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "This Pelican plugin creates an nginx-compatible map between the final page locations and prior locations, defined in the `Alias` attribute for any article or page.",
    "version": "2.0.0",
    "project_urls": {
        "Documentation": "https://docs.getpelican.com",
        "Homepage": "https://github.com/gaige/nginx_alias_map",
        "Issue Tracker": "https://github.com/gaige/nginx_alias_map/issues",
        "Repository": "https://github.com/gaige/nginx_alias_map"
    },
    "split_keywords": [
        "pelican",
        " plugin"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8df85c44c8e648c843ddbedf33fd260cccfa719c33965b416dd66e860092a9f1",
                "md5": "e76703b9269f4581f32b128dd04fee41",
                "sha256": "40aa11d763dfc6ec5fd9843fceeb722d7942e15fa389d6ed5b924e6dd779d551"
            },
            "downloads": -1,
            "filename": "pelican_nginx_alias_map-2.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e76703b9269f4581f32b128dd04fee41",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.8",
            "size": 7368,
            "upload_time": "2024-04-09T18:51:41",
            "upload_time_iso_8601": "2024-04-09T18:51:41.870170Z",
            "url": "https://files.pythonhosted.org/packages/8d/f8/5c44c8e648c843ddbedf33fd260cccfa719c33965b416dd66e860092a9f1/pelican_nginx_alias_map-2.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "67a3c7464e71994d7da4da468e7ee034cd861bc296bf054a9b306b295a29c40a",
                "md5": "5f57b44542985ed0ccbbe0010ef54b35",
                "sha256": "e224beb4f94d51262f6d927aea7a92c446f4dbc469330297e399b24fa94af500"
            },
            "downloads": -1,
            "filename": "pelican_nginx_alias_map-2.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "5f57b44542985ed0ccbbe0010ef54b35",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.8",
            "size": 5796,
            "upload_time": "2024-04-09T18:51:43",
            "upload_time_iso_8601": "2024-04-09T18:51:43.411604Z",
            "url": "https://files.pythonhosted.org/packages/67/a3/c7464e71994d7da4da468e7ee034cd861bc296bf054a9b306b295a29c40a/pelican_nginx_alias_map-2.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-09 18:51:43",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "gaige",
    "github_project": "nginx_alias_map",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "pelican-nginx-alias-map"
}
        
Elapsed time: 0.22478s