Anda dapat membuat halaman dokumentasi untuk buat pada modul Scribunto ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
Penyunting dapat melakukan uji coba pada halaman bak pasir (buat | cermin) dan kasus uji (buat) modul ini.
Subhalaman modul ini.
localgetImageName=require('Module:Portal').image localp={} localfunctioncheckPortalExists(portal) returnnot(mw.title.makeTitle(100,portal).id==0) end localtrackingEnabled=true -- Check whether to do tracking in this namespace -- Returns true unless the page is one of the banned namespaces localfunctioncheckTrackingNamespace() localthisPage=mw.title.getCurrentTitle() if(thisPage.namespace==1)-- Talk or(thisPage.namespace==2)-- User or(thisPage.namespace==3)-- User talk or(thisPage.namespace==5)-- Wikipedia talk or(thisPage.namespace==7)-- File talk or(thisPage.namespace==11)-- Template talk or(thisPage.namespace==15)-- Category talk or(thisPage.namespace==101)-- Portal talk or(thisPage.namespace==118)-- Draft or(thisPage.namespace==119)-- Draft talk or(thisPage.namespace==829)-- Module talk then returnfalse end returntrue end -- Check whether to do tracking on this pagename -- Returns false if the page title matches one of the banned strings -- Otherwise returns true localfunctioncheckTrackingPagename() localthisPage=mw.title.getCurrentTitle() localthisPageLC=mw.ustring.lower(thisPage.text) if(string.match(thisPageLC,"/archive")~=nil)then returnfalse end if(string.match(thisPageLC,"/doc")~=nil)then returnfalse end if(string.match(thisPageLC,"/test")~=nil)then returnfalse end returntrue end functionp._main(portals,args) localroot="" mw.logObject(args) -- ignore extra portals listed -- If no portals have been specified, display an error and add the page to a tracking category. -- Tracking is on by default. -- It is disabled if any of the following is true -- 1/ the parameter "tracking" is set to 'no, 'n', or 'false' -- 2/ the current page fails the namespace tests in checkTrackingNamespace() -- 3/ the current page fails the pagename tests in checkTrackingPagename() if(args.tracking=='no')or(args.tracking=='n')or(args.tracking=='false')then trackingEnabled=false end if(checkTrackingNamespace()==false)then trackingEnabled=false end if(checkTrackingPagename()==false)then trackingEnabled=false end ifnotportals[1]then root='<span style="font-size:100%;" class="error">galat: nama portal tidak ada.</span></strong>"' iftrackingEnabledthen root=root..'[[Kategori:Templat portal tanpa parameter]][[Kategori:Templat portal-inline tanpa parameter]]' end returntostring(root) end ifportals[2]orportals[3]then root='<span style="font-size:100%;" class="error">error: Template:portal-inline accepts only one portal as a parameter</span></strong> "' iftrackingEnabledthen root=root..'[[Kategori:Templat portal-inline dengan lebih dari satu parameter portal]]' end end ifnotpcall(checkPortalExists,portals[1])ornotcheckPortalExists(portals[1])then -- Getting here means a redlinked portal has been found ifnot((args.redlinks=='yes')or(args.redlinks=='y')or(args.redlinks=='true')or(args.redlinks=='include'))then -- just return if redlinks is not "yes" or similar returntostring(root) end iftrackingEnabledthen root='[[Kategori:Templat portal dengan portal berpranala merah]][[Kategori:Templat portal-inline dengan portal berpranala merah]]' end end ifargs['size']=="tiny"then args['size']="16x16px" else args['size']="32x28px" end localdisplayName="" ifnot(args['text']==""orargs['text']==nil)then displayName=args['text'] elseifnot(args.short==""orargs.short==nil)then displayName=portals[1] else displayName="Portal "..portals[1] end -- display portal-inline content root=root..string.format('[[File:%s|class=noviewer|%s]] [[Portal:%s|%s]]',getImageName{portals[1]},args['size'],portals[1],displayName) returntostring(root) end -- copied from [[Module:Portal]] localfunctionprocessPortalArgs(args) -- This function processes a table of arguments and returns two tables: an array of portal names for processing by ipairs, and a table of -- the named arguments that specify style options, etc. We need to use ipairs because we want to list all the portals in the order -- they were passed to the template, but we also want to be able to deal with positional arguments passed explicitly, for example -- {{portal-inline|Politics}}. The behaviour of ipairs is undefined if nil values are present, so we need to make sure they are all removed. args=type(args)=='table'andargsor{} localportals={} localnamedArgs={} fork,vinpairs(args)do iftype(k)=='number'andtype(v)=='string'then-- Make sure we have no non-string portal names. table.insert(portals,k) elseiftype(k)~='number'then namedArgs[k]=v end end table.sort(portals) fori,vinipairs(portals)do portals[i]=args[v] end returnportals,namedArgs end localfunctionmakeWrapper(funcName) -- Processes external arguments and sends them to the other functions. returnfunction(frame) -- If called via #invoke, use the args passed into the invoking -- template, or the args passed to #invoke if any exist. Otherwise -- assume args are being passed directly in from the debug console -- or from another Lua module. localorigArgs iftype(frame.getParent)=='function'then origArgs=frame:getParent().args fork,vinpairs(frame.args)do origArgs=frame.args break end else origArgs=frame end -- Trim whitespace and remove blank arguments. localargs={} fork,vinpairs(origArgs)do iftype(v)=='string'then v=mw.text.trim(v) end ifv~=''then args[k]=v end end returnp[funcName](processPortalArgs(args))-- passes two tables to func: an array of portal names, and a table of named arguments. end end for_,funcNameinipairs{'main'}do p[funcName]=makeWrapper('_'..funcName) end returnp