diff --git a/databags/translate.ini b/databags/translate.ini index f44992e..29ebf13 100644 --- a/databags/translate.ini +++ b/databags/translate.ini @@ -2,6 +2,7 @@ ; Breadcrumbs home = Home edit_on_github = Edit on GitHub +create_on_github = Translate on GitHub ; Footer sitemap = Sitemap @@ -118,6 +119,7 @@ incomplete_space_before_link = false ; Breadcrumbs home = Inicio edit_on_github = Editar en GitHub +create_on_github = Traducir en GitHub ; Footer sitemap = Mapa del Sitio diff --git a/packages/lektor_pybee_plugin/lektor_pybee_plugin.py b/packages/lektor_pybee_plugin/lektor_pybee_plugin.py index 0ffd5ec..319e2ac 100644 --- a/packages/lektor_pybee_plugin/lektor_pybee_plugin.py +++ b/packages/lektor_pybee_plugin/lektor_pybee_plugin.py @@ -1,9 +1,12 @@ # -*- coding: utf-8 -*- """This is a custom local plugin to ad extra functionality to pybee site.""" +# Standrd library imports +import urllib # Third party imports from lektor.pluginsystem import Plugin from lektor.db import Record +from markupsafe import Markup class PyBeePlugin(Plugin): @@ -28,6 +31,21 @@ class PyBeePlugin(Plugin): return alt_available + def urlencode_limit(string, limit=6000): + """Encodes url for uri but if over limit returns None""" + if type(string) == 'Markup': + string = string.unescape() + + if len(string) <= limit: + string = string.encode('utf8') + string = urllib.quote_plus(string) + string = Markup(string) + else: + string = None + + return string + self.env.jinja_env.globals.update( is_alt_content_available=is_alt_content_available ) + self.env.jinja_env.globals.update(urlencode_limit=urlencode_limit) diff --git a/templates/layout.html b/templates/layout.html index a13bb22..4eb9751 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -13,6 +13,7 @@ {% set t_sitemap = transbag('translate', this.alt, 'sitemap') %} {% set t_welcome = transbag('translate', this.alt, 'welcome') %} {% set t_edit_on_github = transbag('translate', this.alt, 'edit_on_github') %} +{% set t_create_on_github = transbag('translate', this.alt, 'create_on_github') %} @@ -84,21 +85,28 @@ ga('send', 'pageview'); - {# This method is provided by a custom plugin found in /packages/lektor_pybee_plugin/ #} - {% if is_alt_content_available(this) %}
- {% endif %} -