Database changes have finished applying - please report any issues you're (still) seeing to support@shoutwiki.com.
Moduuli:InsiderCite
Jedipediasta, vapaasta Tähtien sota-tietosanakirjasta tänään, 2. heinäkuuta 2025
Siirry navigaatioonSiirry hakuun
Tämän moduulin ohjeistuksen voi tehdä sivulle Moduuli:InsiderCite/ohje
1 -- This module implements [[Template:InsiderCite]].
2
3 local p = {}
4
5 function p._main(args)
6 -- Define defaults
7 local image = 'SWInsider.png'
8 local invert = true
9 local publication = 'Star Wars Insider'
10 local defaultIssue = '{{{1}}}'
11
12 -- Find optional values, and override defaults if necessary
13 local size, page, display, issue, extra
14 size = 'x12px'
15 if args[1]
16 and (
17 args[1]:find('^Special%s')
18 or args[1]:find('^Best%s')
19 or args[1]:find('^Digital%s')
20 )
21 then
22 if args[2] then
23 page = args[2]
24 display = args[3] or args[2]
25 end
26 issue = args[1] or defaultIssue
27 elseif args.issue1 then
28 if args[1] then
29 page = args[1]
30 display = args[2] or args[1]
31 end
32 issue = args.issue1
33 local issue2 = args.issue2 or '{{{issue2}}}'
34 extra = string.format(
35 '–[[%s %s|%s]]',
36 publication, issue2, issue2
37 )
38 elseif tonumber(args[1]) and tonumber(args[1]) <= 22 then
39 image = 'LFCMlogo.jpg'
40 invert = false
41 publication = 'The Lucasfilm Fan Club Magazine'
42 size = 'x16px'
43 if args[2] then
44 page = args[2]
45 display = args[3] or args[2]
46 end
47 issue = args[1] or defaultIssue
48 else
49 if args[2] then
50 page = args[2]
51 display = args[3] or args[2]
52 end
53 issue = args[1] or defaultIssue
54 end
55
56 -- Make the file link
57 local fileLink = string.format(
58 '[[Tiedosto:%s%s|text-top|link=Star Wars Insider]]',
59 image,
60 size and '|' .. size or ''
61 )
62
63 -- Make the story link
64 local storyLink
65 if page and display then
66 storyLink = string.format("”[[%s|%s]]”—", page, display)
67 else
68 storyLink = ''
69 end
70
71 -- Make the issue link
72 local issueLink = string.format(
73 "[[%s %s|''%s'' %s]]",
74 publication, issue, publication, issue
75 )
76
77 -- Make the final output.
78 extra = extra or ''
79 if invert then
80 return '<span class="invert-images">' .. fileLink .. '</span> ' .. storyLink .. issueLink .. extra
81 else
82 return fileLink .. ' ' .. storyLink .. issueLink .. extra
83 end
84 end
85
86 function p.main(frame)
87 local args = {}
88 for k, v in pairs(frame:getParent().args) do
89 v = v:match('^%s*(.-)%s*$') -- trim whitespace
90 if v ~= '' then
91 args[k] = v
92 end
93 end
94 return p._main(args)
95 end
96
97 return p