×
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

    Figlet Extension: Difference between revisions

    Content added Content deleted
    imported>DrOwl
    mNo edit summary
    imported>DrOwl
    No edit summary
    Line 29: Line 29:
    # Figlet Mediawiki extension
    # Figlet Mediawiki extension
    # using shell figlet
    # using shell figlet
    # by DrOwl 21.06.2005 <- a Date in the Future ,ehe ;)
    # by DrOwl 21.06.2005
    #modded from
    #modded from
    # by mutante 25.03.2005
    # by mutante 25.03.2005
    # modded again 21.05.2005 ,mutante

    # the short but working version, 19.06.2006
    #install extension hook
    #install extension hook
    $wgExtensionFunctions[] = "wfFigletExtension";
    $wgExtensionFunctions[] = "wfFigletExtension";



    #extension hook callback function
    #extension hook callback function
    function wfFigletExtension() {
    function wfFigletExtension() {
    global $wgParser;
    global $wgParser;
    #install parser hook for <figlet> tags
    #install parser hook for <figlet> tags
    $wgParser->setHook( "figlet", "renderFiglet" );
    $wgParser->setHook( "figlet", "renderFiglet" );
    }
    }


    function renderFiglet( $input ) {
    function renderFiglet( $input ) {
    global $wgOutputEncoding;
    global $wgOutputEncoding;
    # $input = mysql_escape_string($input);
    $input = mysql_escape_string($input);
    if (!$input) $input = "mu"; #ifno input then mu


    $output="<pre>";
    $input =~ /[Aa-Zz]|[1-0];
    # $input = mysql_escape_string($input);
    $output.=`figlet $input`;
    $output.="</pre>";
    # $figlet = passthru('echo $input | /home/drowl/figlet/figlet -d /home/drowl/figlet/fonts');

    # $figlet = passthru("figlet moo");
    # just "figlet moo" works on the shell, so you can save the echo and pipe.
    # But the problem with passthru is that we always only get the first line of the returned text.
    # I am being told: <+jome> #mutante: php.net/exec AND
    # < jannek> mutante: if you fetch stdout lik ethis $foo = `system command`;
    # then foo will be a string with the output of the command.

    # Tested out a bit, and this should work. mutante. (not yet)...

    $output="&lt;nowiki&gt;&lt;pre&gt;&lt;/nowiki&gt;";
    $output.=system ("figlet $input");
    $output.="&lt;nowiki&gt;&lt;/pre&gt;&lt;/nowiki&gt;";


    return $output;
    return $output;
    }

    }


    ?>
    ?>

    Revision as of 20:38, 19 June 2006

    Integrate figlet text into wiki pages using figletlink in a custom Mediawiki extension:

    this is a first untested version with just monkey knolage of how to make it work

    Syntax

    <figlet>text</figlet>

    Example

    <figlet>moo</figlet>

    example Result

    | '_ ` _ \ / _ \ / _ \ 
    | | | | | | (_) | (_) |
    |_| |_| |_|\___/ \___/ 
    

    test Result

    <figlet>moo</figlet>

    (not installed on anything this is only beta i dont have figlet installed on this server)

    Source

    <?php
    # Figlet Mediawiki extension
    # using shell figlet 
    # by DrOwl 21.06.2005
    #modded from
    # by mutante 25.03.2005
    # modded again 21.05.2005 ,mutante
    # the short but working version, 19.06.2006
    #install extension hook
    $wgExtensionFunctions[] = "wfFigletExtension";
    
    #extension hook callback function
    function wfFigletExtension() { 
    global $wgParser;
       
    #install parser hook for <figlet> tags
    $wgParser->setHook( "figlet", "renderFiglet" );
       }
    
    function renderFiglet( $input ) {
     global $wgOutputEncoding;
            
    $input = mysql_escape_string($input);
    
    $output="<pre>";
    $output.=`figlet $input`;
    $output.="

    ";

    return $output; }

    ?>

    not installed yet, see ongoing talk.

    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.