Module:Guidance: Difference between revisions

From the Audiovisual Identity Database, the motion graphics museum

Content deleted Content added
Compooper (talk | contribs)
First phase of new redesign implementation with Warning boxes
Camenati (talk | contribs)
No edit summary
Tag: Reverted
Line 2: Line 2:


r = { --keyword, short name, formatted name, severity
r = { --keyword, short name, formatted name, severity
{ "flashing", "flashing images", "[[:wikipedia:photosensitive epilepsy|flashing images]]", 1 },
{ "flashing",
{ "graphic", "graphic violence", "graphic violence or gore", 2 },
"flashing images",
"[[:wikipedia:photosensitive epilepsy|flashing images]]",
{ "jumpscare", "a jump scare", "a [[:wikipedia:jump scare|jump scare]]", 1 },
{ "nudity", "nudity", "nudity", 2 },
1,
{ "sex", "sexual activity", "sexual activity", 2 },
},
{ "language", "strong language", "strong language", 2 }
{ "graphic",
"graphic violence",
"graphic violence or gore",
2,
},
{ "jumpscare",
"a jump scare",
"a [[:wikipedia:jump scare|jump scare]]",
1,
},
{ "nudity",
"nudity",
"nudity",
2,
},
{ "sex",
"sexual activity",
"sexual activity",
2,
},
{
"language",
"strong language",
"strong language",
2,
}
}
}
ri = 6
ri = 6


function p.reasons(frame)
function p.reasons(frame)
for i = ri,1,-1 do
for i = ri, 1, -1 do
if string.find(frame.args[1],r[i][1]) then
if string.find(frame.args[1], r[i][1]) then
if ro == nil then
if ro == nil then
ro = r[i][3]
ro = r[i][3]
elseif string.find(ro,", and ") then
elseif string.find(ro, ", and ") then
ro = r[i][3]..", "..ro
ro = r[i][3] .. ", " .. ro
else
else
ro = r[i][3]..", and "..ro
ro = r[i][3] .. ", and " .. ro
end
end
end
end
end
end
return ro;
return ro
end
end

function p.warn_1(frame)
function p.warn_1(frame)
for i = ri,1,-1 do
for i = ri, 1, -1 do
if string.find(frame.args[1],r[i][1]) and (r[i][4] == 1) then
if string.find(frame.args[1], r[i][1]) and (r[i][4] == 1) then
if w1 == nil then
if w1 == nil then
w1 = r[i][2].." occur."
w1 = r[i][2] .. " occur."
elseif string.find(w1," and ") then
elseif string.find(w1, " and ") then
w1 = r[i][2]..", "..w1
w1 = r[i][2] .. ", " .. w1
else
else
w1 = r[i][2].." and "..w1
w1 = r[i][2] .. " and " .. w1
end
end
end
end
end
end
return w1;
return w1
end
end


function p.warn_2(frame)
function p.warn_2(frame)
for i = ri,1,-1 do
for i = ri, 1, -1 do
if string.find(frame.args[1],r[i][1]) and (r[i][4] == 2) then
if string.find(frame.args[1], r[i][1]) and (r[i][4] == 2) then
if (w2 == nil) then
if (w2 == nil) then
w2 = r[i][2]
w2 = r[i][2]
elseif string.find(w2," and ") then
elseif string.find(w2, " and ") then
w2 = r[i][2]..", "..w2
w2 = r[i][2] .. ", " .. w2
else
else
w2 = r[i][2].." and "..w2
w2 = r[i][2] .. " and " .. w2
end
end
end
end
end
end
if w2 ~= nil then
if w2 ~= nil then
if string.find(w2," and ") then
if string.find(w2, " and ") then
w2 = w2.." are"
w2 = w2 .. " are"
else
else
w2 = w2.." is"
w2 = w2 .. " is"
end
end
end
end
return w2;
return w2
end
end


function p.category(frame)
function p.category(frame)
for i = 1,ri,1 do
for i = 1, ri, 1 do
if string.find(frame.args[1],r[i][1]) then
if string.find(frame.args[1], r[i][1]) then
if rc == nil then
if rc == nil then
rc = "[[Category:Logos with content warnings for "..r[i][2].."]]"
rc = "[[Category:Logos with content warnings for " .. r[i][2] .. "]]"
else
else
rc = rc.."[[Category:Logos with content warnings for "..r[i][2].."]]"
rc = rc .. "[[Category:Logos with content warnings for " .. r[i][2] .. "]]"
end
end
end
end
end
end
return rc
return rc
end
end


