Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Side by Side Diff: cms/bin/generate_static_pages.py

Issue 5694103719247872: Issue 2133 - Allow to specify default translation inline in pages rather than in a separate file (Closed)
Patch Set: Created March 12, 2015, 7:34 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | cms/converters.py » ('j') | cms/converters.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # coding: utf-8 1 # coding: utf-8
2 2
3 # This file is part of the Adblock Plus web scripts, 3 # This file is part of the Adblock Plus web scripts,
4 # Copyright (C) 2006-2015 Eyeo GmbH 4 # Copyright (C) 2006-2015 Eyeo GmbH
5 # 5 #
6 # Adblock Plus is free software: you can redistribute it and/or modify 6 # Adblock Plus is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License version 3 as 7 # it under the terms of the GNU General Public License version 3 as
8 # published by the Free Software Foundation. 8 # published by the Free Software Foundation.
9 # 9 #
10 # Adblock Plus is distributed in the hope that it will be useful, 10 # Adblock Plus is distributed in the hope that it will be useful,
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 55
56 with MercurialSource(repo) as source: 56 with MercurialSource(repo) as source:
57 # Cache the result for some functions - we can assume here that the data 57 # Cache the result for some functions - we can assume here that the data
58 # never changes 58 # never changes
59 source.resolve_link = memoize(source.resolve_link) 59 source.resolve_link = memoize(source.resolve_link)
60 source.read_config = memoize(source.read_config) 60 source.read_config = memoize(source.read_config)
61 source.read_template = memoize(source.read_template) 61 source.read_template = memoize(source.read_template)
62 source.read_locale = memoize(source.read_locale) 62 source.read_locale = memoize(source.read_locale)
63 source.read_include = memoize(source.read_include) 63 source.read_include = memoize(source.read_include)
64 64
65 config = source.read_config()
66 defaultlocale = config.get("general", "defaultlocale")
65 locales = list(source.list_locales()) 67 locales = list(source.list_locales())
66 for page, format in source.list_pages(): 68 for page, format in source.list_pages():
67 for locale in locales: 69 for locale in locales:
68 if source.has_locale(locale, page): 70 if locale == defaultlocale or source.has_locale(locale, page):
69 pagedata = process_page(source, locale, page, format) 71 pagedata = process_page(source, locale, page, format)
70 72
71 # Make sure links to static files are versioned 73 # Make sure links to static files are versioned
72 pagedata = re.sub(r'(<script\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % sour ce.version, pagedata) 74 pagedata = re.sub(r'(<script\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % sour ce.version, pagedata)
73 pagedata = re.sub(r'(<link\s[^<>]*\bhref="/[^"<>]+)', r"\1?%s" % sourc e.version, pagedata) 75 pagedata = re.sub(r'(<link\s[^<>]*\bhref="/[^"<>]+)', r"\1?%s" % sourc e.version, pagedata)
74 pagedata = re.sub(r'(<img\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source. version, pagedata) 76 pagedata = re.sub(r'(<img\s[^<>]*\bsrc="/[^"<>]+)', r"\1?%s" % source. version, pagedata)
75 77
76 write_file([locale] + page.split("/"), pagedata) 78 write_file([locale] + page.split("/"), pagedata)
77 79
78 for filename in source.list_localizable_files(): 80 for filename in source.list_localizable_files():
(...skipping 17 matching lines...) Expand all
96 os.rmdir(path) 98 os.rmdir(path)
97 remove_unknown(output_dir) 99 remove_unknown(output_dir)
98 100
99 if __name__ == "__main__": 101 if __name__ == "__main__":
100 if len(sys.argv) < 3: 102 if len(sys.argv) < 3:
101 print >>sys.stderr, "Usage: %s source_repository output_dir" % sys.argv[0] 103 print >>sys.stderr, "Usage: %s source_repository output_dir" % sys.argv[0]
102 sys.exit(1) 104 sys.exit(1)
103 105
104 repo, output_dir = sys.argv[1:3] 106 repo, output_dir = sys.argv[1:3]
105 generate_pages(repo, output_dir) 107 generate_pages(repo, output_dir)
OLDNEW
« no previous file with comments | « no previous file | cms/converters.py » ('j') | cms/converters.py » ('J')

Powered by Google App Engine
This is Rietveld