<commit_before>import * as React from 'react'
import { computed, action } from 'mobx'
import TextWrap from './TextWrap'
import ChartConfig from './ChartConfig'
import Bounds from './Bounds'
import * as parseUrl from 'url-parse'

interface SourcesFooterProps {
    chart: ChartConfig,
    maxWidth: number
}

export default class SourcesFooter {
    props: SourcesFooterProps
    constructor(props: SourcesFooterProps) {
        this.props = props
    }

    @computed get maxWidth() {
        return this.props.maxWidth
    }

    @computed get sourcesText(): string {
        const sourcesLine = this.props.chart.data.sourcesLine
        return sourcesLine ? `Source: ${sourcesLine}` : ''
    }

    @computed get noteText(): string {
        return this.props.chart.note ? `Note: ${this.props.chart.note}` : ''
    }

    @computed get defaultLicenseSvg(): string {
        return `<a target='_blank' style='fill: #777;' href='http://ourworldindata.org'>OurWorldInData.org</a> • <a style="fill: #777;" href="http://creativecommons.org/licenses/by-sa/4.0/deed.en_US" target="_blank">CC BY-SA</a>`
    }

    @computed get licenseSvg(): string {
        const { originUrl } = this.props.chart.data
        let licenseSvg = `*data-entry* • <a style="fill: #777;" href="http://creativecommons.org/licenses/by-sa/4.0/deed.en_US" target="_blank">CC BY-SA</a>`

        // Make sure the link back to OWID is consistent
        // And don't show the full url if there isn't enough room
        if (originUrl && originUrl.toLowerCase().indexOf("ourworldindata.org") !== -1) {
            const url = parseUrl(originUrl)
            const finalUrl = `https://ourworldindata.org${url.pathname}`
            if (Bounds.forText(finalUrl, { fontSize: this.fontSize }).width > 0.7*this.maxWidth)<commit_msg>Don't show entry link in the entry itself<commit_after>import * as React from 'react'
import { computed, action } from 'mobx'
import TextWrap from './TextWrap'
import ChartConfig from './ChartConfig'
import Bounds from './Bounds'
import * as parseUrl from 'url-parse'

interface SourcesFooterProps {
    chart: ChartConfig,
    maxWidth: number
}

export default class SourcesFooter {
    props: SourcesFooterProps
    constructor(props: SourcesFooterProps) {
        this.props = props
    }

    @computed get maxWidth() {
        return this.props.maxWidth
    }

    @computed get sourcesText(): string {
        const sourcesLine = this.props.chart.data.sourcesLine
        return sourcesLine ? `Source: ${sourcesLine}` : ''
    }

    @computed get noteText(): string {
        return this.props.chart.note ? `Note: ${this.props.chart.note}` : ''
    }

    @computed get defaultLicenseSvg(): string {
        return `<a target='_blank' style='fill: #777;' href='http://ourworldindata.org'>OurWorldInData.org</a> • <a style="fill: #777;" href="http://creativecommons.org/licenses/by-sa/4.0/deed.en_US" target="_blank">CC BY-SA</a>`
    }

    @computed get licenseSvg(): string {
        if (this.props.chart.isNativeEmbed)
            return ""

        const { originUrl } = this.props.chart.data
        let licenseSvg = `*data-entry* • <a style="fill: #777;" href="http://creativecommons.org/licenses/by-sa/4.0/deed.en_US" target="_blank">CC BY-SA</a>`

        // Make sure the link back to OWID is consistent
        // And don't show the full url if there isn't enough room
        if (originUrl && originUrl.toLowerCase().indexOf("ourworldindata.org") !== -1) {
            const url = parseUrl(originUrl)
            const finalUrl = `https://ourworldindata.org${url.pathname}`
            if (Bounds.forText(finalUrl, { fontSize: this.fontSize }).width > 0.7*this.maxWidth)
{'fraction_non_alphanumeric': 0.13847407005158838, 'fraction_numerical': 0.008688569101276133, 'mean_word_length': 3.084257206208426, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 17, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3715107', 'n_tokens_mistral': 1160, 'n_tokens_neox': 1119, 'n_words': 283}