import random import urlparse from os import path from django.conf import settings import jingo import jinja2 from funfactory.settings_base import path as base_path from funfactory.urlresolvers import reverse L10N_MEDIA_PATH = base_path('media', '%s', 'l10n') def _l10n_media_exists(type, locale, url): """ checks if a localized media file exists for the locale """ return path.exists(path.join(L10N_MEDIA_PATH % type, locale, url)) @jingo.register.function @jinja2.contextfunction def php_url(ctx, url): """Process a URL on the PHP site and prefix the locale to it.""" locale = getattr(ctx['request'], 'locale', None) # Do this only if we have a locale and the URL is absolute if locale and url[0] == '/': return path.join('/', locale, url.lstrip('/')) return url
import urlparse from os import path from django.conf import settings import jingo import jinja2 from funfactory.settings_base import path as base_path from funfactory.urlresolvers import reverse L10N_IMG_PATH = base_path('media', 'img', 'l10n') def _l10n_media_exists(locale, url): """ checks if a localized media file exists for the locale """ return path.exists(path.join(L10N_IMG_PATH, locale, url)) @jingo.register.function @jinja2.contextfunction def php_url(ctx, url): """Process a URL on the PHP site and prefix the locale to it.""" locale = getattr(ctx['request'], 'locale', None) # Do this only if we have a locale and the URL is absolute if locale and url[0] == '/': return path.join('/', locale, url.lstrip('/')) return url
import urlparse from os import path from django.conf import settings import jingo import jinja2 from funfactory.settings_base import path as base_path from funfactory.urlresolvers import reverse L10N_IMG_PATH = base_path('media', 'img', 'l10n') def _l10n_media_exists(locale, url): """ checks if a localized media file exists for the locale """ return path.exists(path.join(L10N_IMG_PATH, locale, url)) @jingo.register.function @jinja2.contextfunction def php_url(ctx, url): """Process a URL on the PHP site and prefix the locale to it.""" locale = getattr(ctx['request'], 'locale', None) # Do this only if we have a locale and the URL is absolute if locale and url[0] == '/': return path.join('/', locale, url.lstrip('/')) return url @jingo.register.function
import jingo import markdown as md from bs4 import BeautifulSoup from commonware.response.decorators import xframe_allow from django.core.mail import EmailMessage from django.views.decorators.cache import cache_page from django.views.decorators.csrf import csrf_protect from lib import l10n_utils from funfactory.settings_base import path as base_path from forms import PrivacyContactForm LEGAL_DOCS_PATH = base_path('vendor-local', 'src', 'legal-docs') def load_legal_doc(request, doc_name): """ Load a static Markdown file and return the document as a BeautifulSoup object for easier manipulation. """ locale = l10n_utils.get_locale(request) source = path.join(LEGAL_DOCS_PATH, doc_name, locale + '.md') output = StringIO.StringIO() if not path.exists(source): source = path.join(LEGAL_DOCS_PATH, doc_name, 'en-US.md') # Parse the Markdown file
import random import urlparse from os import path from django.conf import settings from django.template.defaultfilters import slugify as django_slugify import jingo import jinja2 from funfactory.settings_base import path as base_path from funfactory.urlresolvers import reverse L10N_MEDIA_PATH = base_path("media", "%s", "l10n") def _l10n_media_exists(type, locale, url): """ checks if a localized media file exists for the locale """ return path.exists(path.join(L10N_MEDIA_PATH % type, locale, url)) @jingo.register.function @jinja2.contextfunction def php_url(ctx, url): """Process a URL on the PHP site and prefix the locale to it.""" locale = getattr(ctx["request"], "locale", None) # Do this only if we have a locale and the URL is absolute if locale and url[0] == "/": return path.join("/", locale, url.lstrip("/")) return url
import random import urlparse from os import path from django.conf import settings from django.template.defaultfilters import slugify as django_slugify import jingo import jinja2 from funfactory.settings_base import path as base_path from funfactory.urlresolvers import reverse L10N_MEDIA_PATH = base_path('media', '%s', 'l10n') def _l10n_media_exists(type, locale, url): """ checks if a localized media file exists for the locale """ return path.exists(path.join(L10N_MEDIA_PATH % type, locale, url)) @jingo.register.function @jinja2.contextfunction def php_url(ctx, url): """Process a URL on the PHP site and prefix the locale to it.""" locale = getattr(ctx['request'], 'locale', None) # Do this only if we have a locale and the URL is absolute if locale and url[0] == '/': return path.join('/', locale, url.lstrip('/')) return url