Template:MIA citation: Difference between revisions

From Leftypedia
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
(26 intermediate revisions by the same user not shown)
Line 42: Line 42:
Sample
Sample
[[category:original templates]]</noinclude><!--
[[category:original templates]]</noinclude><!--
===============================================================================================================================================================


TEMPLATE BEGINS HERE
TEMPLATE BEGINS HERE
Line 50: Line 52:
#0.1: The following returns codes that are then used by the switch function.
#0.1: The following returns codes that are then used by the switch function.
-->{{switch by pattern|_input={{string split|{{{link|{{{1|}}}}}}|/archive/|2}}
-->{{switch by pattern|_input={{string split|{{{link|{{{1|}}}}}}|/archive/|2}}
   | capital = marx/works/18%d%d%-c%d
   | capital = marx/works/18%d%d%-c%d
  | sus      = marx/works/1880/soc%-utop
  | manifesto = marx/works/1848/communist%-manifesto
   | _default = NO SPECIAL CASE
   | _default = NO SPECIAL CASE
   }}<!--
   }}<!--
This converts the code from the above into a sub-template or direct formatting to output for each given special case.
 
#0.2: Convert the code from the above into a sub-template or directly formatted output text for each given special case.
-->
-->
  | capital =
  | capital =
Line 62: Line 67:
   | link = {{{link|{{{1|}}}}}}
   | link = {{{link|{{{1|}}}}}}
   }}
   }}
| sus = [[Friedrich Engels|Engels, Friedrich]] (1880). ''[[Socialism: Utopian and Scientific]]''. {{#if:{{switch by pattern|_input={{{link|{{{1|}}}}}}|_returncaptures=y|marx/works/1880/soc%-utop/ch0(%d)}}|Chapter {{switch by pattern|_input={{{link|{{{1|}}}}}}|_returncaptures=y|marx/works/1880/soc%-utop/ch0(%d)}}: "{{tarray|get|The Development of Utopian Socialism//Dialectics//Historical Materialism|//|{{switch by pattern|_input={{{link|{{{1|}}}}}}|_returncaptures=y|marx/works/1880/soc%-utop/ch0(%d)}}}}."|}} [{{{link|{{{1|}}}}}} Available online]
| manifesto = [[Karl Marx|Marx, Karl]] (1848). ''[[The Communist Manifesto|Manifesto of the Communist Party]]''. {{#if:{{switch by pattern|_input={{{link|{{{1|}}}}}}|_returncaptures=y|marx/works/1848/communist%-manifesto/ch0(%d)}}|Chapter {{switch by pattern|_input={{{link|{{{1|}}}}}}|_returncaptures=y|marx/works/1848/communist%-manifesto/ch0(%d)}}: "{{tarray|get|Bourgeois and Proletarians//Proletarians and Communists//Socialist and Communist Literature//Position of the Communists in Relation to the Various Existing Opposition Parties|//|{{switch by pattern|_input={{{link|{{{1|}}}}}}|_returncaptures=y|marx/works/1848/communist%-manifesto/ch0(%d)}}}}."|}} [{{{link|{{{1|}}}}}} Available online]
  |
  |
  }}|<!--
  }}|<!--
Line 67: Line 74:
End of special case section.
End of special case section.


