ПОСЕТИТЕЛЬ ЦЕНТРА!
Ты читаешь священную базу, но система видит тебя как абдулита без имени. Чтобы вносить правки в незащищённые статьи, карать грешников и нести ДОбро, тебе необходимо авторизоваться.
Действуй:

Модуль:RandomArticle

Материал из AbduloverA.com

Для документации этого модуля может быть создана страница Модуль:RandomArticle/doc

local p = {}

-- === БАЗА ДАННЫХ 1: ИЗБРАННЫЕ СТАТЬИ ===
local featured_data = {
    { title = "Абдулонаучный трактат", bg_image = "Priz.jpg" },
    { title = "Абдуловерование", bg_image = "Priz.jpg" },
    { title = "Биборан", bg_image = "Priz.jpg" }
}

-- === БАЗА ДАННЫХ 2: СЛУЧАЙНЫЕ СТАТЬИ ===
-- ВНИМАНИЕ: Сюда вписывать ТОЛЬКО точные названия существующих статей!
local random_data = {
    { title = "Биборан (версия для детей)", bg_image = "Kosti.jpg" },
    { title = "Суетлан", bg_image = "Kosti.jpg" },
    { title = "Brigman", bg_image = "Kosti.jpg" },
    { title = "Ozon671games", bg_image = "Kosti.jpg" },
    { title = "Vanomas", bg_image = "Kosti.jpg" },
    { title = "Влад Савельев", bg_image = "Kosti.jpg" },
    { title = "Алексей Поднебесный", bg_image = "Kosti.jpg" },
    { title = "Богосатана", bg_image = "Kosti.jpg" },
    { title = "Грешники", bg_image = "Kosti.jpg" }
}

-- =====================================================================
-- СУПЕР-ПАРСЕР: ВЫТЯГИВАЕТ КАРТИНКУ И ТЕКСТ (С ОБХОДОМ РЕДИРЕКТОВ)
-- =====================================================================
local function getArticleData(title_text)
    local page = mw.title.new(title_text)
    if not page or not page.exists then 
        return "Ava-abdulov-face.jpg", "Священная статья не найдена в архивах..." 
    end
    
    if page.isRedirect then
        page = page.redirectTarget
    end
    
    local content = page:getContent()
    if not content then 
        return "Ava-abdulov-face.jpg", "Ошибка доступа к тексту..." 
    end

    local img = mw.ustring.match(content, "|%s*изображение%s*=%s*([^%\n|]+)")
    if not img then img = mw.ustring.match(content, "%[%[Файл:([^|%]]+)") end
    if not img then img = mw.ustring.match(content, "%[%[File:([^|%]]+)") end
    if not img then img = mw.ustring.match(content, "image%s*=%s*([^%\n|]+)") end
    if not img then img = "Ava-abdulov-face.jpg" end 
    
    img = mw.text.trim(img)

    local text = content
    text = mw.ustring.gsub(text, "<!%-%-.-%-%->", "") 
    text = mw.ustring.gsub(text, "<ref[^>]*>.-</ref>", "") 
    text = mw.ustring.gsub(text, "<ref[^>]*/>", "")
    
    local prev
    repeat
        prev = text
        text = mw.ustring.gsub(text, "%{%b{}%}", "")
    until text == prev
    
    text = mw.ustring.gsub(text, "{%|.-|%}", "") 
    text = mw.ustring.gsub(text, "%[%[Файл:[^%]]+%]%]", "") 
    text = mw.ustring.gsub(text, "%[%[Категория:[^%]]+%]%]", "") 
    text = mw.ustring.gsub(text, "==+[^=]+==+", "") 
    
    text = mw.ustring.gsub(text, "%[%[([^|%]]+)%|([^%]]+)%]%]", "%2")
    text = mw.ustring.gsub(text, "%[%[([^%]]+)%]%]", "%1")
    text = mw.ustring.gsub(text, "''+", "")
    text = mw.ustring.gsub(text, "<[^>]+>", "")

    local snippet = ""
    for line in mw.text.gsplit(text, "\n") do
        line = mw.text.trim(line)
        if mw.ustring.len(line) > 15 and not mw.ustring.match(line, "^#REDIRECT") and not mw.ustring.match(line, "^#перенаправление") then 
            snippet = snippet .. " " .. line
            if mw.ustring.len(snippet) > 200 then 
                break
            end
        end
    end

    if mw.ustring.len(snippet) < 10 then
        snippet = "Синхронизация с инфополем Абдулова... Детальное описание сокрыто."
    else
        snippet = mw.text.truncate(mw.text.trim(snippet), 230, "...")
    end

    return img, snippet
