This module was made as a sandbox for the user Rail. This documentation is kept to prevent redlinks.
-- <nowiki>
-- THIS WHOLE THING HAS TO BE REWRITTEN
--
-- Not the best module but it works
-- Quick help for comparing/listing pages while merging 2 or more wikis
-- Currently supports only PL
local list = {}
local getArgs = require( 'Dev:Arguments' ).getArgs
local locales = {
['intro'] = 'Poniżej znajduje się numerowana lista stron wraz z linkami umożliwiającymi łatwiejsze połączenie treści z wiki.',
['link-compare'] = 'porównaj',
['link-export'] = 'eksportuj',
['link-history'] = 'historia',
['batch-intro'] = 'Poniżej znajduje się gotowa lista stron ze źródłowej wiki, którą administratorzy mogą wykorzystać w celu wyeksportowania stron ze śródłowej wiki, a następnie zaimportowania ich na stronie Specjalna:Import.'
}
-- https://stackoverflow.com/a/7615129
local function split( inputstr, sep )
if sep == nil then
sep = '%s'
end
local t = {}
for str in string.gmatch( inputstr, '([^' .. sep .. ']+)') do
table.insert( t, str )
end
return t
end
local function getLinksList( wiki, list, wiki2 )
local wikitext = '\n'
for key, value in pairs( list ) do
local linkSchema = '# \'\'[[w:c:' .. wiki .. ':' .. value .. '|' .. value .. ']]\'\' '
local exportLink = '[[w:c:' .. wiki .. ':Special:Export/' .. value .. '|' .. locales['link-export'] .. ']]'
if wiki2 ~= Nil then
local separator = ' | '
local compareLink = '[[w:c:' .. wiki2 .. ':' .. value .. '|' .. locales['link-compare'] .. ']]'
local historyURI = tostring( mw.uri.fullUrl( value ) ) .. '?action=history'
local historyLink = '['.. historyURI .. ' ' .. locales['link-history'] .. ']'
wikitext = wikitext .. linkSchema .. '(' .. historyLink .. separator .. compareLink .. separator .. exportLink .. ')\n'
else
wikitext = wikitext .. linkSchema .. '(' .. exportLink .. ')\n'
end
end
return wikitext
end
local function getImportBatch( list )
local batch = ''
for key, value in pairs( list ) do
batch = batch .. value .. '\n'
end
return batch
end
function list.main( frame )
local args = getArgs( frame )
local wikiURL = args['wiki']
local wikiPages = args['pages'] or args['strony']
local includeBatch = args['batch'] or args['lista']
local includeCompare = args['compare'] or args['porównaj']
local processPages = split( wikiPages, '\n' )
local wrapper = mw.html.create( 'div' ):attr( 'id', 'wiki-pages-report' )
local intro = wrapper:tag( 'p' ):wikitext( locales['intro'] )
local linksList = wrapper:tag( 'div' ):attr( 'id', 'wiki-pages-list' )
if includeCompare ~= Nil then
linksList:wikitext( getLinksList( wikiURL, processPages, includeCompare ) )
else
linksList:wikitext( getLinksList( wikiURL, processPages ) )
end
if includeBatch ~= Nil then
local batchIntro = wrapper:tag( 'p' ):wikitext( locales['batch-intro'] )
local batchList = wrapper:tag( 'pre' )
:attr( 'id', 'wiki-pages-batch' )
:wikitext( getImportBatch( processPages ) )
end
return wrapper
end
return list