def activity_svg(request): bars = [] opacities = {0: ".1", 1: ".3", 2: ".5", 3: ".7"} data = get_activity() top_count = max(data) for i, count in enumerate(data): height = int(76 * count / top_count) item = { "rx": 2, "width": 6, "height": height, "id": "b{}".format(i), "x": 10 * i, "y": 86 - height, } if height < 20: item["fill"] = "#f6664c" elif height < 45: item["fill"] = "#38f" else: item["fill"] = "#2eccaa" if i in opacities: item["opacity"] = opacities[i] bars.append(item) return render( request, "svg/activity.svg", {"bars": bars}, content_type="image/svg+xml; charset=utf-8", )
def activity_svg(request): bars = [] opacities = {0: '.1', 1: '.3', 2: '.5', 3: '.7'} data = get_activity() top_count = max(data) for i, count in enumerate(data): height = int(76 * count / top_count) item = { 'rx': 2, 'width': 6, 'height': height, 'id': 'b{}'.format(i), 'x': 10 * i, 'y': 86 - height, } if height < 20: item['fill'] = '#f6664c' elif height < 45: item['fill'] = '#38f' else: item['fill'] = '#2eccaa' if i in opacities: item['opacity'] = opacities[i] bars.append(item) return render( request, 'svg/activity.svg', {'bars': bars}, content_type='image/svg+xml; charset=utf-8', )
def weblate_web(request): if request.resolver_match and request.resolver_match.url_name: match = request.resolver_match url_name = ":".join(match.namespaces + [match.url_name]) url_kwargs = match.kwargs else: url_name = "home" url_kwargs = {} # Get canonical URl, unfortunately there seems to be no clean # way, so just strip /en/ from the URL # See also https://stackoverflow.com/a/27727877/225718 with override("en"): canonical_url = reverse(url_name, kwargs=url_kwargs) if canonical_url.startswith("/en/"): canonical_url = canonical_url[3:] language_urls = [] for code, name in settings.LANGUAGES: with override(code): language_urls.append({ "name": name, "code": code, "url": reverse(url_name, kwargs=url_kwargs), }) downloads = [f"Weblate-{VERSION}.{ext}" for ext in EXTENSIONS] language_col = ceil(len(settings.LANGUAGES) / 3) return { "downloads": downloads, "canonical_url": canonical_url, "language_urls": language_urls, "donate_links": Donation.objects.filter(active=True, reward=3), "activity_sum": sum(get_activity()[-7:]), "contributors": SimpleLazyObject(get_contributors), "changes": SimpleLazyObject(get_changes), "language_columns": [ language_urls[:language_col], language_urls[language_col:language_col * 2], language_urls[language_col * 2:], ], }
def weblate_web(request): if request.resolver_match and request.resolver_match.url_name: match = request.resolver_match url_name = ':'.join(match.namespaces + [match.url_name]) url_kwargs = match.kwargs else: url_name = 'home' url_kwargs = {} # Get canonical URl, unfortunately there seems to be no clean # way, so just strip /en/ from the URL # See also https://stackoverflow.com/a/27727877/225718 with override('en'): canonical_url = reverse(url_name, kwargs=url_kwargs) if canonical_url.startswith('/en/'): canonical_url = canonical_url[3:] language_urls = [] for code, name in settings.LANGUAGES: with override(code): language_urls.append({ 'name': name, 'code': code, 'url': reverse(url_name, kwargs=url_kwargs), }) downloads = ['Weblate-{0}.{1}'.format(VERSION, ext) for ext in EXTENSIONS] language_col = ceil(len(settings.LANGUAGES) / 3) return { 'downloads': downloads, 'canonical_url': canonical_url, 'language_urls': language_urls, 'donate_links': Donation.objects.filter(active=True, reward=3), 'activity_sum': sum(get_activity()[-7:]), 'contributors': get_contributors(), 'changes': get_changes(), 'language_columns': [ language_urls[:language_col], language_urls[language_col:language_col * 2], language_urls[language_col * 2:], ], }
def handle(self, *args, **options): get_contributors(True) get_activity(True) get_changes(True)