end

-- === ОСНОВНОЙ КОД ГЕНЕРАЦИИ ===
function p.main(frame)
    math.randomseed(os.time())
    
    local f_item = featured_data[math.random(#featured_data)]
    local r_item = random_data[math.random(#random_data)]
    
    local f_img, f_text = getArticleData(f_item.title)
    local r_img, r_text = getArticleData(r_item.title)
    
    -- ИСПРАВЛЕНИЕ ПАРАЛЛАКСА: Привязка к TOP вместо BOTTOM, чтобы лица не обрезались!
    local f_bg_img = ""
    if f_item.bg_image and f_item.bg_image ~= "" then
        f_bg_img = string.format('<div class="abdul-parallax ghost-blend" style="position: absolute; left: -50px; top: 10px; z-index: 0; opacity: 0.35; pointer-events: none;">[[Файл:%s|x600px|link=|frameless]]</div>', f_item.bg_image)
    end
    
    local r_bg_img = ""
    if r_item.bg_image and r_item.bg_image ~= "" then
        r_bg_img = string.format('<div class="abdul-parallax ghost-blend" style="position: absolute; right: -70px; top: 10px; z-index: 0; opacity: 0.35; pointer-events: none;">[[Файл:%s|x600px|link=|frameless]]</div>', r_item.bg_image)
    end
    
    local html_template = [=[
<div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 20px; margin: 15px 0; width: 100%%; align-items: stretch;">

<div class="abdul-dark-panel abdul-module-card" style="margin-bottom: 0; border-top: 4px solid #ff5252; padding: 25px; box-sizing: border-box; position: relative; overflow: hidden; display: flex; flex-direction: column;">
%s
<div style="position: relative; z-index: 1; display: flex; flex-direction: column; flex-grow: 1;">
<div style="font-size: 1.3em; font-weight: bold; color: #ff5252; text-transform: uppercase; text-align: center; letter-spacing: 1px; margin-bottom: 15px; line-height: 1.2;">🏆 Избранная Статья</div>
<div style="font-size: 1.4em; font-weight: bold; text-align: center; text-transform: uppercase; margin-bottom: 15px; line-height: 1.2;">
[[%s|<span style="color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.8);">%s</span>]]
</div>

<div class="abdul-module-flex-area">
<div class="abdul-module-text">
%s
</div>
<div class="abdul-module-img">
[[Файл:%s|170px|link=%s]]
</div>
</div>

<div class="abdul-buttons-container" style="margin-top: auto; padding-top: 0; border: none;">
[[%s|<span class="abdul-btn btn-red" style="width: 100%%; box-sizing: border-box; padding: 10px 15px;"><span class="btn-icon">📖</span> ЧИТАТЬ ПОЛНОСТЬЮ</span>]]
</div>
</div>
</div>

<div class="abdul-dark-panel abdul-module-card" style="margin-bottom: 0; border-top: 4px solid #ffd700; padding: 25px; box-sizing: border-box; position: relative; overflow: hidden; display: flex; flex-direction: column;">
%s
<div style="position: relative; z-index: 1; display: flex; flex-direction: column; flex-grow: 1;">
<div style="font-size: 1.3em; font-weight: bold; color: #ffd700; text-transform: uppercase; text-align: center; letter-spacing: 1px; margin-bottom: 15px; line-height: 1.2;">🎲 Случайная Статья</div>
<div style="font-size: 1.4em; font-weight: bold; text-align: center; text-transform: uppercase; margin-bottom: 15px; line-height: 1.2;">
[[%s|<span style="color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.8);">%s</span>]]
</div>

<div class="abdul-module-flex-area">
<div class="abdul-module-img">
[[Файл:%s|170px|link=%s]]
</div>
<div class="abdul-module-text">
%s
</div>
</div>

<div class="abdul-buttons-container" style="margin-top: auto; padding-top: 0; border: none;">
[[%s|<span class="abdul-btn btn-orange" style="width: 100%%; box-sizing: border-box; padding: 10px 15px;"><span class="btn-icon">📖</span> ЧИТАТЬ ПОЛНОСТЬЮ</span>]]
</div>
</div>
</div>

</div>
]=]
    
    return string.format(html_template, 
        f_bg_img, f_item.title, f_item.title, f_text, f_img, f_item.title, f_item.title,
        r_bg_img, r_item.title, r_item.title, r_img, r_item.title, r_text, r_item.title
    )
end

return p