Módulo:Bases turismo

Origem: Wikipédia, a enciclopédia livre.
Saltar para a navegação Saltar para a pesquisa
Broom icon.svg Este módulo não apresenta nenhuma documentação.
Por favor, documente-o caso o saiba usar ou tenha conhecimentos para tal.
local p = {}
local wikidata = require "Module:Wikidata/Testes"

local bases = {
-- { nome, propriedade Wikidata, format URL}
{"Booking.com", "P3607", "https://www.booking.com/hotel/$1.fr.html"},
{"eParks", "P4170", "http://www.eparks.com/parkstores/$1.html"},
{"Foursquare", "P1968", "https://foursquare.com/v/$1"},
{"HappyCow", "P3877", "https://www.happycow.net/reviews/$1"},
{"Hotels.com", "P3898", "https://fr.hotels.com/ho$1/"},
{"Michelin Restaurants", "P4160", "https://restaurant.michelin.fr/$1"},
{"Michelin Voyages", "P4161", "https://voyages.michelin.fr/$1"},
{"Radzima.org", "P2491", "http://www.radzima.org/be/$1.html"},
{"Recreation.gov", "P3609", "https://www.recreation.gov/recreationalAreaDetails.do?recAreaId=$1"},
{"Routard.com", "P4986", "http://www.routard.com/guide_voyage_lieu/$1-wd.htm"},
{"Touring Club Italiano", "P5601", "https://www.touringclub.it/destinazione/$1"},
{"TripAdvisor", "P3134", "https://www.tripadvisor.com/$1"},
{"UK Pub History", "P4340", "https://pubhistory.co.uk/$1.shtml"},
{"Yelp", "P3108", "https://www.yelp.com/biz/$1"},
}

function p.main(frame)    
    local id = frame.args.id
    if id == "" then
        id = nil
    end

    local entity = mw.wikibase.getEntityObject(id)
    if not entity then
        return nil
    end
    local vals = {}
    for i, base in pairs(bases) do
        local val = wikidata.formatStatements{entity = entity, text = base[1], property = base[2], urlpattern = base[3], numval = 1, addcat = true}
        if val then
            table.insert(vals, val)
        end
    end
    if #vals == 0 then
        return nil
    end
    local header = ''
    if #vals > 1 then
        header = "Recursos relativos ao turismo : "
    else
        header = 'Recursos relativos ao turismo : '
    end
    return wikidata.addLinkBack(header .. table.concat( vals, ' • ' ), entity, "identifiers" ) -- link para a seção Wikidata apropriada
end

return p