Module:Test processing of plainlist table

From Livermore History Collaborative
Revision as of 10:21, 3 December 2025 by Bmcfann (talk | contribs)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Test processing of plainlist table/doc

local p = {} --p stands for package

--set up plainlist table as if it had been generated within this module from plainlist input

query_table = {}

query_table["Source:Source n39"] = {["Newspaper Item Number"] = "n39", ["Newspaper Title"] =  "St. Helena Star", ["Newspaper Page"] = "2", ["Newspaper Column"] = "4", ["Publication Date"] = "1894-10-05", ["Newspaper Full Text"] = "Miss Nellie Boston of Livermore spent several days in St. Helena the first of the week the guest of Mrs. W. F. Mixon. Miss Boston attended school in St. Helena for several months five years ago, making her home with Mr. and Mrs. J. H. Dungan. She is now a teacher in the Livermore public school.", ["Newspaper Excerpt"] = "\"\"", ["Newspaper Summary"] = "\"\"", ["Newspaper Online Source"] = "https://www.newspapers.com/article/the-st-helena-star/181533425/"}

query_table["Source:Source 49"] = {["Newspaper Item Number"] = "n49", ["Newspaper Title"] =  "Woodland Daily Democrat", ["Newspaper Page"] = "3", ["Newspaper Column"] = "6", ["Publication Date"] = "1896-06-30", ["Newspaper Full Text"] = "Miss Nellie Boston, of Livermore, is the guest of her aunt, Mrs. J. H. Dungan.", ["Newspaper Online Source"] = "https://www.newspapers.com/article/woodland-daily-democrat/181534143/"}

query_table["Source:Source n475"] = {["Newspaper Item Number"] = "n475", ["Newspaper Title"] = "Oakland Tribune", ["Newspaper Page"] = "12", ["Newspaper Column"] = "4", ["Publication Date"] = "1902-10-25", ["Newspaper Excerpt"] = "The Haywards Public School has been greatly overcrowded this term and the condition was not relieved until recently, when a number of pupils from each room were placed in another room, and an extra teacher employed. The new class has been installed in the laboratory, with Miss N. Boston of Livermore, as teacher.", ["Newspaper Online Source"] = "https://www.newspapers.com/article/oakland-tribune/182504599/"}

query_table["Source:Source n14"] = {["Newspaper Item Number"] = "n14", ["Newspaper Title"] =  "Genoa Weekly Courier", ["Newspaper Page"] = "3", ["Newspaper Column"] = "3", ["Publication Date"] =  "1886-05-21", ["Newspaper Summary"] =  "List of students at Mottsville school who passed their yearly examination. Nellie Boston is in 1st Division. She also received the prize for excellent spelling.", ["Newspaper Online Source"] =  "https://douglascounty.advantage-preservation.com/viewer/?i=f&d=01011875-12312023&e=nellie%20boston&m=between&ord=e1&fn=genoa_weekly_courier_usa_nevada_genoa_18860521_english_3&df=1&dt=10"}


--[[Many of the property names, e.g. "Newspaper Item Number" are not valid field names because they contain spaces. So the bracket and quote notation has to be used in the table constructors. Note that the query result has interpreted "" in the property field as two quotation marks (two characters), not an empty string.]]


property_names = {"Newspaper Item Number", "Newspaper Title", "Newspaper Page", "Newspaper Column", "Publication Date", "Newspaper Full Text", "Newspaper Excerpt", "Newspaper Summary","Newspaper Online Source"}


function p.process_plainlist( frame )
  
  for source_item, properties_table in pairs(query_table) do
 
    local row1 = frame:expandTemplate{ title = 'cited item citation row', args = {newspaper_title = properties_table["Newspaper Title"], publication_date = properties_table["Publication Date"], newspaper_page = properties_table["Newspaper Page"], newspaper_column = properties_table["Newspaper Column"]} }

    local row2 = frame:expandTemplate{ title = 'cited item property row', args = {property = 'Item Number',  value = properties_table["Newspaper Item Number"]} }

    if properties_table["Newspaper Full Text"] ~= nil then
      local row3 = frame:expandTemplate{ title = 'cited item property row', args = {property = 'Full Text', value = properties_table["Newspaper Full Text"]} }
    else
      local row3 = ""
    end

    if properties_table["Newspaper Summary"] ~= nil then
      local row4 = frame:expandTemplate{ title = 'cited item property row', args = {property = 'Summary', value = properties_table["Newspaper Summary"]} }
    else
      local row4 = ""
    end

    if properties_table["Newspaper Excerpt"] ~= nil then
      local row5 = frame:expandTemplate{ title = 'cited item property row', args = {property = 'Excerpt', value = properties_table["Newspaper Excerpt"]} }
    else
      local row5 = ""
    end

    local row6 = frame:expandTemplate{ title = 'cited item property row', args = {property = 'Source', value = properties_table["Newspaper Online Source"]} }

  end


  return "<ul>" .. row1 .. row2 .. row3 .. row4 .. row5 .. row6 .. "</ul>"

end

return p