{ "info": { "author": "John Fink", "author_email": "johnfink8@gmail.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Framework :: Django", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 2.5", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Multimedia :: Graphics", "Topic :: Multimedia :: Graphics :: Graphics Conversion" ], "description": "django-sprites is a Django app with two bundled models that handle \nSprites and their associated SpriteItems.\n-----------\n\n * A Sprite is a combined image, consisting of one or more \n SpriteItems, each of which is an image intended to be used as an \n image background for an HTML element.\n \n * Combining these background images into a single image can \n enormously save on load times. There is a lot of time loss in \n sequentially requesting multiple images from the same server, and \n only 2-4 can be requested simultaneously. So if you have 20 or \n 30, that could add hundreds or thousands of milliseconds to your \n overall page load.\n \n * Each SpriteItem contains the info actually relevant to your site \n design, like the image itself, dimensions (which are calculated),\n HTML attributes like class and id, and these are used by the \n model methods to generate styling, full CSS lines, and/or an HTML\n tag source with the relevant image behind it and any input HTML \n inside.\n\nRequirements:\n-----------\n\n * PIL, with libjpeg support\n \n * Django (obviously)\n \n * Uuid\n \n * urllib2\n \nSetup:\n-----------\n\n * pip install django-sprites\n\n * Add to your settings.py INSTALLED_APPS:\n 'sprites',\n \n * Also in settings.py:\n MEDIA_ROOT = 'path/to/your/actual/intended/media/root'\n \n This will be used along with the relative paths in the next \n config items to determine save locations for images.\n \n \n MEDIA_URL = 'http://myserver.mydomain.com/media'\n \n This is used by Django to generate URLs for ImageFiles, in\n addition to the relative paths below. Fully-qualified path is\n not actually required, but it's better to make it fully-\n qualified here so that you can use the HTML on any domain, not\n just the same as your Django app.\n \n * Also in settings.py (optional):\n SPRITE_PATH = ''\n SPRITE_ITEM_PATH = ''\n \n These default to 'sprites' and 'sprite_items', respectively.\n \nUsage:\n-----------\n \n * Bulk load images into a sprite by calling:\n \n sprite=Sprite.create_from_urls(['http://path.to/first.jpg',\n 'http://path.to/second.jpg'...])\n # or...\n sprite=Sprite.create_from_local_files(['/path/to/first/file',\n '/path/to/second/file'])\n \n for spriteitem in sprite.spriteitem_set.all():\n # each spriteitem should get a (unique) css_id at least, \n # and a css_class if you intend to do any further styling\n pass\n \n * SpriteItem properties\n - spriteitem.style - outputs CSS style directives, without \n specifying it with a selector\n i.e.: \"display:block; background: url(whatever); etc.;\"\n \n - spriteitem.css - outputs the same style directives, with a \n selector based on spriteitem.css_id\n i.e.: \"#myimage {display:block; etc.;}\"\n \n - spriteitem.tag_with_style - ouputs a safe-marked (ready to \n use in a template) HTML span tag with embedded style attrib,\n including any internal HTML given by spriteitem.internal_html\n \n - spriteitem.thumbnail - If created, this is a OneToOne that \n links to another SpriteItem, which by convention (but not \n as a requirement) is a thumbnail of spriteitem.\n \n - spriteitem.make_thumbnail(width=64,height=64) - return a \n PIL.Image copy of spriteitem.image of size width,height. \n Aspect ratio is preserved, so size may not match exactly.\n \n This is used by sprite.create_thumbnails(width,height), \n which generates new spriteitems, associates those \n spriteitems with those of sprite as their thumbnails, and \n returns the newly created sprite.\n \n - spriteitem.sprite.build() should be called after making \n changes to a sprite. The methods internal to this app handle\n this sanely, but if you make changes you'll have to determine\n when and how often to re-build your sprites. I'd suggest \n building a set of sprites to build first, so you don't \n \n * Middleware\n Adding 'sprites.middleware.SpriteReplaceByClass', to \n MIDDLEWARE_CLASSES enables the replacement of IMG elements\n with styled DIVs. The SRC of the IMG will become the (sprite)\n background of the DIV. The DOM translation isn't perfect \n going from IMG to DIV, so be careful with this. By default, \n IMGs with css class 'sprite_img' will be replaced. The class \n can be changed with SPRITE_REPLACE_CSS_CLASS in settings.py.\n \n Note: The middleware relies on BeautifulSoup. Because one \n does not simply regex into HTML.\n\n \n * Note: Other than the middleware, this isn't really meant to be \n used by itself. Ideally, you'll have some kind of model that \n you'll ForeignKey relate to SpriteItem, like:\n \n class SiteElement(models.Model):\n spriteitem=models.ForeignKey(SpriteItem)\n link=models.CharField(max_length=255,null=True,blank=True)\n \n def get_tag(self):\n if self.link is not None:\n return '%s'%(\n self.link,self.spriteitem.tag_with_style)\n return self.spriteitem.tag_with_style\n \n * Should support django-storages backend extensions. Tested \n working with S3BotoStorage, at least.\n \n * Detects and sets image filetype based on the PIL-detected format \n of the component SpriteItem images. Ultimately it uses the last\n SpriteItem attached to the Sprite to set the format.\n\n\nToDo:\n-----------\n \n * Make it split up by image format, maybe. Mixing JPEGs into a \n sprite detected as GIF looks atrocious.\n \n * Write tests\n \n * Finish ToDo list", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/johnfink8/django-sprites", "keywords": "django sprite image", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "django-sprites", "package_url": "https://pypi.org/project/django-sprites/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/django-sprites/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/johnfink8/django-sprites" }, "release_url": "https://pypi.org/project/django-sprites/0.4.0/", "requires_dist": null, "requires_python": null, "summary": "Django app models to handle image sprites to speed up page loads that have multiple small images.", "version": "0.4.0" }, "last_serial": 790717, "releases": { "0.1.0": [ { "comment_text": "", "digests": { "md5": "bd84951998b19b8ca82d0931215f5a47", "sha256": "f6c32cf89acaca6dfe54a07eb350279709f10a47d5737c14cd3b8f6ccfea5b11" }, "downloads": -1, "filename": "django-sprites-0.1.0.tar.gz", "has_sig": false, "md5_digest": "bd84951998b19b8ca82d0931215f5a47", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5080, "upload_time": "2012-03-19T06:41:18", "url": "https://files.pythonhosted.org/packages/cc/d9/23bf6f76f40adf011a35fa6774c98eeb0755ac171f685d4e5d3f1868f3e5/django-sprites-0.1.0.tar.gz" } ], "0.2.0": [ { "comment_text": "", "digests": { "md5": "336da6ded78d306888aa8e6919cd0eda", "sha256": "aad7d0cd433828d690368f3259076a69374b4d43d63f25b71c810b5486694f5f" }, "downloads": -1, "filename": "django-sprites-0.2.0.tar.gz", "has_sig": false, "md5_digest": "336da6ded78d306888aa8e6919cd0eda", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 5239, "upload_time": "2012-03-19T19:02:31", "url": "https://files.pythonhosted.org/packages/e4/15/ae27c447e45a4a837492e70dce32c1436a342539f37235898ff8c7ac9dbf/django-sprites-0.2.0.tar.gz" } ], "0.3.0": [ { "comment_text": "", "digests": { "md5": "52aa0d28607a4e5fe9c0bae7f06e94f9", "sha256": "5b4d0ff5553388959f1c0a7c469aec2f3f913c9a785459cf9b8157174b7b038b" }, "downloads": -1, "filename": "django-sprites-0.3.0.tar.gz", "has_sig": false, "md5_digest": "52aa0d28607a4e5fe9c0bae7f06e94f9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6297, "upload_time": "2012-03-20T06:55:36", "url": "https://files.pythonhosted.org/packages/b2/63/da71ef535eb8f3f50b7ee484749eb681acd14b56516ecae7b20d6f7fa839/django-sprites-0.3.0.tar.gz" } ], "0.4.0": [ { "comment_text": "", "digests": { "md5": "2152249e05114a8e62460d183aa47306", "sha256": "786096955c3fdfa6380788b032cd07e8d102c2aaabca239813a44939571bb8ab" }, "downloads": -1, "filename": "django-sprites-0.4.0.tar.gz", "has_sig": false, "md5_digest": "2152249e05114a8e62460d183aa47306", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7076, "upload_time": "2012-03-20T19:03:38", "url": "https://files.pythonhosted.org/packages/40/3d/c4019803d8062f7e0737769fd7309461cc187497d4e62b93e8f8cfc843b6/django-sprites-0.4.0.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "2152249e05114a8e62460d183aa47306", "sha256": "786096955c3fdfa6380788b032cd07e8d102c2aaabca239813a44939571bb8ab" }, "downloads": -1, "filename": "django-sprites-0.4.0.tar.gz", "has_sig": false, "md5_digest": "2152249e05114a8e62460d183aa47306", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 7076, "upload_time": "2012-03-20T19:03:38", "url": "https://files.pythonhosted.org/packages/40/3d/c4019803d8062f7e0737769fd7309461cc187497d4e62b93e8f8cfc843b6/django-sprites-0.4.0.tar.gz" } ] }