Index: cms/bin/generate_static_pages.py |
=================================================================== |
--- a/cms/bin/generate_static_pages.py |
+++ b/cms/bin/generate_static_pages.py |
@@ -14,16 +14,18 @@ |
# |
# You should have received a copy of the GNU General Public License |
# along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
import sys, os, re, errno, codecs |
from ..utils import process_page |
from ..sources import MercurialSource |
+MIN_TRANSLATED = 0.3 |
+ |
def memoize(func): |
memoized = {} |
def wrapper(*args): |
try: |
return memoized[args] |
except KeyError: |
return memoized.setdefault(args, func(*args)) |
return wrapper |
@@ -65,24 +67,25 @@ def generate_pages(repo, output_dir): |
config = source.read_config() |
defaultlocale = config.get("general", "defaultlocale") |
locales = list(source.list_locales()) |
if defaultlocale not in locales: |
locales.append(defaultlocale) |
for page, format in source.list_pages(): |
for locale in locales: |
if locale == defaultlocale or source.has_locale(locale, page): |
- pagedata = process_page(source, locale, page, format) |
+ pagedata = process_page(source, locale, page, format, |
+ min_translated=MIN_TRANSLATED) |
+ if pagedata: |
+ # Make sure links to static files are versioned |
+ pagedata = re.sub(r'(<script\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source.version, pagedata) |
+ pagedata = re.sub(r'(<link\s[^<>]*\bhref="/[^"<>]+)', r"\1?%s" % source.version, pagedata) |
+ pagedata = re.sub(r'(<img\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source.version, pagedata) |
- # Make sure links to static files are versioned |
- pagedata = re.sub(r'(<script\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source.version, pagedata) |
- pagedata = re.sub(r'(<link\s[^<>]*\bhref="/[^"<>]+)', r"\1?%s" % source.version, pagedata) |
- pagedata = re.sub(r'(<img\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source.version, pagedata) |
- |
- write_file([locale] + page.split("/"), pagedata) |
+ write_file([locale] + page.split("/"), pagedata) |
for filename in source.list_localizable_files(): |
for locale in locales: |
if source.has_localizable_file(locale, filename): |
filedata = source.read_localizable_file(locale, filename) |
write_file([locale] + filename.split("/"), filedata, binary=True) |
for filename in source.list_static(): |