m>Trappist the monk |
|
Line 1: |
Line 1: |
| local identifiers = {};
| | {{short description|American activist and author}} |
| | {{Infobox writer |
| | | embed = |
| | | honorific_prefix = |
| | | name = Mattilda Bernstein Sycamore |
| | | honorific_suffix = |
| | | image = Mattilda Bernstein Sycamore 280606.jpg |
| | | image_size = |
| | | image_upright = |
| | | alt = |
| | | caption = |
| | | native_name = |
| | | native_name_lang = |
| | | pseudonym = |
| | | birth_name = |
| | | birth_date = <!-- {{Birth date and age|YYYY|MM|DD}} --> |
| | | birth_place = Washington, D.C. |
| | | death_date = <!-- {{Death date and age|YYYY|MM|DD|YYYY|MM|DD}} --> |
| | | death_place = |
| | | resting_place = |
| | | occupation = |
| | | language = |
| | | residence = |
| | | nationality = American |
| | | citizenship = |
| | | education = |
| | | alma_mater = |
| | | period = |
| | | genre = non-fiction, novel, memoir <!-- or: | genres = --> |
| | | subject = <!-- or: | subjects = --> |
| | | movement = |
| | | notableworks = <!-- or: | notablework = --> |
| | | spouse = <!-- or: | spouses = --> |
| | | partner = <!-- or: | partners = --> |
| | | children = |
| | | relatives = |
| | | awards = Lambda Literary Award |
| | | signature = |
| | | signature_alt = |
| | | years_active = |
| | | module = |
| | | website = <!-- {{URL|example.org}} --> |
| | | portaldisp = <!-- "on", "yes", "true", etc; or omit --> |
| | }} |
| | '''Mattilda Bernstein Sycamore''' is an American author and activist. She is the author of a memoir and three novels, and the editor of five nonfiction anthologies. |
|
| |
|
| | ==Early life and education== |
| | Sycamore was born in [[Washington, D.C.]] to a [[American Jews|Jewish]] family<ref>{{cite web|url=https://www.dailyemerald.com/2013/04/04/qa-with-queer-activist-and-author-mattilda-bernstein-sycamore/|title=Q&A with Queer activist and author Mattilda Bernstein Sycamore – Emerald Media|date=4 April 2013|publisher=}}</ref> and was raised in the Potomac Highlands neighborhood of [[Rockville, Maryland]].<ref>{{cite web|url=https://www.mattildabernsteinsycamore.com/maybe-you-remember-this |title=Maybe You Remember This |publisher=mattildabernsteinsycamore.com |accessdate=2019-07-06}}</ref> After spending a year in college at [[Brown University]], in 1992 she moved to [[San Francisco]] where she became involved in activism with [[ACT UP]]. |
|
| |
|
| --[[--------------------------< F O R W A R D D E C L A R A T I O N S >--------------------------------------
| | == Activism and literary career == |
| ]] | | Sycamore was involved in [[ACT UP]] in the early 1990s and [[Fed Up Queers]] in the late 1990s. In 1998, she was the host of the first [[Gay Shame]] event in New York, appearing with performer [[Penny Arcade (performer)|Penny Arcade]], writer [[Eileen Myles]], cabaret artists [[Kiki and Herb]], and [[queercore]] band [[Three Dollar Bill]] held in Brooklyn, NY, which was captured in the documentary film entitled ''Gay Shame 98'', by Scott Berry. She was one of the instigators of Gay Shame in San Francisco, which started in 2000 and became "a year-round direct action extravaganza dedicated to exposing all hypocrites".<ref>{{cite web|url=http://nobodypasses.blogspot.com/2008/10/pulling-it-together.html|title=NOBODY PASSES, darling: Pulling it together|last=Sycamore|first=Mattilda Bernstein|date=6 October 2008|publisher=}}</ref> Sycamore was involved in the cultural center [[Dumba]], and is a leading critic of assimilationist trends in [[gay]] culture.<ref name="nakao">{{citation|last=Nakao|first=Annie|title=Rejecting 'normal' in favor of a distinct gay identity|date=2004-09-19|url=http://www.sfgate.com/cgi-bin/article.cgi?f=/c/a/2004/09/19/LVGQ48P21I1.DTL|periodical=[[San Francisco Chronicle]]|accessdate=2007-10-05}}</ref><ref name="revolting">{{citation|last=Sycamore|first=Matt Bernstein|title=That's Revolting!: Queer Strategies for Resisting Assimilation|page=238|year=2004|publisher=Soft Skull Press|isbn=1-932360-56-5}}</ref><ref>{{citation|title=What if Gay Marriage is the Wrong Fight?|url=http://www.lipmagazine.org/articles/featmattilda_gaymarriage_p.html|periodical=[[LiP Magazine]]}}</ref> |
|
| |
|
| local is_set, in_array, set_error, select_one, add_maint_cat; -- functions in Module:Citation/CS1/Utilities
| | In January, 2009, Sycamore initiated a public postering project called Lostmissing, which she describes as: |
|
| |
|
| local z; -- table of tables defined in Module:Citation/CS1/Utilities
| | {{quote|You know when you have a friend who you think will always be there—no matter what, at least you'll have that friendship, right? Lostmissing is a public art project about the loss of that relationship, a specific relationship for me—right now it's missing.<ref>{{cite web|url=http://nobodypasses.blogspot.com/2009/01/lostmissing-public-art-project-here-are.html|title=NOBODY PASSES, darling: Lostmissing: a public art project|first=Mattilda Bernstein|last=Sycamore|date=31 January 2009|publisher=}}</ref>}} |
|
| |
|
| local cfg; -- table of configuration tables that are defined in Module:Citation/CS1/Configuration
| | Sycamore opposed the push among the [[LGBT]] movement for [[same-sex marriage]], arguing that it distracts from more pressing issues like the securing of [[universal health care]] and housing security for all.<ref>''UTNE Reader'', November–December 2008.</ref><ref name="npr.org">{{citation |url=https://www.npr.org/templates/story/story.php?storyId=127740436 |title=A 'Queer' Argument Against Marriage |publisher=[[NPR]]}}</ref> Sycamore also opposed the LGBT movement's focus on inclusion in the US military, arguing instead that the movement should be focused on opposing the harmful impacts of the military at home and abroad. In 2010, she appeared on [[Democracy Now!]] in the segment ''[https://www.democracynow.org/2010/10/22/does_opposing_dont_ask_dont_tell Does Opposing “Don’t Ask, Don’t Tell” Bolster US Militarism? A Debate with Lt. Dan Choi and Queer Activist Mattilda Bernstein Sycamore],'' and later penned op-eds against trans inclusion in the military in ''[[Truthout]]''<ref>{{Cite news|url=https://truthout.org/articles/transgender-troops-should-be-an-oxymoron/|title="Transgender Troops" Should Be an Oxymoron|work=Truthout|access-date=2018-11-24|language=en-US}}</ref> and ''[[The Baffler]].''<ref>{{Cite news|url=https://thebaffler.com/latest/swords-into-marketshare|title=Swords into Marketshare {{!}} Mattilda Bernstein Sycamore|date=2017-09-21|work=The Baffler|access-date=2018-11-24|language=en-US}}</ref> In 2018, in collaboration with [[Dean Spade]], Sycamore co-organized a ''Queer Anti-Militarism Townhall: Trans Liberation Not U.S. Invasion'' at the [[Seattle Public Library]], alongside other queer and trans anti-military voices, including [[Micha Cárdenas]], Soya Jung, [[Nikkita Oliver]] and Matt Remle. Sycamore contributed to ''Against Equality: Queer Critiques of Gay Marriage,''<ref>{{Cite book|title=Against equality : queer critiques of gay marriage|date=2010|publisher=Against Equality Pub. Collective|others=Conrad, Ryan, 1983-, Nair, Yasmin.|isbn=9780615392684|location=Lewiston, Me.|oclc=686772854}}</ref> and wrote the introduction to ''Against Equality: Queer Revolution, Not Mere Inclusion,''<ref>{{Cite book|title=Against equality : queer revolution, not mere inclusion|others=Conrad, Ryan, 1983-|date = 2015-03-20|isbn=978-1849351843|location=Oakland, CA, USA|oclc=858603259}}</ref> anthologies printed by the [[Against Equality]] collective in 2010 and 2014. In 2008, Sycamore was named as a "visionary" as part of [[Utne Reader]] magazine's "50 Visionaries Who Are Changing the World."<ref>{{citation |url=http://www.utne.com/2008-11-13/50-Visionaries-Who-Are-Changing-Your-World.aspx |title=Visionaries Who Are Changing the World |periodical=[[Utne Reader]]}}</ref> |
|
| |
|
| | ==Awards and honors== |
| | Sycamore was awarded the [[Lambda Literary Award]] for Transgender Non-Fiction on June 2, 2014, for her 2013 book ''The End of San Francisco''.<ref>{{Cite news|url=https://www.lambdaliterary.org/26th-annual-lambda-literary-award-finalists-and-winners/|title=26th Annual Lambda Literary Award Finalists and Winners|last=Johnson|first=William|date=2014-03-07|work=Lambda Literary|access-date=2018-10-18|language=en-US}}</ref> [[NPR]]'s Book Concierge included ''Sketchtasy'' on its list of the Best Books of 2018.<ref>{{Cite news|url=https://apps.npr.org/best-books-2018/|title=NPR's Book Concierge|work=NPR.org|access-date=2018-12-02|language=en}}</ref> |
|
| |
|
| --[[--------------------------< E X T E R N A L _ L I N K _ I D >----------------------------------------------
| | ==Personal life== |
| | Regarding [[gender identity]], Sycamore identifies as [[genderqueer]] and uses the pronouns 'she' and 'her'.<ref>{{Cite news|url=https://www.npr.org/templates/story/story.php?storyId=127740436|title=A 'Queer' Argument Against Marriage|work=NPR.org|access-date=2018-12-02|language=en}}</ref> She has described herself as, "A genderqueer, faggot, and a queen, on the trans continuum, in a gender bending, gender blur kind of place. But the words I relate to the most are probably 'faggot' and 'queen.' 'Queer' would be more of a broader political identity."<ref>{{cite web|url=http://wewhofeeldifferently.info/interview.php?interview=110|title=We Who Feel Differently – Interviews|website=wewhofeeldifferently.info}}</ref> |
|
| |
|
| Formats a wiki style external link
| | == Bibliography == |
|
| |
|
| ]]
| | === Novels === |
|
| |
|
| local function external_link_id(options)
| | *''Sketchtasy'' Vancouver, BC: Arsenal Pulp Press, 2018. {{ISBN|9781551527291}}, {{OCLC|1028209630}}<ref>{{Cite web|url=https://www.latimes.com/books/la-ca-jc-mattilda-bernstein-sycamore-20181016-story.html|title=Mattilda Bernstein Sycamore on the difficult queer '90s Boston of her novel 'Sketchtasy' - Los Angeles Times|last=Schaub|first=Michael|website=latimes.com|access-date=2018-10-27}}</ref> |
| local url_string = options.id;
| | *''So Many Ways to Sleep Badly'' San Francisco : City Lights Books, 2008. {{ISBN|9780872864689}}, {{OCLC|768530865}}<ref>{{Cite book|title=So many ways to sleep badly|last=Bernstein.|first=Sycamore, Mattilda|date=2008|publisher=City Lights Books|isbn=9780872864689|location=San Francisco|oclc=216936694}}</ref> |
| if options.encode == true or options.encode == nil then
| | *''Pulling Taffy'' San Francisco, Calif. : Suspect Thoughts, 2004. {{ISBN|9780971084636}}, {{OCLC|56658648}}<ref>{{Cite book|url=https://archive.org/details/pullingtaffy00syca|title=Pulling taffy|last=Bernstein.|first=Sycamore, Matt|date=2003|publisher=Suspect Thoughts Press|isbn=0971084637|location=San Francisco|oclc=51323127|url-access=registration}}</ref> |
| url_string = mw.uri.encode( url_string );
| |
| end
| |
| return mw.ustring.format( '[[%s|%s]]%s[%s%s%s %s]',
| |
| options.link, options.label, options.separator or " ",
| |
| options.prefix, url_string, options.suffix or "",
| |
| mw.text.nowiki(options.id)
| |
| );
| |
| end
| |
|
| |
|
| | === Memoir === |
| | *''The End of San Francisco'' San Francisco : City Lights, 2013. {{ISBN|9780872865723}}, {{OCLC|812258393}}<ref>{{Cite book|title=The end of San Francisco|last=Bernstein.|first=Sycamore, Mattilda|isbn=9780872865723|location=San Francisco|oclc=812258393}}</ref> |
|
| |
|
| --[[--------------------------< I N T E R N A L _ L I N K _ I D >----------------------------------------------
| | === Nonfiction Anthologies === |
| | *''Why Are Faggots So Afraid of Faggots? Flaming Challenges to Masculinity, Objectification, and the Desire to Conform'' Oakland: AK Press, 2012. {{ISBN|9781849350884}}, {{OCLC|854723328}}<ref>{{Cite book|title=Why are faggots so afraid of faggots? : flaming challenges to masculinity, objectification, and the desire to conform|date=2012|publisher=AK Press|others=Sycamore, Mattilda Bernstein.|isbn=9781849350884|location=Oakland, CA|oclc=709680948}}</ref> |
| | *''Nobody Passes: Rejecting the Rules of Gender and Conformity'' Emeryville, CA: Seal Press, 2006. {{ISBN|9781580051842}}, {{OCLC|71285289}}<ref>{{Cite book|title=Nobody passes : rejecting the rules of gender and conformity|date=2006|publisher=Seal Press|others=Sycamore, Matt Bernstein.|isbn=9781580051842|location=Emeryville, CA|oclc=71285289}}</ref> |
| | *''That's Revolting!: Queer Strategies for Resisting Assimilation'' Brooklyn : Soft Skull Press : Distributed by Publishers Group West, 2004. {{ISBN|9781593761950}}, {{OCLC|182552895}}<ref>{{Cite book|title=That's revolting! : queer strategies for resisting assimilation|date=2004|publisher=Soft Skull Press|others=Sycamore, Mattilda Bernstein.|isbn=1932360565|location=Brooklyn|oclc=56367271}}</ref> |
| | *''Dangerous Families: Queer Writing on Surviving'' (2004)<ref>{{Cite book|title=Dangerous families : queer writing on surviving|date=2004|publisher=Harrington Park Press|others=Sycamore, Mattilda Bernstein.|isbn=1560234210|location=New York|oclc=51969191}}</ref> |
| | *''Tricks and Treats: Sex Workers Write About Their Clients'' New York : Haworth Press, 2000. {{ISBN|9780789007032}}, {{OCLC|1013296341}}<ref>{{Cite book|title=Tricks and treats : sex workers write about their clients|date=2000|publisher=Harrington Park Press|others=Sycamore, Matt Bernstein.|isbn=0789007037|location=New York|oclc=42786270}}</ref> |
|
| |
|
| Formats a wiki style internal link
| | ==Filmography== |
| | *''All That Sheltering Emptiness'' (2010), 16mm, 7 mins<ref>{{Cite web|url=http://www.cfmdc.org/film/3562|title=Canadian Filmmakers Distribution Centre|website=www.cfmdc.org|access-date=2018-10-18}}</ref> |
|
| |
|
| ]]
| | == References == |
| | {{reflist|2}} |
|
| |
|
| local function internal_link_id(options)
| | ==External links== |
| return mw.ustring.format( '[[%s|%s]]%s[[%s%s%s|%s]]',
| | *{{official|http://www.mattildabernsteinsycamore.com}} |
| options.link, options.label, options.separator or " ",
| | *[http://www.citylights.com/resources/download.cfm?GCOI=87286100861180&thefile=An_Interview_With_Mattilda_Bernstein_Sycamore.pdf An interview with Mattilda Bernstein Sycamore, August 2008] |
| options.prefix, options.id, options.suffix or "",
| | *[http://www.democracynow.org/2010/10/22/does_opposing_dont_ask_dont_tell Does Opposing "Don't Ask, Don't Tell" Bolster US Militarism?] – video debate by ''[[Democracy Now!]]'' |
| mw.text.nowiki(options.id)
| | *''New York Journal of Books'' review of 2013 title, [http://nyjournalofbooks.com/review/end-san-francisco ''The End of San Francisco''] |
| );
| | *[http://www.brooklynrail.org/2014/02/books/the-brutality-of-believing-mattilda-bernstein-sycamore-in-conversation-with-kathleen-rooney The Brutality of Believing: Mattilda Bernstein Sycamore in Conversation with Kathleen Rooney. Brooklyn Rail, February 2014] |
| end
| |
|
| |
|
| | {{Authority control}} |
|
| |
|
| --[[--------------------------< IS _ V A L I D _ I S X N >-----------------------------------------------------
| | {{DEFAULTSORT:Sycamore, Mattilda Bernstein}} |
| | | [[Category:American activists]] |
| ISBN-10 and ISSN validator code calculates checksum across all isbn/issn digits including the check digit.
| | [[Category:American feminists]] |
| ISBN-13 is checked in check_isbn().
| | [[Category:Genderqueer people]] |
| | | [[Category:LGBT writers from the United States]] |
| If the number is valid the result will be 0. Before calling this function, issbn/issn must be checked for length
| | [[Category:Transgender and transsexual writers]] |
| and stripped of dashes, spaces and other non-isxn characters.
| | [[Category:Living people]] |
| | | [[Category:Queer feminists]] |
| ]]
| | [[Category:Queer writers]] |
| | | [[Category:Transfeminists]] |
| local function is_valid_isxn (isxn_str, len)
| | [[Category:Anarcha-feminists]] |
| local temp = 0;
| | [[Category:American anarchists]] |
| isxn_str = { isxn_str:byte(1, len) }; -- make a table of byte values '0' → 0x30 .. '9' → 0x39, 'X' → 0x58
| | [[Category:Postmodern feminists]] |
| len = len+1; -- adjust to be a loop counter
| | [[Category:Lambda Literary Award winners]] |
| for i, v in ipairs( isxn_str ) do -- loop through all of the bytes and calculate the checksum
| | [[Category:Non-binary writers]] |
| if v == string.byte( "X" ) then -- if checkdigit is X (compares the byte value of 'X' which is 0x58)
| | [[Category:Year of birth missing (living people)]] |
| temp = temp + 10*( len - i ); -- it represents 10 decimal
| | [[Category:20th-century American writers]] |
| else
| | [[Category:21st-century American novelists]] |
| temp = temp + tonumber( string.char(v) )*(len-i);
| | [[Category:LGBT people from Washington, D.C.]] |
| end
| | [[Category:People from Rockville, Maryland]] |
| end
| | [[Category:Transgender and transsexual Jews]] |
| return temp % 11 == 0; -- returns true if calculation result is zero
| | [[Category:LGBT memoirists]] |
| end
| | [[Category:Writers from Washington, D.C.]] |
| | |
| | |
| --[[--------------------------< IS _ V A L I D _ I S X N _ 1 3 >----------------------------------------------
| |
| | |
| ISBN-13 and ISMN validator code calculates checksum across all 13 isbn/ismn digits including the check digit.
| |
| If the number is valid, the result will be 0. Before calling this function, isbn-13/ismn must be checked for length
| |
| and stripped of dashes, spaces and other non-isxn-13 characters.
| |
| | |
| ]] | |
| | |
| local function is_valid_isxn_13 (isxn_str)
| |
| local temp=0;
| |
|
| |
| isxn_str = { isxn_str:byte(1, 13) }; -- make a table of byte values '0' → 0x30 .. '9' → 0x39
| |
| for i, v in ipairs( isxn_str ) do
| |
| temp = temp + (3 - 2*(i % 2)) * tonumber( string.char(v) ); -- multiply odd index digits by 1, even index digits by 3 and sum; includes check digit
| |
| end
| |
| return temp % 10 == 0; -- sum modulo 10 is zero when isbn-13/ismn is correct
| |
| end
| |
| | |
| | |
| --[[--------------------------< C H E C K _ I S B N >------------------------------------------------------------
| |
| | |
| Determines whether an ISBN string is valid
| |
| | |
| ]]
| |
| | |
| local function check_isbn( isbn_str )
| |
| if nil ~= isbn_str:match("[^%s-0-9X]") then return false; end -- fail if isbn_str contains anything but digits, hyphens, or the uppercase X
| |
| isbn_str = isbn_str:gsub( "-", "" ):gsub( " ", "" ); -- remove hyphens and spaces
| |
| local len = isbn_str:len();
| |
|
| |
| if len ~= 10 and len ~= 13 then
| |
| return false;
| |
| end
| |
| | |
| if len == 10 then
| |
| if isbn_str:match( "^%d*X?$" ) == nil then return false; end
| |
| return is_valid_isxn(isbn_str, 10);
| |
| else
| |
| local temp = 0;
| |
| if isbn_str:match( "^97[89]%d*$" ) == nil then return false; end -- isbn13 begins with 978 or 979; ismn begins with 979
| |
| return is_valid_isxn_13 (isbn_str);
| |
| end
| |
| end
| |
| | |
| | |
| --[[--------------------------< I S M N >----------------------------------------------------------------------
| |
| | |
| Determines whether an ISMN string is valid. Similar to isbn-13, ismn is 13 digits begining 979-0-... and uses the
| |
| same check digit calculations. See http://www.ismn-international.org/download/Web_ISMN_Users_Manual_2008-6.pdf
| |
| section 2, pages 9–12.
| |
| | |
| ]] | |
| | |
| local function ismn (id)
| |
| local handler = cfg.id_handlers['ISMN'];
| |
| local text;
| |
| local valid_ismn = true;
| |
| | |
| id=id:gsub( "[%s-–]", "" ); -- strip spaces, hyphens, and endashes from the ismn
| |
| | |
| if 13 ~= id:len() or id:match( "^9790%d*$" ) == nil then -- ismn must be 13 digits and begin 9790
| |
| valid_ismn = false;
| |
| else
| |
| valid_ismn=is_valid_isxn_13 (id); -- validate ismn
| |
| end
| |
| | |
| -- text = internal_link_id({link = handler.link, label = handler.label, -- use this (or external version) when there is some place to link to
| |
| -- prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
| |
|
| |
| text="[[" .. handler.link .. "|" .. handler.label .. "]]" .. handler.separator .. id; -- because no place to link to yet
| |
| | |
| if false == valid_ismn then
| |
| text = text .. ' ' .. set_error( 'bad_ismn' ) -- add an error message if the ismn is invalid
| |
| end
| |
|
| |
| return text;
| |
| end
| |
| | |
| | |
| --[[--------------------------< I S S N >----------------------------------------------------------------------
| |
| | |
| Validate and format an issn. This code fixes the case where an editor has included an ISSN in the citation but
| |
| has separated the two groups of four digits with a space. When that condition occurred, the resulting link looked
| |
| like this:
| |
| | |
| |issn=0819 4327 gives: [http://www.worldcat.org/issn/0819 4327 0819 4327] -- can't have spaces in an external link
| |
|
| |
| This code now prevents that by inserting a hyphen at the issn midpoint. It also validates the issn for length
| |
| and makes sure that the checkdigit agrees with the calculated value. Incorrect length (8 digits), characters
| |
| other than 0-9 and X, or checkdigit / calculated value mismatch will all cause a check issn error message. The
| |
| issn is always displayed with a hyphen, even if the issn was given as a single group of 8 digits.
| |
| | |
| ]] | |
| | |
| local function issn(id, e)
| |
| local issn_copy = id; -- save a copy of unadulterated issn; use this version for display if issn does not validate
| |
| local handler;
| |
| local text;
| |
| local valid_issn = true;
| |
|
| |
| if e then
| |
| handler = cfg.id_handlers['EISSN'];
| |
| else
| |
| handler = cfg.id_handlers['ISSN'];
| |
| end
| |
| | |
| id=id:gsub( "[%s-–]", "" ); -- strip spaces, hyphens, and endashes from the issn
| |
| | |
| if 8 ~= id:len() or nil == id:match( "^%d*X?$" ) then -- validate the issn: 8 digits long, containing only 0-9 or X in the last position
| |
| valid_issn=false; -- wrong length or improper character
| |
| else
| |
| valid_issn=is_valid_isxn(id, 8); -- validate issn
| |
| end
| |
| | |
| if true == valid_issn then
| |
| id = string.sub( id, 1, 4 ) .. "-" .. string.sub( id, 5 ); -- if valid, display correctly formatted version
| |
| else
| |
| id = issn_copy; -- if not valid, use the show the invalid issn with error message
| |
| end
| |
|
| |
| text = external_link_id({link = handler.link, label = handler.label,
| |
| prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
| |
|
| |
| if false == valid_issn then
| |
| text = text .. ' ' .. set_error( 'bad_issn', e and 'e' or '' ) -- add an error message if the issn is invalid
| |
| end
| |
|
| |
| return text
| |
| end
| |
| | |
| | |
| --[[--------------------------< A M A Z O N >------------------------------------------------------------------
| |
| | |
| Formats a link to Amazon. Do simple error checking: asin must be mix of 10 numeric or uppercase alpha
| |
| characters. If a mix, first character must be uppercase alpha; if all numeric, asins must be 10-digit
| |
| isbn. If 10-digit isbn, add a maintenance category so a bot or awb script can replace |asin= with |isbn=.
| |
| Error message if not 10 characters, if not isbn10, if mixed and first character is a digit.
| |
| | |
| ]] | |
| | |
| local function amazon(id, domain)
| |
| local err_cat = ""
| |
| | |
| if not id:match("^[%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u][%d%u]$") then
| |
| err_cat = ' ' .. set_error ('bad_asin'); -- asin is not a mix of 10 uppercase alpha and numeric characters
| |
| else
| |
| if id:match("^%d%d%d%d%d%d%d%d%d[%dX]$") then -- if 10-digit numeric (or 9 digits with terminal X)
| |
| if check_isbn( id ) then -- see if asin value is isbn10
| |
| add_maint_cat ('ASIN');
| |
| elseif not is_set (err_cat) then
| |
| err_cat = ' ' .. set_error ('bad_asin'); -- asin is not isbn10
| |
| end
| |
| elseif not id:match("^%u[%d%u]+$") then
| |
| err_cat = ' ' .. set_error ('bad_asin'); -- asin doesn't begin with uppercase alpha
| |
| end
| |
| end
| |
| if not is_set(domain) then
| |
| domain = "com";
| |
| elseif in_array (domain, {'jp', 'uk'}) then -- Japan, United Kingdom
| |
| domain = "co." .. domain;
| |
| elseif in_array (domain, {'au', 'br', 'mx'}) then -- Australia, Brazil, Mexico
| |
| domain = "com." .. domain;
| |
| end
| |
| local handler = cfg.id_handlers['ASIN'];
| |
| return external_link_id({link=handler.link,
| |
| label=handler.label, prefix=handler.prefix .. domain .. "/dp/",
| |
| id=id, encode=handler.encode, separator = handler.separator}) .. err_cat;
| |
| end
| |
| | |
| | |
| --[[--------------------------< A R X I V >--------------------------------------------------------------------
| |
| | |
| See: http://arxiv.org/help/arxiv_identifier
| |
| | |
| format and error check arXiv identifier. There are three valid forms of the identifier:
| |
| the first form, valid only between date codes 9108 and 0703 is:
| |
| arXiv:<archive>.<class>/<date code><number><version>
| |
| where:
| |
| <archive> is a string of alpha characters - may be hyphenated; no other punctuation
| |
| <class> is a string of alpha characters - may be hyphenated; no other punctuation
| |
| <date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
| |
| first digit of YY for this form can only 9 and 0
| |
| <number> is a three-digit number
| |
| <version> is a 1 or more digit number preceded with a lowercase v; no spaces (undocumented)
| |
|
| |
| the second form, valid from April 2007 through December 2014 is:
| |
| arXiv:<date code>.<number><version>
| |
| where:
| |
| <date code> is four digits in the form YYMM where YY is the last two digits of the four-digit year and MM is the month number January = 01
| |
| <number> is a four-digit number
| |
| <version> is a 1 or more digit number preceded with a lowercase v; no spaces
| |
| | |
| the third form, valid from January 2015 is:
| |
| arXiv:<date code>.<number><version>
| |
| where:
| |
| <date code> and <version> are as defined for 0704-1412
| |
| <number> is a five-digit number
| |
| ]] | |
| | |
| local function arxiv (id, class)
| |
| local handler = cfg.id_handlers['ARXIV'];
| |
| local year, month, version;
| |
| local err_cat = '';
| |
| local text;
| |
|
| |
| if id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%d$") or id:match("^%a[%a%.%-]+/[90]%d[01]%d%d%d%dv%d+$") then -- test for the 9108-0703 format w/ & w/o version
| |
| year, month = id:match("^%a[%a%.%-]+/([90]%d)([01]%d)%d%d%d[v%d]*$");
| |
| year = tonumber(year);
| |
| month = tonumber(month);
| |
| if ((not (90 < year or 8 > year)) or (1 > month or 12 < month)) or -- if invalid year or invalid month
| |
| ((91 == year and 7 > month) or (7 == year and 3 < month)) then -- if years ok, are starting and ending months ok?
| |
| err_cat = ' ' .. set_error( 'bad_arxiv' ); -- set error message
| |
| end
| |
| elseif id:match("^%d%d[01]%d%.%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%dv%d+$") then -- test for the 0704-1412 w/ & w/o version
| |
| year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d[v%d]*$");
| |
| year = tonumber(year);
| |
| month = tonumber(month);
| |
| if ((7 > year) or (14 < year) or (1 > month or 12 < month)) or -- is year invalid or is month invalid? (doesn't test for future years)
| |
| ((7 == year) and (4 > month)) then --or -- when year is 07, is month invalid (before April)?
| |
| err_cat = ' ' .. set_error( 'bad_arxiv' ); -- set error message
| |
| end
| |
| elseif id:match("^%d%d[01]%d%.%d%d%d%d%d$") or id:match("^%d%d[01]%d%.%d%d%d%d%dv%d+$") then -- test for the 1501- format w/ & w/o version
| |
| year, month = id:match("^(%d%d)([01]%d)%.%d%d%d%d%d[v%d]*$");
| |
| year = tonumber(year);
| |
| month = tonumber(month);
| |
| if ((15 > year) or (1 > month or 12 < month)) then -- is year invalid or is month invalid? (doesn't test for future years)
| |
| err_cat = ' ' .. set_error( 'bad_arxiv' ); -- set error message
| |
| end
| |
| else
| |
| err_cat = ' ' .. set_error( 'bad_arxiv' ); -- arXiv id doesn't match any format
| |
| end
| |
| | |
| text = external_link_id({link = handler.link, label = handler.label,
| |
| prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
| |
| | |
| if is_set (class) then
| |
| class = ' [[' .. '//arxiv.org/archive/' .. class .. ' ' .. class .. ']]'; -- external link within square brackets, not wikilink
| |
| else
| |
| class = ''; -- empty string for concatenation
| |
| end
| |
|
| |
| return text .. class;
| |
| end
| |
| | |
| | |
| --[[--------------------------< N O R M A L I Z E _ L C C N >--------------------------------------------------
| |
| | |
| lccn normalization (http://www.loc.gov/marc/lccn-namespace.html#normalization)
| |
| 1. Remove all blanks.
| |
| 2. If there is a forward slash (/) in the string, remove it, and remove all characters to the right of the forward slash.
| |
| 3. If there is a hyphen in the string:
| |
| a. Remove it.
| |
| b. Inspect the substring following (to the right of) the (removed) hyphen. Then (and assuming that steps 1 and 2 have been carried out):
| |
| 1. All these characters should be digits, and there should be six or less. (not done in this function)
| |
| 2. If the length of the substring is less than 6, left-fill the substring with zeroes until the length is six.
| |
| | |
| Returns a normalized lccn for lccn() to validate. There is no error checking (step 3.b.1) performed in this function.
| |
| ]] | |
| | |
| local function normalize_lccn (lccn)
| |
| lccn = lccn:gsub ("%s", ""); -- 1. strip whitespace
| |
| | |
| if nil ~= string.find (lccn,'/') then
| |
| lccn = lccn:match ("(.-)/"); -- 2. remove forward slash and all character to the right of it
| |
| end
| |
| | |
| local prefix
| |
| local suffix
| |
| prefix, suffix = lccn:match ("(.+)%-(.+)"); -- 3.a remove hyphen by splitting the string into prefix and suffix
| |
| | |
| if nil ~= suffix then -- if there was a hyphen
| |
| suffix=string.rep("0", 6-string.len (suffix)) .. suffix; -- 3.b.2 left fill the suffix with 0s if suffix length less than 6
| |
| lccn=prefix..suffix; -- reassemble the lccn
| |
| end
| |
|
| |
| return lccn;
| |
| end
| |
| | |
| | |
| --[[--------------------------< L C C N >----------------------------------------------------------------------
| |
| | |
| Format LCCN link and do simple error checking. LCCN is a character string 8-12 characters long. The length of
| |
| the LCCN dictates the character type of the first 1-3 characters; the rightmost eight are always digits.
| |
| http://info-uri.info/registry/OAIHandler?verb=GetRecord&metadataPrefix=reg&identifier=info:lccn/
| |
| | |
| length = 8 then all digits
| |
| length = 9 then lccn[1] is lower case alpha
| |
| length = 10 then lccn[1] and lccn[2] are both lower case alpha or both digits
| |
| length = 11 then lccn[1] is lower case alpha, lccn[2] and lccn[3] are both lower case alpha or both digits
| |
| length = 12 then lccn[1] and lccn[2] are both lower case alpha
| |
| | |
| ]]
| |
| | |
| local function lccn(lccn)
| |
| local handler = cfg.id_handlers['LCCN'];
| |
| local err_cat = ''; -- presume that LCCN is valid
| |
| local id = lccn; -- local copy of the lccn
| |
| | |
| id = normalize_lccn (id); -- get canonical form (no whitespace, hyphens, forward slashes)
| |
| local len = id:len(); -- get the length of the lccn
| |
| | |
| if 8 == len then
| |
| if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits)
| |
| err_cat = ' ' .. set_error( 'bad_lccn' ); -- set an error message
| |
| end
| |
| elseif 9 == len then -- LCCN should be adddddddd
| |
| if nil == id:match("%l%d%d%d%d%d%d%d%d") then -- does it match our pattern?
| |
| err_cat = ' ' .. set_error( 'bad_lccn' ); -- set an error message
| |
| end
| |
| elseif 10 == len then -- LCCN should be aadddddddd or dddddddddd
| |
| if id:match("[^%d]") then -- if LCCN has anything but digits (nil if only digits) ...
| |
| if nil == id:match("^%l%l%d%d%d%d%d%d%d%d") then -- ... see if it matches our pattern
| |
| err_cat = ' ' .. set_error( 'bad_lccn' ); -- no match, set an error message
| |
| end
| |
| end
| |
| elseif 11 == len then -- LCCN should be aaadddddddd or adddddddddd
| |
| if not (id:match("^%l%l%l%d%d%d%d%d%d%d%d") or id:match("^%l%d%d%d%d%d%d%d%d%d%d")) then -- see if it matches one of our patterns
| |
| err_cat = ' ' .. set_error( 'bad_lccn' ); -- no match, set an error message
| |
| end
| |
| elseif 12 == len then -- LCCN should be aadddddddddd
| |
| if not id:match("^%l%l%d%d%d%d%d%d%d%d%d%d") then -- see if it matches our pattern
| |
| err_cat = ' ' .. set_error( 'bad_lccn' ); -- no match, set an error message
| |
| end
| |
| else
| |
| err_cat = ' ' .. set_error( 'bad_lccn' ); -- wrong length, set an error message
| |
| end
| |
| | |
| if not is_set (err_cat) and nil ~= lccn:find ('%s') then
| |
| err_cat = ' ' .. set_error( 'bad_lccn' ); -- lccn contains a space, set an error message
| |
| end
| |
| | |
| return external_link_id({link = handler.link, label = handler.label,
| |
| prefix=handler.prefix,id=lccn,separator=handler.separator, encode=handler.encode}) .. err_cat;
| |
| end
| |
| | |
| | |
| --[[--------------------------< P M I D >----------------------------------------------------------------------
| |
| | |
| Format PMID and do simple error checking. PMIDs are sequential numbers beginning at 1 and counting up. This
| |
| code checks the PMID to see that it contains only digits and is less than test_limit; the value in local variable
| |
| test_limit will need to be updated periodically as more PMIDs are issued.
| |
| | |
| ]]
| |
| | |
| local function pmid(id)
| |
| local test_limit = 30000000; -- update this value as PMIDs approach
| |
| local handler = cfg.id_handlers['PMID'];
| |
| local err_cat = ''; -- presume that PMID is valid
| |
|
| |
| if id:match("[^%d]") then -- if PMID has anything but digits
| |
| err_cat = ' ' .. set_error( 'bad_pmid' ); -- set an error message
| |
| else -- PMID is only digits
| |
| local id_num = tonumber(id); -- convert id to a number for range testing
| |
| if 1 > id_num or test_limit < id_num then -- if PMID is outside test limit boundaries
| |
| err_cat = ' ' .. set_error( 'bad_pmid' ); -- set an error message
| |
| end
| |
| end
| |
|
| |
| return external_link_id({link = handler.link, label = handler.label,
| |
| prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
| |
| end
| |
| | |
| | |
| --[[--------------------------< I S _ E M B A R G O E D >------------------------------------------------------
| |
| | |
| Determines if a PMC identifier's online version is embargoed. Compares the date in |embargo= against today's date. If embargo date is
| |
| in the future, returns the content of |embargo=; otherwise, returns and empty string because the embargo has expired or because
| |
| |embargo= was not set in this cite.
| |
| | |
| ]]
| |
| | |
| local function is_embargoed (embargo)
| |
| if is_set (embargo) then
| |
| local lang = mw.getContentLanguage();
| |
| local good1, embargo_date, good2, todays_date;
| |
| good1, embargo_date = pcall( lang.formatDate, lang, 'U', embargo );
| |
| good2, todays_date = pcall( lang.formatDate, lang, 'U' );
| |
|
| |
| if good1 and good2 then -- if embargo date and today's date are good dates
| |
| if tonumber( embargo_date ) >= tonumber( todays_date ) then -- is embargo date is in the future?
| |
| return embargo; -- still embargoed
| |
| else
| |
| add_maint_cat ('embargo')
| |
| return ''; -- unset because embargo has expired
| |
| end
| |
| end
| |
| end
| |
| return ''; -- |embargo= not set return empty string
| |
| end
| |
| | |
| | |
| --[[--------------------------< P M C >------------------------------------------------------------------------
| |
| | |
| Format a PMC, do simple error checking, and check for embargoed articles.
| |
| | |
| The embargo parameter takes a date for a value. If the embargo date is in the future the PMC identifier will not
| |
| be linked to the article. If the embargo date is today or in the past, or if it is empty or omitted, then the
| |
| PMC identifier is linked to the article through the link at cfg.id_handlers['PMC'].prefix.
| |
| | |
| PMC embargo date testing is done in function is_embargoed () which is called earlier because when the citation
| |
| has |pmc=<value> but does not have a |url= then |title= is linked with the PMC link. Function is_embargoed ()
| |
| returns the embargo date if the PMC article is still embargoed, otherwise it returns an empty string.
| |
| | |
| PMCs are sequential numbers beginning at 1 and counting up. This code checks the PMC to see that it contains only digits and is less
| |
| than test_limit; the value in local variable test_limit will need to be updated periodically as more PMCs are issued.
| |
| | |
| ]]
| |
| | |
| local function pmc(id, embargo)
| |
| local test_limit = 5000000; -- update this value as PMCs approach
| |
| local handler = cfg.id_handlers['PMC'];
| |
| local err_cat = ''; -- presume that PMC is valid
| |
|
| |
| local text;
| |
| | |
| if id:match("[^%d]") then -- if PMC has anything but digits
| |
| err_cat = ' ' .. set_error( 'bad_pmc' ); -- set an error message
| |
| else -- PMC is only digits
| |
| local id_num = tonumber(id); -- convert id to a number for range testing
| |
| if 1 > id_num or test_limit < id_num then -- if PMC is outside test limit boundaries
| |
| err_cat = ' ' .. set_error( 'bad_pmc' ); -- set an error message
| |
| end
| |
| end
| |
|
| |
| if is_set (embargo) then -- is PMC is still embargoed?
| |
| text="[[" .. handler.link .. "|" .. handler.label .. "]]:" .. handler.separator .. id .. err_cat; -- still embargoed so no external link
| |
| else
| |
| text = external_link_id({link = handler.link, label = handler.label, -- no embargo date or embargo has expired, ok to link to article
| |
| prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode}) .. err_cat;
| |
| end
| |
| return text;
| |
| end
| |
| | |
| | |
| --[[--------------------------< D O I >------------------------------------------------------------------------
| |
| | |
| Formats a DOI and checks for DOI errors.
| |
| | |
| DOI names contain two parts: prefix and suffix separated by a forward slash.
| |
| Prefix: directory indicator '10.' followed by a registrant code
| |
| Suffix: character string of any length chosen by the registrant
| |
| | |
| This function checks a DOI name for: prefix/suffix. If the doi name contains spaces or endashes, or, if it ends
| |
| with a period or a comma, this function will emit a bad_doi error message.
| |
| | |
| DOI names are case-insensitive and can incorporate any printable Unicode characters so the test for spaces, endash,
| |
| and terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
| |
| if ever used in doi names.
| |
| | |
| ]]
| |
| | |
| local function doi(id, inactive)
| |
| local cat = ""
| |
| local handler = cfg.id_handlers['DOI'];
| |
|
| |
| local text;
| |
| if is_set(inactive) then
| |
| local inactive_year = inactive:match("%d%d%d%d") or ''; -- try to get the year portion from the inactive date
| |
| text = "[[" .. handler.link .. "|" .. handler.label .. "]]:" .. id;
| |
| if is_set(inactive_year) then
| |
| table.insert( z.error_categories, "Pages with DOIs inactive since " .. inactive_year );
| |
| else
| |
| table.insert( z.error_categories, "Pages with inactive DOIs" ); -- when inactive doesn't contain a recognizable year
| |
| end
| |
| inactive = " (" .. cfg.messages['inactive'] .. " " .. inactive .. ")"
| |
| else
| |
| text = external_link_id({link = handler.link, label = handler.label,
| |
| prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
| |
| inactive = ""
| |
| end
| |
| | |
| if nil == id:match("^10%.[^%s–]-/[^%s–]-[^%.,]$") then -- doi must begin with '10.', must contain a fwd slash, must not contain spaces or endashes, and must not end with period or comma
| |
| cat = ' ' .. set_error( 'bad_doi' );
| |
| end
| |
| return text .. inactive .. cat
| |
| end
| |
| | |
| | |
| --[[--------------------------< H D L >------------------------------------------------------------------------
| |
| | |
| Formats an HDL with minor error checking.
| |
| | |
| HDL names contain two parts: prefix and suffix separated by a forward slash.
| |
| Prefix: character string using any character in the UCS-2 character set except '/'
| |
| Suffix: character string of any length using any character in the UCS-2 character set chosen by the registrant
| |
| | |
| This function checks a HDL name for: prefix/suffix. If the HDL name contains spaces, endashes, or, if it ends
| |
| with a period or a comma, this function will emit a bad_hdl error message.
| |
| | |
| HDL names are case-insensitive and can incorporate any printable Unicode characters so the test for endashes and
| |
| terminal punctuation may not be technically correct but it appears, that in practice these characters are rarely
| |
| if ever used in HDLs.
| |
| | |
| ]]
| |
| | |
| local function hdl(id)
| |
| local handler = cfg.id_handlers['HDL'];
| |
|
| |
| local text = external_link_id({link = handler.link, label = handler.label,
| |
| prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
| |
| | |
| if nil == id:match("^[^%s–]-/[^%s–]-[^%.,]$") then -- hdl must contain a fwd slash, must not contain spaces, endashes, and must not end with period or comma
| |
| text = text .. ' ' .. set_error( 'bad_hdl' );
| |
| end
| |
| return text;
| |
| end
| |
| | |
| | |
| --[[--------------------------< O P E N L I B R A R Y >--------------------------------------------------------
| |
| | |
| Formats an OpenLibrary link, and checks for associated errors.
| |
| | |
| ]] | |
| | |
| local function openlibrary(id)
| |
| local code = id:match("^%d+([AMW])$"); -- only digits followed by 'A', 'M', or 'W'
| |
| local handler = cfg.id_handlers['OL'];
| |
| | |
| if ( code == "A" ) then
| |
| return external_link_id({link=handler.link, label=handler.label,
| |
| prefix=handler.prefix .. 'authors/OL',
| |
| id=id, separator=handler.separator, encode = handler.encode})
| |
| elseif ( code == "M" ) then
| |
| return external_link_id({link=handler.link, label=handler.label,
| |
| prefix=handler.prefix .. 'books/OL',
| |
| id=id, separator=handler.separator, encode = handler.encode})
| |
| elseif ( code == "W" ) then
| |
| return external_link_id({link=handler.link, label=handler.label,
| |
| prefix=handler.prefix .. 'works/OL',
| |
| id=id, separator=handler.separator, encode = handler.encode})
| |
| else
| |
| return external_link_id({link=handler.link, label=handler.label,
| |
| prefix=handler.prefix .. 'OL',
| |
| id=id, separator=handler.separator, encode = handler.encode}) .. ' ' .. set_error( 'bad_ol' );
| |
| end
| |
| end
| |
| | |
| | |
| --[[--------------------------< M E S S A G E _ I D >----------------------------------------------------------
| |
| | |
| Validate and format a usenet message id. Simple error checking, looks for 'id-left@id-right' not enclosed in
| |
| '<' and/or '>' angle brackets.
| |
| | |
| ]]
| |
| | |
| local function message_id (id)
| |
| local handler = cfg.id_handlers['USENETID'];
| |
| | |
| local text = external_link_id({link = handler.link, label = handler.label,
| |
| prefix=handler.prefix,id=id,separator=handler.separator, encode=handler.encode})
| |
|
| |
| if not id:match('^.+@.+$') or not id:match('^[^<].*[^>]$')then -- doesn't have '@' or has one or first or last character is '< or '>'
| |
| text = text .. ' ' .. set_error( 'bad_message_id' ) -- add an error message if the message id is invalid
| |
| end
| |
|
| |
| return text
| |
| end
| |
| | |
| | |
| --[[--------------------------< B U I L D _ I D _ L I S T >--------------------------------------------------------
| |
| | |
| Takes a table of IDs created by extract_ids() and turns it into a table of formatted ID outputs.
| |
| | |
| inputs:
| |
| id_list – table of identifiers built by extract_ids()
| |
| options – table of various template parameter values used to modify some manually handled identifiers
| |
| | |
| ]]
| |
| | |
| local function build_id_list( id_list, options )
| |
| local new_list, handler = {};
| |
| | |
| local function fallback(k) return { __index = function(t,i) return cfg.id_handlers[k][i] end } end;
| |
|
| |
| for k, v in pairs( id_list ) do -- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
| |
| -- fallback to read-only cfg
| |
| handler = setmetatable( { ['id'] = v }, fallback(k) );
| |
|
| |
| if handler.mode == 'external' then
| |
| table.insert( new_list, {handler.label, external_link_id( handler ) } );
| |
| elseif handler.mode == 'internal' then
| |
| table.insert( new_list, {handler.label, internal_link_id( handler ) } );
| |
| elseif handler.mode ~= 'manual' then
| |
| error( cfg.messages['unknown_ID_mode'] );
| |
| elseif k == 'DOI' then
| |
| table.insert( new_list, {handler.label, doi( v, options.DoiBroken ) } );
| |
| elseif k == 'HDL' then
| |
| table.insert( new_list, {handler.label, hdl( v ) } );
| |
| elseif k == 'ARXIV' then
| |
| table.insert( new_list, {handler.label, arxiv( v, options.Class ) } );
| |
| elseif k == 'ASIN' then
| |
| table.insert( new_list, {handler.label, amazon( v, options.ASINTLD ) } );
| |
| elseif k == 'LCCN' then
| |
| table.insert( new_list, {handler.label, lccn( v ) } );
| |
| elseif k == 'OL' or k == 'OLA' then
| |
| table.insert( new_list, {handler.label, openlibrary( v ) } );
| |
| elseif k == 'PMC' then
| |
| table.insert( new_list, {handler.label, pmc( v, options.Embargo ) } );
| |
| elseif k == 'PMID' then
| |
| table.insert( new_list, {handler.label, pmid( v ) } );
| |
| elseif k == 'ISMN' then
| |
| table.insert( new_list, {handler.label, ismn( v ) } );
| |
| elseif k == 'ISSN' then
| |
| table.insert( new_list, {handler.label, issn( v ) } );
| |
| elseif k == 'EISSN' then
| |
| table.insert( new_list, {handler.label, issn( v, true ) } ); -- true distinguishes eissn from issn
| |
| elseif k == 'ISBN' then
| |
| local ISBN = internal_link_id( handler );
| |
| if not check_isbn( v ) and not is_set(options.IgnoreISBN) then
| |
| ISBN = ISBN .. set_error( 'bad_isbn', {}, false, " ", "" );
| |
| end
| |
| table.insert( new_list, {handler.label, ISBN } );
| |
| elseif k == 'USENETID' then
| |
| table.insert( new_list, {handler.label, message_id( v ) } );
| |
| else
| |
| error( cfg.messages['unknown_manual_ID'] );
| |
| end
| |
| end
| |
|
| |
| local function comp( a, b ) -- used in following table.sort()
| |
| return a[1] < b[1];
| |
| end
| |
|
| |
| table.sort( new_list, comp );
| |
| for k, v in ipairs( new_list ) do
| |
| new_list[k] = v[2];
| |
| end
| |
|
| |
| return new_list;
| |
| end
| |
| | |
| | |
| --[[--------------------------< E X T R A C T _ I D S >------------------------------------------------------------
| |
| | |
| Populates ID table from arguments using configuration settings. Loops through cfg.id_handlers and searches args for
| |
| any of the parameters listed in each cfg.id_handlers['...'].parameters. If found, adds the parameter and value to
| |
| the identifier list. Emits redundant error message is more than one alias exists in args
| |
| | |
| ]]
| |
| | |
| local function extract_ids( args )
| |
| local id_list = {}; -- list of identifiers found in args
| |
| for k, v in pairs( cfg.id_handlers ) do -- k is uc identifier name as index to cfg.id_handlers; e.g. cfg.id_handlers['ISBN'], v is a table
| |
| v = select_one( args, v.parameters, 'redundant_parameters' ); -- v.parameters is a table of aliases for k; here we pick one from args if present
| |
| if is_set(v) then id_list[k] = v; end -- if found in args, add identifier to our list
| |
| end
| |
| return id_list;
| |
| end
| |
| | |
| | |
| --[[--------------------------< S E T _ S E L E C T E D _ M O D U L E S >--------------------------------------
| |
| | |
| Sets local cfg table and imported functions table to same (live or sandbox) as that used by the other modules.
| |
| | |
| ]] | |
| | |
| local function set_selected_modules (cfg_table_ptr, utilities_page_ptr)
| |
| cfg = cfg_table_ptr;
| |
| | |
| is_set = utilities_page_ptr.is_set; -- import functions from select Module:Citation/CS1/Utilities module
| |
| in_array = utilities_page_ptr.in_array;
| |
| set_error = utilities_page_ptr.set_error;
| |
| select_one = utilities_page_ptr.select_one;
| |
| add_maint_cat = utilities_page_ptr.add_maint_cat;
| |
| | |
| z = utilities_page_ptr.z; -- table of tables in Module:Citation/CS1/Utilities
| |
| end
| |
| | |
| | |
| | |
| return {
| |
| build_id_list = build_id_list,
| |
| extract_ids = extract_ids,
| |
| is_embargoed = is_embargoed;
| |
| set_selected_modules = set_selected_modules;
| |
| }
| |