-- Function for the smaller "guidance detail" notices (under testing)
-- Function for the smaller "guidance detail" notices (under testing)
function p.small(frame)
function p.small(frame)
-- Banners
-- Banners
bd = "none"
bd = "none"
b = {
b = {
frame:expandTemplate{title="ambox",args={
frame:expandTemplate {
small = "left",
title = "ambox",
args = {
type = "style",
small = "left",
nocat = "yes",
type = "style",
image = "[[File:Sound icon.png|30px]]",
nocat = "yes",
style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #ffa800;padding: 10px 0 10px 0.5em;",
image = "[[File:Sound icon.png|30px]]",
text = "The video of this logo '''may be too loud''' or severely distorted."
style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #ffa800;padding: 10px 0 10px 0.5em;",
}},
text = "The video of this logo '''may be too loud''' or severely distorted."
frame:expandTemplate{title="ambox",args={
}
small = "left",
type = "style",
},
frame:expandTemplate {
nocat = "yes",
title = "ambox",
image = "[[File:Phone icon.png|30px]]",
args = {
style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #ffa800;padding: 10px 0 10px 0.5em;",
small = "left",
text = "This logo '''contains an old telephone number'''. Please do not try to dial it."
type = "style",
}},
nocat = "yes",
}
image = "[[File:Phone icon.png|30px]]",
-- Text
style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #ffa800;padding: 10px 0 10px 0.5em;",
for i = ri,1,-1 do
text = "This logo '''contains an old telephone number'''. Please do not try to dial it."
if string.find(frame.args[1],r[i][1]) and r[i][4] == 1 then
}
if string.match(frame.args[1],r[i][1]..'%([%d,:-]*%)') then
},
ti = 0
frame:expandTemplate {
tt = {}
title = "ambox",
for j in string.gmatch(string.match(frame.args[1],r[i][1].."%([%d,:-]*%)"),"[%d:-]+") do
args = {
ti = ti + 1
small = "left",
tt[ti] = j
type = "style",
end
nocat = "yes",
for j = ti,1,-1 do
image = "[[File:Avid-jumpscare-ace.png|40px]]",
if ts == nil then
style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #da0c3f;padding: 10px 0 10px 0.5em;",
ts = tt[j]
text = "This logo contains " .. rd .. "."
elseif string.find(ts," and ") then
}
ts = tt[j]..", "..ts
}
else
}
ts = tt[j].." and "..ts
-- Text
end
for i = ri, 1, -1 do
end
if string.find(frame.args[1], r[i][1]) and r[i][4] == 1 then
td = r[i][3].."''' at "..ts
if string.match(frame.args[1], r[i][1] .. '%([%d,:-]*%)') then
else
ti = 0
td = r[i][3].."''' for the whole duration"
tt = {}
end
for j in string.gmatch(string.match(frame.args[1], r[i][1] .. "%([%d,:-]*%)"), "[%d:-]+") do
if rd == nil then
ti = ti + 1
rd = td
tt[ti] = j
elseif string.find(rd,", and ") then
end
rd = td..", '''"..rd
for j = ti, 1, -1 do
else
if ts == nil then
rd = td..", and '''"..rd
ts = tt[j]
end
elseif string.find(ts, " and ") then
end
ts = tt[j] .. ", " .. ts
end
else
if rd ~= nil then
ts = tt[j] .. " and " .. ts
rd = frame:expandTemplate{title="ambox",args={
end
small = "left",
end
type = "content",
td = r[i][3] .. "''' at " .. ts
nocat = "yes",
else
image = "[[File:Alert icon.png|30px]]",
td = r[i][3] .. "''' for the whole duration"
style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #da0c3f;padding: 10px 0 10px 0.5em;",
end
text = "This logo '''contains "..rd.."."}}
if rd == nil then
end
rd = td
if string.find(frame.args[1],"audio") then
elseif string.find(rd, ", and ") then
if rd ~= nil then
rd = td .. ", '''" .. rd
rd = rd..b[1]
else
else
rd = td .. ", and '''" .. rd
rd = b[1]
end
end
end
end
end
if string.find(frame.args[1],"phone") then
if rd ~= nil then
if rd ~= nil then
rd = frame:expandTemplate {
rd = rd..b[2]
title = "ambox",
else
args = {
rd = b[2]
small = "left",
end
type = "content",
end
nocat = "yes",
return rd
image = "[[File:Alert icon.png|30px]]",
style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #da0c3f;padding: 10px 0 10px 0.5em;",
text = "This logo contains " .. rd .. "."
}
}
end
if string.find(frame.args[1], "audio") then
if rd ~= nil then
rd = rd .. b[1]
else
rd = b[1]
end
end
if string.find(frame.args[1], "phone") then
if rd ~= nil then
rd = rd .. b[2]
else
rd = b[2]
end
end
if string.find(frame.args[1], "jumpscare") then
if rd ~= nil then
rd = rd .. b[3]
else
rd = b[3]
end
end
return rd
end
end

return p
return p

Revision as of 18:41, 1 August 2023

Documentation for this module may be created at Module:Guidance/doc

local p = {} --p stands for package

r = { --keyword, short name, formatted name, severity
    { "flashing", "flashing images", "[[:wikipedia:photosensitive epilepsy|flashing images]]", 1 },
    { "graphic", "graphic violence", "graphic violence or gore", 2 },
    { "jumpscare", "a jump scare", "a [[:wikipedia:jump scare|jump scare]]", 1 },
    { "nudity", "nudity", "nudity", 2 },
    { "sex", "sexual activity", "sexual activity", 2 },
    { "language", "strong language", "strong language", 2 }
}
ri = 6

