Module:Sandbox/trappist the monk/layurl

require ('strict');

local data=mw.loadData ('Module:Sandbox/trappist the monk/layurl/data'); local articles_using_layurl_t = data.articles_using_layurl; local wp_med_articles_t = data.wp_med_articles; local wp_med_articles_using_layurl_t = {}; local get_args = require ('Module:Arguments').getArgs;

--[[--< M A I N >--

For each article title in articles_using_layurl_t look for that article title in the selected wp:med articles list. If found add the article title to wp_med_articles_using_layurl_t sequence table.

There are three wp:med article lists: all wp:med articles (Category:All WikiProject Medicine articles) all wp:med fa articles (Category:FA-Class medicine articles) all wp:med ga articles (Category:GA-Class medicine articles)

|list=yes – return an unordered list of wikilinked articles from the selected wp:med list that use |lay-url= |fa=yes – target list is wp_med_fa_articles |ga=yes – target list is wp_med_ga_articles when neither |fa=yes not |ga=yes then target list is wp_med_articles

]]

local function main (frame) local args_t = get_args (frame); local list_t;																-- holds the chosen wp:med article list if 'yes' == args_t.fa then list_t = data.wp_med_fa_articles;										-- use the featured articles list elseif 'yes' == args_t.ga then list_t = data.wp_med_ga_articles;										-- use the good articles list else list_t = data.wp_med_articles;											-- use the list of all wp:med articles end

for title, _ in pairs (articles_using_layurl_t) do							-- get next title from  if list_t[title] then													-- is in selected wp:med ? title = '*' .. title .. '';										-- yes, make a wikilink with unordered=list markup table.insert (wp_med_articles_using_layurl_t, title);				-- add wikilinked to  end end

if 'yes' == args_t['list'] then table.sort (wp_med_articles_using_layurl_t);							-- sort the results return table.concat (wp_med_articles_using_layurl_t, '\n');				-- return an unordered list of article titles end return #wp_med_articles_using_layurl_t;										-- return the total number of titles found end

----< E X P O R T >--

return { main = main, }