No edit summary |
No edit summary Tag: (დამალული) |
||
(65 intermediate revisions by the same user not shown) | |||
Line 4: | Line 4: | ||
-- Module:Top |
-- Module:Top |
||
-- |
-- |
||
+ | -- ამ მოდულით აისახება სიმბოლოები სტატიების გვერდების მარჯვენა კუთხეებში, |
||
− | -- This module renders the icons in the top-right corner of articles, as well |
||
+ | -- ისევე, როგორც კანონიკური და ლეგენდების ჩანართები იმ გვერდებზე, რომლებსაც აქვთ |
||
− | -- as the Canon and Legends tabs for pages with a Canon/Legends counterpart. |
||
+ | -- პარალელური, მსგავსი სახელწოდების მქონე გვერდები, მონიშნული როგორც კანონი ან |
||
− | -- It also formats the page title with {{DISPLAYTITLE}}. It is a rewrite of |
||
+ | -- ლეგენდები. მოდულს აგრეთვე თანდართული აქვს {{DISPLAYTITLE}}, რაც ნიშნავს, |
||
− | -- [[Template:Top]]. |
||
+ | -- რომ თარგში "Top" პარამეტრ title-ის გამpოყენებით შეიძლება ნებისმიერი სათაურის |
||
+ | -- ასახვა, თუმცა, თუკი თავდაპირველი სახელწოდება შეიცავს ფრჩხილებში ჩასმულ დამატებით |
||
+ | -- ტექსტს, იგი თავად გვერდზე ამ შემთხვევაში აისახება შედარებით მცირე ზომის შრიფტით. |
||
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
− | local DEBUG_MODE = false -- |
+ | local DEBUG_MODE = false -- თუ მითითებულია true, შეცდომები არ არის ასახული |
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
+ | -- სიმბოლოების მონაცემები |
||
− | -- Icon data |
||
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
--[[ |
--[[ |
||
+ | -- აქ ინახება მონაცემები ყველა სიმბოლოზე, რომელიც აისახება ზედა მარჯვენა კუთხეში. |
||
− | -- This table stores data for all the icons displayed in the top-right. It can |
||
+ | -- დასაშვებია შემდეგი პარამეტრები: |
||
− | -- have the following fields: |
||
+ | -- * image - სიმბოლოს გამოსახულების სახელი, წინსართ "File:"-ის გარეშე (აუცილებელი პარამეტრი). |
||
− | -- * image - the icon image name, minus any "File:" prefix (required). |
||
+ | -- * tooltip - სიმბოლოს მინიშნება (არ არის აუცილებელი). |
||
− | -- * tooltip - the icon tooltip (optional). |
||
+ | -- * link - გვერდი, რომელზეც გადავდივართ სიმბოლოზე დაწკაპუნებით (არ არის აუცილებელი). |
||
− | -- * link - the page to link from the icon (optional). |
||
+ | -- * category - კატეგორია, რომელიც სიმბოლოს თანდართული აქვს, წინსართ "Category:"-ს გარეშე |
||
− | -- * category - a category to go with the icon, minus any "Category:" prefix |
||
+ | -- (არ არის აუცილებელი). |
||
− | -- (optional). |
||
+ | -- * protectionAction - დაცვის აღმნიშვნელი სიმბოლოებისთვის - მაგალითად, იმ შემთხვევაში, |
||
− | -- * protectionAction - for protection icons, an action such as "edit" or "move" |
||
+ | -- როდესაც სტატია დაცულია გადატანისგან ან ზოგადად, რედაქტირებისგან (არ არის აუცილებელი). |
||
− | -- to check (optional). |
||
+ | -- * protectionLevel - დაცვის დონე დაცვის სიმბოლოების შემთხვევაში. |
||
− | -- * protectionLevel - for protection icons, the protection level to check, |
||
+ | -- მაგალითია "sysop". თუ გვერდს არ აქვს მითითებული დაცვის სწორი დონე, |
||
− | -- such as "sysop". If the page doesn't have the right protection level |
||
+ | -- იგი მოხვდება სპეციალურ კატეგორიაში და სიბბოლო არ აისახება (არ არის აუცილებელი). |
||
− | -- it is put in a tracking category and the icon is not displayed |
||
+ | -- შენიშვნა: ეს არის მხოლოდ მონაცემთა შესანახი მოდული. ქვეცხრილებზე წვდომა შესაძლებელია |
||
− | -- (optional). |
||
+ | -- მექანიკურად, ამიტომ ახალი ქვეცხრილების დამატებით ახალი სიმბოლოები არ დაემატება, ხოლო ქვეცხრილების |
||
− | -- Note: this is just a convenient place to store the data. The subtables are |
||
+ | -- ამოშლა მოდულის მუშაობას შეაფერხებს. |
||
− | -- accessed from the code manually, so adding new subtables won't automatically |
||
− | -- add new icons, and removing subtables may break things. |
||
--]] |
--]] |
||
local iconData = { |
local iconData = { |
||
can = { |
can = { |
||
− | image = ' |
+ | image = 'Top-canon.png', |
+ | tooltip = 'ეს სტატია აღწერს თემას, რომელიც ითვლება კანონის ნაწილად.', |
||
− | tooltip = 'This article details a subject that is considered canon.', |
||
− | link = ' |
+ | link = 'კანონი' |
}, |
}, |
||
leg = { |
leg = { |
||
− | image = ' |
+ | image = 'Top-legends.png', |
+ | tooltip = 'ეს სტატია აღწერს თემას, რომელიც შედის ვარსკვლავური ომების ლეგენდებში.', |
||
− | tooltip = 'This article details a subject that falls under the Legends brand.', |
||
+ | link = 'ვარსკვლავური ომების ლეგენდები' |
||
− | link = 'Star Wars Legends' |
||
+ | }, |
||
+ | ncc = { |
||
+ | image = 'Top-NCC.png', |
||
+ | tooltip = 'ეს სტატია აღწერს თემას, რომელიც არ ითვლება კანონის ნაწილად.', |
||
+ | link = 'კანონი' |
||
+ | }, |
||
+ | ncl = { |
||
+ | image = 'Top-NCL.png', |
||
+ | tooltip = 'ეს სტატია აღწერს თემას, რომელიც არ ითვლება კანონის ნაწილად ლეგენდების უწყვეტობაში.', |
||
+ | link = 'ვარსკვლავური ომების ლეგენდები' |
||
}, |
}, |
||
pre = { |
pre = { |
||
− | image = " |
+ | image = "Top-pre.png", |
+ | tooltip = "ამ სტატიის თემა აღწერს რესპუბლიკის ჩამოყალიბებამდე მომხდარ მოვლენებს.", |
||
− | tooltip = "The subject of this article appeared before the Before the Republic era.", |
||
+ | link = "რესპუბლიკის დაარსებამდე" |
||
− | link = "Pre-Republic era" |
||
}, |
}, |
||
btr = { |
btr = { |
||
− | image = " |
+ | image = "Top-pre.png", |
+ | tooltip = "ამ სტატიის თემა აღწერს რესპუბლიკამდე მომხდარ მოვლენებს.", |
||
− | tooltip = "The subject of this article appeared Before the Republic.", |
||
− | link = " |
+ | link = "რესპუბლიკამდე" |
}, |
}, |
||
old = { |
old = { |
||
− | image = " |
+ | image = "Top-old.png", |
+ | tooltip = "ამ სტატიის თემა აღწერს ძველი რესპუბლიკის დროს მომხდარ მოვლენებს.", |
||
− | tooltip = "The subject of this article appeared in the Old Republic era.", |
||
+ | link = "ძველი რესპუბლიკის ეპოქა (საგამომცემლო ეპოქა)" |
||
− | link = "Old Republic era" |
||
}, |
}, |
||
imp = { |
imp = { |
||
− | image = " |
+ | image = "Top-imp.png", |
+ | tooltip = "ამ სტატიის თემა აღწერს იმპერიის აღზევების ეპოქის დროს მომხდარ მოვლენებს.", |
||
− | tooltip = "The subject of this article appeared in the Rise of the Empire era.", |
||
+ | link = "იმპერიის აღზევების ეპოქა" |
||
− | link = "Rise of the Empire era" |
||
}, |
}, |
||
reb = { |
reb = { |
||
− | image = " |
+ | image = "Top-reb.png", |
+ | tooltip = "ამ სტატიის თემა აღწერს ამბოხების ეპოქის დროს მომხდარ მოვლენებს.", |
||
− | tooltip = "The subject of this article appeared in the Rebellion era.", |
||
− | link = " |
+ | link = "ამბოხების ეპოქა" |
}, |
}, |
||
new = { |
new = { |
||
− | image = " |
+ | image = "Top-new.png", |
+ | tooltip = "ამ სტატიის თემა აღწერს ახალი რესპუბლიკის ეპოქის დროს მომხდარ მოვლენებს.", |
||
− | tooltip = "The subject of this article appeared in the New Republic era.", |
||
+ | link = "ახალი რესპუბლიკის ეპოქა (საგამომცემლო ეპოქა)" |
||
− | link = "New Republic era" |
||
}, |
}, |
||
njo = { |
njo = { |
||
− | image = " |
+ | image = "Top-njo.png", |
+ | tooltip = "ამ სტატიის თემა აღწერს ჯედაების ახალი ორდენის ეპოქის დროს მომხდარ მოვლენებს.", |
||
− | tooltip = "The subject of this article appeared in the New Jedi Order era.", |
||
+ | link = "ჯედაების ახალი ორდენის ეპოქა (საგამომცემლო ეპოქა)" |
||
− | link = "New Jedi Order era" |
||
}, |
}, |
||
lgc = { |
lgc = { |
||
− | image = " |
+ | image = "Top-leg.png", |
+ | tooltip = "ამ სტატიის თემა აღწერს მემკვიდრეობის ეპოქის დროს მომხდარ მოვლენებს.", |
||
− | tooltip = "The subject of this article appeared in the Legacy era.", |
||
+ | link = "მემკვიდრეობის ეპოქა" |
||
− | link = "Legacy era" |
||
}, |
}, |
||
inf = { |
inf = { |
||
− | image = " |
+ | image = "Top-inf.png", |
+ | tooltip = "ამ სტატიის თემა ითვლება ვარსკვლავური ომების უსასრულობების ნაწილად.", |
||
− | tooltip = "The subject of this article is considered part of Star Wars Infinities.", |
||
− | link = " |
+ | link = "უსასრულობები" |
}, |
}, |
||
real = { |
real = { |
||
− | image = " |
+ | image = "Top-real.png", |
+ | tooltip = "ამ სტატიის თემა არსებობს ნამდვილ სამყაროში ან შეესაბამება მას.", |
||
− | tooltip = "The subject of this article exists in or is relevant to the real world.", |
||
+ | link = "Category:სტატიები ნამდვილი სამყაროს შესახებ", |
||
− | link = "Category:Real-world articles", |
||
+ | category = "სტატიები ნამდვილი სამყაროს შესახებ" |
||
− | category = "Real-world articles" |
||
+ | }, |
||
+ | audio = { |
||
+ | image = "Youtube-top.png|20px", |
||
+ | tooltip = "მოუსმინეთ ამ სტატიის აუდიოვარიანტს ინგლისურად ორიგინალური ვუკიპედიის YouTube-ის ოფიციალურ არხზე.", |
||
+ | category = "სტატიები აუდიოვერსიებით" |
||
}, |
}, |
||
fa = { |
fa = { |
||
− | image = " |
+ | image = "Top-FeaturedIcon.png", |
+ | tooltip = "ეს არის ჰოლოპედიის რჩეული სტატია.", |
||
− | tooltip = "This is a Wookieepedia Featured Article.", |
||
+ | link = "ჰოლოპედია:რჩეული სტატიები", |
||
− | link = "Wookieepedia:Featured articles", |
||
+ | category = "ჰოლოპედიის რჩეული სტატიები" |
||
− | category = "Wookieepedia Featured articles" |
||
}, |
}, |
||
ffa = { |
ffa = { |
||
− | image = " |
+ | image = "Top-DefeaturedIcon.png", |
+ | tooltip = "ეს არის ჰოლოპედიის ყოფილი რჩეული სტატია.", |
||
− | tooltip = "This is a former Wookieepedia Featured Article.", |
||
+ | link = "ჰოლოპედია:რჩეული სტატიები", |
||
− | link = "Wookieepedia:Featured articles", |
||
+ | category = "ჰოლოპედიის ყოფილი რჩეული სტატიები" |
||
− | category = "Wookieepedia former Featured articles" |
||
}, |
}, |
||
ga = { |
ga = { |
||
− | image = " |
+ | image = "Top-GoodIcon.png", |
+ | tooltip = "ეს არის ჰოლოპედიის კარგი სტატია.", |
||
− | tooltip = "This is a Wookieepedia Good Article.", |
||
+ | link = "ჰოლოპედია:კარგი სტატიები", |
||
− | link = "Wookieepedia:Good articles", |
||
+ | category = "ჰოლოპედია:კარგი სტატიები" |
||
− | category = "Wookieepedia Good articles" |
||
}, |
}, |
||
fga = { |
fga = { |
||
− | image = " |
+ | image = "Top-FormerGAicon.png", |
+ | tooltip = "ეს არის ჰოლოპედიის კარგი სტატია.", |
||
− | tooltip = "This is a former Wookieepedia Good Article.", |
||
+ | link = "ჰოლოპედია:კარგი სტატიები", |
||
− | link = "Wookieepedia:Good articles", |
||
+ | category = "ჰოლოპედიის კარგი სტატიები" |
||
− | category = "Wookieepedia former Good articles" |
||
}, |
}, |
||
ca = { |
ca = { |
||
− | image = " |
+ | image = "Top-ComprehensiveArticle.png", |
+ | tooltip = "ეს არის ჰოლოპედიის ვრცელი სტატია.", |
||
− | tooltip = "This is a Wookieepedia Comprehensive Article.", |
||
+ | link = "ჰოლოპედია:ვრცელი სტატიები", |
||
− | link = "Wookieepedia:Comprehensive articles", |
||
+ | category = "ჰოლოპედიის ვრცელი სტატიები" |
||
− | category = "Wookieepedia Comprehensive articles" |
||
}, |
}, |
||
fca = { |
fca = { |
||
− | image = " |
+ | image = "Top-FormerCAIcon.png", |
+ | tooltip = "ეს არის ჰოლოპედიის ყოფილი ვრცელი სტატია.", |
||
− | tooltip = "This is a former Wookieepedia Comprehensive Article.", |
||
+ | link = "ჰოლოპედია:ვრცელი სტატიები", |
||
− | link = "Wookieepedia:Comprehensive articles", |
||
+ | category = "ჰოლოპედიის ყოფილი ვრცელი სტატიები" |
||
− | category = "Wookieepedia former Comprehensive articles" |
||
}, |
}, |
||
fprot = { |
fprot = { |
||
protectionAction = "edit", |
protectionAction = "edit", |
||
protectionLevel = "sysop", |
protectionLevel = "sysop", |
||
− | image = " |
+ | image = "Top-Fprotect.png", |
+ | tooltip = "ეს სტატია რედაქტირებისგან დაცულია.", |
||
− | tooltip = "This article is protected from editing.", |
||
+ | link = "ჰოლოპედია:დაცვის_პოლიტიკა#სრული_დაცვა", |
||
− | link = "Wookieepedia:Protection_policy#Full_protection", |
||
− | category = " |
+ | category = "დაცული გვერდები" |
}, |
}, |
||
sprot = { |
sprot = { |
||
protectionAction = "edit", |
protectionAction = "edit", |
||
protectionLevel = "autoconfirmed", |
protectionLevel = "autoconfirmed", |
||
− | image = " |
+ | image = "Top-Sprotect.png", |
+ | tooltip = "ეს სტატია რედაქტირებისგან ნაწილობრივ დაცულია.", |
||
− | tooltip = "This article is semi-protected.", |
||
+ | link = "ჰოლოპედია:დაცვის_პოლიტიკა#ნაწილობრივ_დაცვა", |
||
− | link = "Wookieepedia:Protection_policy#Semi-protection", |
||
+ | category = "ნაწილობრივ დაცული გვერდები" |
||
− | category = "Semi-protected articles" |
||
}, |
}, |
||
ssprot = { |
ssprot = { |
||
− | image = " |
+ | image = "Top-Ssprotect.png", |
+ | tooltip = "ეს სტატია რედაქტირებისგან ნაწილობრივ დაცულია გაძლიერებული უსაფრთხოებით.", |
||
− | tooltip = "This article is super-semi-protected.", |
||
+ | link = "ჰოლოპედია:დაცვის_პოლიტიკა#ნაწილობრივ_დაცვა_გაძლიერებული_უსაფრთხოებით", |
||
− | link = "Wookieepedia:Protection_policy#Super-semi-protection", |
||
+ | category = "გაძლიერებული უსაფრთხოებით ნაწილობრივ დაცული გვერდები" |
||
− | category = "Super-semi-protected articles" |
||
}, |
}, |
||
mprot = { |
mprot = { |
||
protectionAction = "move", |
protectionAction = "move", |
||
protectionLevel = "sysop", |
protectionLevel = "sysop", |
||
− | image = " |
+ | image = "Top-Mprotect.png", |
+ | tooltip = "ეს სტატია დაცულია გადატანისგან.", |
||
− | tooltip = "This article is move protected.", |
||
+ | link = "ჰოლოპედია:დაცვის_პოლიტიკა#გადატანისგან_დაცვა", |
||
− | link = "Wookieepedia:Protection_policy#Move protection", |
||
+ | category = "გადატანისგან დაცული გვერდები" |
||
− | category = "Move protected articles" |
||
}, |
}, |
||
uprot = { |
uprot = { |
||
protectionAction = "upload", |
protectionAction = "upload", |
||
protectionLevel = "sysop", |
protectionLevel = "sysop", |
||
− | image = " |
+ | image = "Top-Uprotect.png", |
+ | tooltip = "ეს ფაილი დაცულია ატვირთვისგან.", |
||
− | tooltip = "This file is upload protected.", |
||
+ | link = "ჰოლოპედია:დაცვის_პოლიტიკა#ატვირთვისგან_დაცვა", |
||
− | link = "Wookieepedia:Protection_policy#Upload protection", |
||
+ | category = "ატვირთვისგან დაცული ფაილები" |
||
− | category = "Upload protected files" |
||
}, |
}, |
||
noncanon = { |
noncanon = { |
||
− | image = " |
+ | image = "Top-inf.png", |
+ | tooltip = "ამ სტატიის თემა ითვლება არაკანონიკურად." |
||
− | tooltip = "The subject of this article is considered non-canon." |
||
} |
} |
||
} |
} |
||
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
+ | -- დამხმარე ფუნქციები |
||
− | -- Helper functions |
||
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
+ | -- მითითებული გვერდის არსებობის შემოწმება. pcall გამოიყენება შეცდომების ასახვის მიზნით, თუკი |
||
− | -- Find whether the specified page exists. We use pcall to catch errors if we |
||
+ | -- პარსერული ფუნქციების დასაშვებ რაოდენობას ვაჭარბებთ, ან სხვა შეცდომების შემთხვევაში. |
||
− | -- are over the expensive parser function count limit, or a number of other |
||
+ | -- ეს ფუნქცია ზრდის ყოველი ახალი გვერდის პარსერული ფუნქციების დასაშვებ რაოდენობას. |
||
− | -- juicy errors. This function increases the expensive parser function count |
||
− | -- for every new page called. |
||
local function exists(page) |
local function exists(page) |
||
local success, title = pcall(mw.title.new, page) |
local success, title = pcall(mw.title.new, page) |
||
Line 191: | Line 207: | ||
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
+ | -- ეპოქების კლასი |
||
− | -- Eras class |
||
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
+ | -- ეს კლასი ასრულებს მოდულის ყველა მნიშვნელოვან ფუნქციას. კლასი |
||
− | -- The eras class does all of the heavy lifting in the module. We use a class |
||
+ | -- გამოიყენება ჩვეულებრივი ფუნქციების სანაცვლოდ, რათა ავიცილოთ ყოველი ცალკეული |
||
− | -- rather than normal functions so that we can avoid passing lots of different |
||
+ | -- ფუნქციის მრავალი მნბიშვნელობა. |
||
− | -- values around for each different function. |
||
local Eras = {} |
local Eras = {} |
||
+ | Eras.__index = Eras -- მემკვიდრეობის ჩართვა იმ ცხრილებისთვის, რომლებიც "Top" გამოიყენება როგორც მეტაცხრილი |
||
− | Eras.__index = Eras -- Set up inheritance for tables that use Eras as a metatable. |
||
+ | -- ეს ფუნქცია ქმნის ახალი ეპოქების ობიექტს. აქ მიეთითება ყველა მნიშვნელობა არგუმენტებიდან |
||
− | -- This function makes a new eras object. Here we set all the values from the |
||
+ | -- დa ხდება ნებისმიერი აუცილებელი წინასწარი დამუშავება. |
||
− | -- arguments and do any preprocessing that we need. |
||
function Eras.new(args, title) |
function Eras.new(args, title) |
||
− | local obj = setmetatable({}, Eras) -- |
+ | local obj = setmetatable({}, Eras) -- ობიექტის მემკვიდრეობით მიღება "Top"-იდან. |
obj.title = title or mw.title.getCurrentTitle() |
obj.title = title or mw.title.getCurrentTitle() |
||
+ | -- ობიექტის სტრუქტურის მითითება |
||
− | -- Set object structure |
||
obj.categories = {} |
obj.categories = {} |
||
+ | -- ასახული სახელწოდების პარამეტრების მითითება |
||
− | -- Set display title parameters |
||
obj.noDisplayTitle = args.notitle |
obj.noDisplayTitle = args.notitle |
||
obj.displayTitleBase = args.title |
obj.displayTitleBase = args.title |
||
obj.displayTitleParen = args.title2 |
obj.displayTitleParen = args.title2 |
||
+ | -- აუდიოვერსიის ბმული, თუკი ასეთი არსებობს |
||
− | -- Set hidden status |
||
+ | obj.audio = args.audio |
||
+ | |||
+ | -- დამალულის სტატუსის მითითება |
||
obj.isHidden = args.hide |
obj.isHidden = args.hide |
||
− | -- |
+ | -- notoc-ის მითითება |
obj.hideToc = args.notoc |
obj.hideToc = args.notoc |
||
+ | -- კანონის და ლეგენდების სტატიების სახელწოდებების მითითება |
||
− | -- Set canon and legends article names for the subject |
||
obj.legendsArticle = args.legends |
obj.legendsArticle = args.legends |
||
obj.canonArticle = args.canon |
obj.canonArticle = args.canon |
||
Line 229: | Line 248: | ||
end |
end |
||
+ | -- სიმბოლოების მონაცემების მიღება. |
||
− | -- Get the icon data. |
||
do |
do |
||
local icons = {} |
local icons = {} |
||
Line 237: | Line 256: | ||
icons[string.lower(v)] = t |
icons[string.lower(v)] = t |
||
else |
else |
||
+ | -- მითითებული სიმბოლო სიმბოლოების მონაცემებში არ მოიპოვება, ამიტომ |
||
− | -- The specified icon wasn't found in the icon data, so set a |
||
+ | -- დაამატეთ კატეგორიის მიდევნების ნიშნული: |
||
− | -- tracking category flag. |
||
obj.hasBadParameter = true |
obj.hasBadParameter = true |
||
end |
end |
||
+ | end |
||
+ | if obj.audio then |
||
+ | local t = iconData["audio"] |
||
+ | t.link = obj.audio |
||
+ | icons["audio"] = t |
||
end |
end |
||
obj.icons = icons |
obj.icons = icons |
||
Line 248: | Line 272: | ||
end |
end |
||
+ | -- შეცდომის ამოწევა. თუ DEBUG_MODE-ს მითითებული აქვს false, აქ წამოწეული შეცდომები |
||
− | -- Raise an error. If DEBUG_MODE is set to false, then errors raised here |
||
+ | -- გადაეცემა გატანის ფუნქციას p._main. |
||
− | -- are caught by the export function p._main. |
||
function Eras:raiseError(msg) |
function Eras:raiseError(msg) |
||
local level |
local level |
||
Line 255: | Line 279: | ||
level = nil |
level = nil |
||
else |
else |
||
+ | level = 0 -- მოდულის სახელწოდების და სტრიქონის ნომრის დახშობა შეცდომის შესახებ შეტყობინებაში. |
||
− | level = 0 -- Suppress module name and line number in the error message. |
||
end |
end |
||
error(msg, level) |
error(msg, level) |
||
end |
end |
||
+ | -- კატეგორიის დამატება, თარგის გამოტანის ბოლოს ასახვისას. |
||
− | -- Add a category, to be rendered at the very end of the template output. |
||
function Eras:addCategory(cat, sort) |
function Eras:addCategory(cat, sort) |
||
table.insert(self.categories, {category = cat, sortKey = sort}) |
table.insert(self.categories, {category = cat, sortKey = sort}) |
||
end |
end |
||
+ | -- სომბოლოს მონაცემთა ქვეცხრილის მიღების მალხმობის მეთოდი. |
||
− | -- Shortcut method for getting an icon data subtable. |
||
function Eras:getIconData(code) |
function Eras:getIconData(code) |
||
return self.icons[code] |
return self.icons[code] |
||
end |
end |
||
+ | -- არის თუ არა ამჟამინდელ სახელწოდებაში ბოლოს ასახული /კანონი. |
||
− | -- Whether the current title ends with /Canon. |
||
+ | -- შენიშვნა: ქართულ ჰოლოპედიაში უნდა შევეცადოთ, რომ კანონიკურ |
||
+ | -- თემებთან დაკავშირებული სტატიების სახელწოდება არ შეიცავდეს ბოლოსართს /კანონი, |
||
+ | -- კანონიკურ თემებთან დაჯავშირებული სტატია ყოველთვის უნდა იყოს წარმოდგენილი |
||
+ | -- ამ ბოლოსართის გარეშე. |
||
function Eras:hasCanonTitle() |
function Eras:hasCanonTitle() |
||
− | return self.title.text:find('/ |
+ | return self.title.text:find('/კანონი$') |
end |
end |
||
+ | -- არის თუ არა ამჟამინდელ სახელწოდებაში ბოლოს ასახული /ლეგენდები. |
||
− | -- Whether the current title ends with /Legends. |
||
function Eras:hasLegendsTitle() |
function Eras:hasLegendsTitle() |
||
− | return self.title.text:find('/ |
+ | return self.title.text:find('/ლეგენდები$') |
end |
end |
||
+ | -- ასახავს ლოგიკურ მნიშვნელობას, რომელიც ასახავს, არის თუ არა სიმბოლოები მითითებული |
||
− | -- Returns a boolean showing whether any of the icons were specified by the |
||
+ | -- მომხმარებლის მიერ. |
||
− | -- user. |
||
function Eras:hasAnyOfIcons(...) |
function Eras:hasAnyOfIcons(...) |
||
for i = 1, select('#', ...) do |
for i = 1, select('#', ...) do |
||
Line 291: | Line 319: | ||
end |
end |
||
+ | -- აანალიზებს გვერდის სახელწოდებას და უთითებს {{DISPLAYTITLE}}-ს. |
||
− | -- Analyses the page name and sets {{DISPLAYTITLE}}. |
||
function Eras:renderDisplayTitle() |
function Eras:renderDisplayTitle() |
||
local pagename = self.title.text |
local pagename = self.title.text |
||
+ | -- გასვლა, თუკი არ უნდა მივუთითოთ სახელწოდება ან თუ ეს სახელწოდება |
||
− | -- Exit if we have been told not to set a title or if the title begins with |
||
+ | -- იწყება მრგვალი ფრჩხილი. |
||
− | -- an opening parenthesis. |
||
if self.noDisplayTitle or pagename:find('^%(') then |
if self.noDisplayTitle or pagename:find('^%(') then |
||
return nil |
return nil |
||
end |
end |
||
+ | -- ასახვის ბაზის და ასახვის მრგვალი ფრჩხილების მოძიება. |
||
− | -- Find the display base and the display parentheses. |
||
local dBase = self.displayTitleBase |
local dBase = self.displayTitleBase |
||
local dParen = self.displayTitleParen |
local dParen = self.displayTitleParen |
||
if not dBase or not dParen then |
if not dBase or not dParen then |
||
+ | -- გვერდის ანალიზი, რათა მოვიძიოთ ძირითადი ნაწილი და დამაბოლოებელი მრგვალი ფრჩხილები. |
||
− | -- Analyse the pagename to find base part and any ending parentheses. |
||
+ | -- /კანონი ამოიშლება, ხოლო მრგვალი ფრჩხილები მიიღება მხოლოდ იმ შემთხვევაში, თუ ისინი |
||
− | -- /Canon is removed, and parentheses are only recognised if they are |
||
+ | -- გვერდის სახელწოდების ბოლოს არის მითითებული. |
||
− | -- at the end of the pagename. |
||
− | local trimmedPagename = pagename:gsub('/ |
+ | local trimmedPagename = pagename:gsub('/კანონი$', '') |
− | trimmedPagename = trimmedPagename:gsub('/ |
+ | trimmedPagename = trimmedPagename:gsub('/ლეგენდები$', '') |
local base, paren = trimmedPagename:match('^(.*)%s*%((.-)%)$') |
local base, paren = trimmedPagename:match('^(.*)%s*%((.-)%)$') |
||
if not base then |
if not base then |
||
base = trimmedPagename |
base = trimmedPagename |
||
end |
end |
||
+ | -- გამოვიყენოთ მოპოვებული მნიშვნელობები მხოლოდ იმ შემთხვევაში, თუ |
||
− | -- Use the values we found, but only if a value has not already been |
||
+ | -- მნიშვნელობა უკვე არ არის მითითებული. |
||
− | -- specified. |
||
dBase = dBase or base |
dBase = dBase or base |
||
dParen = dParen or paren |
dParen = dParen or paren |
||
end |
end |
||
+ | -- ასახვის სტრიქონის შექმნა |
||
− | -- Build the display string |
||
local display |
local display |
||
if dParen then |
if dParen then |
||
Line 331: | Line 359: | ||
end |
end |
||
+ | -- DISPLAYTITLE-ის გაფართოებული პარსერული ფუნქციის დაბრუნება. |
||
− | -- Return the expanded DISPLAYTITLE parser function. |
||
return mw.getCurrentFrame():preprocess(string.format( |
return mw.getCurrentFrame():preprocess(string.format( |
||
'{{DISPLAYTITLE:%s}}', |
'{{DISPLAYTITLE:%s}}', |
||
Line 338: | Line 366: | ||
end |
end |
||
+ | -- სიმბოლოთა მითითებული მონაცემებიდან ასახავს ეპოქის სიმბოლოს. მუშაობს პარამეტრებთან image, |
||
− | -- Renders an eras icon from the given icon data. It deals with the image, |
||
− | -- tooltip, link |
+ | -- tooltip, link და category, მაგრამ არა დაცვის ველებთან. |
function Eras:renderIcon(data) |
function Eras:renderIcon(data) |
||
+ | -- კატეგორიის ბოლოს ასახვა, თუკი იგი არსებობს. |
||
− | -- Render the category at the end if it exists. |
||
if data.category then |
if data.category then |
||
self:addCategory(data.category) |
self:addCategory(data.category) |
||
end |
end |
||
+ | -- სიმბოლოს ასახვა და დაბრუნება. |
||
− | -- Render the icon and return it. |
||
local ret = {} |
local ret = {} |
||
ret[#ret + 1] = '[[File:' |
ret[#ret + 1] = '[[File:' |
||
Line 361: | Line 389: | ||
end |
end |
||
+ | -- ასახავს დაცვის სიმბოლოს მითითებული მონაცემების მიხედვით. თუკი გვერდს არ აქვს |
||
− | -- Renders a protection eras icon from the given data. If the page doesn't have |
||
+ | -- დაცვის მითითებული დონე, აბრუნებს ნულს და ამატებს სიმბოლოს, რომელიც |
||
− | -- the specified protection level, returns nil and adds a flag to add a |
||
+ | -- დამუშავებისას მიდევნების კატეგორიას ამატებს. |
||
− | -- tracking category later on in processing. |
||
function Eras:renderProtectionIcon(data) |
function Eras:renderProtectionIcon(data) |
||
if not data.protectionAction then |
if not data.protectionAction then |
||
Line 377: | Line 405: | ||
end |
end |
||
+ | -- ასახავს პირველ სიმბოლოს, იქნება ეს კანონი თუ ლეგენდები, ან ნულს, თუკი უწყვეტობა დაუდგენელია |
||
− | -- Renders the first icon, either Canon or Legends, or nil if the continuity |
||
− | -- couldn't be determined. This is equivalent to the previous {{Eraicon/canon}} |
||
− | -- template. |
||
function Eras:renderContinuityIcon() |
function Eras:renderContinuityIcon() |
||
if self.check then |
if self.check then |
||
− | self:addCategory(' |
+ | self:addCategory('სტატიების სხვადასხვა სათაურები') |
end |
end |
||
+ | -- ჯერ დავადგინოთ, თუ რომელ უწყვეტობას ვიყენებთ, თუკი ასეთი არსებობს. |
||
− | -- First, find what continuity to use, if any. |
||
− | local continuity, isUsingCategory |
+ | local continuity, isUsingCategory, nonCanon |
− | if self:hasAnyOfIcons(' |
+ | if self:hasAnyOfIcons('ncc', 'ncl') then |
+ | nonCanon = true |
||
+ | else |
||
+ | nonCanon = false |
||
+ | end |
||
+ | if self:hasAnyOfIcons('leg', 'ncl') then |
||
continuity = 'legends' |
continuity = 'legends' |
||
if not self:hasAnyOfIcons('real') then |
if not self:hasAnyOfIcons('real') then |
||
Line 405: | Line 436: | ||
continuity = 'legends' |
continuity = 'legends' |
||
isUsingCategory = true |
isUsingCategory = true |
||
− | elseif exists(self.title.text .. '/ |
+ | elseif exists(self.title.text .. '/ლეგენდები') then |
continuity = 'canon' |
continuity = 'canon' |
||
isUsingCategory = true |
isUsingCategory = true |
||
− | elseif exists(self.title.text .. '/ |
+ | elseif exists(self.title.text .. '/კანონი') then |
continuity = 'legends' |
continuity = 'legends' |
||
isUsingCategory = true |
isUsingCategory = true |
||
Line 424: | Line 455: | ||
isUsingCategory = false |
isUsingCategory = false |
||
elseif self:hasAnyOfIcons('real') then |
elseif self:hasAnyOfIcons('real') then |
||
− | if self:hasAnyOfIcons('can') then |
+ | if self:hasAnyOfIcons('can', 'ncc') then |
continuity = 'canon' |
continuity = 'canon' |
||
end |
end |
||
Line 434: | Line 465: | ||
end |
end |
||
+ | -- სიმბოლოების მონაცემთა გენერირება და სიმბოლოს შექმნა |
||
− | -- Generate the icon data and make the icon. |
||
+ | local data |
||
if continuity == 'canon' then |
if continuity == 'canon' then |
||
+ | if nonCanon then |
||
− | local data = iconData['can'] |
||
+ | data = iconData['ncc'] |
||
− | if isUsingCategory then |
||
+ | if isUsingCategory then |
||
− | data.category = 'Canon articles' |
||
+ | data.category = 'სტატიები არაკანონიკურ საკითხებზე' |
||
+ | end |
||
+ | else |
||
+ | data = iconData['can'] |
||
+ | if isUsingCategory then |
||
+ | data.category = 'სტატიები კანონიკურ საკითხებზე' |
||
+ | end |
||
end |
end |
||
return self:renderIcon(data) |
return self:renderIcon(data) |
||
elseif continuity == 'legends' then |
elseif continuity == 'legends' then |
||
+ | if nonCanon then |
||
− | local data = iconData['leg'] |
||
+ | data = iconData['ncl'] |
||
− | if isUsingCategory then |
||
+ | if isUsingCategory then |
||
− | data.category = 'Legends articles' |
||
+ | data.category = 'სტატიები ლეგენდების არაკანონიკურ საკითხებზე' |
||
+ | end |
||
+ | else |
||
+ | data = iconData['leg'] |
||
+ | if isUsingCategory then |
||
+ | data.category = 'სტატიები ლეგენდების საკითხებზე' |
||
+ | end |
||
end |
end |
||
return self:renderIcon(data) |
return self:renderIcon(data) |
||
Line 450: | Line 496: | ||
end |
end |
||
+ | -- ასახავს სიმბოლოებს, რომლებიც გამოცემების ამა თუ იმ ეპოქას შეესაბამება. |
||
− | -- Renders the icons that respond to a publishing era. |
||
function Eras:renderPublishingIcons() |
function Eras:renderPublishingIcons() |
||
− | if not self:hasAnyOfIcons('can') |
+ | if not self:hasAnyOfIcons('can', 'ncc') |
and not self.legendsArticle |
and not self.legendsArticle |
||
and not self:hasCanonTitle() |
and not self:hasCanonTitle() |
||
Line 468: | Line 514: | ||
end |
end |
||
+ | -- ასახავს სხვა სიმბოლოებს, მაგალითად, რჩეული ან დაცვის სტატუსის მქონე სტატიაში. |
||
− | -- Renders other icons, e.g. featured article status and protection status. |
||
function Eras:renderNonPublishingIcons() |
function Eras:renderNonPublishingIcons() |
||
local ret = {} |
local ret = {} |
||
− | local codes = {'real', 'fa', 'ffa', 'ga', 'fga', 'ca', 'fca'} |
+ | local codes = {'real', 'audio', 'fa', 'ffa', 'ga', 'fga', 'ca', 'fca'} |
for _, code in ipairs(codes) do |
for _, code in ipairs(codes) do |
||
local data = self:getIconData(code) |
local data = self:getIconData(code) |
||
Line 488: | Line 534: | ||
end |
end |
||
+ | -- ასახავს ყველა სიმბოლოს და აქცვეს მათ ტეგში div. |
||
− | -- Render all the icons and eclose them in a surrounding div tag. |
||
function Eras:renderIcons() |
function Eras:renderIcons() |
||
local icons = {} |
local icons = {} |
||
Line 507: | Line 553: | ||
end |
end |
||
+ | -- ასახავს კანონის და ლეგენდების ჩანართებს სტატიებში, რომლებიც ორივე უწყვეტობაში არის მოქცეული. |
||
− | -- Renders the Canon and Legends tabs for articles that are in both |
||
− | -- continuities. |
||
function Eras:renderCanonTab() |
function Eras:renderCanonTab() |
||
if self.isHidden or self.title.namespace ~= 0 then |
if self.isHidden or self.title.namespace ~= 0 then |
||
+ | -- დასრულება, თუკი დამალულია ან არ არის სახელთა ძირითად სივრცეში. |
||
− | -- Exit if we have been explicitly hidden or if we are not in the main |
||
-- namespace. |
-- namespace. |
||
return nil |
return nil |
||
end |
end |
||
+ | -- მოვიძიოთ გვერდის ტიპი, კანონიკური სახელწოდება და ლეგენდების სახელწოდება. |
||
− | -- Find the page type, canon title, and legends title. |
||
local pageType, canonTitle, legendsTitle |
local pageType, canonTitle, legendsTitle |
||
if self.legendsArticle then |
if self.legendsArticle then |
||
Line 529: | Line 574: | ||
pageType = 'canon' |
pageType = 'canon' |
||
canonTitle = self.title.text |
canonTitle = self.title.text |
||
− | legendsTitle = canonTitle:match('^(.*)/ |
+ | legendsTitle = canonTitle:match('^(.*)/კანონი$') or canonTitle |
elseif self:hasLegendsTitle() then |
elseif self:hasLegendsTitle() then |
||
pageType = 'legends' |
pageType = 'legends' |
||
legendsTitle = self.title.text |
legendsTitle = self.title.text |
||
− | canonTitle = legendsTitle:match('^(.*)/ |
+ | canonTitle = legendsTitle:match('^(.*)/ლეგენდები$') or legendsTitle |
− | elseif exists(self.title.text .. '/ |
+ | elseif exists(self.title.text .. '/ლეგენდები') then |
pageType = 'canon' |
pageType = 'canon' |
||
− | legendsTitle = self.title.text .. '/ |
+ | legendsTitle = self.title.text .. '/ლეგენდები' |
canonTitle = self.title.text |
canonTitle = self.title.text |
||
− | elseif exists(self.title.text .. '/ |
+ | elseif exists(self.title.text .. '/კანონი') then |
pageType = 'legends' |
pageType = 'legends' |
||
− | canonTitle = self.title.text .. '/ |
+ | canonTitle = self.title.text .. '/კანონი' |
legendsTitle = self.title.text |
legendsTitle = self.title.text |
||
else |
else |
||
+ | -- ვერ ვადგენთ, აქვს თუ არა სტატიას ერთდროულად კანონიკური და ლეგენდების ვერსია, |
||
− | -- Could not determine that the article has both a Canon and a Legends |
||
+ | -- ამიტომ გავდივართ. |
||
− | -- version, so exit. |
||
return nil |
return nil |
||
end |
end |
||
if self:hasCanonTitle() then |
if self:hasCanonTitle() then |
||
+ | self:addCategory('სტატიები ქვესათაურში კანონის ქვეგვერდით') |
||
− | self:addCategory('Articles with /Canon') |
||
end |
end |
||
+ | -- კატეგორიების დამატება |
||
− | -- Add categories. |
||
if pageType == 'canon' then |
if pageType == 'canon' then |
||
+ | self:addCategory('კანონიკური სტატიები ლეგენდების ანალოგებით') |
||
− | self:addCategory('Canon articles with Legends counterparts') |
||
elseif pageType == 'legends' then |
elseif pageType == 'legends' then |
||
+ | self:addCategory('ლეგენდების სტატიები კანონიკური ანალოგებით') |
||
− | self:addCategory('Legends articles with canon counterparts') |
||
else |
else |
||
− | self:addCategory(' |
+ | self:addCategory('იზოლირებული სტატიები') |
end |
end |
||
+ | -- ცხრილის ძირეულის შექმნა |
||
− | -- Make the table root. |
||
local root = mw.html.create('table') |
local root = mw.html.create('table') |
||
root |
root |
||
Line 580: | Line 625: | ||
local row = root:tag('tr') |
local row = root:tag('tr') |
||
+ | -- ამით იქმნება კანონის/ლეგენდების უჯრა. ფუნქციის სახით მისი აქ არსებობა, ჯაჭვის სანაცვლოდ, |
||
− | -- This makes one Canon/Legends cell. Having this as a function rather than |
||
+ | -- გვეხმარება იგივე კოდის ორჯერ ჩამატებისგან თავის არიდებაში. |
||
− | -- doing it with chaining allows us to avoid putting the same code in twice. |
||
local function makeCell(id, color, image, link, tooltip) |
local function makeCell(id, color, image, link, tooltip) |
||
local cell = mw.html.create('td') |
local cell = mw.html.create('td') |
||
Line 591: | Line 636: | ||
:css('font-size', '150%') |
:css('font-size', '150%') |
||
:css('font-weight', 'bold') |
:css('font-weight', 'bold') |
||
− | :css(' |
+ | :css('min-width', '149px') |
− | :css('min-width', '170px') |
||
:css('vertical-align', 'top') |
:css('vertical-align', 'top') |
||
:css('border-radius', '5px 5px 0 0') |
:css('border-radius', '5px 5px 0 0') |
||
Line 602: | Line 646: | ||
end |
end |
||
+ | -- კანონის უჯრის შექმნა. |
||
− | local foregroundColor = '#002e54' |
||
− | local backgroundColor = '#d8e9fc' |
||
− | |||
− | -- Make the canon cell. |
||
do |
do |
||
local link = canonTitle |
local link = canonTitle |
||
Line 613: | Line 654: | ||
color = foregroundColor |
color = foregroundColor |
||
image = 'Tab-canon-white.png' |
image = 'Tab-canon-white.png' |
||
+ | tooltip = 'ეს სტატია აღწერს აღნიშნული თემის კანონიკურ ვერსიას.' |
||
− | tooltip = 'This article covers the Canon version of this subject.' |
||
else |
else |
||
id = 'canontab-canon_ctcb' |
id = 'canontab-canon_ctcb' |
||
color = backgroundColor |
color = backgroundColor |
||
image = 'Tab-canon-black.png' |
image = 'Tab-canon-black.png' |
||
+ | tooltip = "დააწკაპუნეთ აქ, რათა მოხვდეთ ჰოლოპედიაში წარმოდგენილ თემის კანონიკურ ვერსიაზე." |
||
− | tooltip = "Click here for Wookieepedia's article on the Canon " .. |
||
− | "version of this subject." |
||
end |
end |
||
row:node(makeCell(id, color, image, link, tooltip)) |
row:node(makeCell(id, color, image, link, tooltip)) |
||
end |
end |
||
+ | -- პირველი გამყოფი უჯრა |
||
− | -- First separator cell |
||
row:tag('td') |
row:tag('td') |
||
:attr('id', 'canontab-separator1') |
:attr('id', 'canontab-separator1') |
||
− | :css('width', ' |
+ | :css('width', '1px') |
− | :css('border-bottom', ' |
+ | :css('border-bottom', '0px') |
:wikitext(' ') |
:wikitext(' ') |
||
+ | -- ლეგენდების უჯრის შექმნა |
||
− | -- Make the legends cell |
||
do |
do |
||
local link = legendsTitle |
local link = legendsTitle |
||
Line 639: | Line 679: | ||
color = foregroundColor |
color = foregroundColor |
||
image = 'Tab-legends-white.png' |
image = 'Tab-legends-white.png' |
||
+ | tooltip = 'ეს სტატია აღწერს აღნიშნული თემის ლეგენდარულ ვერსიას.' |
||
− | tooltip = 'This article covers the Legends version of this subject.' |
||
− | else -- |
+ | else -- კანონის გვერდია |
id = 'canontab-legends_ctlb' |
id = 'canontab-legends_ctlb' |
||
color = backgroundColor |
color = backgroundColor |
||
image = 'Tab-legends-black.png' |
image = 'Tab-legends-black.png' |
||
+ | tooltip = "დააწკაპუნეთ აქ, რათა მოხვდეთ ჰოლოპედიაში წარმოდგენილ თემის ლეგენდების ვერსიაზე." |
||
− | tooltip = "Click here for Wookieepedia's article on the Legends " .. |
||
− | "version of this subject." |
||
end |
end |
||
row:node(makeCell(id, color, image, link, tooltip)) |
row:node(makeCell(id, color, image, link, tooltip)) |
||
end |
end |
||
+ | -- მეორე გამყოფი უჯრა |
||
− | -- Second separator cell |
||
row:tag('td') |
row:tag('td') |
||
:attr('id', 'canontab-separator2') |
:attr('id', 'canontab-separator2') |
||
Line 659: | Line 698: | ||
end |
end |
||
+ | -- ყველა კატეგორიის ასახვა, რომლებიც მითითებულია Eras:addCategory-ს მეშვეობით ან კატეგორიის სიმბოლოებით. |
||
− | -- Render all the categories that were specified using Eras:addCategory or with |
||
− | -- category flags. |
||
function Eras:renderCategories() |
function Eras:renderCategories() |
||
local fullPagename = self.title.prefixedText |
local fullPagename = self.title.prefixedText |
||
if fullPagename == 'Template:Eras' then |
if fullPagename == 'Template:Eras' then |
||
+ | -- გავდივართ, თუ შავ სიაში შეტანილ გვერდზე ვიმყოფებით. |
||
− | -- Exit if we are on a blacklisted page. |
||
return nil |
return nil |
||
end |
end |
||
Line 670: | Line 708: | ||
local pagename = self.title.text |
local pagename = self.title.text |
||
+ | -- ასახავს ერთ კატეგორიას. |
||
− | -- Renders one category. |
||
local function renderCategory(cat, sort) |
local function renderCategory(cat, sort) |
||
return string.format( |
return string.format( |
||
Line 679: | Line 717: | ||
local ret = {} |
local ret = {} |
||
− | -- |
+ | -- ასახავს კატეგორიებს ფუნქციიდან Eras:addCategory |
for i, t in ipairs(self.categories) do |
for i, t in ipairs(self.categories) do |
||
ret[i] = renderCategory(t.category, t.sortKey) |
ret[i] = renderCategory(t.category, t.sortKey) |
||
end |
end |
||
+ | -- ასახავს კატეგორიებს კატეგორიების ნიშნულებიდან. |
||
− | -- Render categories from category flags. |
||
if self.hasBadParameter then |
if self.hasBadParameter then |
||
ret[#ret + 1] = renderCategory( |
ret[#ret + 1] = renderCategory( |
||
+ | 'გვერდები ზედა თარგში არასწორი პარამეტრით' |
||
− | 'Pages with bad parameters in Template:Top' |
||
) |
) |
||
end |
end |
||
if self.hasIncorrectProtectionIcon then |
if self.hasIncorrectProtectionIcon then |
||
ret[#ret + 1] = renderCategory( |
ret[#ret + 1] = renderCategory( |
||
+ | 'გვერდები დაცვის არასწორი სიმბოლოებით' |
||
− | 'Pages with incorrect protection icons' |
||
) |
) |
||
end |
end |
||
Line 699: | Line 737: | ||
end |
end |
||
+ | -- დავამატოთ __NOTOC__, თუკი აუცილებელია |
||
− | -- Add __NOTOC__ if needed |
||
function Eras:renderNotoc() |
function Eras:renderNotoc() |
||
if self.hideToc then |
if self.hideToc then |
||
Line 707: | Line 745: | ||
end |
end |
||
+ | -- ეს მეთოდი გამოიყენება იმ შემთხვევაში, როდესაც ფუნქცია tostring ზედას ობიექტში. |
||
− | -- This method is called when the tostring function is used on the Eras object. |
||
+ | -- (მოქმედებს ზუსტად ისე, როგორც ფუნქცია Eras.__index.) იყენებს ზედა დონის ასახვის მოდელებს |
||
− | -- (This works in a similar fashion to Eras.__index above.) It calls all the |
||
+ | -- და აბრუნებს საბოლოო შედეგს. |
||
− | -- top-level render methods and returns the final output. |
||
function Eras:__tostring() |
function Eras:__tostring() |
||
local ret = {} |
local ret = {} |
||
Line 721: | Line 759: | ||
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
+ | -- გატანები |
||
− | -- Exports |
||
------------------------------------------------------------------------------- |
------------------------------------------------------------------------------- |
||
local p = {} |
local p = {} |
||
+ | -- ეს ფუნქცია არის შესვლის წერტილი Lua-ზე დაფუძნებული სხვა მეთოდებიდან. |
||
− | -- This function is the entry point from other Lua modules. |
||
function p._main(args) |
function p._main(args) |
||
+ | -- მივუთითოთ ფუნქცია pcall-იდან, რათა თავი მოვუყაროთ შეცდომებს |
||
− | -- Define a function to call from pcall so that we can catch any errors |
||
+ | -- და ვუჩვენოთ ისინი მომხმარებელს, ბუნდოვანი "სკრიპტის შეცდომის" სანაცვლოდ. |
||
− | -- and display them to the user rather than the cryptic "Script error". |
||
+ | -- (სინამდვილეში, იგი არ არის ბუნდოვანი. შეცდომაზე დაწკაპუნებით აისახება, |
||
− | -- (It's not so cryptic if you click on it to see the error message, but |
||
+ | -- თუ რა არის პრობლემა, მაგრამ ბევრმა მომხმარებელმა ამის შესახებ არ იცის.) |
||
− | -- not so many users know to do that.) |
||
local function getErasResult () |
local function getErasResult () |
||
local erasObj = Eras.new(args) |
local erasObj = Eras.new(args) |
||
+ | -- დროებითი მეთოდი, რომელიც შეცდომას მალავს Lego-სთან დაკავშირებულ სტატიებში |
||
− | -- Temporary hack to hide ugly error message on LEGO articles |
||
if erasObj == false then |
if erasObj == false then |
||
− | return '[[' .. 'Category: |
+ | return '[[' .. 'Category:გვერდები ზედა თარგში არასწორი პარამეტრებით]]' |
end |
end |
||
return tostring(erasObj) |
return tostring(erasObj) |
||
end |
end |
||
+ | -- შედეგის მიღება. შეცდომებს თვს ვუყრით, თუკი გამართვის რეჟიმის მნიშვნელობა მითითებულია როგორც false. |
||
− | -- Get the result. We only catch errors if debug mode is set to false. |
||
local success, result |
local success, result |
||
if DEBUG_MODE then |
if DEBUG_MODE then |
||
Line 750: | Line 788: | ||
end |
end |
||
+ | -- შედეგის დაბრუნება, თუკი არ არის შეცდომები, ხოლო შეცდომის შესახებ ფორმატირებული შეტყობინების |
||
− | -- Return the result if there were no errors, and a formatted error message |
||
− | -- |
+ | -- - თუკი არის. |
if success then |
if success then |
||
return result |
return result |
||
else |
else |
||
return string.format( |
return string.format( |
||
− | '<strong class="error">[[Template: |
+ | '<strong class="error">შეცდომა [[Template:ზედა]]: %s.</strong>' .. |
− | '[[' .. 'Category: |
+ | '[[' .. 'Category:გვერდები ზედა თარგში არასწორი პარამეტრით]]', |
+ | result -- ეს არის შეტყობინება შეცდომის შესახებ |
||
− | result -- this is the error message |
||
) |
) |
||
end |
end |
||
end |
end |
||
+ | -- ეს არის ვიკიტექსტიდან ხელმისაწვდომი ფუნქცია. მასზე წვდომა შესაძლებელია თარგიდან |
||
− | -- This is the function accessed from wikitext. It must be accessed through |
||
+ | -- თარგში გამოძახებული ფუნქციების სახით შეიძლება ჩაისვას მხოლოდ ტექსტი "{{#invoke:Top|main}}" |
||
− | -- a template. The template should transclude only the text |
||
+ | -- და, თარგის ნებისმიერი გამოყენების დროს, ნებისმიერი არგუმენტი, რომელიც მას მიმართავს, მოდულით მუშავდება. |
||
− | -- "{{#invoke:Eras|main}}", and then when that template is used, any arguments |
||
− | -- passed to it are magically sent through to the module. |
||
function p.main(frame) |
function p.main(frame) |
||
local args = {} |
local args = {} |
||
for k, v in pairs(frame:getParent().args) do |
for k, v in pairs(frame:getParent().args) do |
||
− | v = v:match('^%s*(.-)%s*$') -- |
+ | v = v:match('^%s*(.-)%s*$') -- ცარიელი სივრცის მოცილება |
if v ~= '' then |
if v ~= '' then |
||
args[k] = v |
args[k] = v |
||
Line 781: | Line 818: | ||
-- </nowiki> |
-- </nowiki> |
||
− | -- [[Category: |
+ | -- [[Category:ეპოქების გამოყენების თარგები|{{PAGENAME}}]] |
Latest revision as of 21:55, 23 February 2024
აქ წარმოდგენილია მოდულის დოკუმენტაცია |
---|
ყურადღება: ეს მოდული შესაძლოა, ნაწილოვრივ ან სრულად დამალული იყოს. |
იხილეთ Module:Top/doc, რათა შეცვალოთ ეს დოკუმენტაცია |
გამოყენების ინსტრუქციები[]
{{#invoke:Top|main}}
მოდული გამოიყენება თარგებში:
- {{ზედა}}
-- <nowiki>
-------------------------------------------------------------------------------
-- Module:Top
--
-- ამ მოდულით აისახება სიმბოლოები სტატიების გვერდების მარჯვენა კუთხეებში,
-- ისევე, როგორც კანონიკური და ლეგენდების ჩანართები იმ გვერდებზე, რომლებსაც აქვთ
-- პარალელური, მსგავსი სახელწოდების მქონე გვერდები, მონიშნული როგორც კანონი ან
-- ლეგენდები. მოდულს აგრეთვე თანდართული აქვს {{DISPLAYTITLE}}, რაც ნიშნავს,
-- რომ თარგში "Top" პარამეტრ title-ის გამpოყენებით შეიძლება ნებისმიერი სათაურის
-- ასახვა, თუმცა, თუკი თავდაპირველი სახელწოდება შეიცავს ფრჩხილებში ჩასმულ დამატებით
-- ტექსტს, იგი თავად გვერდზე ამ შემთხვევაში აისახება შედარებით მცირე ზომის შრიფტით.
-------------------------------------------------------------------------------
local DEBUG_MODE = false -- თუ მითითებულია true, შეცდომები არ არის ასახული
-------------------------------------------------------------------------------
-- სიმბოლოების მონაცემები
-------------------------------------------------------------------------------
--[[
-- აქ ინახება მონაცემები ყველა სიმბოლოზე, რომელიც აისახება ზედა მარჯვენა კუთხეში.
-- დასაშვებია შემდეგი პარამეტრები:
-- * image - სიმბოლოს გამოსახულების სახელი, წინსართ "File:"-ის გარეშე (აუცილებელი პარამეტრი).
-- * tooltip - სიმბოლოს მინიშნება (არ არის აუცილებელი).
-- * link - გვერდი, რომელზეც გადავდივართ სიმბოლოზე დაწკაპუნებით (არ არის აუცილებელი).
-- * category - კატეგორია, რომელიც სიმბოლოს თანდართული აქვს, წინსართ "Category:"-ს გარეშე
-- (არ არის აუცილებელი).
-- * protectionAction - დაცვის აღმნიშვნელი სიმბოლოებისთვის - მაგალითად, იმ შემთხვევაში,
-- როდესაც სტატია დაცულია გადატანისგან ან ზოგადად, რედაქტირებისგან (არ არის აუცილებელი).
-- * protectionLevel - დაცვის დონე დაცვის სიმბოლოების შემთხვევაში.
-- მაგალითია "sysop". თუ გვერდს არ აქვს მითითებული დაცვის სწორი დონე,
-- იგი მოხვდება სპეციალურ კატეგორიაში და სიბბოლო არ აისახება (არ არის აუცილებელი).
-- შენიშვნა: ეს არის მხოლოდ მონაცემთა შესანახი მოდული. ქვეცხრილებზე წვდომა შესაძლებელია
-- მექანიკურად, ამიტომ ახალი ქვეცხრილების დამატებით ახალი სიმბოლოები არ დაემატება, ხოლო ქვეცხრილების
-- ამოშლა მოდულის მუშაობას შეაფერხებს.
--]]
local iconData = {
can = {
image = 'Top-canon.png',
tooltip = 'ეს სტატია აღწერს თემას, რომელიც ითვლება კანონის ნაწილად.',
link = 'კანონი'
},
leg = {
image = 'Top-legends.png',
tooltip = 'ეს სტატია აღწერს თემას, რომელიც შედის ვარსკვლავური ომების ლეგენდებში.',
link = 'ვარსკვლავური ომების ლეგენდები'
},
ncc = {
image = 'Top-NCC.png',
tooltip = 'ეს სტატია აღწერს თემას, რომელიც არ ითვლება კანონის ნაწილად.',
link = 'კანონი'
},
ncl = {
image = 'Top-NCL.png',
tooltip = 'ეს სტატია აღწერს თემას, რომელიც არ ითვლება კანონის ნაწილად ლეგენდების უწყვეტობაში.',
link = 'ვარსკვლავური ომების ლეგენდები'
},
pre = {
image = "Top-pre.png",
tooltip = "ამ სტატიის თემა აღწერს რესპუბლიკის ჩამოყალიბებამდე მომხდარ მოვლენებს.",
link = "რესპუბლიკის დაარსებამდე"
},
btr = {
image = "Top-pre.png",
tooltip = "ამ სტატიის თემა აღწერს რესპუბლიკამდე მომხდარ მოვლენებს.",
link = "რესპუბლიკამდე"
},
old = {
image = "Top-old.png",
tooltip = "ამ სტატიის თემა აღწერს ძველი რესპუბლიკის დროს მომხდარ მოვლენებს.",
link = "ძველი რესპუბლიკის ეპოქა (საგამომცემლო ეპოქა)"
},
imp = {
image = "Top-imp.png",
tooltip = "ამ სტატიის თემა აღწერს იმპერიის აღზევების ეპოქის დროს მომხდარ მოვლენებს.",
link = "იმპერიის აღზევების ეპოქა"
},
reb = {
image = "Top-reb.png",
tooltip = "ამ სტატიის თემა აღწერს ამბოხების ეპოქის დროს მომხდარ მოვლენებს.",
link = "ამბოხების ეპოქა"
},
new = {
image = "Top-new.png",
tooltip = "ამ სტატიის თემა აღწერს ახალი რესპუბლიკის ეპოქის დროს მომხდარ მოვლენებს.",
link = "ახალი რესპუბლიკის ეპოქა (საგამომცემლო ეპოქა)"
},
njo = {
image = "Top-njo.png",
tooltip = "ამ სტატიის თემა აღწერს ჯედაების ახალი ორდენის ეპოქის დროს მომხდარ მოვლენებს.",
link = "ჯედაების ახალი ორდენის ეპოქა (საგამომცემლო ეპოქა)"
},
lgc = {
image = "Top-leg.png",
tooltip = "ამ სტატიის თემა აღწერს მემკვიდრეობის ეპოქის დროს მომხდარ მოვლენებს.",
link = "მემკვიდრეობის ეპოქა"
},
inf = {
image = "Top-inf.png",
tooltip = "ამ სტატიის თემა ითვლება ვარსკვლავური ომების უსასრულობების ნაწილად.",
link = "უსასრულობები"
},
real = {
image = "Top-real.png",
tooltip = "ამ სტატიის თემა არსებობს ნამდვილ სამყაროში ან შეესაბამება მას.",
link = "Category:სტატიები ნამდვილი სამყაროს შესახებ",
category = "სტატიები ნამდვილი სამყაროს შესახებ"
},
audio = {
image = "Youtube-top.png|20px",
tooltip = "მოუსმინეთ ამ სტატიის აუდიოვარიანტს ინგლისურად ორიგინალური ვუკიპედიის YouTube-ის ოფიციალურ არხზე.",
category = "სტატიები აუდიოვერსიებით"
},
fa = {
image = "Top-FeaturedIcon.png",
tooltip = "ეს არის ჰოლოპედიის რჩეული სტატია.",
link = "ჰოლოპედია:რჩეული სტატიები",
category = "ჰოლოპედიის რჩეული სტატიები"
},
ffa = {
image = "Top-DefeaturedIcon.png",
tooltip = "ეს არის ჰოლოპედიის ყოფილი რჩეული სტატია.",
link = "ჰოლოპედია:რჩეული სტატიები",
category = "ჰოლოპედიის ყოფილი რჩეული სტატიები"
},
ga = {
image = "Top-GoodIcon.png",
tooltip = "ეს არის ჰოლოპედიის კარგი სტატია.",
link = "ჰოლოპედია:კარგი სტატიები",
category = "ჰოლოპედია:კარგი სტატიები"
},
fga = {
image = "Top-FormerGAicon.png",
tooltip = "ეს არის ჰოლოპედიის კარგი სტატია.",
link = "ჰოლოპედია:კარგი სტატიები",
category = "ჰოლოპედიის კარგი სტატიები"
},
ca = {
image = "Top-ComprehensiveArticle.png",
tooltip = "ეს არის ჰოლოპედიის ვრცელი სტატია.",
link = "ჰოლოპედია:ვრცელი სტატიები",
category = "ჰოლოპედიის ვრცელი სტატიები"
},
fca = {
image = "Top-FormerCAIcon.png",
tooltip = "ეს არის ჰოლოპედიის ყოფილი ვრცელი სტატია.",
link = "ჰოლოპედია:ვრცელი სტატიები",
category = "ჰოლოპედიის ყოფილი ვრცელი სტატიები"
},
fprot = {
protectionAction = "edit",
protectionLevel = "sysop",
image = "Top-Fprotect.png",
tooltip = "ეს სტატია რედაქტირებისგან დაცულია.",
link = "ჰოლოპედია:დაცვის_პოლიტიკა#სრული_დაცვა",
category = "დაცული გვერდები"
},
sprot = {
protectionAction = "edit",
protectionLevel = "autoconfirmed",
image = "Top-Sprotect.png",
tooltip = "ეს სტატია რედაქტირებისგან ნაწილობრივ დაცულია.",
link = "ჰოლოპედია:დაცვის_პოლიტიკა#ნაწილობრივ_დაცვა",
category = "ნაწილობრივ დაცული გვერდები"
},
ssprot = {
image = "Top-Ssprotect.png",
tooltip = "ეს სტატია რედაქტირებისგან ნაწილობრივ დაცულია გაძლიერებული უსაფრთხოებით.",
link = "ჰოლოპედია:დაცვის_პოლიტიკა#ნაწილობრივ_დაცვა_გაძლიერებული_უსაფრთხოებით",
category = "გაძლიერებული უსაფრთხოებით ნაწილობრივ დაცული გვერდები"
},
mprot = {
protectionAction = "move",
protectionLevel = "sysop",
image = "Top-Mprotect.png",
tooltip = "ეს სტატია დაცულია გადატანისგან.",
link = "ჰოლოპედია:დაცვის_პოლიტიკა#გადატანისგან_დაცვა",
category = "გადატანისგან დაცული გვერდები"
},
uprot = {
protectionAction = "upload",
protectionLevel = "sysop",
image = "Top-Uprotect.png",
tooltip = "ეს ფაილი დაცულია ატვირთვისგან.",
link = "ჰოლოპედია:დაცვის_პოლიტიკა#ატვირთვისგან_დაცვა",
category = "ატვირთვისგან დაცული ფაილები"
},
noncanon = {
image = "Top-inf.png",
tooltip = "ამ სტატიის თემა ითვლება არაკანონიკურად."
}
}
-------------------------------------------------------------------------------
-- დამხმარე ფუნქციები
-------------------------------------------------------------------------------
-- მითითებული გვერდის არსებობის შემოწმება. pcall გამოიყენება შეცდომების ასახვის მიზნით, თუკი
-- პარსერული ფუნქციების დასაშვებ რაოდენობას ვაჭარბებთ, ან სხვა შეცდომების შემთხვევაში.
-- ეს ფუნქცია ზრდის ყოველი ახალი გვერდის პარსერული ფუნქციების დასაშვებ რაოდენობას.
local function exists(page)
local success, title = pcall(mw.title.new, page)
return success and title and title.exists or false
end
-------------------------------------------------------------------------------
-- ეპოქების კლასი
-------------------------------------------------------------------------------
-- ეს კლასი ასრულებს მოდულის ყველა მნიშვნელოვან ფუნქციას. კლასი
-- გამოიყენება ჩვეულებრივი ფუნქციების სანაცვლოდ, რათა ავიცილოთ ყოველი ცალკეული
-- ფუნქციის მრავალი მნბიშვნელობა.
local Eras = {}
Eras.__index = Eras -- მემკვიდრეობის ჩართვა იმ ცხრილებისთვის, რომლებიც "Top" გამოიყენება როგორც მეტაცხრილი
-- ეს ფუნქცია ქმნის ახალი ეპოქების ობიექტს. აქ მიეთითება ყველა მნიშვნელობა არგუმენტებიდან
-- დa ხდება ნებისმიერი აუცილებელი წინასწარი დამუშავება.
function Eras.new(args, title)
local obj = setmetatable({}, Eras) -- ობიექტის მემკვიდრეობით მიღება "Top"-იდან.
obj.title = title or mw.title.getCurrentTitle()
-- ობიექტის სტრუქტურის მითითება
obj.categories = {}
-- ასახული სახელწოდების პარამეტრების მითითება
obj.noDisplayTitle = args.notitle
obj.displayTitleBase = args.title
obj.displayTitleParen = args.title2
-- აუდიოვერსიის ბმული, თუკი ასეთი არსებობს
obj.audio = args.audio
-- დამალულის სტატუსის მითითება
obj.isHidden = args.hide
-- notoc-ის მითითება
obj.hideToc = args.notoc
-- კანონის და ლეგენდების სტატიების სახელწოდებების მითითება
obj.legendsArticle = args.legends
obj.canonArticle = args.canon
if args.canon then
obj.check = true
end
-- სიმბოლოების მონაცემების მიღება.
do
local icons = {}
for _, v in ipairs(args) do
local t = iconData[string.lower(v)]
if t then
icons[string.lower(v)] = t
else
-- მითითებული სიმბოლო სიმბოლოების მონაცემებში არ მოიპოვება, ამიტომ
-- დაამატეთ კატეგორიის მიდევნების ნიშნული:
obj.hasBadParameter = true
end
end
if obj.audio then
local t = iconData["audio"]
t.link = obj.audio
icons["audio"] = t
end
obj.icons = icons
end
return obj
end
-- შეცდომის ამოწევა. თუ DEBUG_MODE-ს მითითებული აქვს false, აქ წამოწეული შეცდომები
-- გადაეცემა გატანის ფუნქციას p._main.
function Eras:raiseError(msg)
local level
if DEBUG_MODE then
level = nil
else
level = 0 -- მოდულის სახელწოდების და სტრიქონის ნომრის დახშობა შეცდომის შესახებ შეტყობინებაში.
end
error(msg, level)
end
-- კატეგორიის დამატება, თარგის გამოტანის ბოლოს ასახვისას.
function Eras:addCategory(cat, sort)
table.insert(self.categories, {category = cat, sortKey = sort})
end
-- სომბოლოს მონაცემთა ქვეცხრილის მიღების მალხმობის მეთოდი.
function Eras:getIconData(code)
return self.icons[code]
end
-- არის თუ არა ამჟამინდელ სახელწოდებაში ბოლოს ასახული /კანონი.
-- შენიშვნა: ქართულ ჰოლოპედიაში უნდა შევეცადოთ, რომ კანონიკურ
-- თემებთან დაკავშირებული სტატიების სახელწოდება არ შეიცავდეს ბოლოსართს /კანონი,
-- კანონიკურ თემებთან დაჯავშირებული სტატია ყოველთვის უნდა იყოს წარმოდგენილი
-- ამ ბოლოსართის გარეშე.
function Eras:hasCanonTitle()
return self.title.text:find('/კანონი$')
end
-- არის თუ არა ამჟამინდელ სახელწოდებაში ბოლოს ასახული /ლეგენდები.
function Eras:hasLegendsTitle()
return self.title.text:find('/ლეგენდები$')
end
-- ასახავს ლოგიკურ მნიშვნელობას, რომელიც ასახავს, არის თუ არა სიმბოლოები მითითებული
-- მომხმარებლის მიერ.
function Eras:hasAnyOfIcons(...)
for i = 1, select('#', ...) do
if self:getIconData(select(i, ...)) then
return true
end
end
return false
end
-- აანალიზებს გვერდის სახელწოდებას და უთითებს {{DISPLAYTITLE}}-ს.
function Eras:renderDisplayTitle()
local pagename = self.title.text
-- გასვლა, თუკი არ უნდა მივუთითოთ სახელწოდება ან თუ ეს სახელწოდება
-- იწყება მრგვალი ფრჩხილი.
if self.noDisplayTitle or pagename:find('^%(') then
return nil
end
-- ასახვის ბაზის და ასახვის მრგვალი ფრჩხილების მოძიება.
local dBase = self.displayTitleBase
local dParen = self.displayTitleParen
if not dBase or not dParen then
-- გვერდის ანალიზი, რათა მოვიძიოთ ძირითადი ნაწილი და დამაბოლოებელი მრგვალი ფრჩხილები.
-- /კანონი ამოიშლება, ხოლო მრგვალი ფრჩხილები მიიღება მხოლოდ იმ შემთხვევაში, თუ ისინი
-- გვერდის სახელწოდების ბოლოს არის მითითებული.
local trimmedPagename = pagename:gsub('/კანონი$', '')
trimmedPagename = trimmedPagename:gsub('/ლეგენდები$', '')
local base, paren = trimmedPagename:match('^(.*)%s*%((.-)%)$')
if not base then
base = trimmedPagename
end
-- გამოვიყენოთ მოპოვებული მნიშვნელობები მხოლოდ იმ შემთხვევაში, თუ
-- მნიშვნელობა უკვე არ არის მითითებული.
dBase = dBase or base
dParen = dParen or paren
end
-- ასახვის სტრიქონის შექმნა
local display
if dParen then
display = string.format('%s <small>(%s)</small>', dBase, dParen)
else
display = dBase
end
if self.title.namespace ~= 0 then
display = mw.site.namespaces[self.title.namespace].name .. ':' .. display
end
-- DISPLAYTITLE-ის გაფართოებული პარსერული ფუნქციის დაბრუნება.
return mw.getCurrentFrame():preprocess(string.format(
'{{DISPLAYTITLE:%s}}',
display
))
end
-- სიმბოლოთა მითითებული მონაცემებიდან ასახავს ეპოქის სიმბოლოს. მუშაობს პარამეტრებთან image,
-- tooltip, link და category, მაგრამ არა დაცვის ველებთან.
function Eras:renderIcon(data)
-- კატეგორიის ბოლოს ასახვა, თუკი იგი არსებობს.
if data.category then
self:addCategory(data.category)
end
-- სიმბოლოს ასახვა და დაბრუნება.
local ret = {}
ret[#ret + 1] = '[[File:'
ret[#ret + 1] = data.image
if data.tooltip then
ret[#ret + 1] = '|'
ret[#ret + 1] = data.tooltip
end
if data.link then
ret[#ret + 1] = '|link='
ret[#ret + 1] = data.link
end
ret[#ret + 1] = ']]'
return table.concat(ret)
end
-- ასახავს დაცვის სიმბოლოს მითითებული მონაცემების მიხედვით. თუკი გვერდს არ აქვს
-- დაცვის მითითებული დონე, აბრუნებს ნულს და ამატებს სიმბოლოს, რომელიც
-- დამუშავებისას მიდევნების კატეგორიას ამატებს.
function Eras:renderProtectionIcon(data)
if not data.protectionAction then
return self:renderIcon(data)
end
local protectionLevel = self.title.protectionLevels[data.protectionAction]
protectionLevel = protectionLevel and protectionLevel[1]
if protectionLevel and protectionLevel == data.protectionLevel then
return self:renderIcon(data)
else
self.hasIncorrectProtectionIcon = true
end
end
-- ასახავს პირველ სიმბოლოს, იქნება ეს კანონი თუ ლეგენდები, ან ნულს, თუკი უწყვეტობა დაუდგენელია
function Eras:renderContinuityIcon()
if self.check then
self:addCategory('სტატიების სხვადასხვა სათაურები')
end
-- ჯერ დავადგინოთ, თუ რომელ უწყვეტობას ვიყენებთ, თუკი ასეთი არსებობს.
local continuity, isUsingCategory, nonCanon
if self:hasAnyOfIcons('ncc', 'ncl') then
nonCanon = true
else
nonCanon = false
end
if self:hasAnyOfIcons('leg', 'ncl') then
continuity = 'legends'
if not self:hasAnyOfIcons('real') then
isUsingCategory = true
end
elseif self.title.namespace == 0 then
if self:hasLegendsTitle() then
continuity = 'legends'
isUsingCategory = true
elseif self:hasCanonTitle() then
continuity = 'canon'
isUsingCategory = true
elseif self.legendsArticle then
continuity = 'canon'
isUsingCategory = true
elseif self.canonArticle then
continuity = 'legends'
isUsingCategory = true
elseif exists(self.title.text .. '/ლეგენდები') then
continuity = 'canon'
isUsingCategory = true
elseif exists(self.title.text .. '/კანონი') then
continuity = 'legends'
isUsingCategory = true
elseif self:hasAnyOfIcons('pre', 'btr', 'old', 'imp', 'reb', 'new',
'njo', 'lgc')
then
continuity = 'legends'
if self:hasAnyOfIcons('real') then
isUsingCategory = false
else
isUsingCategory = true
end
elseif self:hasAnyOfIcons('inf', 'noncanon') then
continuity = 'legends'
isUsingCategory = false
elseif self:hasAnyOfIcons('real') then
if self:hasAnyOfIcons('can', 'ncc') then
continuity = 'canon'
end
isUsingCategory = false
else
continuity = 'canon'
isUsingCategory = true
end
end
-- სიმბოლოების მონაცემთა გენერირება და სიმბოლოს შექმნა
local data
if continuity == 'canon' then
if nonCanon then
data = iconData['ncc']
if isUsingCategory then
data.category = 'სტატიები არაკანონიკურ საკითხებზე'
end
else
data = iconData['can']
if isUsingCategory then
data.category = 'სტატიები კანონიკურ საკითხებზე'
end
end
return self:renderIcon(data)
elseif continuity == 'legends' then
if nonCanon then
data = iconData['ncl']
if isUsingCategory then
data.category = 'სტატიები ლეგენდების არაკანონიკურ საკითხებზე'
end
else
data = iconData['leg']
if isUsingCategory then
data.category = 'სტატიები ლეგენდების საკითხებზე'
end
end
return self:renderIcon(data)
end
end
-- ასახავს სიმბოლოებს, რომლებიც გამოცემების ამა თუ იმ ეპოქას შეესაბამება.
function Eras:renderPublishingIcons()
if not self:hasAnyOfIcons('can', 'ncc')
and not self.legendsArticle
and not self:hasCanonTitle()
then
local ret = {}
local codes = {'pre', 'btr', 'old', 'imp', 'reb', 'new', 'njo', 'lgc', 'inf'}
for _, code in ipairs(codes) do
local data = self:getIconData(code)
if data then
ret[#ret + 1] = self:renderIcon(data)
end
end
return table.concat(ret)
end
end
-- ასახავს სხვა სიმბოლოებს, მაგალითად, რჩეული ან დაცვის სტატუსის მქონე სტატიაში.
function Eras:renderNonPublishingIcons()
local ret = {}
local codes = {'real', 'audio', 'fa', 'ffa', 'ga', 'fga', 'ca', 'fca'}
for _, code in ipairs(codes) do
local data = self:getIconData(code)
if data then
ret[#ret + 1] = self:renderIcon(data)
end
end
local protectionCodes = {'fprot', 'sprot', 'ssprot', 'mprot', 'uprot'}
for _, code in ipairs(protectionCodes) do
local data = self:getIconData(code)
if data then
ret[#ret + 1] = self:renderProtectionIcon(data)
end
end
return table.concat(ret)
end
-- ასახავს ყველა სიმბოლოს და აქცვეს მათ ტეგში div.
function Eras:renderIcons()
local icons = {}
icons[#icons + 1] = self:renderContinuityIcon()
icons[#icons + 1] = self:renderPublishingIcons()
icons[#icons + 1] = self:renderNonPublishingIcons()
icons = table.concat(icons)
local root = mw.html.create('div')
root
:attr('id', 'title-eraicons')
:css('float', 'right')
:css('position', 'static')
:css('display', 'none')
:wikitext(icons)
return tostring(root)
end
-- ასახავს კანონის და ლეგენდების ჩანართებს სტატიებში, რომლებიც ორივე უწყვეტობაში არის მოქცეული.
function Eras:renderCanonTab()
if self.isHidden or self.title.namespace ~= 0 then
-- დასრულება, თუკი დამალულია ან არ არის სახელთა ძირითად სივრცეში.
-- namespace.
return nil
end
-- მოვიძიოთ გვერდის ტიპი, კანონიკური სახელწოდება და ლეგენდების სახელწოდება.
local pageType, canonTitle, legendsTitle
if self.legendsArticle then
pageType = 'canon'
canonTitle = self.title.text
legendsTitle = self.legendsArticle
elseif self.canonArticle then
pageType = 'legends'
canonTitle = self.canonArticle
legendsTitle = self.title.text
elseif self:hasCanonTitle() then
pageType = 'canon'
canonTitle = self.title.text
legendsTitle = canonTitle:match('^(.*)/კანონი$') or canonTitle
elseif self:hasLegendsTitle() then
pageType = 'legends'
legendsTitle = self.title.text
canonTitle = legendsTitle:match('^(.*)/ლეგენდები$') or legendsTitle
elseif exists(self.title.text .. '/ლეგენდები') then
pageType = 'canon'
legendsTitle = self.title.text .. '/ლეგენდები'
canonTitle = self.title.text
elseif exists(self.title.text .. '/კანონი') then
pageType = 'legends'
canonTitle = self.title.text .. '/კანონი'
legendsTitle = self.title.text
else
-- ვერ ვადგენთ, აქვს თუ არა სტატიას ერთდროულად კანონიკური და ლეგენდების ვერსია,
-- ამიტომ გავდივართ.
return nil
end
if self:hasCanonTitle() then
self:addCategory('სტატიები ქვესათაურში კანონის ქვეგვერდით')
end
-- კატეგორიების დამატება
if pageType == 'canon' then
self:addCategory('კანონიკური სტატიები ლეგენდების ანალოგებით')
elseif pageType == 'legends' then
self:addCategory('ლეგენდების სტატიები კანონიკური ანალოგებით')
else
self:addCategory('იზოლირებული სტატიები')
end
-- ცხრილის ძირეულის შექმნა
local root = mw.html.create('table')
root
:attr('id', 'canontab')
:css('text-align', 'center')
:css('padding', '0')
:css('margin', '0 0 5px 0')
:css('border-left', '0')
:css('border-right', '0')
:css('border-top', '0')
:css('border-bottom', '0')
:css('border-spacing', '0')
:css('border-collapse', 'collapse')
:css('width', '100%')
:css('vertical-align', 'top')
local row = root:tag('tr')
-- ამით იქმნება კანონის/ლეგენდების უჯრა. ფუნქციის სახით მისი აქ არსებობა, ჯაჭვის სანაცვლოდ,
-- გვეხმარება იგივე კოდის ორჯერ ჩამატებისგან თავის არიდებაში.
local function makeCell(id, color, image, link, tooltip)
local cell = mw.html.create('td')
cell
:attr('id', id)
:css('padding', '5px 0 5px 0')
:css('background-color', color)
:css('line-height', '0.95em')
:css('font-size', '150%')
:css('font-weight', 'bold')
:css('min-width', '149px')
:css('vertical-align', 'top')
:css('border-radius', '5px 5px 0 0')
:wikitext(string.format(
' [[File:%s|link=%s|%s]]',
image, link, tooltip
))
return cell
end
-- კანონის უჯრის შექმნა.
do
local link = canonTitle
local color, image, tooltip
if pageType == 'canon' then
id = 'canontab-canon_ctcw'
color = foregroundColor
image = 'Tab-canon-white.png'
tooltip = 'ეს სტატია აღწერს აღნიშნული თემის კანონიკურ ვერსიას.'
else
id = 'canontab-canon_ctcb'
color = backgroundColor
image = 'Tab-canon-black.png'
tooltip = "დააწკაპუნეთ აქ, რათა მოხვდეთ ჰოლოპედიაში წარმოდგენილ თემის კანონიკურ ვერსიაზე."
end
row:node(makeCell(id, color, image, link, tooltip))
end
-- პირველი გამყოფი უჯრა
row:tag('td')
:attr('id', 'canontab-separator1')
:css('width', '1px')
:css('border-bottom', '0px')
:wikitext(' ')
-- ლეგენდების უჯრის შექმნა
do
local link = legendsTitle
local color, image, tooltip
if pageType ~= 'canon' then -- is a Legends page
id = 'canontab-legends_ctlw'
color = foregroundColor
image = 'Tab-legends-white.png'
tooltip = 'ეს სტატია აღწერს აღნიშნული თემის ლეგენდარულ ვერსიას.'
else -- კანონის გვერდია
id = 'canontab-legends_ctlb'
color = backgroundColor
image = 'Tab-legends-black.png'
tooltip = "დააწკაპუნეთ აქ, რათა მოხვდეთ ჰოლოპედიაში წარმოდგენილ თემის ლეგენდების ვერსიაზე."
end
row:node(makeCell(id, color, image, link, tooltip))
end
-- მეორე გამყოფი უჯრა
row:tag('td')
:attr('id', 'canontab-separator2')
:css('width', '3000px')
:wikitext(' ')
return tostring(root)
end
-- ყველა კატეგორიის ასახვა, რომლებიც მითითებულია Eras:addCategory-ს მეშვეობით ან კატეგორიის სიმბოლოებით.
function Eras:renderCategories()
local fullPagename = self.title.prefixedText
if fullPagename == 'Template:Eras' then
-- გავდივართ, თუ შავ სიაში შეტანილ გვერდზე ვიმყოფებით.
return nil
end
local pagename = self.title.text
-- ასახავს ერთ კატეგორიას.
local function renderCategory(cat, sort)
return string.format(
'[[%s:%s|%s]]', 'Category', cat, sort or pagename
)
end
local ret = {}
-- ასახავს კატეგორიებს ფუნქციიდან Eras:addCategory
for i, t in ipairs(self.categories) do
ret[i] = renderCategory(t.category, t.sortKey)
end
-- ასახავს კატეგორიებს კატეგორიების ნიშნულებიდან.
if self.hasBadParameter then
ret[#ret + 1] = renderCategory(
'გვერდები ზედა თარგში არასწორი პარამეტრით'
)
end
if self.hasIncorrectProtectionIcon then
ret[#ret + 1] = renderCategory(
'გვერდები დაცვის არასწორი სიმბოლოებით'
)
end
return table.concat(ret)
end
-- დავამატოთ __NOTOC__, თუკი აუცილებელია
function Eras:renderNotoc()
if self.hideToc then
return '__NOTOC__'
end
return nil
end
-- ეს მეთოდი გამოიყენება იმ შემთხვევაში, როდესაც ფუნქცია tostring ზედას ობიექტში.
-- (მოქმედებს ზუსტად ისე, როგორც ფუნქცია Eras.__index.) იყენებს ზედა დონის ასახვის მოდელებს
-- და აბრუნებს საბოლოო შედეგს.
function Eras:__tostring()
local ret = {}
ret[#ret + 1] = self:renderDisplayTitle()
ret[#ret + 1] = self:renderIcons()
ret[#ret + 1] = self:renderCanonTab()
ret[#ret + 1] = self:renderCategories()
ret[#ret + 1] = self:renderNotoc()
return table.concat(ret)
end
-------------------------------------------------------------------------------
-- გატანები
-------------------------------------------------------------------------------
local p = {}
-- ეს ფუნქცია არის შესვლის წერტილი Lua-ზე დაფუძნებული სხვა მეთოდებიდან.
function p._main(args)
-- მივუთითოთ ფუნქცია pcall-იდან, რათა თავი მოვუყაროთ შეცდომებს
-- და ვუჩვენოთ ისინი მომხმარებელს, ბუნდოვანი "სკრიპტის შეცდომის" სანაცვლოდ.
-- (სინამდვილეში, იგი არ არის ბუნდოვანი. შეცდომაზე დაწკაპუნებით აისახება,
-- თუ რა არის პრობლემა, მაგრამ ბევრმა მომხმარებელმა ამის შესახებ არ იცის.)
local function getErasResult ()
local erasObj = Eras.new(args)
-- დროებითი მეთოდი, რომელიც შეცდომას მალავს Lego-სთან დაკავშირებულ სტატიებში
if erasObj == false then
return '[[' .. 'Category:გვერდები ზედა თარგში არასწორი პარამეტრებით]]'
end
return tostring(erasObj)
end
-- შედეგის მიღება. შეცდომებს თვს ვუყრით, თუკი გამართვის რეჟიმის მნიშვნელობა მითითებულია როგორც false.
local success, result
if DEBUG_MODE then
success = true
result = getErasResult()
else
success, result = pcall(getErasResult)
end
-- შედეგის დაბრუნება, თუკი არ არის შეცდომები, ხოლო შეცდომის შესახებ ფორმატირებული შეტყობინების
-- - თუკი არის.
if success then
return result
else
return string.format(
'<strong class="error">შეცდომა [[Template:ზედა]]: %s.</strong>' ..
'[[' .. 'Category:გვერდები ზედა თარგში არასწორი პარამეტრით]]',
result -- ეს არის შეტყობინება შეცდომის შესახებ
)
end
end
-- ეს არის ვიკიტექსტიდან ხელმისაწვდომი ფუნქცია. მასზე წვდომა შესაძლებელია თარგიდან
-- თარგში გამოძახებული ფუნქციების სახით შეიძლება ჩაისვას მხოლოდ ტექსტი "{{#invoke:Top|main}}"
-- და, თარგის ნებისმიერი გამოყენების დროს, ნებისმიერი არგუმენტი, რომელიც მას მიმართავს, მოდულით მუშავდება.
function p.main(frame)
local args = {}
for k, v in pairs(frame:getParent().args) do
v = v:match('^%s*(.-)%s*$') -- ცარიელი სივრცის მოცილება
if v ~= '' then
args[k] = v
end
end
return p._main(args)
end
return p
-- </nowiki>
-- [[Category:ეპოქების გამოყენების თარგები|{{PAGENAME}}]]