Module:Sandbox/CAS222222221

This is an old revision of this page, as edited by 風中的刀劍 (talk | contribs) at 03:15, 11 December 2014 (User:CAS222222221/sandbox). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local getArgs = require('Module:Arguments').getArgs
 
local p = {}

local categoryList = {
	{'fa', '特色'},
	{'a', '甲'},
	{'ga', '优良'},
	{'b', '乙'},
	{'c', '丙'},
	{'start', '初'},
	{'stub', '小作品'},
	{'fl', '特色列表'},
	{'list', '列表'},
	
	{'category', '分类'},
	{'disambig', '消歧义'},
	{'file', '文件'},
	{'portal', '主题'},
	{'project', '专题'},
	{'template', '模板'},
	{'na', '非条目'},
	{'unassessed', '未评'},

}

local importanceList = {
	{'top', '极高'},
	{'high', '高'},
	{'mid', '中'},
	{'low', '低'},
	{'bottom', '极低'},
	{'no', '无'},
	{'na','不适用'},
	{'unknown', '未知'},
}

function p.main(frame)
	local args = getArgs(frame, {
		valueFunc = function (key, value)
			if key == '' or key == nil then
				value = ''
			end
			return value
		end 
	})
	return p._main(args)
end

local function projectName(project, taskforce)
	local ret
	
	if taskforce ~= '' then
		ret = taskforce
	else
		ret = project
	end
	
	return ret
end

local function classCategory(classCode, projectName)
	local ret
	
	if classCode ~= 'total' then
		ret = categortList[classCode][2] .. '级' .. projectName .. '条目'
	else
		ret = ''
	end
	
	return ret
end

local function importanceCategory(importanceCode, projectName)
	local ret
	
	if importanceCode ~= 'total' then
		ret = importanceList[importanceCode][2] .. '重要度' .. projectName .. '条目'
	else
		ret = ''
	end
	
	return ret
end

local function url(classCode, importanceCode, projectName)
	
	local ret
	
	ret =	mw.uri.fullUrl(
			'toollabs:catscan2/catscan2.php',
			'language=zh&' .. 
			'categories=' .. classCategory(classCode, projectName) .. '%0D%0A' .. importanceCategory(importanceCode, projectName) .. '&' .. 
			'ns[1]=1&ns[3]=1&ns[5]=1&ns[7]=1&ns[9]=1&ns[11]=1&ns[13]=1&ns[15]=1&ns[101]=1&ns[829]&' .. 
			'templates_yes=' .. template .. '&' ..
			'doit=1' 
		)
	
end

local function numberWithUrl(classCode, importanceCode, project, taskforce)
	local ret
	ret = 	'[' ..
			url(classCode, importanceCode, projectName) ..
			' ' ..
			args[classCode_importanceCode] ..
			']'
	return ret
end

function p._main(args)
	-- Main module code goes here.
	return numberWithUrl(ga, low, A, B)
end
 
return p