Module:CiteLacan

From No Subject
Jump to navigation Jump to search

Documentation for this module may be created at Module:CiteLacan/doc

local p = {}

-- =============================================================================
-- DATA: CANONICAL WORKS (Metadata stored in one place)
-- =============================================================================
local WORKS = {
    -- Major Collections
    ecrits = { link = 'Écrits', title = 'Écrits', date = '1966' },
    ecrits_selection = { link = 'Écrits: A Selection', title = 'Écrits: A Selection', date = '1977' },
    ecrits_complete = { link = 'Écrits: The First Complete Edition in English', title = 'Écrits: The First Complete Edition in English', date = '2006' },
    autres_ecrits = { link = 'Autres écrits', title = 'Autres écrits', date = '2001' },
    
    -- Core Essays / Early Works
    paranoia = { link = 'Jacques Lacan/On Paranoiac Psychosis', title = 'On Paranoiac Psychosis in Its Relations to the Personality', date = '1932' },
    family_complexes = { link = 'Complexes familiaux dans la formation de l’individu', title = 'The Family Complexes', date = '1938' },
    aggressivity = { link = 'Aggressivity in Psychoanalysis', title = 'Aggressivity in Psychoanalysis', date = '1948' },
    mirror_stage = { link = 'Mirror Stage', title = 'The Mirror Stage', date = '1949' },
    rome_discourse = { link = 'Function and Field of Speech and Language in Psychoanalysis', title = 'The Function and Field of Speech and Language in Psychoanalysis', date = '1953' },
    hyppolite = { link = 'Response to Jean Hyppolite', title = 'Response to Jean Hyppolite', date = '1954' },
    freudian_thing = { link = 'The Freudian Thing', title = 'The Freudian Thing', date = '1955' },
    fetishism = { link = 'Fetishism: The Symbolic, the Real and the Imaginary', title = 'Fetishism: The Symbolic, the Real and the Imaginary', date = '1956' },
    agency_letter = { link = 'The Agency of the Letter in the Unconscious', title = 'The Agency of the Letter in the Unconscious', date = '1957' },
    signification_phallus = { link = 'The Signification of the Phallus', title = 'The Signification of the Phallus', date = '1958' },
    direction_treatment = { link = 'The Direction of the Treatment', title = 'The Direction of the Treatment', date = '1958' },
    subversion_subject = { link = 'The Subversion of the Subject and the Dialectic of Desire', title = 'The Subversion of the Subject and the Dialectic of Desire', date = '1960' },
    kant_with_sade = { link = 'Kant with Sade', title = 'Kant with Sade', date = '1963' },
    position_unconscious = { link = 'Position of the Unconscious', title = 'The Position of the Unconscious', date = '1964' },
    science_truth = { link = 'Science and Truth (Lacan)', title = 'Science and Truth', date = '1966' },
    subject_finally = { link = 'Du sujet enfin en question', title = 'On the Subject Finally in Question', date = '1966' },
    reply_philosophy = { link = 'Réponse aux étudiants en philosophie', title = 'Reply to Philosophy Students', date = '1966–1967' },
    lituraterre = { link = 'Lituraterre', title = 'Lituraterre', date = '1971' },
    notes_child = { link = 'Notes on the Child', title = 'Notes on the Child', date = '1969' },
    
    -- Lectures / Broadcasts
    radiophonie = { link = 'Radiophonie', title = 'Radiophonie', date = '1970' },
    television = { link = 'Télévision', title = 'Télévision', date = '1974' },
    louvain = { link = 'Conférence à Louvain', title = 'Conference at Louvain', date = '1972' },
    geneva = { link = 'Geneva Lecture on the Symptom', title = 'Geneva Lecture on the Symptom', date = '1975' },
    ens = { link = 'Discours à l\'École normale supérieure', title = 'Discourse at the École normale supérieure', date = '1960s' },
    sainte_anne = { link = 'Entretiens à Sainte-Anne', title = 'Interviews at Sainte-Anne', date = '1967–1970s' },
    
    -- Institutional / Letters
    foundation = { link = 'Acte de fondation de l\'École freudienne de Paris', title = 'Act of Foundation of the Freudian School of Paris', date = '1964' },
    proposition_1967 = { link = 'Proposition of 9 October 1967', title = 'Proposition of 9 October 1967', date = '1967' },
    dissolution = { link = 'Dissolution de l\'École freudienne de Paris', title = 'Dissolution of the Freudian School of Paris', date = '1980' },
    cia = { link = 'Lettre à la CIA', title = 'Letter to the CIA', date = '1973' },
    italians = { link = 'Lettre aux Italiens', title = 'Letter to the Italians', date = '1974' },
    scilicet = { link = 'Scilicet', title = 'Marginalia in Scilicet', date = '1968–1980' },
    ornicar = { link = 'Ornicar?', title = 'Articles in Ornicar?', date = '1975–1981' },
}

