Bahaipedia
Bahaipediaدانشنامه بهائی
Menú
Cambios recientes
Haga su pregunta
Página al azar
Categorías
Ayuda en Wikipedia
En otros proyectos
Herramientas
Lo que enlaza aquí
Cambios relacionados
Subir archivo
Páginas especiales
Versión para imprimir
Enlace permanente
Información de la página
Módulo
Discusión
Ver historial
No has accedido
Discusión
Contribuciones
Crear una cuenta
Acceder
Navigation
Navigation
Navegación
Navigation
ナビゲーション
Điều hướng
导航
Navegação
ناوبری
Навигация
Cambios recientes
Haga su pregunta
Página al azar
Categorías
Ayuda en Wikipedia
En otros proyectos
Learn more
Weitere Informationen
Aprender más
En savoir plus
詳しく読む
Tìm hiểu thêm
了解更多
Saiba mais
یاد بگیرید بیشتر
Узнать больше
Fe bahá’í
Bahá’u’lláh
‘Abdu’l-Bahá
Principios bahá’ís
Tools
Werkzeuge
Herramientas
Outils
ツール
Công cụ
工具
Ferramentas
ابزارها
Инструменты
Lo que enlaza aquí
Cambios relacionados
Subir archivo
Páginas especiales
Versión para imprimir
Enlace permanente
Información de la página
Translations
Übersetzungen
Traducciones
Traductions
各言語版
Bản dịch
翻译
Traduções
به زبان‌های دیگر
Переводы

Módulo:Cita

De Bahaipedia
Saltar a:navegación, buscar

La Plantilla:Citas usa este módulo para generar citas basadas en el título de un libro. Ver la plantilla para más información.


local p = {}

function p.generateCitation(frame)
    local userInput = frame.args[1] or ""
    local pageNumbers = frame.args[2] or ""
    local itemNumber = nil
    local category = "[[Categoría:Artículos que requieren Bahaidata]]"

    -- Check if the input is a valid Wikibase item ID (like Q123)
    if mw.wikibase.isValidEntityId(userInput) then
        itemNumber = userInput
    else
        itemNumber = mw.wikibase.getEntityIdForTitle(userInput)
        if not itemNumber then
            local page = mw.title.new(userInput)
            if page then
                local rtarget = page.redirectTarget
                if rtarget then
                    itemNumber = mw.wikibase.getEntityIdForTitle(rtarget.fullText)
                end
            end
        end
    end

    if not itemNumber then
        return "''" .. userInput .. "''" .. (pageNumbers ~= "" and ", p." .. pageNumbers or "") .. " " .. category
    end

    -- Retrieve and store data
    local entity = mw.wikibase.getEntity(itemNumber)

    -- Retrieve and format each property
    local titleValue = entity.claims['P47'] and entity.claims['P47'][1].mainsnak.datavalue.value.text or ""
    if titleValue == "" then
        return "''" .. userInput .. "''" .. (pageNumbers ~= "" and ", p." .. pageNumbers or "") .. " " .. category
    end

    local authorValue = entity.claims['P10'] and mw.wikibase.getLabel(entity.claims['P10'][1].mainsnak.datavalue.value.id) or ""
    local translatorValue = entity.claims['P32'] and mw.wikibase.getLabel(entity.claims['P32'][1].mainsnak.datavalue.value.id) or ""
    local publicationDate = entity.claims['P29'] and mw.text.split(entity.claims['P29'][1].mainsnak.datavalue.value.time, '-')[1]:gsub('^%+', '') or ""
    local publisherValue = entity.claims['P26'] and mw.wikibase.getLabel(entity.claims['P26'][1].mainsnak.datavalue.value.id) or ""
    local countryValue = entity.claims['P48'] and mw.wikibase.getLabel(entity.claims['P48'][1].mainsnak.datavalue.value.id) or ""
    local isbn10Value = entity.claims['P31'] and entity.claims['P31'][1].mainsnak.datavalue.value or ""
    local isbn13Value = entity.claims['P49'] and entity.claims['P49'][1].mainsnak.datavalue.value or ""

    -- Determine page citation format
    local pagePrefix = "p."
    if pageNumbers:find(",") or pageNumbers:find("-") then
        pagePrefix = "pp."
    end

    -- Construct the citation
    local citation = ""
    if authorValue ~= "" then
        citation = authorValue .. " (" .. publicationDate .. "). "
    end
    
    citation = citation .. "''" .. titleValue .. "''"
    
    if translatorValue ~= "" then
        citation = citation .. ", trans. " .. translatorValue
    end
    
    if countryValue ~= "" and publisherValue ~= "" then
        citation = citation .. ". " .. countryValue .. ": " .. publisherValue
    end
    
    if publicationDate ~= "" and authorValue == "" then
        citation = citation .. ". " .. publicationDate
    end
    
    if pageNumbers ~= "" then
        citation = citation .. ". " .. pagePrefix .. " " .. pageNumbers
    end

    if isbn10Value ~= "" or isbn13Value ~= "" then
        citation = citation .. ". ISBN " .. (isbn10Value ~= "" and isbn10Value or isbn13Value)
    end
    
    citation = citation .. "."

    -- Return the final citation
    return citation
end

return p
Obtenido de «https://es.bahaipedia.org/index.php?title=Módulo:Cita&oldid=2917»
Esta página se editó por última vez el 26 feb 2025 a las 10:52.
El contenido está disponible bajo la licencia Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License a menos que se indique lo contrario.
Política de privacidad
Acerca de Bahaipedia
Descargos
Powered by MediaWiki