×
Create a new article
Write your page title here:
We currently have 3,189 articles on s23. Type your article name above or create one of the articles listed here!



    s23
    3,189Articles

    JargonExtension: Difference between revisions

    Content added Content deleted
    imported>mutante
    m (New page: Insert JargonFile definitions on wiki pages. The simplest way to do so is to insert <nowiki><jargon /></nowiki> in a page, that will use the current page title as lookup term. Altern...)
     
    imported>mutante
    mNo edit summary
    Line 1: Line 1:
    === About ===

    Insert [[JargonFile]] definitions on wiki pages.
    Insert [[JargonFile]] definitions on wiki pages.


    Line 8: Line 10:


    The extension uses the [[Debian]] package [[jargon]]. <tt>apt-get install jargon</tt>. (Also see [[vh]]).
    The extension uses the [[Debian]] package [[jargon]]. <tt>apt-get install jargon</tt>. (Also see [[vh]]).

    You can help here by going to a page that already uses it and click the red "Next" or "Prev" links and simply insert <nowiki><jargon /></nowiki> and nothing else into it and clicking save.

    === ToDo ===

    <tasks>
    [ ] Include all JargonFile terms as wiki pages (All)
    </tasks>

    === Source ===

    ==== Install ====

    To install copy into ./extensions/JargonExtension.php and then <tt>include("extensions/JargonExtension.php");</tt> in LocalSettings.php as usual with [[Mediawiki]] extensions.


    <HighlightSyntax>
    <HighlightSyntax>

    Revision as of 15:18, 28 October 2007

    About

    Insert JargonFile definitions on wiki pages.

    The simplest way to do so is to insert <jargon /> in a page, that will use the current page title as lookup term.

    Alternatively you can use <jargon>something</jargon>.

    Pages using it are also automatically included in Category:Jargon.

    The extension uses the Debian package jargon. apt-get install jargon. (Also see vh).

    You can help here by going to a page that already uses it and click the red "Next" or "Prev" links and simply insert <jargon /> and nothing else into it and clicking save.

    ToDo

    <tasks> [ ] Include all JargonFile terms as wiki pages (All) </tasks>

    Source

    Install

    To install copy into ./extensions/JargonExtension.php and then include("extensions/JargonExtension.php"); in LocalSettings.php as usual with Mediawiki extensions.

    <HighlightSyntax> <?php

    1. JargonFile terms on Mediawiki pages
    2. On inserting <jargon>something</jargon> in a wiki page,
    3. execute "jargon something" on the shell and return the formatted output
    4. mutante/s23 - 10/2007

    $wgExtensionCredits['other'][] = array(

           'name' => 'JargonFile extension',
           'author' => 'mutante',
           'version' => '10/2007',
           'url' => 'http://s23.org/wiki/JargonExtension',
           'description' => 'displays the JargonFile entry for a term on a wiki page.'
    

    );

    $wgExtensionFunctions[] = "wfJargonExtension";

    function wfJargonExtension() { global $wgParser; $wgParser->setHook( "jargon", "getJargon" ); }

    function getJargon( $input, $args, &$parser ) { global $wgParser; global $wgTitle;

    1. Get the definition of a term from the JargonFile
    1. if no input term is set get the current page title and use that

    if ($input=="") { $mytitle=$wgTitle->mTextform; $term=$mytitle; } else {

    1. if there is input use that but avoid evil stuff from user

    $term = escapeshellarg($input); }

    1. execute, we dont want the info messages from errout

    $jargon=`jargon 2>/dev/null $term`;

    1. Get next link

    $next=explode("Next: ",$jargon); $next=explode(",",$next[1]); $next=$next[0];

    1. Get previous link

    $prev=explode("Prev: ",$jargon); $prev=explode(",",$prev[1]); $prev=$prev[0];

    1. remove header line

    $jargon=explode("=",$jargon); $jargon=$jargon[2];


    1. build output

    $output="

    "; $output.="
    "; $output.="This is the Jargon File entry for $term - Next: ".$next.", Prev: ".$prev."
    ".$jargon."
    * (text is auto-included via JargonExtension by mutante using jargon with VERSION 4.0.0, 24 JUL 1996 - JargonFile by Eric S. Raymond is in the public domain)

    \n";


    1. trim,parse and return it

    $output=trim($output); $parsed_output = $parser->recursiveTagParse( $output ); return $parsed_output;

    }

    ?> </HighlightSyntax>

    Cookies help us deliver our services. By using our services, you agree to our use of cookies.
    Cookies help us deliver our services. By using our services, you agree to our use of cookies.