{ "info": { "author": "Peter Inglesby", "author_email": "peter.inglesby@gmail.com", "bugtrack_url": null, "classifiers": [], "description": "# Django Amber\n\n[![Build Status](https://travis-ci.org/inglesp/django-amber.svg?branch=master)](https://travis-ci.org/inglesp/django-amber)\n\nHarness the power of Django to build your static sites!\n\n## Status\n\nAlpha-ish. Django Amber is not yet used in production anywhere.\n\n\n## Installation\n\nInstall Django Amber with `pip`:\n\n pip install django-amber\n\n\n## Usage\n\n### The basic idea\n\nDjango Amber is a static site generator, in the mould of\n[Jekyll](https://jekyllrb.com/) or [Pelican](http://docs.getpelican.com/)\n\nWith Django Amber, you build your website using Django, making use of the full\nDjango toolkit: models, views, urlconfs, templates, tests, and so on. Django\nAmber then provides a way to dump the dynamically generated contents of your\nsite to a tree of static files on the filesystem, so that they can be served by\nyour favourite webserver or static site host.\n\nAdditionally, instead of storing your data in a database, your data is\nserialized to files on the filesystem. This means that you can keep your data\nunder version control, and benefit from all the tooling which that brings.\nEach model instance is serialized to its own file. Serialization is documented\nunder \"Models\" below.\n\n\n### Management commands\n\nDjango Amber provides several management commands for managing your\napplication's data.\n\n\n#### `buildsite`\n\nYou should use this command to generate a static copy of your website's pages,\nso that it can be served by a webserver or static site host.\n\nThis command first runs the `loadpages` command, to populate the application's\ndatabase. It then starts a local development server (via `runserver`), and\ncrawls the site, following every link starting at `/`.\n\nThe crawled pages are written to the `output` directory.\n\nAdditionally, if the `DJANGO_AMBER_CNAME` setting is set, a file is written to\nthe `output` directory whose contents is the value of this setting. This is\nuseful for deploying to GitHub Pages.\n\n\n#### `serve`\n\nYou should use this command in development, as a beefed-up version of\n`runserver`.\n\nThis command takes an optional positional argument, the port on which to run\nthe server. By default, this is `8000`.\n\nThis command starts a local development server (via `runserver`) and serves the\napplication as normal.\n\nBefore the server starts, it runs the `loadpages` command to populate the\napplication's database from the files serialized on the filesystem.\n\nWhile the server is running, this command watches for any changes to the\nserialized files on the filesystem, and updates the application's database\naccordingly.\n\n\n#### `loadpages`\n\nYou probably won't need need to invoke this command directly.\n\nThis command deserializes the contents of the filesystem, and loads objects\ninto the application's database.\n\n\n#### `dumppages`\n\nYou probably won't need need to invoke this command directly.\n\nThis command serializes the contents of the application's database to the\nfilesystem.\n\n\n### Models\n\nAll models whose data is serialized to the filesystem must inherit either from\n`ModelWithContent` or `ModelWithoutContent`, which are [abstract base\nclasses](https://docs.djangoproject.com/en/1.9/topics/db/models/#abstract-base-classes)\ndefined in `django_amber.models`.\n\nWhat follows is a description of these classes, including the fields they\nprovide to their subclasses, and details of instances of these classes are\nserialized. It is probably clearer to read the example later on.\n\n\n#### `django_amber.models.ModelWithContent`\n\nSubclasses of `ModelWithContent` are for models whose instances represent\nobjects with a significant amount of content, for instance a whole web page, a\nnews article, or a blog post.\n\nSubclasses inherit the following fields:\n\n* `key`: A `CharField` whose value identifies the model instance uniquely.\n This is used as the base of the filename when the model instance is\n serialized to the filesystem, and is also used when to identify related models\n (see below).\n* `content`: A `TextField` whose value is the content corresponding to the page\n in question.\n* `content_format`: A `CharField` whose value is the file extension\n corresponding to the format of the content. For instance, if the content is\n [Markdown](https://daringfireball.net/projects/markdown/), the value should\n be `\"md\"`. This is used as the file extension when the model instance is\n serialized to the filesystem.\n\nSubclasses can define any other fields as required.\n\nBy default, instances of subclasses of `ModelWithContent` will be serialized to\nthe filesystem at `[app_label]]/data/[model_name]/[key].[content_format]`.\nThis can be overridden by setting the `dump_path_dir` class variable. See the\n`Article` model in `tests.models.py` for an example of this.\n\nThe file containing a serialized model instance will have two parts. Firstly,\nall fields, except for the three mentioned above, are serialized as YAML.\n`ForeignKey`s and `ManyToManyField`s are handled as described below. Then\nfollow three dashes (`---`), and then follows the value of the `content` field.\n\n\n#### `django_amber.models.ModelWithoutContent`\n\nSubclasses of `ModelWithoutContent` are for models whose instances represent\nobjects that do not have a significant amount of content.\n\nSubclasses inherit the following field:\n\n* `key`: A `CharField` whose value identifies the model instance uniquely.\n This is used as the base of the filename when the model instance is\n serialized to the filesystem, and is also used when to identify related models\n (see below).\n\nSubclasses can define any other fields as required.\n\nBy default, instances of subclasses of `ModelWithContent` will be serialized to\nthe filesystem at `[app_label]]/data/[model_name]/[key].yml`. This can be\noverridden by setting the `dump_path_dir` class variable. See the\n`Article` model in `tests.models.py` for an example of this.\n\nThe file containing a serialized model instance contains all fields, except for\n`key`, serialized as YAML. `ForeignKey`s and `ManyToManyField`s are handled as\ndescribed below.\n\n\n#### Relationships between models\n\nThis is definitely easier explained by example... see below.\n\nIf model `A` has a `ForeignKey` field to model `B`, when an instance `a` of `A`\nis serialized, the serialized value of `b` will be `a.b.key`.\n\nSimilarly, if model `A` has a `ManyToManyField` field to model `C`, when an\ninstance `a` of `A` is serialized, the serialized value of `cs` will be the\nlist `[c.key for c in a.cs]`.\n\nTo ensure that objects can be deserialized correctly, all `ForeignKey` fields\nmust have `null` set to `True`.\n\n\n### Example\n\nSuppose we want to build a site that displays articles on a range of topics.\nEach article has an author, and may have many tags.\n\nWe have the following three models in an app called `myapp`.\n\n\n class Article(ModelWithContent):\n title = models.CharField(max_length=255)\n author = models.ForeignKey('Author', null=True)\n tags = models.ManyToManyField('Tag', related_name='articles')\n\n class Author(ModelWithoutContent):\n name = models.CharField(max_length=255)\n email = models.EmailField()\n\n class Tag(ModelWithoutContent):\n name = models.CharField(max_length=255)\n description = models.CharField(max_length=255)\n\n\nWe can create instances of these models by creating some files on the\nfilesystem:\n\n```\n# myapp/pages/article/django.md\nauthor: jane\ntags:\n- django\ntitle: All about Django\n---\nThis is an article about *Django*.\n```\n\n```\n# myapp/metadata/author/jane.yml\nname: Jane Smith\nemail: jane@example.com\n```\n\n```\n# myapp/metadata/tag/django.yml\nname: Django\ndescription: Django is the web framework for perfectionists with deadlines\n```\n\n(Alternatively, we could populate the Django database via eg the admin, and\nthen run the `dumppages` command to write the data to the filesystem.)\n\n\n## Development\n\nRun tests with `tox`.\n\n\n## About the name\n\n[Thales of Miletus](https://en.wikipedia.org/wiki/Thales) used amber to\ngenerate static electricity.", "description_content_type": null, "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/inglesp/django-amber", "keywords": "", "license": "License :: OSI Approved :: MIT License", "maintainer": "", "maintainer_email": "", "name": "django-amber", "package_url": "https://pypi.org/project/django-amber/", "platform": "", "project_url": "https://pypi.org/project/django-amber/", "project_urls": { "Homepage": "http://github.com/inglesp/django-amber" }, "release_url": "https://pypi.org/project/django-amber/0.8.0/", "requires_dist": null, "requires_python": "", "summary": "A Django-powered static site generator", "version": "0.8.0" }, "last_serial": 3109817, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "8771b3de41a100df9eea4b6b5b9f43f8", "sha256": "531e54681bce8cae1e7375c5208b872ae15ca7f3aab840d730b16fb141c9c133" }, "downloads": -1, "filename": "django-amber-0.1.0.tar.gz", "has_sig": false, "md5_digest": "8771b3de41a100df9eea4b6b5b9f43f8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 13333, "upload_time": "2016-07-16T19:38:00", "url": "https://files.pythonhosted.org/packages/94/c6/3556ed1a08576290f474e1b914e799ab49478947774d104548197a37ab79/django-amber-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "3e6d66eb6566a811c434f9fb4b406536", "sha256": "0d69c28f83bab014c06ddf405708ad99e61fa13db02e59ecd1f325dcf06b2b72" }, "downloads": -1, "filename": "django-amber-0.2.0.tar.gz", "has_sig": false, "md5_digest": "3e6d66eb6566a811c434f9fb4b406536", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14543, "upload_time": "2016-07-28T23:34:45", "url": "https://files.pythonhosted.org/packages/08/37/1a437f52049b3619111dcee4420eaf324ed0cafb97f5737e1b4153cf45bf/django-amber-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "6b1e0a0031b92409309601d1b0992163", "sha256": "c8ff1cbebae49cf52d59b53a92f90d07a888ba66a73ce6d0b875a246ae010da2" }, "downloads": -1, "filename": "django-amber-0.3.0.tar.gz", "has_sig": false, "md5_digest": "6b1e0a0031b92409309601d1b0992163", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14001, "upload_time": "2016-08-01T14:12:47", "url": "https://files.pythonhosted.org/packages/5b/a0/00571266b4387dd3a91ee9689f2b8aa62c25aafffc52f842cc7c47e8da63/django-amber-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "706787ffb7bafa69e923a2d49a2e981f", "sha256": "e527f1502e7d339b84232997796e524017785362ed3d1dcc6ba1829859edf34b" }, "downloads": -1, "filename": "django-amber-0.4.0.tar.gz", "has_sig": false, "md5_digest": "706787ffb7bafa69e923a2d49a2e981f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14161, "upload_time": "2016-08-09T11:32:42", "url": "https://files.pythonhosted.org/packages/1d/6c/842866554854c8db7458a760dd575e967ff6ac943f1f8df023b566f7e949/django-amber-0.4.0.tar.gz" } ], "0.5.0": [ { "comment_text": "", "digests": { "md5": "236025825726e76d947180b0b67cd070", "sha256": "2931a2d360273f7f7d64e8372e5cdd7dbb7863ade06f3d562d523dab037ca000" }, "downloads": -1, "filename": "django-amber-0.5.0.tar.gz", "has_sig": false, "md5_digest": "236025825726e76d947180b0b67cd070", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14173, "upload_time": "2016-09-09T08:12:33", "url": "https://files.pythonhosted.org/packages/06/bb/df523a07069f622f48f2be7285cfd0b36e34bb6c5826382c013ca64d6e2a/django-amber-0.5.0.tar.gz" } ], "0.6.0": [ { "comment_text": "", "digests": { "md5": "803761fc1158ea4b0a913659825201cd", "sha256": "b2942da4ca5f56023d60b40010ffae7dc58747851832c0944924d8e0cc5be4f7" }, "downloads": -1, "filename": "django-amber-0.6.0.tar.gz", "has_sig": false, "md5_digest": "803761fc1158ea4b0a913659825201cd", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14215, "upload_time": "2016-09-09T16:59:59", "url": "https://files.pythonhosted.org/packages/2d/a3/4a49d790b18f59ae6971e91b220f3ed103a835b3ee26fbfcd4c02f7c0584/django-amber-0.6.0.tar.gz" } ], "0.7.0": [ { "comment_text": "", "digests": { "md5": "2c150c79b4e46eef1cc7c86d18e5292c", "sha256": "3fd999e7ce3307cdb5dd9e39d9508737fd2a09d0e5c0b2b35a190eca97f6e8f3" }, "downloads": -1, "filename": "django-amber-0.7.0.tar.gz", "has_sig": false, "md5_digest": "2c150c79b4e46eef1cc7c86d18e5292c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14718, "upload_time": "2017-01-23T17:04:59", "url": "https://files.pythonhosted.org/packages/ce/16/a94ccd674a1ca43d7a98db734be5bb07525152d3dfee0771722e96b0c477/django-amber-0.7.0.tar.gz" } ], "0.8.0": [ { "comment_text": "", "digests": { "md5": "d1eb991cd27268608a0d120696b06360", "sha256": "d4e87a50f1bdbf573711dcb60028d04d69f000b357661dee5d2ce44b342936a5" }, "downloads": -1, "filename": "django-amber-0.8.0.tar.gz", "has_sig": false, "md5_digest": "d1eb991cd27268608a0d120696b06360", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14733, "upload_time": "2017-08-20T14:47:49", "url": "https://files.pythonhosted.org/packages/10/0b/324952e2be2b266d0fea72d644d20af38cd1e76456a3b6cb5ee0a140bfa6/django-amber-0.8.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d1eb991cd27268608a0d120696b06360", "sha256": "d4e87a50f1bdbf573711dcb60028d04d69f000b357661dee5d2ce44b342936a5" }, "downloads": -1, "filename": "django-amber-0.8.0.tar.gz", "has_sig": false, "md5_digest": "d1eb991cd27268608a0d120696b06360", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14733, "upload_time": "2017-08-20T14:47:49", "url": "https://files.pythonhosted.org/packages/10/0b/324952e2be2b266d0fea72d644d20af38cd1e76456a3b6cb5ee0a140bfa6/django-amber-0.8.0.tar.gz" } ] }