Modul:LinkISBN: Unterschied zwischen den Versionen
K
+demo
(+span-tag) |
K (+demo) |
||
Zeile 4: | Zeile 4: | ||
li.invalid = ' <span class="error">Ungültige ISBN</span>[[Kategorie:Seiten mit ISBN-Fehlern]]' | li.invalid = ' <span class="error">Ungültige ISBN</span>[[Kategorie:Seiten mit ISBN-Fehlern]]' | ||
li.invalidDemo = ' <span class="error">Ungültige ISBN</span>' | |||
li.special = 'Spezial:ISBN-Suche/' -- Special:BookSources | li.special = 'Spezial:ISBN-Suche/' -- Special:BookSources | ||
Zeile 9: | Zeile 10: | ||
li.delimiters = { ' and ', ' or ', ' und ', ' oder ', ';' } | li.delimiters = { ' and ', ' or ', ' und ', ' oder ', ';' } | ||
function li.linkISBN( m, noerror ) | function li.linkISBN( m, noerror, demo ) | ||
local mm = mw.text.trim( m ) | local mm = mw.text.trim( m ) | ||
if mm == '' then return mm end -- empty string | if mm == '' then return mm end -- empty string | ||
Zeile 22: | Zeile 23: | ||
mm = mw.ustring.gsub( mm, 'ISBN ', '' ) | mm = mw.ustring.gsub( mm, 'ISBN ', '' ) | ||
t = '<span class="wv-booksources" title="' .. li.special .. mm .. '">[[' .. li.special .. mm .. '|' .. 'ISBN ' .. mm .. ']]</span>' | t = '<span class="wv-booksources" title="' .. li.special .. mm .. '">[[' .. li.special .. mm .. '|' .. 'ISBN ' .. mm .. ']]</span>' | ||
if not noerror then t = t .. ci._check_isbn( mm, li.invalid ) end | if not noerror then | ||
if demo == 'true' then | |||
t = t .. ci._check_isbn( mm, li.invalidDemo ) | |||
else | |||
t = t .. ci._check_isbn( mm, li.invalid ) | |||
end | |||
end | |||
if comment ~= '' then t = t .. ' ' .. comment end | if comment ~= '' then t = t .. ' ' .. comment end | ||
Zeile 33: | Zeile 41: | ||
if (args['noerror'] == 'j') or (args['noerror'] == 'y') then args['noerror'] = true | if (args['noerror'] == 'j') or (args['noerror'] == 'y') then args['noerror'] = true | ||
else args['noerror'] = false end | else args['noerror'] = false end | ||
args['demo'] = args['demo'] or '' | |||
local s | local s | ||
Zeile 45: | Zeile 54: | ||
-- split seperate ISBNs and analyse them | -- split seperate ISBNs and analyse them | ||
for s in mw.ustring.gmatch( args.isbn .. ',', '([^,]+)' ) do | for s in mw.ustring.gmatch( args.isbn .. ',', '([^,]+)' ) do | ||
s = li.linkISBN( s, args['noerror'] ) | s = li.linkISBN( s, args['noerror'], args['demo'] ) | ||
if s ~= '' then | if s ~= '' then | ||
if result == '' then result = s | if result == '' then result = s |