-- =============================================================================
-- DATA: SEMINARS
-- =============================================================================
local SEMINARS = {
    [1] = { link = 'Seminar I', title = 'Seminar I: Freud’s Papers on Technique', date = '1953–1954' },
    [2] = { link = 'Seminar II', title = 'Seminar II: The Ego in Freud’s Theory', date = '1954–1955' },
    [3] = { link = 'Seminar III', title = 'Seminar III: The Psychoses', date = '1955–1956' },
    [4] = { link = 'Seminar IV', title = 'Seminar IV: The Object Relation', date = '1956–1957' },
    [5] = { link = 'Seminar V', title = 'Seminar V: The Formations of the Unconscious', date = '1957–1958' },
    [6] = { link = 'Seminar VI', title = 'Seminar VI: Desire and Its Interpretation', date = '1958–1959' },
    [7] = { link = 'Seminar VII', title = 'Seminar VII: The Ethics of Psychoanalysis', date = '1959–1960' },
    [8] = { link = 'Seminar VIII', title = 'Seminar VIII: Transference', date = '1960–1961' },
    [9] = { link = 'Seminar IX', title = 'Seminar IX: Identification', date = '1961–1962' },
    [10] = { link = 'Seminar X', title = 'Seminar X: Anxiety', date = '1962–1963' },
    [11] = { link = 'Seminar XI', title = 'Seminar XI: The Four Fundamental Concepts of Psychoanalysis', date = '1964' },
    [12] = { link = 'Seminar XII', title = 'Seminar XII: Crucial Problems for Psychoanalysis', date = '1964–1965' },
    [13] = { link = 'Seminar XIII', title = 'Seminar XIII: The Object of Psychoanalysis', date = '1965–1966' },
    [14] = { link = 'Seminar XIV', title = 'Seminar XIV: The Logic of Fantasy', date = '1966–1967' },
    [15] = { link = 'Seminar XV', title = 'Seminar XV: The Psychoanalytic Act', date = '1967–1968' },
    [16] = { link = 'Seminar XVI', title = 'Seminar XVI: From an Other to the other', date = '1968–1969' },
    [17] = { link = 'Seminar XVII', title = 'Seminar XVII: The Other Side of Psychoanalysis', date = '1969–1970' },
    [18] = { link = 'Seminar XVIII', title = 'Seminar XVIII: Of a Discourse That Might Not Be a Semblance', date = '1971' },
    [19] = { link = 'Seminar XIX', title = 'Seminar XIX: …Or Worse', date = '1971–1972' },
    [20] = { link = 'Seminar XX', title = 'Seminar XX: Encore', date = '1972–1973' },
    [21] = { link = 'Seminar XXI', title = 'Seminar XXI: Les non-dupes errent', date = '1973–1974' },
    [22] = { link = 'Seminar XXII', title = 'Seminar XXII: RSI', date = '1974–1975' },
    [23] = { link = 'Seminar XXIII', title = 'Seminar XXIII: The Sinthome', date = '1975–1976' },
    [24] = { link = 'Seminar XXIV', title = 'Seminar XXIV: L’insu que sait de l’une-bévue s’aile à mourre', date = '1976–1977' },
    [25] = { link = 'Seminar XXV', title = 'Seminar XXV: The Moment to Conclude', date = '1977–1978' },
    [26] = { link = 'Seminar XXVI', title = 'Seminar XXVI: Topology and Time', date = '1978–1979' },
    [27] = { link = 'Seminar XXVII', title = 'Seminar XXVII: Dissolution', date = '1979–1980' },
    caracas = { link = 'Caracas Seminar', title = 'Caracas Seminar', date = '1980' },
}