#1: Author name
#1: Author name. The "replace" functions are only here to normalize the input string by removing any periods or commas.
-->{{#switch: {{replace|{{replace|{{lc:{{{author|{{{2|{{first word|{{string split|{{{link|{{{1|}}}}}}|/archive/|2}}|sep=/}}<!--shitty hack because i'm not a conputer geinius-->}}} }}} }}|,|}}|.|}}
-->{{#switch: {{replace|{{replace|{{lc:{{{author|{{{2|{{first word|{{string split|{{{link|{{{1|}}}}}}|/archive/|2}}|sep=/}}<!--shitty hack because i'm not a conputer geinius-->}}} }}} }}|,|}}|.|}}
| stalin
| j v stalin
| stalin joseph
| stalin j v
| stalin josef = [[Joseph Stalin|Stalin, J.V.]]
  | marx
  | marx
  | karl marx
  | karl marx
  | marx karl = [[Karl Marx|Marx, Karl]]
  | marx karl = <!--
Checks the date for any year after Marx's death - all Engels works are under /marx/!! (hopefully this solution works somewhat)
-->{{#ifexpr: 1883 < {{{year|{{{3|{{switch by pattern|_input={{{link|{{{1|}}}}}}|_returncaptures=y|/(%d%d%d%d)/|_default=0}}}}}}}}|[[Friedrich Engels|Engels, Friedrich]]|[[Karl Marx|Marx, Karl]]}}
| friedrich engels
| engels friedrich
| engels
| frederick engels
| engels frederick = [[Friedrich Engels|Engels, Friedrich]]
  | lenin
  | lenin
  | v i lenin
  | v i lenin
  | vladimir lenin
  | vladimir lenin
  | lenin vladimir = [[Vladimir Lenin|Lenin, V. I.]]
  | lenin vladimir = [[Vladimir Lenin|Lenin, V. I.]]
| stalin
| j stalin
| stalin j
| joseph stalin
| stalin joseph
| j v stalin
| stalin j v
| josef stalin
| stalin josef
| j v dzhugashvili<!--Think you're cute, huh?--> = [[Joseph Stalin|Stalin, J.V.]]
  | adam smith
  | adam smith
  | smith-adam
  | smith-adam
Line 105: Line 124:


#3: Title with wikilink.
#3: Title with wikilink.
-->{{#if:{{{title|{{{4|}}}}}}|<includeonly>''[[{{title case|{{{title|{{{4|}}}}}}}}]]''. </includeonly>|<includeonly>[[category:pages incorrectly using the MIA citation template]]</includeonly>}}<!--
-->{{#if:{{{title|{{{4|}}}}}}|<includeonly>''[[{{#ifeq:{{{titlecase|}}}|false|{{{title|{{{4|}}}}}}|{{title case|{{{title|{{{4|}}}}}}}}}}]]''. </includeonly>|<includeonly>[[category:pages incorrectly using the MIA citation template]]</includeonly>}}<!--


#4: Hyperlink.
#4: Hyperlink.
Line 112: Line 131:
#5: Quotation cited (optional)
#5: Quotation cited (optional)
-->{{#if:{{{quote|{{{quotation|{{{5|}}}}}}}}}
-->{{#if:{{{quote|{{{quotation|{{{5|}}}}}}}}}
   | . "{{#ucfirst:{{switch by pattern
   | . "{{ucfirstletter|{{#iferror:{{switch by pattern
         | _input = {{trim quotes|{{{quote|{{{quotation|{{{5|}}}}}}}}}}}
         | _input = {{trim quotes|{{{quote|{{{quotation|{{{5|}}}}}}}}}}}
         | {{trim quotes|{{{quote|{{{quotation|{{{5|}}}}}}}}}}} = ^.+[?!:.]$<!-- i.e., ending with valid punctuation.-->
         | {{trim quotes|{{{quote|{{{quotation|{{{5|}}}}}}}}}}} = ^.+[?!:.]$<!-- i.e., ending with valid punctuation.-->
         | {{str sub new|{{trim quotes|{{{quote|{{{quotation|{{{5|}}}}}}}}}}}|1|-2}}... = ^.+[,;]$<!-- i.e., replace invalid punctuation with ellipsis.-->
         | {{str sub new|{{trim quotes|{{{quote|{{{quotation|{{{5|}}}}}}}}}}}|1|-2}}... = ^.+[,;]$<!-- i.e., replace invalid punctuation with ellipsis.-->
         | {{trim quotes|{{{quote|{{{quotation|{{{5|}}}}}}}}}}}. = %w$<!-- i.e., add final period if no end-punctuation found at all.-->
         | {{trim quotes|{{{quote|{{{quotation|{{{5|}}}}}}}}}}}. = %w$<!-- i.e., add final period if no end-punctuation found at all.-->
         }}}}"
         | _default = {{{quote|{{{quotation|{{{5|}}}}}}}}}<!-- If some freaky shit is happening, just drop the quote and get out of there. Get out!-->
        }}|{{{quote|{{{quotation|{{{5|}}}}}}}}}}}}}"
   |
   |
   }}<!--
   }}<!--

Revision as of 02:27, 7 June 2024

In this templatespace:

Template talk:

WIP template implemented by Harrystein to make citing Marxists.org a lot easier!

Usage

This is designed to read whatever Marxists.org URL you give it and output a nicely-formatted title, author, and year, complete with links to Leftypedia articles on those topics (aka "Wikilinks"). It doesn't use any LUA or outside coding/bots, which at the moment would be harder by an order of magnitude. If such things are implemented later, they should be used in concert with this template or, if they are pretty foolproof, supersede it.

Visual editor

In visual editing, you should be able to copy-paste the code shown below (adapted or otherwise) into your page. I would have to test this to see issues with it. If not, then [explain here how to make the link the only argument, even if not named, i.e. {{{1}}} ] -6/5/24

Source editor

This template is designed to do most of the work for you. I suggest starting by putting the link in, like so:

{{MIA citation|<link>}}

Any missing or incorrect details should be corrected:

{{MIA citation|<link>|author=<author>|year=<year>|title=<title>}}

See below for some examples.

Capital works the best and hopefully should be fully implemented with no gaps:

{{MIA citation | https://www.marxists.org/archive/marx/works/1867-c1/ch03.htm#S1}}
{{MIA citation | https://www.marxists.org/archive/marx/works/1885-c2/ch20_02.htm}}
{{MIA citation | https://www.marxists.org/archive/marx/works/1894-c3/ch13.htm}}

More Marx works will be added upon request or popular usage.

The template also works reasonably well with other works:

{{MIA citation | https://www.marxists.org/archive/draper/1990/zionism/13-antisemitism.htm}}
{{MIA citation | https://www.marxists.org/reference/archive/stalin/works/1938/09.htm | title = dialectical and Historical Materialism}}
{{MIA citation | https://www.marxists.org/archive/lenin/works/1917/staterev/ch01.htm | title = state and revolution}}
{{MIA citation | https://www.marxists.org/reference/archive/smith-adam/works/wealth-of-nations/book01/ch01.htm | title = the wealth of nations | year = 1776}}

Sample[1]

  1. [Author missing] (). [ Available online] at the Marxists Internet Archive