📜 ⬆️ ⬇️

Take the trash with you!



“Take the garbage with you!” - this is the name of the site that I made a couple of weeks ago at the weekend ( I did almost 2 days) , just in time for the spring season, when many people start to go out of town to rest.

The main idea is simple - to convince people that nature needs to be kept clean. To do this, I urge everyone to clean up the garbage for themselves (and not only for themselves), as well as to choose from various options of posters in A4 format, which can be printed on a regular printer and pinned to a tree with stationery buttons, this form of visual agitation
')



Graphics


First of all, it should be said that I took such wonderful pictures for posters on the site openclipart.org . They are distributed under a free license, and are very high quality drawn in the vector, so they could not be better suited as a clipart.

I painted the posters in the Inkscape vector editor, after which I saved the pdf files that site visitors can download and print. The editor coped with this task remarkably.

"Engine"


In quotes - because there is a cat crying code.
The site works on django using one model and three functions. For each poster with an animal there is a link to Wikipedia and a video, this is done so that visitors can learn more about the animal from the poster. The download links for pdf are processed by a function that keeps statistics on the downloads of posters. This is almost the entire site code:

models.py # coding: utf-8 import os import settings from django.db import models from django.core.files.storage import FileSystemStorage class OverwriteStorage(FileSystemStorage): def get_available_name(self, name): """ Returns a filename that's free on the target storage system, and available for new content to be written to. """ # If the filename already exists, remove it as if it was a true file system if self.exists(name): os.remove(os.path.join(settings.MEDIA_ROOT, name)) return name fs=OverwriteStorage(location=settings.MEDIA_ROOT) class Poster(models.Model): title = models.CharField(max_length=100, verbose_name=" ") thumbnail = models.ImageField(upload_to='images/posters',verbose_name=" ") preview = models.ImageField(upload_to='images/posters',verbose_name=" ") pdf = models.FileField("PDF  ", upload_to='posters/', storage=fs) downloads = models.IntegerField("  ", default=0) wiki_youtube_title = models.CharField(max_length=100, blank=True, default="", verbose_name="     ") wiki_url = models.URLField("    ", blank=True) video = models.TextField("   ", blank=True) youtube_url = models.URLField("  -", blank=True) def __unicode__(self): return u' "%s"' % self.title def get_absolute_url(self): return "/poster/%d/" % self.id class Meta(): ordering = ['id'] verbose_name = "" verbose_name_plural = "" views.py # coding: utf-8 from models import * from django.shortcuts import render_to_response, get_object_or_404 from django.template import RequestContext from django.http import HttpResponseRedirect def index(request): posters = Poster.objects.all() return render_to_response('website/index.html', {'posters': posters,}, context_instance=RequestContext(request)) def poster(request, poster_id, please_explain=False): poster = get_object_or_404(Poster, id=poster_id) return render_to_response('website/poster.html', {'poster': poster, 'please_explain': please_explain,}, context_instance=RequestContext(request)) def download_poster(request, poster_id): poster = get_object_or_404(Poster, id=poster_id) poster.downloads += 1 poster.save() return HttpResponseRedirect('/static/' + poster.pdf.url) 


In the model, I added youtube_url, because each time html code is excessively inserted, especially on all pages of the player of the same size. Add added, and the migration and templates are not reworked, because and so it works. In general, under-optimized.

please_explain in the poster view is added so that visitors from another site who clicked on banners saw a short explanation of why this site is needed.

css


Because I am not a designer, I used simple styles for decoration, and the Compass framework is used to work with css. It allows you to develop site layouts based on the grid, which makes it much easier for people like me to create more or less cross-browser content (IE is supported out of the box). At one time I negatively related to css frameworks, but Compass changed my attitude.

At the heart of Compass are two other frameworks - SASS and Blueprint . SASS is actually such a preprocessor for css files - there are variables, functions equivalent and much more.

The source code of the * .scss file is compiled and you get a regular css file, but with comments. It can then be processed by any compressor and everything will be OK.

If you decide to install Compass in Ubuntu, the sequence is as follows (at least 10.04):

 sudo apt-get install ruby rubygems rubygems-update cd /var/lib/gems/../gems/rubygems-update-.. sudo ruby setup.rb sudo gem install compass 

As for rubberiness, blueprint and compass - for some reason, the latest version does not optimally compile mixin liquid. Suboptimally - in the sense of simply appending it to the end of the file, overriding higher styles, because of this, the css file is much larger in size. To defeat this, you can use the following construction in your main scss file:
 @import "blueprint/reset"; @import "blueprint/scaffolding"; @import "blueprint/liquid"; @import "blueprint/typography"; @import "blueprint/utilities"; @import "blueprint/form"; @import "blueprint/interaction"; @include blueprint-typography; @include blueprint-utilities; @include blueprint-liquid-grid; @include blueprint-interaction; @include blueprint-form; 

Promised pictures


My friend has a website, and he offered to hang banners on it to attract attention to the site. I decided that I needed to find some interesting little-known facts about animals, and use them as texts. It turned out like this:

Your opinion and participation


Naturally, I am primarily interested in your opinion - what can be improved? Maybe there are some thoughts that can be added to the site. I thought even on the pages of posters add instructions for making simple origami on animals, and my daughter offered to add jokes.

And of course, a big request to tell about this site to your friends and acquaintances, especially today is Friday, for sure, many will go to nature tomorrow. The more people who care, the better our lives and cleaner nature.

Source: https://habr.com/ru/post/118586/


All Articles