Difference between pages "ConsoleOutput MediaWiki Extension" and "Test"

From Funtoo
(Difference between pages)
Jump to navigation Jump to search
 
 
Line 1: Line 1:
The ConsoleOutput MediaWiki extension was created by Daniel Robbins to provide highlighting of user input for interactive terminal session blocks. To use it, surround user input with  <tt>&lt;console&gt;</tt> opening and closing tags. This tag works similarly to a <tt>&lt;pre&gt;</tt> tag, and preserves output formatting in the quoted text.
{{#get_web_data:url=http://build.funtoo.org/index.xml|format=xml|use xpath|data=builds=/subarches/subarch[@name='amd64-bulldozer']/@builds}}
;Builds: {{#external_value:builds}}


To highlight text typed by a user, rather than program output, put a <tt>##i##</tt> input code immediately before user input on each line. This will cause all text from the <tt>##i##</tt> to the end of the line to be highlighted in orange to offset it from the prompt and other other program output.
asdflk asdlfk asdlf alsdf lasd flasd flasd flasd flasd flasd flasd flas dflasd flasdl flasdf lasdfl alsdf lasdf lasdflafsd la sdf
<div style="align: center;"><div style="border: 1px solid #888;">
[[{{#show: Organization:Brownrice Internet| ?Logo|link=none}}|350px|class=img-responsive|link=Organization:Brownrice Internet]]</div><br/>
[[Organization:Brownrice Internet|Learn about Funtoo-friendly organization: Brownrice Internet]]</div>
asdflk asdlfk asdlf alsdf lasd flasd flasd flasd flasd flasd flasd flas dflasd flasdl flasdf lasdfl alsdf lasdf lasdflafsd la sdf
{{fullurl:News:The Many Builds of Funtoo Linux}}
{{#widget:AddThis}}


* {{c|##i##}} - Tag all following text on this line as user input.
I like the {{f|/etc/make.conf}} file, which can also be referred to as {{f|/etc/portage/make.conf}}. It is a groovy file. Another cool file is {{f|/etc/fstab}}.
* {{c|##b##}} - Highlight the rest of the line in bold.
* {{c|##b##text here##!b##}} - Highlight the text between both markers in bold.
* {{c|##i##text here##!i##}} - Highlight the text between both markers as user input.
* {{c|##g##}} - Green
* {{c|##y##}} - Yellow
* {{c|##bl##}} - Blue
* {{c|##r##}} - Red


=== Examples ===
=== make.conf mentions ===
Here are a few examples of the ConsoleOutput extension. First this is how you might typically display {{c|ls}} output, with a particular directory highlighted:


<console>
{{#ask: [[Mentions file::make.conf]]
www@www-smw ~/public_html $ ##i##ls
| format=category
COPYING  LocalSettings.php    api.php  ##b##extensions##!b##  index.php  maintenance          redirect.php    skins              thumb_handler.php5
}}
CREDITS  README                api.php5  images        index.php5  mw-config            redirect.php5  tests              wiki.phtml
FAQ      RELEASE-NOTES-1.19    bin      img_auth.php  languages  opensearch_desc.php  redirect.phtml  thumb.php
HISTORY  StartProfiler.sample  cache    img_auth.php5  load.php    opensearch_desc.php5  resources      thumb.php5
INSTALL  UPGRADE              docs      includes      load.php5  profileinfo.php      serialized      thumb_handler.php
www@www-smw ~/public_html $ ##i##cd extensions/
</console>
 
And here is how you might display a more detailed example of console output, using colors:


{{console|body=
{{console|body=
# ##i##bluetoothctl  
# ##i##bluetoothctl  
[##g##NEW##!g##] Controller 00:02:72:C9:62:65 antec [default]
[##g##NEW##!g##] Controller 00:02:72:C9:62:65 antec [default]
##bl##[bluetooth]##!bl### ##i##power on
##bl##[bluetooth]##!bl###power on
Changing power on succeeded
Changing power on succeeded
##bl##[bluetooth]##!bl### ##i##agent on
##bl##[bluetooth]##!bl### ##i##agent on
Line 59: Line 50:
#
#
}}
}}
To install, make the following modifications to your skin:
<syntaxhighlight lang="css">
--- mediawiki-1.19.1/skins/vector/screen.css    2012-06-13 18:22:39.000000000 +0000
+++ public_html/skins/vector/screen.css 2012-08-27 04:34:47.507912892 +0000
@@ -683,10 +683,47 @@
        list-style-image: url(images/bullet-icon.png);
}
-pre {
-      line-height: 1.3em;
+/* ConsoleOutput.php start */
+
+.shell, pre, code, tt, div.mw-geshi {
+        font-size: 12px;
+        font-family: Consolas, 'andale mono','lucida console', monospace;
+}
+
+.shell, pre, div.mw-geshi {
+        background-color: #F8F8FF;
+        line-height: 15px;
+        padding: 10px;
+        border: none;
+        border-top: 2px solid #C6C9E0;
+        border-bottom: 2px solid #C6C9E0;
+        margin: 0;
+        overflow-x: auto;
+        overflow-y: hidden;
+}
+
+.code {
+        color: #666;
+}
+
+.code_input {
+        color: #000;
}
+.code_red {
+        color: #f00;
+}
+
+.code_blue {
+        color: #00f;
+}
+
+.shell_green {
+        color: #080;
+}
+
+/* ConsoleOutput.php end */
+
/* Site Notice (includes notices from CentralNotice extension) */
#siteNotice {
        font-size: 0.8em;
</syntaxhighlight>
Then install the following code in your <tt>extensions</tt> directory and include it with a <tt>require_once( "$IP/extensions/ConsoleOutput.php" );</tt> in <tt>LocalSettings.php</tt>:
<syntaxhighlight lang="php">
<?php
$wgExtensionCredits['validextensionclass'][] = array(
    'name' => 'ConsoleOutput',
    'author' => 'Daniel Robbins',
    'url' => 'https://github.com/danielrobbins/mediawiki-consoleoutput',
    'description' => 'This extension allows you to display colorized console output in mediawiki'
);
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
        $wgHooks['ParserFirstCallInit'][] = 'consoleOutputSetup';
} else {
        $wgExtensionFunctions[] = 'consoleOutputSetup';
}
function consoleOutputSetup( $data )
{
    global $wgParser;
    $wgParser->setHook('console', 'consoleRender');
    return true;
}
function consoleRender($input, $args, $parser)
{
    if (count($args))
    {
        return "<strong class='error'>" .
              "ConsoleOutput: arguments not supported" .
              "</strong>";
    }
    # Display < and > as literals, so escape them:
    $input = preg_replace('/>/','&gt;', $input);
    $input = preg_replace('/</','&lt;', $input);
    # http://www.perlmonks.org/?node_id=518444
    # See "Matching a pattern that doesn't include another pattern:
    $input = preg_replace('/##i##((?:(?!##!i##).)*)##!i##/','<span class="code_input">$1</span>', $input);
    $input = preg_replace('/##i##(.*)/','<span class="code_input">$1</span>', $input);
    $input = preg_replace('/##b##((?:(?!##!b##).)*)##!b##/','<b>$1</b>', $input);
    $input = preg_replace('/##b##(.*)/','<b>$1</b>', $input);
    return "<pre class=\"code\">" . $input . "&lt;/pre>";
}
?>
</syntaxhighlight>
[[Category:MediaWiki Hacks]]

Revision as of 15:22, January 12, 2015

Exception parsing XML: String could not be parsed as XML.

Builds

asdflk asdlfk asdlf alsdf lasd flasd flasd flasd flasd flasd flasd flas dflasd flasdl flasdf lasdfl alsdf lasdf lasdflafsd la sdf

[[{{#show: Organization:Brownrice Internet| ?Logo|link=none}}|350px|class=img-responsive|link=Organization:Brownrice Internet]]

Learn about Funtoo-friendly organization: Brownrice Internet

asdflk asdlfk asdlf alsdf lasd flasd flasd flasd flasd flasd flasd flas dflasd flasdl flasdf lasdfl alsdf lasdf lasdflafsd la sdf https://www.funtoo.org/News:The_Many_Builds_of_Funtoo_Linux

I like the /etc/make.conf file, which can also be referred to as /etc/portage/make.conf. It is a groovy file. Another cool file is /etc/fstab.

make.conf mentions

{{#ask: Mentions file::make.conf | format=category }}

root # bluetoothctl 
[NEW] Controller 00:02:72:C9:62:65 antec [default]
root ##bl##[bluetooth]##!bl###power on
Changing power on succeeded
root ##bl##[bluetooth]##!bl### agent on
Agent registered
root ##bl##[bluetooth]##!bl### scan on
Discovery started
root ##bl##[bluetooth]##!bl### devices
Device 00:1F:20:3D:1E:75 Logitech K760
root ##bl##[bluetooth]##!bl### pair 00:1F:20:3D:1E:75
Attempting to pair with 00:1F:20:3D:1E:75
[CHG] Device 00:1F:20:3D:1E:75 Connected: yes
root ##r##[agent]##!r## Passkey: 454358
root ##r##[agent]##!r## Passkey: 454358
root ##r##[agent]##!r## Passkey: 454358
root ##r##[agent]##!r## Passkey: 454358
root ##r##[agent]##!r## Passkey: 454358
root ##r##[agent]##!r## Passkey: 454358
root ##r##[agent]##!r## Passkey: 454358
[CHG] Device 00:1F:20:3D:1E:75 Paired: yes
Pairing successful
[CHG] Device 00:1F:20:3D:1E:75 Connected: no
root ##bl##[bluetooth]##!bl### connect 00:1F:20:3D:1E:75
Attempting to connect to 00:1F:20:3D:1E:75
[CHG] Device 00:1F:20:3D:1E:75 Connected: yes
Connection successful
root ##bl##[bluetooth]##!bl### quit
[DEL] Controller 00:02:72:C9:62:65 antec [default]
root #