پودمان:نامک

از ویکی‌پدیا، دانشنامهٔ آزاد
توضیحات پودمان[نمایش] [ویرایش] [تاریخچه] [پاکسازی]

این الگو، پایهٔ توابع برخی یادکردها است. وقتی الگویی این توابع را مستقیم فرامی‌خواند، (با دستور #درخواست)، پارمترهای آن خودکار به این پودمان فرستاده می‌شوند، مگر زمانی که الگو مقداردهی دیگری برای پارامتر نیاز داشته باشد.

کاربرد[ویرایش]

توابع کاربردپذیر:

  • ouvrage(frame) – الگوی {{نسک}}
  • chapitre(frame) – الگوی {{فرگرد}}
  • article(frame) – الگوی {{پژوهه}}
  • lienWeb(frame) – الگوی {{پیوند تارنما}}
  • lienBrise(frame) – الگوی {{پیوند شکسته}}
  • dictionnaire(frame) – الگوی فرگرد را فرامی‌خواند اگر پارامتر عنوان فصل یا جستار یا نمایه خالی نباشد، وگرنه الگوی نسک را فرامی‌خواند.
  • ISBN(frame) – affiche en petit et entre parenthèses ISBN suivi d'autant de codes que de paramètres non nommés, avec lien à la page ad hoc ;
  • ISSN(frame) – affiche en petit et entre parenthèses ISSN suivi d'autant de codes que de paramètres non nommés, avec lien à la page ad hoc ;
  • enLigne() – similaire au الگوی {{خواندن برخط}} (le texte par défaut est «برخط»).

پودمان‌هایی که در این پودمان به کار رفته‌اند:

نمونه[ویرایش]

به‌کارگیری تابع ouvrage در الگو برای نمایش ارجاع:

  • {{#درخواست:نامک |ouvrage |نویسنده=Martine Michu |عنوان=Mes vacances à la mer}}
  • Martine Michu, Mes vacances à la mer

به‌کارگیری الگویی با پارامتر « تکه = 28 » می‌دهد:

  • Martine Michu, Mes vacances à la mer, ص. 28

-- Le module biblio centralise les différentes fonctions utiles pour les bibliographie et références.

local Biblio = {  }

require( 'strict' )
local Outils = require( 'پودمان:ابزارها' )


Biblio.ouvrage = function ( frame )
	local args = Outils.extractArgs( frame )
	local Ouvrage = require( 'پودمان:نامک/نسک' )
	return Ouvrage.ouvrage( args ) 
end


Biblio.chapitre = function ( frame )
	local args = Outils.extractArgs( frame )
	local Ouvrage = require( 'پودمان:نامک/نسک' )
	return Ouvrage.chapitre( args ) 
end


Biblio.article = function ( frame )
	local args = Outils.extractArgs( frame )
	local Ouvrage = require( 'پودمان:نامک/پژوهه' )
	return Ouvrage.article( args ) 
end


Biblio.lienWeb = function( frame )
	local args = Outils.extractArgs( frame )
	local Ouvrage = require( 'پودمان:نامک/پیوند تارنما' )
	return Ouvrage.lienWeb( args ) 
end

Biblio.lienBrise = function( frame )
	local args = Outils.extractArgs( frame )
	local Ouvrage = require( 'پودمان:نامک/پیوند تارنما' )
	return Ouvrage.lienBrise( args )
end


Biblio.dictionnaire = function( frame )
	local args = Outils.extractArgs( frame )
	local article = Outils.validTextArg( args, 'نمایه', 'جستار', 'عنوان فرگرد' )
	local Ouvrage = require( 'پودمان:نامک/نسک' )
	if article then
		args['عنوان فرگرد'] = article
		return Ouvrage.chapitre( args ) 
	else
		args.titre = args['عنوان نسک']
		args['زیرعنوان'] = args['زیرعنوان نسک']
		args.auteur1 = args['نویسنده نسک']
		args.auteurs = args['نویسندگان نسک']
		return Ouvrage.ouvrage( args )
	end
end

-- catégorise une page en fonction du namespace
local function categorise(args)
	local namespaceCategorisation = { [0] = true, [4] = true, [10] = true, [12] = true, [14] = true, [100] = true, [104] = true }
	local category = args[1]
	local flag = args[2]
	if type(category) == 'string'
		and flag 
		and namespaceCategorisation[ mw.title.getCurrentTitle().namespace ]
	then
		return '[[رده:' .. category .. ']]'
	end
	return ''
end

Biblio.ISBN = function ( frame )
	local args = Outils.extractArgs( frame )
	if Outils.trim( args[1] ) then
		local newArgs = { isbn = args[1] }
		local i = 2
		while args[i] do
			newArgs[ 'شابک' .. i ] = args[i]
			i = i + 1
		end
		return Biblio.identifiantsBiblio( newArgs )
	else 
		return '<small>([[شابک]]&nbsp;inconnu)</small>' .. categorise{ 'نیازمند شابک', true }
	end
end

Biblio.rechercheIsbn = function( frame )
	local args = Outils.extractArgs( frame )
	local References = require( 'پودمان:نامک/بازخنان' )
	local newArgs = { isbn = args[1], sansLabel = true, categ = {} }
	local isbn = References.isbn( newArgs ) or ''
	local categ = categorise{ 'صفحات دارای شابک نامعتبر', newArgs.categ.isbnInvalid }
	return isbn .. categ
end


Biblio.EAN = function ( frame )
	local args = Outils.extractArgs( frame )
	if Outils.trim( args[1] ) then
		local newArgs = { ean = args[1], categ = {} }
		local i = 2
		while args[i] do
			newArgs[ 'ean' .. i ] = args[i]
			i = i + 1
		end
		return Biblio.identifiantsBiblio( newArgs )
	else 
		return '<small>([[EAN 13|EAN]]&nbsp;inconnu)</small>[[رده:EAN نیازمند]]'
	end
end


Biblio.ISSN = function ( frame )
	local args = Outils.extractArgs( frame )
	if Outils.trim( args[1] ) then
		local newArgs = { issn = args[1], categ = {} }
		local i = 2
		while args[i] do
			newArgs[ 'شاپا' .. i ] = args[i]
			i = i + 1
		end
		return Biblio.identifiantsBiblio( newArgs )
	else 
		return '<small>([[شاپا]]&nbsp;inconnu)</small>' .. categorise{ 'نیازمند شاپا', true }
	end
end

Biblio.rechercheIssn = function( frame )
	local args = Outils.extractArgs( frame )
	local References = require( 'پودمان:نامک/بازخنان' )
	local newArgs = { issn = args[1], sansLabel = true, categ = {} }
	local issn = References.issn( newArgs ) or ''
	local categ = categorise{ 'صفحات دارای شاپا نامعتبر', newArgs.categ.issnInvalid }
	return issn .. categ
end

Biblio.BNF = function ( frame )
	local References = require( 'پودمان:نامک/بازخنان' )
	return References.bnf( Outils.extractArgs( frame )[1] )
end

Biblio.enLigne = function ( frame )
	local args = Outils.extractArgs( frame )
	local References = require( 'پودمان:نامک/بازخنان' )
	return '<small>[' .. References.enLigne( args )  .. ']</small>'
end

Biblio.identifiantsBiblio = function( frame )
	local args = Outils.extractArgs( frame )
	args.categ = {}
	local References = require( 'پودمان:نامک/بازخنان' )
	return ( References.affichageLiensExternes( args, nil, true, true ) or '' )
		.. categorise{ 'صفحات دارای شابک نامعتبر', args.categ.isbnInvalid }
		.. categorise{ 'صفحات دارای شاپا نامعبر', args.categ.issnInvalid }
		.. categorise{ 'Page avec EAN invalide', args.categ.eanInvalid }
end

return Biblio