How to use the weblate.utils.site.get_site_url function in weblate

To help you get started, we’ve selected a few weblate examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github WeblateOrg / weblate / weblate / utils / render.py View on Github external
if isinstance(component, Component):
        kwargs['component_name'] = component.name
        kwargs['component_slug'] = component.slug
        kwargs['component_remote_branch'] = \
            component.repository.get_remote_branch_name()
        if 'url' not in kwargs:
            kwargs['url'] = get_site_url(component.get_absolute_url())
        project = component.project
        kwargs.pop('component', None)

    if isinstance(project, Project):
        kwargs['project_name'] = project.name
        kwargs['project_slug'] = project.slug
        if 'url' not in kwargs:
            kwargs['url'] = get_site_url(project.get_absolute_url())
        kwargs.pop('project', None)

    with override('en'):
        return Template(
            template,
            engine=RestrictedEngine(),
        ).render(
            Context(kwargs, autoescape=False),
        )
github WeblateOrg / weblate / weblate / trans / views / widgets.py View on Github external
color_list = []
        for color in widget_class.colors:
            kwargs = {
                'project': obj.slug,
                'widget': widget_name,
                'color': color,
                'extension': widget_class.extension,
            }
            if lang is not None:
                kwargs['lang'] = lang
            if component is not None:
                kwargs['component'] = component
            color_url = reverse('widget-image', kwargs=kwargs)
            color_list.append({
                'name': color,
                'url': get_site_url(color_url),
            })
        widget_list.append({
            'name': widget_name,
            'colors': color_list,
            'verbose': widget_class.verbose,
        })

    return render(
        request,
        'widgets.html',
        {
            'engage_url': engage_url,
            'engage_link': engage_link,
            'engage_url_track': engage_url_track,
            'widget_list': widget_list,
            'widget_base_url': widget_base_url,
github WeblateOrg / weblate / weblate / formats / exporters.py View on Github external
def __init__(self, project=None, language=None, url=None,
                 translation=None, fieldnames=None):
        if translation is not None:
            self.plural = translation.plural
            self.project = translation.component.project
            self.language = translation.language
            self.url = get_site_url(translation.get_absolute_url())
        else:
            self.project = project
            self.language = language
            self.plural = language.plural
            self.url = url
        self.fieldnames = fieldnames
github WeblateOrg / weblate / weblate / accounts / notifications.py View on Github external
def get_context(self, change=None, subscription=None, extracontext=None):
        """Return context for rendering mail"""
        result = {
            'LANGUAGE_CODE': get_language(),
            'LANGUAGE_BIDI': get_language_bidi(),
            'current_site_url': get_site_url(),
            'site_title': settings.SITE_TITLE,
            'notification_name': self.verbose,
        }
        if subscription is not None:
            result['unsubscribe_nonce'] = TimestampSigner().sign(subscription.pk)
        if extracontext:
            result.update(extracontext)
        if change:
            result['change'] = change
            # Extract change attributes
            attribs = (
                'unit',
                'translation',
                'component',
                'project',
                'dictionary',
github WeblateOrg / weblate / weblate / accounts / notifications.py View on Github external
'component',
                'project',
                'dictionary',
                'comment',
                'suggestion',
                'whiteboard',
                'alert',
                'user',
                'target',
                'old',
                'details',
            )
            for attrib in attribs:
                result[attrib] = getattr(change, attrib)
        if result.get('translation'):
            result['translation_url'] = get_site_url(
                result['translation'].get_absolute_url()
            )
        return result
github WeblateOrg / weblate / weblate / trans / models / project.py View on Github external
def get_share_url(self):
        """Return absolute URL usable for sharing."""
        return get_site_url(reverse('engage', kwargs={'project': self.slug}))
github WeblateOrg / weblate / weblate / addons / scripts.py View on Github external
else:
            target = component
        environment = {
            'WL_VCS': target.vcs,
            'WL_REPO': target.repo,
            'WL_PATH': target.full_path,
            'WL_FILEMASK': component.filemask,
            'WL_TEMPLATE': component.template,
            'WL_NEW_BASE': component.new_base,
            'WL_FILE_FORMAT': component.file_format,
            'WL_BRANCH': component.branch,
            'WL_COMPONENT_SLUG': component.slug,
            'WL_PROJECT_SLUG': component.project.slug,
            'WL_COMPONENT_NAME': component.name,
            'WL_PROJECT_NAME': component.project.name,
            'WL_COMPONENT_URL': get_site_url(component.get_absolute_url()),
            'WL_ENGAGE_URL': component.get_share_url(),
        }
        if translation:
            environment['WL_LANGUAGE'] = translation.language_code
        if env is not None:
            environment.update(env)
        self.execute_process(component, command, environment)
        self.trigger_alerts(component)