class BuildHtml(BuildEbook):
def build(self, fieldfile):
from django.core.files.base import ContentFile
- from slughifi import slughifi
+ from fnpdjango.utils.text.slughifi import slughifi
from sortify import sortify
from librarian import html
from catalogue.models import Fragment, Tag
app_label = 'catalogue'
def save(self, *args, **kwargs):
- from slughifi import slughifi
+ from fnpdjango.utils.text.slughifi import slughifi
from catalogue.utils import ExistingFile, remove_zip
try:
@staticmethod
def tags_from_info(info):
- from slughifi import slughifi
+ from fnpdjango.utils.text.slughifi import slughifi
from sortify import sortify
meta_tags = []
categories = (('kinds', 'kind'), ('genres', 'genre'), ('authors', 'author'), ('epochs', 'epoch'))
from traceback import extract_stack
from django.test import TestCase
from django.test.utils import override_settings
-from slughifi import slughifi
+from fnpdjango.utils.text.slughifi import slughifi
from librarian import WLURI
from django.conf import settings
def get_dynamic_path(media, filename, ext=None, maxlen=100):
- from slughifi import slughifi
+ from fnpdjango.utils.text.slughifi import slughifi
# how to put related book's slug here?
if not ext:
from django.core.cache import get_cache
from catalogue.utils import split_tags
from django.utils.safestring import mark_safe
-from slughifi import slughifi
+from fnpdjango.utils.text.slughifi import slughifi
from django.utils.translation import ugettext_lazy as _
from newtagging import managers
+++ /dev/null
-#!/srv/library/wolnelektury/pythonenv/bin/python
-from __future__ import with_statement
-
-import shutil
-import os
-import sys
-
-from string import Template
-
-def render_template(source, dest, context={}):
- print "Rendering template:",
- with open(source, 'rb') as source_file:
- t = Template(source_file.read())
- with open(dest, 'wb') as dest_file:
- dest_file.write(t.safe_substitute(context))
- print "done."
-
-def restart_wsgi():
- print "Restarting wsgi application:",
- os.system("touch %s" % WSGI_TARGET)
- print "done."
-
-def update_application():
- print "Updating repository.",
- os.system("cd %s; git pull" % PROJECT_ROOT)
-
- print "Installing requirements"
- os.system("%s install -r %s" % (PIP, os.path.join(PROJECT_ROOT, 'requirements.txt')))
-
- print "Installing local requirements"
- os.system("%s install -r %s" % (PIP, os.path.join(ROOT, 'etc', 'requirements.txt')))
- print "done."
-
-ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
-
-PYTHON = os.path.join(ROOT, 'pythonenv', 'bin', 'python')
-PIP = os.path.join(ROOT, 'pythonenv', 'bin', 'pip')
-PYTHON_SITE = os.path.join(ROOT, 'pythonenv', 'lib', 'python2.6', 'site-packages')
-
-PROJECT_NAME = 'wolnelektury'
-PROJECT_ROOT = os.path.join(ROOT, 'application')
-
-MEDIA_ROOT = os.path.join(ROOT, 'www', 'media')
-
-ADMIN_EMAIL = 'lrekucki@gmail.com'
-
-WSGI_TARGET = os.path.join(ROOT, 'www', 'wsgi', PROJECT_NAME + '.wsgi')
-WSGI_DIR = os.path.dirname(WSGI_TARGET)
-
-WSGI_USER = PROJECT_NAME
-WSGI_PROCESSES = 5
-WSGI_THREADS = 1
-
-DOMAIN = 'lektury.staging.nowoczesnapolska.org.pl'
-
-#
-# Load local configuration
-#
-sys.path = [ os.path.join(ROOT, 'etc') ] + sys.path
-
-from local_deployment import *
-
-if __name__ == '__main__':
- update_application()
- render_template(os.path.join(PROJECT_ROOT, PROJECT_NAME + '.wsgi.tmpl'), WSGI_TARGET, context=globals())
- render_template(os.path.join(PROJECT_ROOT, PROJECT_NAME + '.vhost.tmpl'), os.path.join(ROOT, 'etc', PROJECT_NAME + '.vhost'), context=globals())
- restart_wsgi()
-from __future__ import with_statement # needed for python 2.5
-from fabric.api import *
-from fabric.contrib import files
-from fabric.context_managers import path
+from fnpdjango.deploy import *
-import os
-
-# ==========
-# = Config =
-# ==========
-# Globals
env.project_name = 'wolnelektury'
-env.use_south = True
-# Servers
-def staging():
- """Use staging server"""
- env.hosts = ['stigma.nowoczesnapolska.org.pl:2222']
- env.user = 'platforma'
- env.path = '/var/services/wolnelektury'
- env.python = '/usr/bin/python'
- env.virtualenv = '/usr/bin/virtualenv'
- env.pip = '/usr/bin/pip'
+@task
def production():
- """Use production server"""
- env.hosts = ['wolnelektury.pl']
+ env.hosts = ['giewont.icm.edu.pl']
env.user = 'lektury'
- env.path = '/srv/wolnelektury.pl'
- env.python = '/usr/bin/python'
- env.virtualenv = '/usr/bin/virtualenv'
- env.pip = 've/bin/pip'
- env.restart_webserver = restart_gunicorn_debian
-
-# =========
-# = Tasks =
-# =========
-def test():
- "Run the test suite and bail out if it fails"
- require('hosts', 'path', provided_by=[staging, production])
- result = run('cd %(path)s/%(project_name)s; %(python)s manage.py test' % env)
-
-def setup():
- """
- Setup a fresh virtualenv as well as a few useful directories, then run
- a full deployment. virtualenv and pip should be already installed.
- """
- require('hosts', 'path', provided_by=[staging, production])
-
- run('mkdir -p %(path)s; cd %(path)s; %(virtualenv)s .;' % env, pty=True)
- run('cd %(path)s; mkdir releases; mkdir shared; mkdir packages;' % env, pty=True)
- run('cd %(path)s/releases; ln -s . current; ln -s . previous' % env, pty=True)
- deploy()
-
-def deploy():
- """
- Deploy the latest version of the site to the servers,
- install any required third party modules,
- install the virtual host and then restart the webserver
- """
- require('hosts', 'path', provided_by=[staging, production])
-
- import time
- env.release = time.strftime('%Y-%m-%dT%H%M')
-
- upload_tar_from_git()
- upload_wsgi_script()
- upload_vhost_sample()
- upload_celery_conf()
- install_requirements()
- copy_localsettings()
- symlink_current_release()
- migrate()
- collectstatic()
- restart_webserver()
- restart_celery()
-
-def deploy_version(version):
- "Specify a specific version to be made live"
- require('hosts', 'path', provided_by=[localhost,webserver])
- env.version = version
- with cd(env.path):
- run('rm releases/previous; mv releases/current releases/previous;', pty=True)
- run('ln -s %(version)s releases/current' % env, pty=True)
- restart_webserver()
- restart_celery()
-
-def rollback():
- """
- Limited rollback capability. Simple loads the previously current
- version of the code. Rolling back again will swap between the two.
- """
- require('hosts', provided_by=[staging, production])
- require('path')
- with cd(env.path):
- run('mv releases/current releases/_previous;', pty=True)
- run('mv releases/previous releases/current;', pty=True)
- run('mv releases/_previous releases/previous;', pty=True)
- restart_webserver()
- restart_celery()
-
-
-# =====================================================================
-# = Helpers. These are called by other functions rather than directly =
-# =====================================================================
-def upload_tar_from_git():
- "Create an archive from the current Git branch and upload it"
- print '>>> upload tar from git'
- require('release', provided_by=[deploy])
- local('git-archive-all.sh --format tar %(release)s.tar' % env)
- local('gzip %(release)s.tar' % env)
- run('mkdir -p %(path)s/releases/%(release)s' % env, pty=True)
- run('mkdir -p %(path)s/packages' % env, pty=True)
- put('%(release)s.tar.gz' % env, '%(path)s/packages/' % env)
- run('cd %(path)s/releases/%(release)s && tar zxf ../../packages/%(release)s.tar.gz' % env, pty=True)
- local('rm %(release)s.tar.gz' % env)
+ env.app_path = '/srv/wolnelektury.pl'
+ env.services = [
+ DebianGunicorn('wolnelektury'),
+ Supervisord('celery.wolnelektury:'),
+ ]
-def upload_vhost_sample():
- "Create and upload Apache virtual host configuration sample"
- print ">>> upload vhost sample"
- files.upload_template('%(project_name)s.vhost.template' % env, '%(path)s/%(project_name)s.vhost.sample' % env, context=env)
-def upload_wsgi_script():
- "Create and upload a wsgi script sample"
- print ">>> upload wsgi script sample"
- files.upload_template('%(project_name)s.wsgi.template' % env, '%(path)s/%(project_name)s.wsgi' % env, context=env)
- run('chmod ug+x %(path)s/%(project_name)s.wsgi' % env)
-
-def upload_celery_conf():
- "Create and upload a Celery conf for supervisord"
- print ">>> upload celery supervisord conf"
- files.upload_template('%(project_name)s-celery.conf.template' % env, '%(path)s/%(project_name)s-celery.conf' % env, context=env)
- run('chmod ug+x %(path)s/%(project_name)s-celery.conf' % env)
-
-def install_requirements():
- "Install the required packages from the requirements file using pip"
- print '>>> install requirements'
- require('release', provided_by=[deploy])
- run('cd %(path)s; %(pip)s install -E ve -r %(path)s/releases/%(release)s/requirements.txt' % env, pty=True)
-
-def copy_localsettings():
- "Copy localsettings.py from root directory to release directory (if this file exists)"
- print ">>> copy localsettings"
- require('release', provided_by=[deploy])
- require('path', provided_by=[staging, production])
-
- with settings(warn_only=True):
- run('cp %(path)s/localsettings.py %(path)s/releases/%(release)s/%(project_name)s' % env)
-
-def symlink_current_release():
- "Symlink our current release"
- print '>>> symlink current release'
- require('release', provided_by=[deploy])
- require('path', provided_by=[staging, production])
- with cd(env.path):
- run('rm releases/previous; mv releases/current releases/previous')
- run('ln -s %(release)s releases/current' % env)
-
-def migrate():
- "Update the database"
- print '>>> migrate'
- require('project_name', provided_by=[staging, production])
- with cd('%(path)s/releases/current/%(project_name)s' % env):
- run('../../../ve/bin/python manage.py syncdb --noinput' % env, pty=True)
- if env.use_south:
- run('../../../ve/bin/python manage.py migrate' % env, pty=True)
-
-def collectstatic():
- """Collect static files"""
- print '>>> collectstatic'
- require('project_name', provided_by=[staging, production])
- with cd('%(path)s/releases/current/%(project_name)s' % env):
- run('../../../ve/bin/python manage.py collectstatic --noinput' % env, pty=True)
-
-def restart_gunicorn_debian():
- """Restarts gunicorn server using debian script."""
- print '>>> restart gunicorn'
- require('project_name', provided_by=[staging, production])
- with path('/sbin'):
- sudo('gunicorn-debian restart %(project_name)s' % env, shell=False)
-
-def restart_webserver():
- """Restarts the web server."""
- if hasattr(env, 'restart_webserver'):
- env.restart_webserver()
- else:
- require('project_name', provided_by=[staging, production])
- print '>>> restart webserver'
- run('touch %(path)s/%(project_name)s.wsgi' % env)
-
-def restart_celery():
- """Restarts the Celery task queue manager."""
- print '>>> restart Celery'
- require('project_name', provided_by=[staging, production])
- sudo('supervisorctl restart celery.%(project_name)s:' % env, shell=False)
+@task
+def staging():
+ env.hosts = ['san.nowoczesnapolska.org.pl:2223']
+ env.user = 'staging'
+ env.app_path = '/home/staging/wolnelektury.pl'
+ env.services = [
+ DebianGunicorn('wolnelektury'),
+ ]
+++ /dev/null
-class SetRemoteAddrFromXRealIP(object):
- """Sets REMOTE_ADDR from the X-Real-IP header, as set by Nginx."""
- def process_request(self, request):
- try:
- request.META['REMOTE_ADDR'] = request.META['HTTP_X_REAL_IP']
- except KeyError:
- return None
+++ /dev/null
-# -*- coding: utf-8 -*-
-import re
-from types import UnicodeType
-
-from django.template.defaultfilters import slugify
-
-# default unicode character mapping ( you may not see some chars, leave as is )
-char_map = {u'À': 'A', u'Á': 'A', u'Â': 'A', u'Ã': 'A', u'Ä': 'Ae', u'Å': 'A', u'Æ': 'A', u'Ā': 'A', u'Ą': 'A', u'Ă': 'A', u'Ç': 'C', u'Ć': 'C', u'Č': 'C', u'Ĉ': 'C', u'Ċ': 'C', u'Ď': 'D', u'Đ': 'D', u'È': 'E', u'É': 'E', u'Ê': 'E', u'Ë': 'E', u'Ē': 'E', u'Ę': 'E', u'Ě': 'E', u'Ĕ': 'E', u'Ė': 'E', u'Ĝ': 'G', u'Ğ': 'G', u'Ġ': 'G', u'Ģ': 'G', u'Ĥ': 'H', u'Ħ': 'H', u'Ì': 'I', u'Í': 'I', u'Î': 'I', u'Ï': 'I', u'Ī': 'I', u'Ĩ': 'I', u'Ĭ': 'I', u'Į': 'I', u'İ': 'I', u'IJ': 'IJ', u'Ĵ': 'J', u'Ķ': 'K', u'Ľ': 'K', u'Ĺ': 'K', u'Ļ': 'K', u'Ŀ': 'K', u'Ł': 'L', u'Ñ': 'N', u'Ń': 'N', u'Ň': 'N', u'Ņ': 'N', u'Ŋ': 'N', u'Ò': 'O', u'Ó': 'O', u'Ô': 'O', u'Õ': 'O', u'Ö': 'Oe', u'Ø': 'O', u'Ō': 'O', u'Ő': 'O', u'Ŏ': 'O', u'Œ': 'OE', u'Ŕ': 'R', u'Ř': 'R', u'Ŗ': 'R', u'Ś': 'S', u'Ş': 'S', u'Ŝ': 'S', u'Ș': 'S', u'Š': 'S', u'Ť': 'T', u'Ţ': 'T', u'Ŧ': 'T', u'Ț': 'T', u'Ù': 'U', u'Ú': 'U', u'Û': 'U', u'Ü': 'Ue', u'Ū': 'U', u'Ů': 'U', u'Ű': 'U', u'Ŭ': 'U', u'Ũ': 'U', u'Ų': 'U', u'Ŵ': 'W', u'Ŷ': 'Y', u'Ÿ': 'Y', u'Ý': 'Y', u'Ź': 'Z', u'Ż': 'Z', u'Ž': 'Z', u'à': 'a', u'á': 'a', u'â': 'a', u'ã': 'a', u'ä': 'ae', u'ā': 'a', u'ą': 'a', u'ă': 'a', u'å': 'a', u'æ': 'ae', u'ç': 'c', u'ć': 'c', u'č': 'c', u'ĉ': 'c', u'ċ': 'c', u'ď': 'd', u'đ': 'd', u'è': 'e', u'é': 'e', u'ê': 'e', u'ë': 'e', u'ē': 'e', u'ę': 'e', u'ě': 'e', u'ĕ': 'e', u'ė': 'e', u'ƒ': 'f', u'ĝ': 'g', u'ğ': 'g', u'ġ': 'g', u'ģ': 'g', u'ĥ': 'h', u'ħ': 'h', u'ì': 'i', u'í': 'i', u'î': 'i', u'ï': 'i', u'ī': 'i', u'ĩ': 'i', u'ĭ': 'i', u'į': 'i', u'ı': 'i', u'ij': 'ij', u'ĵ': 'j', u'ķ': 'k', u'ĸ': 'k', u'ł': 'l', u'ľ': 'l', u'ĺ': 'l', u'ļ': 'l', u'ŀ': 'l', u'ñ': 'n', u'ń': 'n', u'ň': 'n', u'ņ': 'n', u'ʼn': 'n', u'ŋ': 'n', u'ò': 'o', u'ó': 'o', u'ô': 'o', u'õ': 'o', u'ö': 'oe', u'ø': 'o', u'ō': 'o', u'ő': 'o', u'ŏ': 'o', u'œ': 'oe', u'ŕ': 'r', u'ř': 'r', u'ŗ': 'r', u'ś': 's', u'š': 's', u'ť': 't', u'ù': 'u', u'ú': 'u', u'û': 'u', u'ü': 'ue', u'ū': 'u', u'ů': 'u', u'ű': 'u', u'ŭ': 'u', u'ũ': 'u', u'ų': 'u', u'ŵ': 'w', u'ÿ': 'y', u'ý': 'y', u'ŷ': 'y', u'ż': 'z', u'ź': 'z', u'ž': 'z', u'ß': 'ss', u'ſ': 'ss', u'Α': 'A', u'Ά': 'A', u'Ἀ': 'A', u'Ἁ': 'A', u'Ἂ': 'A', u'Ἃ': 'A', u'Ἄ': 'A', u'Ἅ': 'A', u'Ἆ': 'A', u'Ἇ': 'A', u'ᾈ': 'A', u'ᾉ': 'A', u'ᾊ': 'A', u'ᾋ': 'A', u'ᾌ': 'A', u'ᾍ': 'A', u'ᾎ': 'A', u'ᾏ': 'A', u'Ᾰ': 'A', u'Ᾱ': 'A', u'Ὰ': 'A', u'Ά': 'A', u'ᾼ': 'A', u'Β': 'B', u'Γ': 'G', u'Δ': 'D', u'Ε': 'E', u'Έ': 'E', u'Ἐ': 'E', u'Ἑ': 'E', u'Ἒ': 'E', u'Ἓ': 'E', u'Ἔ': 'E', u'Ἕ': 'E', u'Έ': 'E', u'Ὲ': 'E', u'Ζ': 'Z', u'Η': 'I', u'Ή': 'I', u'Ἠ': 'I', u'Ἡ': 'I', u'Ἢ': 'I', u'Ἣ': 'I', u'Ἤ': 'I', u'Ἥ': 'I', u'Ἦ': 'I', u'Ἧ': 'I', u'ᾘ': 'I', u'ᾙ': 'I', u'ᾚ': 'I', u'ᾛ': 'I', u'ᾜ': 'I', u'ᾝ': 'I', u'ᾞ': 'I', u'ᾟ': 'I', u'Ὴ': 'I', u'Ή': 'I', u'ῌ': 'I', u'Θ': 'TH', u'Ι': 'I', u'Ί': 'I', u'Ϊ': 'I', u'Ἰ': 'I', u'Ἱ': 'I', u'Ἲ': 'I', u'Ἳ': 'I', u'Ἴ': 'I', u'Ἵ': 'I', u'Ἶ': 'I', u'Ἷ': 'I', u'Ῐ': 'I', u'Ῑ': 'I', u'Ὶ': 'I', u'Ί': 'I', u'Κ': 'K', u'Λ': 'L', u'Μ': 'M', u'Ν': 'N', u'Ξ': 'KS', u'Ο': 'O', u'Ό': 'O', u'Ὀ': 'O', u'Ὁ': 'O', u'Ὂ': 'O', u'Ὃ': 'O', u'Ὄ': 'O', u'Ὅ': 'O', u'Ὸ': 'O', u'Ό': 'O', u'Π': 'P', u'Ρ': 'R', u'Ῥ': 'R', u'Σ': 'S', u'Τ': 'T', u'Υ': 'Y', u'Ύ': 'Y', u'Ϋ': 'Y', u'Ὑ': 'Y', u'Ὓ': 'Y', u'Ὕ': 'Y', u'Ὗ': 'Y', u'Ῠ': 'Y', u'Ῡ': 'Y', u'Ὺ': 'Y', u'Ύ': 'Y', u'Φ': 'F', u'Χ': 'X', u'Ψ': 'PS', u'Ω': 'O', u'Ώ': 'O', u'Ὠ': 'O', u'Ὡ': 'O', u'Ὢ': 'O', u'Ὣ': 'O', u'Ὤ': 'O', u'Ὥ': 'O', u'Ὦ': 'O', u'Ὧ': 'O', u'ᾨ': 'O', u'ᾩ': 'O', u'ᾪ': 'O', u'ᾫ': 'O', u'ᾬ': 'O', u'ᾭ': 'O', u'ᾮ': 'O', u'ᾯ': 'O', u'Ὼ': 'O', u'Ώ': 'O', u'ῼ': 'O', u'α': 'a', u'ά': 'a', u'ἀ': 'a', u'ἁ': 'a', u'ἂ': 'a', u'ἃ': 'a', u'ἄ': 'a', u'ἅ': 'a', u'ἆ': 'a', u'ἇ': 'a', u'ᾀ': 'a', u'ᾁ': 'a', u'ᾂ': 'a', u'ᾃ': 'a', u'ᾄ': 'a', u'ᾅ': 'a', u'ᾆ': 'a', u'ᾇ': 'a', u'ὰ': 'a', u'ά': 'a', u'ᾰ': 'a', u'ᾱ': 'a', u'ᾲ': 'a', u'ᾳ': 'a', u'ᾴ': 'a', u'ᾶ': 'a', u'ᾷ': 'a', u'β': 'b', u'γ': 'g', u'δ': 'd', u'ε': 'e', u'έ': 'e', u'ἐ': 'e', u'ἑ': 'e', u'ἒ': 'e', u'ἓ': 'e', u'ἔ': 'e', u'ἕ': 'e', u'ὲ': 'e', u'έ': 'e', u'ζ': 'z', u'η': 'i', u'ή': 'i', u'ἠ': 'i', u'ἡ': 'i', u'ἢ': 'i', u'ἣ': 'i', u'ἤ': 'i', u'ἥ': 'i', u'ἦ': 'i', u'ἧ': 'i', u'ᾐ': 'i', u'ᾑ': 'i', u'ᾒ': 'i', u'ᾓ': 'i', u'ᾔ': 'i', u'ᾕ': 'i', u'ᾖ': 'i', u'ᾗ': 'i', u'ὴ': 'i', u'ή': 'i', u'ῂ': 'i', u'ῃ': 'i', u'ῄ': 'i', u'ῆ': 'i', u'ῇ': 'i', u'θ': 'th', u'ι': 'i', u'ί': 'i', u'ϊ': 'i', u'ΐ': 'i', u'ἰ': 'i', u'ἱ': 'i', u'ἲ': 'i', u'ἳ': 'i', u'ἴ': 'i', u'ἵ': 'i', u'ἶ': 'i', u'ἷ': 'i', u'ὶ': 'i', u'ί': 'i', u'ῐ': 'i', u'ῑ': 'i', u'ῒ': 'i', u'ΐ': 'i', u'ῖ': 'i', u'ῗ': 'i', u'κ': 'k', u'λ': 'l', u'μ': 'm', u'ν': 'n', u'ξ': 'ks', u'ο': 'o', u'ό': 'o', u'ὀ': 'o', u'ὁ': 'o', u'ὂ': 'o', u'ὃ': 'o', u'ὄ': 'o', u'ὅ': 'o', u'ὸ': 'o', u'ό': 'o', u'π': 'p', u'ρ': 'r', u'ῤ': 'r', u'ῥ': 'r', u'σ': 's', u'ς': 's', u'τ': 't', u'υ': 'y', u'ύ': 'y', u'ϋ': 'y', u'ΰ': 'y', u'ὐ': 'y', u'ὑ': 'y', u'ὒ': 'y', u'ὓ': 'y', u'ὔ': 'y', u'ὕ': 'y', u'ὖ': 'y', u'ὗ': 'y', u'ὺ': 'y', u'ύ': 'y', u'ῠ': 'y', u'ῡ': 'y', u'ῢ': 'y', u'ΰ': 'y', u'ῦ': 'y', u'ῧ': 'y', u'φ': 'f', u'χ': 'x', u'ψ': 'ps', u'ω': 'o', u'ώ': 'o', u'ὠ': 'o', u'ὡ': 'o', u'ὢ': 'o', u'ὣ': 'o', u'ὤ': 'o', u'ὥ': 'o', u'ὦ': 'o', u'ὧ': 'o', u'ᾠ': 'o', u'ᾡ': 'o', u'ᾢ': 'o', u'ᾣ': 'o', u'ᾤ': 'o', u'ᾥ': 'o', u'ᾦ': 'o', u'ᾧ': 'o', u'ὼ': 'o', u'ώ': 'o', u'ῲ': 'o', u'ῳ': 'o', u'ῴ': 'o', u'ῶ': 'o', u'ῷ': 'o', u'¨': '', u'΅': '', u'᾿': '', u'῾': '', u'῍': '', u'῝': '', u'῎': '', u'῞': '', u'῏': '', u'῟': '', u'῀': '', u'῁': '', u'΄': '', u'΅': '', u'`': '', u'῭': '', u'ͺ': '', u'᾽': '', u'А': 'A', u'Б': 'B', u'В': 'V', u'Г': 'G', u'Д': 'D', u'Е': 'E', u'Ё': 'E', u'Ж': 'ZH', u'З': 'Z', u'И': 'I', u'Й': 'I', u'К': 'K', u'Л': 'L', u'М': 'M', u'Н': 'N', u'О': 'O', u'П': 'P', u'Р': 'R', u'С': 'S', u'Т': 'T', u'У': 'U', u'Ф': 'F', u'Х': 'KH', u'Ц': 'TS', u'Ч': 'CH', u'Ш': 'SH', u'Щ': 'SHCH', u'Ы': 'Y', u'Э': 'E', u'Ю': 'YU', u'Я': 'YA', u'а': 'A', u'б': 'B', u'в': 'V', u'г': 'G', u'д': 'D', u'е': 'E', u'ё': 'E', u'ж': 'ZH', u'з': 'Z', u'и': 'I', u'й': 'I', u'к': 'K', u'л': 'L', u'м': 'M', u'н': 'N', u'о': 'O', u'п': 'P', u'р': 'R', u'с': 'S', u'т': 'T', u'у': 'U', u'ф': 'F', u'х': 'KH', u'ц': 'TS', u'ч': 'CH', u'ш': 'SH', u'щ': 'SHCH', u'ы': 'Y', u'э': 'E', u'ю': 'YU', u'я': 'YA', u'Ъ': '', u'ъ': '', u'Ь': '', u'ь': '', u'ð': 'd', u'Ð': 'D', u'þ': 'th', u'Þ': 'TH',
- u'ა': 'a', u'ბ': 'b', u'გ': 'g', u'დ': 'd', u'ე': 'e', u'ვ': 'v', u'ზ': 'z', u'თ': 't', u'ი': 'i', u'კ': 'k', u'ლ': 'l', u'მ': 'm', u'ნ': 'n', u'ო': 'o', u'პ': 'p', u'ჟ': 'zh', u'რ': 'r', u'ს': 's', u'ტ': 't', u'უ': 'u', u'ფ': 'p', u'ქ': 'k', u'ღ': 'gh', u'ყ': 'q', u'შ': 'sh', u'ჩ': 'ch', u'ც': 'ts', u'ძ': 'dz', u'წ': 'ts', u'ჭ': 'ch', u'ხ': 'kh', u'ჯ': 'j', u'ჰ': 'h' }
-
-def replace_char(m):
- char = m.group()
- if char_map.has_key(char):
- return char_map[char]
- else:
- return char
-
-def slughifi(value, do_slugify=True, overwrite_char_map={}):
- """
- High Fidelity slugify - slughifi.py, v 0.1
-
- Examples :
-
- >>> text = 'C\'est déjà l\'été.'
-
- >>> slughifi(text)
- 'cest-deja-lete'
-
- >>> slughifi(text, overwrite_char_map={u'\'': '-',})
- 'c-est-deja-l-ete'
-
- >>> slughifi(text, do_slugify=False)
- "C'est deja l'ete."
-
- # Normal slugify removes accented characters
- >>> slugify(text)
- 'cest-dj-lt'
-
- """
-
- # unicodification
- if type(value) != UnicodeType:
- value = unicode(value, 'utf-8', 'ignore')
-
- # overwrite chararcter mapping
- char_map.update(overwrite_char_map)
-
- # try to replace chars
- value = re.sub('[^a-zA-Z0-9\\s\\-]{1}', replace_char, value)
-
- # apply django default slugify
- if do_slugify:
- value = slugify(value)
-
- return value.encode('ascii', 'ignore')
-
# -*- coding: utf-8 -*-
import re
-from slughifi import char_map
+from fnpdjango.utils.text.slughifi import char_map
# Specifies diacritics order.
+-i http://pypi.nowoczesnapolska.org.pl/simple/
+
django-debug-toolbar
polib
BabelDjango
+Fabric
+-i http://pypi.nowoczesnapolska.org.pl/simple/
+
nose>=0.11
django-nose
nosexcover
# django
Django>=1.5,<1.6
+fnpdjango>=0.1.6,<0.2
South>=0.7 # migrations for django
-django-pipeline>=1.2
+django-pipeline>=1.2,<1.3
django-pagination>=1.0
django-maintenancemode>=0.10
-django-piston==0.2.2
+django-piston>=0.2.2,<0.2.3
django-jsonfield
django-picklefield
#django-allauth>=0.4,<0.5
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
-# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
-#
-from lxml import etree
-from slughifi import slughifi
-from django.core.management import setup_environ
-from wolnelektury import settings
-
-setup_environ(settings)
-
-from catalogue.models import Tag
-
-
-doc = etree.parse('rodziny.xml')
-
-for element in doc.findall('//span'):
- themes = [s.strip() for s in element.text.split(',')]
-
- element.text = u''
-
- for theme in themes:
- try:
- Tag.objects.get(slug=slughifi(theme))
-
- link = etree.SubElement(element, 'a', href=u'/katalog/%s' % slughifi(theme))
- link.text = theme
- link.tail = ', '
- last_link = link
- except:
- print "Pomijam %s" % slughifi(theme)
-
- last_link.tail = ''
-
-
-doc.write('ok.xml', xml_declaration=False, pretty_print=True, encoding='utf-8')
+++ /dev/null
-#!/usr/bin/env python
-# -*- coding: utf-8 -*-
-# This file is part of Wolnelektury, licensed under GNU Affero GPLv3 or later.
-# Copyright © Fundacja Nowoczesna Polska. See NOTICE for more information.
-#
-from django.core.management import setup_environ
-from wolnelektury import settings
-import sys
-from os.path import abspath, join, dirname, splitext
-import os
-
-# Add apps and lib directories to PYTHONPATH
-sys.path.insert(0, abspath(join(dirname(__file__), 'apps')))
-sys.path.insert(0, abspath(join(dirname(__file__), 'lib')))
-
-setup_environ(settings)
-
-from catalogue.models import Book
-from mutagen import easyid3
-from slughifi import slughifi
-
-chosen_book_slugs = set()
-
-for file_name in os.listdir('mp3'):
- base_name, ext = splitext(file_name)
- if ext != '.mp3':
- continue
-
- audio = easyid3.EasyID3(join('mp3', file_name))
- title = audio['title'][0]
- artist = title.split(',', 1)[0].strip()
- artist_slug = slughifi(artist)
- title_part = slughifi(title.rsplit(',', 1)[1].strip())
-
- print "--------------------"
- print "File: %s" % file_name
- print "Title: %s" % title
- print
- print "Matching books:"
-
- matching_books = [book for book in Book.tagged.with_all(artist_slug) if book.slug not in chosen_book_slugs]
- matching_books = [book for book in matching_books if title_part in book.slug]
-
- if len(matching_books) > 1:
- for i, book in enumerate(matching_books):
- print "%d: %s (%s)" % (i, book.title, ', '.join(tag.slug for tag in book.tags))
- print
- i = int(input("Choose which book is read in this file:"))
- elif len(matching_books) == 1:
- i = 0
- else:
- print "Skipping %s: No matching book found" % file_name
- continue
-
- print "You chose %d (%s)" % (i, matching_books[i].slug)
-
- chosen_book_slugs.add(matching_books[i].slug)
- os.rename(join('mp3', file_name), join('new_mp3', matching_books[i].slug + '.mp3'))
- os.rename(join('oggvorbis', base_name + '.ogg'), join('new_ogg', matching_books[i].slug + '.ogg'))
-
+++ /dev/null
-<VirtualHost *:80>
- ServerName %(project_name)s.example.com
- ServerAdmin admin@example.com
-
- WSGIDaemonProcess %(project_name)s user=%(user)s group=%(user)s processes=2 threads=15 display-name=%%{GROUP} python-path=%(path)s/lib/python2.5/site-packages
- WSGIProcessGroup %(project_name)s
-
- WSGIScriptAlias / %(path)s/%(project_name)s.wsgi
- <Directory %(path)s>
- Order allow,deny
- allow from all
- </Directory>
-
- Alias /media %(path)s/media
- <Directory %(path)s/media>
- Options Indexes
- Order allow,deny
- Allow from all
- </Directory>
-
- Alias /static %(path)s/releases/current/static
- <Directory %(path)s/releases/current/static>
- Options Indexes
- Order allow,deny
- Allow from all
- </Directory>
-
- LogLevel warn
- ErrorLog /var/log/apache2/error.log
- CustomLog /var/log/apache2/access.log combined
-</VirtualHost>
+++ /dev/null
-<VirtualHost *:80>
- ServerName $DOMAIN
- ServerAdmin $ADMIN_EMAIL
-
- WSGIDaemonProcess $PROJECT_NAME user=$WSGI_USER group=$WSGI_USER processes=$WSGI_PROCESSES threads=$WSGI_THREADS display-name=%{GROUP}
- WSGIProcessGroup $PROJECT_NAME
-
- WSGIScriptAlias / $WSGI_TARGET
- <Directory $WSGI_DIR>
- Order allow,deny
- allow from all
- </Directory>
-
- Alias /media $MEDIA_ROOT
- <Directory $MEDIA_ROOT >
- Order allow,deny
- Allow from all
- </Directory>
-
- LogLevel warn
- ErrorLog /var/log/apache2/$PROJECT_NAME/error.log
- CustomLog /var/log/apache2/$PROJECT_NAME/access.log combined
-</VirtualHost>
+++ /dev/null
-#!%(python)s
-import site
-site.addsitedir('%(path)s/ve/lib/python2.6/site-packages')
-
-import os
-from os.path import abspath, dirname, join
-import sys
-
-# Redirect sys.stdout to sys.stderr for bad libraries like geopy that use
-# print statements for optional import exceptions.
-sys.stdout = sys.stderr
-
-# Add apps and lib directories to PYTHONPATH
-sys.path = [
- '%(path)s/releases/current/%(project_name)s',
- '%(path)s/releases/current',
- '%(path)s/releases/current/apps',
- '%(path)s/releases/current/lib',
- '%(path)s/releases/current/lib/librarian',
-] + sys.path
-
-# Run Django
-os.environ["CELERY_LOADER"] = "django"
-os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
-
-from django.core.handlers.wsgi import WSGIHandler
-application = WSGIHandler()
+++ /dev/null
-#!$PYTHON
-import site
-site.addsitedir('$PYTHON_SITE')
-
-import os
-from os.path import abspath, dirname, join
-import sys
-
-# Redirect sys.stdout to sys.stderr for bad libraries like geopy that use
-# print statements for optional import exceptions.
-sys.stdout = sys.stderr
-
-# Add apps and lib directories to PYTHONPATH
-sys.path = [
- '$PROJECT_ROOT',
- '$PROJECT_ROOT/lib',
- '$PROJECT_ROOT/lib/librarian',
- '$PROJECT_ROOT/apps',
-] + sys.path
-
-# Run Django
-os.environ['DJANGO_SETTINGS_MODULE'] = '$PROJECT_NAME.settings'
-
-from django.core.handlers.wsgi import WSGIHandler
-application = WSGIHandler()
'django.middleware.common.CommonMiddleware',
'django.middleware.cache.FetchFromCacheMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
- 'realip_middleware.SetRemoteAddrFromXRealIP',
+ 'fnpdjango.middleware.SetRemoteAddrFromXRealIP',
]
ROOT_URLCONF = 'wolnelektury.urls'