<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Module%3AUser%3ASuggestBot%2FWikiProjects</id>
	<title>Module:User:SuggestBot/WikiProjects - Revision history</title>
	<link rel="self" type="application/atom+xml" href="http://70.231.62.181/index.php?action=history&amp;feed=atom&amp;title=Module%3AUser%3ASuggestBot%2FWikiProjects"/>
	<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Module:User:SuggestBot/WikiProjects&amp;action=history"/>
	<updated>2026-04-22T08:07:56Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>http://70.231.62.181/index.php?title=Module:User:SuggestBot/WikiProjects&amp;diff=20982258&amp;oldid=prev</id>
		<title>imported&gt;Harej: Making &quot;section&quot; into a different parameter</title>
		<link rel="alternate" type="text/html" href="http://70.231.62.181/index.php?title=Module:User:SuggestBot/WikiProjects&amp;diff=20982258&amp;oldid=prev"/>
		<updated>2015-08-22T19:20:55Z</updated>

		<summary type="html">&lt;p&gt;Making &amp;quot;section&amp;quot; into a different parameter&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;local wp = {}&lt;br /&gt;
&lt;br /&gt;
-- BTW: Lua allows literal strings declarations [[ ]], but the syntax&lt;br /&gt;
-- highlighter doesn&amp;#039;t support them properly, fails if the string contains&lt;br /&gt;
-- another set of square brackets...&lt;br /&gt;
&lt;br /&gt;
-- Number of articles in each list if the page invoking this module is transcluded&lt;br /&gt;
local inc_limit = 2&lt;br /&gt;
&lt;br /&gt;
-- Mapping of article assessment ratings to low/medium/high as numbers&lt;br /&gt;
local rating_numbers = {FA=3, A=3, GA=3, B=2, C=2, Start=1, Stub=1, NA=0}&lt;br /&gt;
local rating_names = {FA=&amp;#039;High&amp;#039;, A=&amp;#039;High&amp;#039;, GA=&amp;#039;High&amp;#039;, B=&amp;#039;Medium&amp;#039;, C=&amp;#039;Medium&amp;#039;,&lt;br /&gt;
	Start=&amp;#039;Low&amp;#039;, Stub=&amp;#039;Low&amp;#039;, NA=&amp;#039;Unassessed&amp;#039;}&lt;br /&gt;
&lt;br /&gt;
-- Mapping of SuggestBot&amp;#039;s task categories (see [[User:SuggestBot/Documentation/Task categories]])&lt;br /&gt;
-- to section titles and descriptions, and the order in which they will be presented&lt;br /&gt;
local taskcat_order = {&amp;#039;source&amp;#039;, &amp;#039;cleanup&amp;#039;, &amp;#039;expand&amp;#039;, &amp;#039;unenc&amp;#039;,&lt;br /&gt;
	&amp;#039;merge&amp;#039;, &amp;#039;wikify&amp;#039;, &amp;#039;orphan&amp;#039;, &amp;#039;stub&amp;#039;}&lt;br /&gt;
local taskcat_map = {&lt;br /&gt;
	source={&lt;br /&gt;
		title=&amp;#039;Add sources&amp;#039;,&lt;br /&gt;
		descr=&amp;#039;See [[Wikipedia:Citing sources]] for more information.&amp;#039;&lt;br /&gt;
	},&lt;br /&gt;
	cleanup={&lt;br /&gt;
		title=&amp;#039;Cleanup&amp;#039;,&lt;br /&gt;
		descr=&amp;#039;Improve the presentation of content.&amp;#039;&lt;br /&gt;
	},&lt;br /&gt;
	expand={&lt;br /&gt;
		title=&amp;#039;Expand&amp;#039;,&lt;br /&gt;
		descr=&amp;#039;Add more information to these articles.&amp;#039;&lt;br /&gt;
	},&lt;br /&gt;
	unenc={&lt;br /&gt;
		title=&amp;#039;Unencyclopaedic&amp;#039;,&lt;br /&gt;
		descr=&amp;#039;Remove content that is not relevant for an encyclopaedia.&amp;#039;&lt;br /&gt;
	},&lt;br /&gt;
	merge={&lt;br /&gt;
		title=&amp;#039;Merge&amp;#039;,&lt;br /&gt;
		descr=&amp;#039;Should this article be merged with another article?&amp;#039;&lt;br /&gt;
	},&lt;br /&gt;
	wikify={&lt;br /&gt;
		title=&amp;#039;Wikify&amp;#039;,&lt;br /&gt;
		descr=&amp;#039;Improve the wiki-formatting on this article.&amp;#039;&lt;br /&gt;
	},&lt;br /&gt;
	orphan={&lt;br /&gt;
		title=&amp;#039;Orphan&amp;#039;,&lt;br /&gt;
		descr=&amp;#039;Few or no articles link to this article.&amp;#039;&lt;br /&gt;
	},&lt;br /&gt;
	stub={&lt;br /&gt;
		title=&amp;#039;Stub&amp;#039;,&lt;br /&gt;
		descr=&amp;#039;Expand on this brief article.&amp;#039;&lt;br /&gt;
	}&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
-- Mapping of needs (specific tasks to improve an article) to descriptions&lt;br /&gt;
local needs_list = {&amp;#039;content&amp;#039;, &amp;#039;headings&amp;#039;, &amp;#039;links&amp;#039;, &amp;#039;images&amp;#039;, &amp;#039;sources&amp;#039;}&lt;br /&gt;
local needs_map = {content=&amp;#039;more content&amp;#039;,&lt;br /&gt;
	headings=&amp;#039;proper section headings&amp;#039;,&lt;br /&gt;
	links=&amp;#039;more wikilinks&amp;#039;,&lt;br /&gt;
	images=&amp;#039;more images&amp;#039;,&lt;br /&gt;
	sources=&amp;#039;more sources&amp;#039;}&lt;br /&gt;
&lt;br /&gt;
-- Local support functions follow below&lt;br /&gt;
&lt;br /&gt;
local function has_key(tbl, key)&lt;br /&gt;
	-- Check if the given table has the given key&lt;br /&gt;
	return tbl[key] ~= nil	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function sort_articles(arglist, task_cats)&lt;br /&gt;
	-- Sort the given argument list into a table mapping task categories&lt;br /&gt;
	-- to a list of articles in that task category.&lt;br /&gt;
	local sorted_arts = {}&lt;br /&gt;
	for i, task_cat in pairs(task_cats) do&lt;br /&gt;
		sorted_arts[task_cat] = {}&lt;br /&gt;
	end&lt;br /&gt;
&lt;br /&gt;
	-- 0-based index of the current article being processed	&lt;br /&gt;
	local cur_art = 0&lt;br /&gt;
	while arglist[(cur_art * 6) + 1] do&lt;br /&gt;
		local cur_idx = cur_art * 6&lt;br /&gt;
		local task_cat = arglist[cur_idx + 1]&lt;br /&gt;
		-- Do we have this task category in our table?&lt;br /&gt;
		if sorted_arts[task_cat] then&lt;br /&gt;
			table.insert(sorted_arts[task_cat], {&lt;br /&gt;
				tag=task_cat, title=arglist[cur_idx + 2],&lt;br /&gt;
				views=arglist[cur_idx + 3],&lt;br /&gt;
				cur_qual=arglist[cur_idx + 4],&lt;br /&gt;
				pred_qual=arglist[cur_idx + 5],&lt;br /&gt;
				tasks=arglist[cur_idx + 6]&lt;br /&gt;
				})&lt;br /&gt;
		end&lt;br /&gt;
		cur_art = cur_art + 1&lt;br /&gt;
	end&lt;br /&gt;
	return sorted_arts&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function randomizeArray(t, limit)&lt;br /&gt;
	-- Randomizes an array. It works by iterating through the list backwards, each time swapping the entry&lt;br /&gt;
	-- &amp;quot;i&amp;quot; with a random entry. Courtesy of Xinhuan at http://forums.wowace.com/showthread.php?p=279756&lt;br /&gt;
	-- If the limit parameter is set, the array is shortened to that many elements after being randomized.&lt;br /&gt;
	-- The lowest possible value is 0, and the highest possible is the length of the array.&lt;br /&gt;
	local len = #t&lt;br /&gt;
	for i = len, 2, -1 do&lt;br /&gt;
		local r = math.random(i)&lt;br /&gt;
		t[i], t[r] = t[r], t[i]&lt;br /&gt;
	end&lt;br /&gt;
	if limit and limit &amp;lt; len then&lt;br /&gt;
		local ret = {}&lt;br /&gt;
		for i, v in ipairs(t) do&lt;br /&gt;
			if i &amp;gt; limit then&lt;br /&gt;
				break&lt;br /&gt;
			end&lt;br /&gt;
			ret[i] = v&lt;br /&gt;
		end&lt;br /&gt;
		return ret&lt;br /&gt;
	else&lt;br /&gt;
		return t&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function make_ratingdesc(assessment, prediction)&lt;br /&gt;
	-- Make a string that describes the article&amp;#039;s quality&lt;br /&gt;
	-- Quality: Low, Assessed class: Stub, Predicted class: Stub&lt;br /&gt;
	return &amp;quot;Quality: &amp;quot; .. rating_names[prediction] ..&lt;br /&gt;
	&amp;quot;, Assessed class: &amp;quot; .. assessment ..&lt;br /&gt;
	&amp;quot;, Predicted class: &amp;quot; .. prediction&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
local function make_needs(needs)&lt;br /&gt;
	-- From the given comma-separated list of needs, make a string that&lt;br /&gt;
	-- describes those needs based on needs_map&lt;br /&gt;
	local result = &amp;#039;&amp;#039;&lt;br /&gt;
	for i, task in ipairs(needs_list) do&lt;br /&gt;
		if string.find(needs, task) then&lt;br /&gt;
			result = result .. &amp;quot;, &amp;quot; .. needs_map[task]&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	-- Remove the first two characters (&amp;quot;, &amp;quot;)&lt;br /&gt;
	result = mw.ustring.sub(result, 3)&lt;br /&gt;
	-- Return with the first character in upper-case, from http://lua-users.org/wiki/StringRecipes&lt;br /&gt;
	return result:gsub(&amp;quot;^%l&amp;quot;, string.upper)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
-- Globally exposed functions follow below&lt;br /&gt;
function wp.suggestions(frame)&lt;br /&gt;
	-- Process the suggested articles given in the frame&amp;#039;s arguments&lt;br /&gt;
	-- and build lists of articles for each task category defined in the global&lt;br /&gt;
	-- list of categories above.&lt;br /&gt;
	&lt;br /&gt;
	-- Keyword arguments: &lt;br /&gt;
	-- * is_included=yes: passed in to limit lists to two items each when&lt;br /&gt;
	--                    the page of the call is transcluded&lt;br /&gt;
	-- * list_col=[colour value]: defines the CSS colour value of list headers&lt;br /&gt;
	-- * item_col=[colour value]: defines the CSS colour value of list items&lt;br /&gt;
	--&lt;br /&gt;
	-- The rest of the arguments are sets of six parameters describing each&lt;br /&gt;
	-- suggested article, as follows:&lt;br /&gt;
	-- 1: task category&lt;br /&gt;
	-- 2: article title&lt;br /&gt;
	-- 3: number of average views/day (14 days prior to the update)&lt;br /&gt;
	-- 4: assessed quality&lt;br /&gt;
	-- 5: predicted quality&lt;br /&gt;
	-- 6: comma-separated list of specific tasks for improving this article&lt;br /&gt;
	&lt;br /&gt;
	local list_col = &amp;#039;#086&amp;#039;&lt;br /&gt;
	local item_col = &amp;#039;#37f&amp;#039;&lt;br /&gt;
	if has_key(frame, &amp;#039;list_col&amp;#039;) then&lt;br /&gt;
		list_col = frame[&amp;#039;list_col&amp;#039;]&lt;br /&gt;
	end&lt;br /&gt;
	if has_key(frame, &amp;#039;item_col&amp;#039;) then&lt;br /&gt;
		item_col = frame[&amp;#039;item_col&amp;#039;]&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	local is_included = false&lt;br /&gt;
	if has_key(frame.args, &amp;#039;is_included&amp;#039;) then&lt;br /&gt;
		is_included = true&lt;br /&gt;
	end&lt;br /&gt;
	&lt;br /&gt;
	-- When was the page this is invoked from last updated?&lt;br /&gt;
	local last_update = frame:expandTemplate{title=&amp;#039;WPX last updated&amp;#039;,&lt;br /&gt;
		args={frame:getParent():getTitle()}}&lt;br /&gt;
	&lt;br /&gt;
	local result = &amp;#039;&amp;#039;&lt;br /&gt;
	&lt;br /&gt;
	-- sort the supplied suggested articles and process into lists…&lt;br /&gt;
	local sorted_articles = sort_articles(frame.args, taskcat_order)&lt;br /&gt;
	for i, task_cat in pairs(taskcat_order) do&lt;br /&gt;
		-- write list start&lt;br /&gt;
		local list_params = {color=list_col,&lt;br /&gt;
			title=taskcat_map[task_cat][&amp;#039;title&amp;#039;],&lt;br /&gt;
			intro=taskcat_map[task_cat][&amp;#039;descr&amp;#039;] .. &amp;quot;&amp;lt;br /&amp;gt;&amp;quot; .. last_update&lt;br /&gt;
		}&lt;br /&gt;
		if is_included then&lt;br /&gt;
			list_params[&amp;#039;constrained&amp;#039;] = &amp;#039;yes&amp;#039;&lt;br /&gt;
		end&lt;br /&gt;
		result = result .. frame:expandTemplate{title=&amp;#039;WPX list start&amp;#039;,&lt;br /&gt;
								args=list_params}&lt;br /&gt;
		&lt;br /&gt;
		-- write some articles&lt;br /&gt;
		local articles = sorted_articles[task_cat]&lt;br /&gt;
		if is_included then&lt;br /&gt;
			articles = randomizeArray(articles, inc_limit)&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		for j, article in pairs(articles) do&lt;br /&gt;
			result = result .. frame:expandTemplate{title=&amp;#039;WPX article recommendation&amp;#039;,&lt;br /&gt;
				args={&lt;br /&gt;
					color=item_col,&lt;br /&gt;
					title=article[&amp;#039;title&amp;#039;],&lt;br /&gt;
					pageviews=article[&amp;#039;views&amp;#039;],&lt;br /&gt;
					rating=rating_numbers[article[&amp;#039;pred_qual&amp;#039;]],&lt;br /&gt;
					rating_description=make_ratingdesc(article[&amp;#039;cur_qual&amp;#039;],&lt;br /&gt;
						article[&amp;#039;pred_qual&amp;#039;]),&lt;br /&gt;
					needs=make_needs(article[&amp;#039;tasks&amp;#039;])&lt;br /&gt;
				}&lt;br /&gt;
			}&lt;br /&gt;
		end&lt;br /&gt;
		&lt;br /&gt;
		-- write list end&lt;br /&gt;
		result = result .. frame:expandTemplate{title=&amp;#039;WPX list end&amp;#039;,&lt;br /&gt;
			args={more=frame:getParent():getTitle(), section=string.gsub(taskcat_map[task_cat][&amp;#039;title&amp;#039;], &amp;#039; &amp;#039;, &amp;#039;_&amp;#039;)}}&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function wp.hello(frame)&lt;br /&gt;
	return &amp;quot;Hello World!&amp;quot;	&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function wp.test_args(frame)&lt;br /&gt;
	result = &amp;quot;The method got the following arguments:&amp;quot;&lt;br /&gt;
	if has_key(frame, &amp;#039;is_included&amp;#039;) then&lt;br /&gt;
		result = result .. &amp;quot;\n* is_included&amp;quot; .. frame.args[&amp;#039;is_included&amp;#039;]&lt;br /&gt;
	end&lt;br /&gt;
	for k, v in pairs(frame.args) do&lt;br /&gt;
		result = result .. &amp;quot;\n* &amp;quot; .. k .. &amp;quot;=&amp;quot; .. v				&lt;br /&gt;
	end&lt;br /&gt;
	return result&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
return wp&lt;/div&gt;</summary>
		<author><name>imported&gt;Harej</name></author>
	</entry>
</feed>