-- Mapping of aliases to the canonical keys above
local ALIASES = {
    -- Major Works
    ['e'] = 'ecrits', ['ecrits'] = 'ecrits',
    ['es'] = 'ecrits_selection', ['selection'] = 'ecrits_selection',
    ['ec'] = 'ecrits_complete', ['complete'] = 'ecrits_complete',
    ['ae'] = 'autres_ecrits', ['autres'] = 'autres_ecrits', ['autres ecrits'] = 'autres_ecrits',
    
    -- Titles (Including "The" variants)
    ['paranoia'] = 'paranoia', ['paranoiac'] = 'paranoia', ['on paranoiac psychosis'] = 'paranoia',
    ['family'] = 'family_complexes', ['family complexes'] = 'family_complexes', ['the family complexes'] = 'family_complexes',
    ['aggressivity'] = 'aggressivity', ['aggressivity in psychoanalysis'] = 'aggressivity',
    ['mirror'] = 'mirror_stage', ['mirror stage'] = 'mirror_stage', ['the mirror stage'] = 'mirror_stage',
    ['rome'] = 'rome_discourse', ['function and field'] = 'rome_discourse', ['discours de rome'] = 'rome_discourse', ['the function and field of speech and language'] = 'rome_discourse',
    ['freudian thing'] = 'freudian_thing', ['the freudian thing'] = 'freudian_thing',
    ['fetishism'] = 'fetishism',
    ['agency'] = 'agency_letter', ['letter'] = 'agency_letter', ['agency of the letter'] = 'agency_letter', ['the agency of the letter'] = 'agency_letter',
    ['phallus'] = 'signification_phallus', ['signification of the phallus'] = 'signification_phallus', ['the signification of the phallus'] = 'signification_phallus',
    ['direction'] = 'direction_treatment', ['treatment'] = 'direction_treatment', ['direction of the treatment'] = 'direction_treatment', ['the direction of the treatment'] = 'direction_treatment',
    ['subversion'] = 'subversion_subject', ['dialectic'] = 'subversion_subject', ['subversion of the subject'] = 'subversion_subject', ['the subversion of the subject'] = 'subversion_subject',
    ['kant'] = 'kant_with_sade', ['kant with sade'] = 'kant_with_sade',
    ['position'] = 'position_unconscious', ['the position of the unconscious'] = 'position_unconscious',
    ['science'] = 'science_truth', ['science and truth'] = 'science_truth', ['the science and truth'] = 'science_truth',
    ['subject finally'] = 'subject_finally', ['subject in question'] = 'subject_finally', ['on the subject finally in question'] = 'subject_finally',
    ['reply philosophy'] = 'reply_philosophy', ['philosophy students'] = 'reply_philosophy', ['reply to philosophy students'] = 'reply_philosophy',
    ['lituraterre'] = 'lituraterre',
    ['child'] = 'notes_child', ['notes on the child'] = 'notes_child', ['the child'] = 'notes_child',
    ['hyppolite'] = 'hyppolite', ['response to hyppolite'] = 'hyppolite',
    
    -- Media / Lectures
    ['radiophonie'] = 'radiophonie',
    ['television'] = 'television', ['télévision'] = 'television',
    ['louvain'] = 'louvain',
    ['geneva'] = 'geneva', ['symptom'] = 'geneva',
    ['ens'] = 'ens',
    ['sainte-anne'] = 'sainte_anne', ['interviews'] = 'sainte_anne',
    
    -- Institutional
    ['foundation'] = 'foundation', ['act of foundation'] = 'foundation',
    ['proposition'] = 'proposition_1967', ['pass'] = 'proposition_1967',
    ['dissolution'] = 'dissolution',
    ['cia'] = 'cia', ['letter to the cia'] = 'cia',
    ['italians'] = 'italians', ['letter to the italians'] = 'italians',
    ['scilicet'] = 'scilicet',
    ['ornicar'] = 'ornicar', ['ornicar?'] = 'ornicar',
    ['caracas'] = 'caracas',
}

-- Roman Numeral conversion
local ROMAN_TO_INT = {
    i=1, ii=2, iii=3, iv=4, v=5, vi=6, vii=7, viii=8, ix=9, x=10,
    xi=11, xii=12, xiii=13, xiv=14, xv=15, xvi=16, xvii=17, xviii=18,
    xix=19, xx=20, xxi=21, xxii=22, xxiii=23, xxiv=24, xxv=25, xxvi=26, xxvii=27
}

-- =============================================================================
-- LOGIC
-- =============================================================================

function p.cite(frame)
    local args = frame:getParent().args
    local raw_input = mw.text.trim(args[1] or ''):lower()
    local page = args[2] or ''
    
    local item = nil
    
    -- 1. Check for Seminar pattern
    local sem_input = raw_input:gsub('^seminar%s+', '')
    local sem_num = tonumber(sem_input) or ROMAN_TO_INT[sem_input]
    
    if sem_num and SEMINARS[sem_num] then
        item = SEMINARS[sem_num]
    elseif raw_input == 'caracas' then
        item = SEMINARS.caracas
    else
        -- 2. Check Aliases
        local canon_key = ALIASES[raw_input]
        if canon_key then
            item = WORKS[canon_key]
        end
    end
    
    -- 3. Fallback / Error
    if not item then
        return string.format(
            '%s <span style="font-size:85%%; color:gray; margin-left:5px;">(Work not recognized)</span>',
            args[1] or 'Unknown'
        )
    end
    
    -- 4. Formatting
    local output = string.format('[[%s|%s]]&nbsp;(%s)', item.link, item.title, item.date)
    
    if page ~= '' then
        output = output .. ', p.&nbsp;' .. page
    end
    
    return '<span class="citation-lacan">' .. output .. '</span>'
end

return p