function p.reasons(frame)
    for i = ri, 1, -1 do
        if string.find(frame.args[1], r[i][1]) then
            if ro == nil then
                ro = r[i][3]
            elseif string.find(ro, ", and ") then
                ro = r[i][3] .. ", " .. ro
            else
                ro = r[i][3] .. ", and " .. ro
            end
        end
    end
    return ro
end

function p.warn_1(frame)
    for i = ri, 1, -1 do
        if string.find(frame.args[1], r[i][1]) and (r[i][4] == 1) then
            if w1 == nil then
                w1 = r[i][2] .. " occur."
            elseif string.find(w1, " and ") then
                w1 = r[i][2] .. ", " .. w1
            else
                w1 = r[i][2] .. " and " .. w1
            end
        end
    end
    return w1
end

function p.warn_2(frame)
    for i = ri, 1, -1 do
        if string.find(frame.args[1], r[i][1]) and (r[i][4] == 2) then
            if (w2 == nil) then
                w2 = r[i][2]
            elseif string.find(w2, " and ") then
                w2 = r[i][2] .. ", " .. w2
            else
                w2 = r[i][2] .. " and " .. w2
            end
        end
    end
    if w2 ~= nil then
        if string.find(w2, " and ") then
            w2 = w2 .. " are"
        else
            w2 = w2 .. " is"
        end
    end
    return w2
end

function p.category(frame)
    for i = 1, ri, 1 do
        if string.find(frame.args[1], r[i][1]) then
            if rc == nil then
                rc = "[[Category:Logos with content warnings for " .. r[i][2] .. "]]"
            else
                rc = rc .. "[[Category:Logos with content warnings for " .. r[i][2] .. "]]"
            end
        end
    end
    return rc
end

-- Function for the smaller "guidance detail" notices (under testing)
function p.small(frame)
    -- Banners
    bd = "none"
    b = {
        frame:expandTemplate {
            title = "ambox",
            args = {
                small = "left",
                type = "style",
                nocat = "yes",
                image = "[[File:Sound icon.png|30px]]",
                style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #ffa800;padding: 10px 0 10px 0.5em;",
                text = "The video of this logo '''may be too loud''' or severely distorted."
            }
        },
        frame:expandTemplate {
            title = "ambox",
            args = {
                small = "left",
                type = "style",
                nocat = "yes",
                image = "[[File:Phone icon.png|30px]]",
                style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #ffa800;padding: 10px 0 10px 0.5em;",
                text = "This logo '''contains an old telephone number'''. Please do not try to dial it."
            }
        },
        frame:expandTemplate {
            title = "ambox",
            args = {
                small = "left",
                type = "style",
                nocat = "yes",
                image = "[[File:Avid-jumpscare-ace.png|40px]]",
                style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #da0c3f;padding: 10px 0 10px 0.5em;",
                text = "This logo contains " .. rd .. "."
            }
        }
    }
    -- Text
    for i = ri, 1, -1 do
        if string.find(frame.args[1], r[i][1]) and r[i][4] == 1 then
            if string.match(frame.args[1], r[i][1] .. '%([%d,:-]*%)') then
                ti = 0
                tt = {}
                for j in string.gmatch(string.match(frame.args[1], r[i][1] .. "%([%d,:-]*%)"), "[%d:-]+") do
                    ti = ti + 1
                    tt[ti] = j
                end
                for j = ti, 1, -1 do
                    if ts == nil then
                        ts = tt[j]
                    elseif string.find(ts, " and ") then
                        ts = tt[j] .. ", " .. ts
                    else
                        ts = tt[j] .. " and " .. ts
                    end
                end
                td = r[i][3] .. "''' at " .. ts
            else
                td = r[i][3] .. "''' for the whole duration"
            end
            if rd == nil then
                rd = td
            elseif string.find(rd, ", and ") then
                rd = td .. ", '''" .. rd
            else
                rd = td .. ", and '''" .. rd
            end
        end
    end
    if rd ~= nil then
        rd = frame:expandTemplate {
            title = "ambox",
            args = {
                small = "left",
                type = "content",
                nocat = "yes",
                image = "[[File:Alert icon.png|30px]]",
                style = "margin:auto;max-width:480px;width:inherit;background:#fcfcfc;border: 0px solid #a2a9b1;border-left: 15px solid #da0c3f;padding: 10px 0 10px 0.5em;",
                text = "This logo contains " .. rd .. "."
            }
        }
    end
    if string.find(frame.args[1], "audio") then
        if rd ~= nil then
            rd = rd .. b[1]
        else
            rd = b[1]
        end
    end
    if string.find(frame.args[1], "phone") then
        if rd ~= nil then
            rd = rd .. b[2]
        else
            rd = b[2]
        end
    end
    if string.find(frame.args[1], "jumpscare") then
        if rd ~= nil then
            rd = rd .. b[3]
        else
            rd = b[3]
        end
    end
    return rd
end

return p
Cookies help us deliver our services. By using our services, you agree to our use of cookies.