Difference between pages "Funtoo Profiles" and "ConsoleOutput MediaWiki Extension"

(Difference between pages)
 
 
Line 1: Line 1:
{{#widget:AddThis}}
+
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, and put a <tt>##i##</tt> input code immediately before user input on each line. This will cause all text from the <tt>##i##</tt> point to the end of the line to be in a darker color. The rest of the text will be in a lighter grey, allowing it to be distinguished more easily from user input. Here are other sequences that can be used:
== What is a profile? ==
+
  
In Gentoo and Funtoo Linux, profiles are used to define base system settings, and have historically had a lot of untapped potential. In Funtoo Linux, I wanted to take advantage of some of this potential to allow Funtoo Linux users to easily tailor their system for various types of roles. Enter the new Funtoo profile system.
+
* <tt>##b##</tt> - highlight the rest of the line in bold.
 +
* <tt>##b## text here ##!b##</tt> - highlight the text between both markers in bold.
 +
* <tt>##i## text here ##!i##</tt> - highlight the text between both markers in a darker color.
  
== What It Is ==
+
This extension can be further extended to add color support, as desired, and some of the CSS for color support can already be found in the code below.
  
Historically, users have had to add a ton of settings to <code>/etc/[[make.conf]]</code> to customize their Gentoo or Funtoo Linux system, which made setup of the operating system more difficult than it should be.
+
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:
  
In Gentoo Linux, it is possible to only define one ''system profile''. Think of a system profile as the default settings that Portage uses for building everything on your system.
 
 
In Funtoo Linux, multiple profiles can be enabled at the same time. These include:
 
 
* '''arch''' - one arch profile is enabled, at build time, and is not changed. This defines CPU architecture-specific settings.
 
* '''build''' - one build profile is enabled, at build time, and is generally not changed. It defines the type of build, such as 'current' or 'stable', and associated settings.
 
* '''flavor''' - one flavor is enabled per system, and can be changed by the user. This defines the general use of the system, such as 'minimal', 'core', 'workstation' or 'desktop'
 
* '''mix-in''' - zero or more mix-ins can be enabled that enable settings specific to a particular subset of features, such as 'gnome', 'kde', 'media', 'mate', 'X', 'hardened'
 
 
{{note|1=
 
See [[Flavors and Mix-ins]] for a complete list of all flavors and mix-ins available in Funtoo Linux, along with descriptions of what each one does.}}
 
 
=== Origins and Benefits ===
 
 
This new system is really a completion of the original cascading profile design that was designed by Daniel Robbins and implemented by Seemant Kulleen as part of Portage. Funtoo Profiles designed to leverage the existing cascading profile system and provide something much more useable and maintainable for users and developers alike. Here are some of its benefits:
 
 
* Fewer settings in <code>/etc/make.conf</code>. <code>CHOST</code> and <code>ARCH</code> no longer set in <code>/etc/make.conf</code>.
 
* Separation of concerns -- arch, build, and flavor-related settings are organized together.
 
* User flexibility - any number of mix-ins can be enabled to tweak masks or USE settings as needed.
 
 
{{note|See [[Custom Profiles]] for information on how to extend the profile system.}}
 
 
== Switch to the Funtoo 1.0 Profile ==
 
 
=== Using eselect ===
 
The preferred method of adding and removing profiles is to use [[eselect|eselect profile]]. This will ensure that profiles are added correctly and in the proper order. The order is imperative for things to work right.
 
 
Type the following to view a list of available options for '''eselect profile''':
 
 
<console>
 
<console>
###i## eselect profile help
+
www@www-smw ~/public_html $ ##i##ls
 +
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>
 
</console>
  
For a start, let's see what the default configuration has to offer. Get an overview using the '''list''' command:
+
And here is how you might display a more detailed example of console output, using colors:
<console>
+
###i## eselect profile list
+
##b####g##Currently available arch profiles:
+
  ##b##[1]  funtoo/1.0/linux-gnu/arch/x86-64bit##!b## *
+
  ##b##[2]##!b##  funtoo/1.0/linux-gnu/arch/pure64
+
##b####g##Currently available build profiles:
+
  ##b##[3]##!b##  funtoo/1.0/linux-gnu/build/stable
+
  ##b##[4]  funtoo/1.0/linux-gnu/build/current##!b## *
+
  ##b##[5]##!b##  funtoo/1.0/linux-gnu/build/experimental
+
##b####g##Currently available flavor profiles:
+
  ##b##[6]##!b##  funtoo/1.0/linux-gnu/flavor/minimal
+
  ##b##[7]  funtoo/1.0/linux-gnu/flavor/core##!b## *
+
  ##b##[8]##!b##  funtoo/1.0/linux-gnu/flavor/desktop
+
  ##b##[9]##!b##  funtoo/1.0/linux-gnu/flavor/workstation
+
  ##b##[10]##!b##  funtoo/1.0/linux-gnu/flavor/hardened
+
##b####g##Currently available mix-ins profiles:
+
  ##b##[11]##!b##  funtoo/1.0/linux-gnu/mix-ins/audio
+
  ##b##[12]##!b##  funtoo/1.0/linux-gnu/mix-ins/cinnamon
+
  ##b##[13]##!b##  funtoo/1.0/linux-gnu/mix-ins/console-extras
+
  ##b##[14]##!b##  funtoo/1.0/linux-gnu/mix-ins/dvd
+
  ##b##[15]##!b##  funtoo/1.0/linux-gnu/mix-ins/gnome
+
  ##b##[16]##!b##  funtoo/1.0/linux-gnu/mix-ins/kde
+
  ##b##[17]##!b##  funtoo/1.0/linux-gnu/mix-ins/mate
+
  ##b##[18]##!b##  funtoo/1.0/linux-gnu/mix-ins/media
+
  ##b##[19]##!b##  funtoo/1.0/linux-gnu/mix-ins/print
+
  ##b##[20]##!b##  funtoo/1.0/linux-gnu/mix-ins/python3-only
+
  ##b##[21]##!b##  funtoo/1.0/linux-gnu/mix-ins/rhel5-compat
+
  ##b##[22]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-db
+
  ##b##[23]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-mail
+
  ##b##[24]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-web
+
  ##b##[25]##!b##  funtoo/1.0/linux-gnu/mix-ins/X
+
  ##b##[26]##!b##  funtoo/1.0/linux-gnu/mix-ins/xfce
+
  ##b##[27]##!b##  funtoo/1.0/linux-gnu/mix-ins/vmware-guest
+
  ##b##[28]##!b##  funtoo/1.0/linux-gnu/mix-ins/hardened
+
</console>
+
  
As in several other Funtoo utilities, a star ('''*''') on the right indicates an active item (your case may differ from the example above).
+
{{console|body=
In most cases you will want to set your "flavor" first. Remember that you can only set ''one'' flavor at time.
+
# ##i##bluetoothctl
 +
[##g##NEW##!g##] Controller 00:02:72:C9:62:65 antec [default]
 +
##bl##[bluetooth]##!bl### ##i##power on
 +
Changing power on succeeded
 +
##bl##[bluetooth]##!bl### ##i##agent on
 +
Agent registered
 +
##bl##[bluetooth]##!bl### ##i##scan on
 +
Discovery started
 +
##bl##[bluetooth]##!bl### ##i##devices
 +
Device 00:1F:20:3D:1E:75 Logitech K760
 +
##bl##[bluetooth]##!bl### ##i##pair 00:1F:20:3D:1E:75
 +
Attempting to pair with 00:1F:20:3D:1E:75
 +
[##y##CHG##!y##] Device 00:1F:20:3D:1E:75 Connected: yes
 +
##r##[agent]##!r## Passkey: 454358
 +
##r##[agent]##!r## Passkey: ##i##4##!i##54358
 +
##r##[agent]##!r## Passkey: ##i##45##!i##4358
 +
##r##[agent]##!r## Passkey: ##i##454##!i##358
 +
##r##[agent]##!r## Passkey: ##i##4543##!i##58
 +
##r##[agent]##!r## Passkey: ##i##45435##!i##8
 +
##r##[agent]##!r## Passkey: ##i##454358##!i##
 +
[##y##CHG##!y##] Device 00:1F:20:3D:1E:75 Paired: yes
 +
Pairing successful
 +
[##y##CHG##!y##] Device 00:1F:20:3D:1E:75 Connected: no
 +
##bl##[bluetooth]##!bl### ##i##connect 00:1F:20:3D:1E:75
 +
Attempting to connect to 00:1F:20:3D:1E:75
 +
[##y##CHG##!y##] Device 00:1F:20:3D:1E:75 Connected: yes
 +
Connection successful
 +
##bl##[bluetooth]##!bl### ##i##quit
 +
[##r##DEL##!r##] Controller 00:02:72:C9:62:65 antec [default]
 +
#
 +
}}
  
To choose your favorite flavor use the '''set-flavor''' command including your selection. In this example, we will set the '''desktop''' flavor:
+
To install, make the following modifications to your skin:
{{note|You ''must'' use numbers to reference to the profiles you want.}}
+
<console>###i## eselect profile set-flavor 8</console>
+
View the result:
+
<console>###i## eselect profile list
+
##b####g##Currently available arch profiles:
+
  ##b##[1]  funtoo/1.0/linux-gnu/arch/x86-64bit##!b## *
+
  ##b##[2]##!b##  funtoo/1.0/linux-gnu/arch/pure64
+
##b####g##Currently available build profiles:
+
  ##b##[3]##!b##  funtoo/1.0/linux-gnu/build/stable
+
  ##b##[4]  funtoo/1.0/linux-gnu/build/current##!b## *
+
  ##b##[5]##!b##  funtoo/1.0/linux-gnu/build/experimental
+
##b####g##Currently available flavor profiles:
+
  ##b##[6]##!b##  funtoo/1.0/linux-gnu/flavor/minimal
+
  ##b##[7]##!b##  funtoo/1.0/linux-gnu/flavor/core
+
  ##b##[8]  funtoo/1.0/linux-gnu/flavor/desktop##!b## *
+
  ##b##[9]##!b##  funtoo/1.0/linux-gnu/flavor/workstation
+
  ##b##[10]##!b##  funtoo/1.0/linux-gnu/flavor/hardened
+
##b####g##Currently available mix-ins profiles:
+
  ##b##[11]  funtoo/1.0/linux-gnu/mix-ins/audio (auto)
+
  ##b##[12]##!b##  funtoo/1.0/linux-gnu/mix-ins/cinnamon
+
  ##b##[13]  funtoo/1.0/linux-gnu/mix-ins/console-extras (auto)
+
  ##b##[14]  funtoo/1.0/linux-gnu/mix-ins/dvd (auto)
+
  ##b##[15]##!b##  funtoo/1.0/linux-gnu/mix-ins/gnome
+
  ##b##[16]##!b##  funtoo/1.0/linux-gnu/mix-ins/kde
+
  ##b##[17]##!b##  funtoo/1.0/linux-gnu/mix-ins/mate
+
  ##b##[18]  funtoo/1.0/linux-gnu/mix-ins/media (auto)
+
  ##b##[19]  funtoo/1.0/linux-gnu/mix-ins/print (auto)
+
  ##b##[20]##!b##  funtoo/1.0/linux-gnu/mix-ins/python3-only
+
  ##b##[21]##!b##  funtoo/1.0/linux-gnu/mix-ins/rhel5-compat
+
  ##b##[22]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-db
+
  ##b##[23]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-mail
+
  ##b##[24]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-web
+
  ##b##[25]  funtoo/1.0/linux-gnu/mix-ins/X (auto)
+
  ##b##[26]##!b##  funtoo/1.0/linux-gnu/mix-ins/xfce
+
  ##b##[27]##!b##  funtoo/1.0/linux-gnu/mix-ins/vmware-guest
+
  ##b##[28]##!b##  funtoo/1.0/linux-gnu/mix-ins/hardened
+
</console>
+
As you see by the '''(auto)''' entries, the '''desktop''' flavor already pre-set some mix-ins for you.
+
  
Now, let's head over and add some mix-ins. To add, say, the mix-ins '''gnome''' and '''kde''' we'd have to enter:
+
<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>
  
<console>
+
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>:
###i## eselect profile add 15
+
###i## eselect profile add 16
+
</console>
+
  
Or, in a one-shot:
+
<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'
 +
);
  
<console>
+
if ( defined( 'MW_SUPPORTS_PARSERFIRSTCALLINIT' ) ) {
###i## eselect profile add 15 16
+
        $wgHooks['ParserFirstCallInit'][] = 'consoleOutputSetup';
</console>
+
} else {
 +
        $wgExtensionFunctions[] = 'consoleOutputSetup';
 +
}
  
If we want to remove a mix-in, for example '''gnome''', simply enter:
+
function consoleOutputSetup( $data )
 +
{
 +
    global $wgParser;
 +
    $wgParser->setHook('console', 'consoleRender');
 +
    return true;
 +
}
  
<console>
+
function consoleRender($input, $args, $parser)
###i## eselect profile remove 15
+
{
</console>
+
    if (count($args))
 +
    {
 +
        return "<strong class='error'>" .
 +
              "ConsoleOutput: arguments not supported" .
 +
              "</strong>";
 +
    }
  
Verification:
+
    # Display < and > as literals, so escape them:
  
<console>###i## eselect profile list
+
    $input = preg_replace('/>/','&gt;', $input);
##b####g##Currently available arch profiles:
+
    $input = preg_replace('/</','&lt;', $input);
  ##b##[1]  funtoo/1.0/linux-gnu/arch/x86-64bit##!b## *
+
  ##b##[2]##!b##  funtoo/1.0/linux-gnu/arch/pure64
+
##b####g##Currently available build profiles:
+
  ##b##[3]##!b##  funtoo/1.0/linux-gnu/build/stable
+
  ##b##[4]  funtoo/1.0/linux-gnu/build/current##!b## *
+
  ##b##[5]##!b##  funtoo/1.0/linux-gnu/build/experimental
+
##b####g##Currently available flavor profiles:
+
  ##b##[6]##!b##  funtoo/1.0/linux-gnu/flavor/minimal
+
  ##b##[7]##!b##  funtoo/1.0/linux-gnu/flavor/core
+
  ##b##[8]  funtoo/1.0/linux-gnu/flavor/desktop##!b## *
+
  ##b##[9]##!b##  funtoo/1.0/linux-gnu/flavor/workstation
+
  ##b##[10]##!b##  funtoo/1.0/linux-gnu/flavor/hardened
+
##b####g##Currently available mix-ins profiles:
+
  ##b##[11]  funtoo/1.0/linux-gnu/mix-ins/audio (auto)
+
  ##b##[12]##!b##  funtoo/1.0/linux-gnu/mix-ins/cinnamon
+
  ##b##[13]  funtoo/1.0/linux-gnu/mix-ins/console-extras (auto)
+
  ##b##[14]  funtoo/1.0/linux-gnu/mix-ins/dvd (auto)
+
  ##b##[15]##!b##  funtoo/1.0/linux-gnu/mix-ins/gnome
+
  ##b##[16]  funtoo/1.0/linux-gnu/mix-ins/kde *
+
  ##b##[17]##!b##  funtoo/1.0/linux-gnu/mix-ins/mate
+
  ##b##[18]  funtoo/1.0/linux-gnu/mix-ins/media (auto)
+
  ##b##[19]  funtoo/1.0/linux-gnu/mix-ins/print (auto)
+
  ##b##[20]##!b##  funtoo/1.0/linux-gnu/mix-ins/python3-only
+
  ##b##[21]##!b##  funtoo/1.0/linux-gnu/mix-ins/rhel5-compat
+
  ##b##[22]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-db
+
  ##b##[23]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-mail
+
  ##b##[24]##!b##  funtoo/1.0/linux-gnu/mix-ins/server-web
+
  ##b##[25]  funtoo/1.0/linux-gnu/mix-ins/X (auto)
+
  ##b##[26]##!b##  funtoo/1.0/linux-gnu/mix-ins/xfce
+
  ##b##[27]##!b##  funtoo/1.0/linux-gnu/mix-ins/vmware-guest
+
  ##b##[28]##!b##  funtoo/1.0/linux-gnu/mix-ins/hardened
+
</console>
+
  
No magic here, whatever you add gets put into the <code>/etc/portage/make.profile/parent</code> file by portage.
+
    # http://www.perlmonks.org/?node_id=518444
 
+
    # See "Matching a pattern that doesn't include another pattern:
In our case, this file contains:
+
<console>
+
###i## cat /etc/portage/make.profile/parent
+
gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
+
gentoo:funtoo/1.0/linux-gnu/build/current
+
gentoo:funtoo/1.0/linux-gnu/flavor/desktop
+
gentoo:funtoo/1.0/linux-gnu/mix-ins/kde
+
</console>
+
{{fancywarning|Please, do not add anything manually into <code>parent</code> file. This may result in profile breakage.}}
+
 
+
== For Developers ==
+
 
+
=== Define the profile sub-sets you will use ===
+
 
+
So far in Funtoo we have used the exact same profiles as Gentoo thus Funtoo/2008.0 was strictly the same thing as Gentoo/2008.0 or the barely the same 10.0. This (monolithic) profile was set though a symbolic link named <code>/etc/make.profile</code> pointing on a complex directory architecture located somewhere under <code>/usr/portage/profiles</code>. This is no longer valid with the Funtoo 1.0 profiles as they are split in several smaller bricks which are then glued together via the  <code>/etc/portage/make.profile/parent</code> file (You do not need to include everything, just use the "bricks" you need). Those bricks belongs to several categories:
+
 
+
# MANDATORY -- An "arch" profile which defines settings for a particular architecture. You'll want to set this to whatever arch your system is and leave it alone. '''Setting it to a different arch than your system could severely break it.'''
+
# MANDATORY -- A "build" profile which should match the tree you wish to use. '''Stable''', '''Current''' (~arch), or '''Experimental''' (use it if you are brave enough and find '''current''' too stable).
+
# MANDATORY -- A "flavor" profile (what was previously known as ''profiles'' is still known as such in Gentoo) which describes the kind of system you want:
+
#* minimal - Be warned, minimal is exactly what it says, the minimal profile stuff you need for a usable system, nothing else. This is really for people who know what they're doing.
+
#* core - This is the core profile. This is for stuff that affects both desktops and servers.
+
#* desktop - Exactly what it says. If you're using a desktop, you should set this as your flavor.
+
#* server - If you're running a server, you should set this as your flavor.
+
# OPTIONAL -- One or more "mix-ins" profiles which describe optional add-ons. 'mix-ins' are the heart of the Funtoo 1.0 profiles. Unlike the monolithic profiles which sets a massive amount of use flags and options for you, we've split them into logical add-on profiles. For instance if you want support for gnome, you would add the gnome mix-in to your current profiles. That mix-in sets all the proper use flags and such for gnome. Same with others. Want dvd support? Add that one in. Using a rhel5 kernel which requires special versions of packages such as udev? There's a mix-in for that too. Run a mail server? web server? There's mix-ins for those also. Expect this category to grow in the future as new mix-ins are created.
+
 
+
The contents of <code>/etc/portage/make.profile/parent</code> for a basic setup might look like this:
+
 
+
{{file|name=/etc/portage/make.profile/parent|body=
+
gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
+
gentoo:funtoo/1.0/linux-gnu/build/current
+
gentoo:funtoo/1.0/linux-gnu/flavor/core
+
}}
+
 
+
A more rounded setup for a desktop might look like this:
+
 
+
{{file|name=/etc/portage/make.profile/parent|body=
+
gentoo:funtoo/1.0/linux-gnu/arch/x86-64bit
+
gentoo:funtoo/1.0/linux-gnu/build/current
+
gentoo:funtoo/1.0/linux-gnu/flavor/desktop
+
gentoo:funtoo/1.0/linux-gnu/mix-ins/dvd
+
gentoo:funtoo/1.0/linux-gnu/mix-ins/media
+
}}
+
  
== Related ==
+
    $input = preg_replace('/##i##((?:(?!##!i##).)*)##!i##/','<span class="code_input">$1</span>', $input);
* [[Flavors and Mix-ins]]
+
    $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:Funtoo features]]
+
[[Category:MediaWiki Hacks]]
[[Category:Portage]]
+
[[Category:Labs]]
+
[[Category:HOWTO]]
+
[[Category:Official Documentation]]
+

Revision as of 01:05, January 12, 2015

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 <console> opening and closing tags, and put a ##i## input code immediately before user input on each line. This will cause all text from the ##i## point to the end of the line to be in a darker color. The rest of the text will be in a lighter grey, allowing it to be distinguished more easily from user input. Here are other sequences that can be used:

  • ##b## - highlight the rest of the line in bold.
  • ##b## text here ##!b## - highlight the text between both markers in bold.
  • ##i## text here ##!i## - highlight the text between both markers in a darker color.

This extension can be further extended to add color support, as desired, and some of the CSS for color support can already be found in the code below.

Here are a few examples of the ConsoleOutput extension. First this is how you might typically display ls output, with a particular directory highlighted:

www@www-smw ~/public_html $ ls
COPYING  LocalSettings.php     api.php   extensions    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 $ cd extensions/

And here is how you might display a more detailed example of console output, using colors:

# bluetoothctl 
[NEW] Controller 00:02:72:C9:62:65 antec [default]
[bluetooth]# power on
Changing power on succeeded
[bluetooth]# agent on
Agent registered
[bluetooth]# scan on
Discovery started
[bluetooth]# devices
Device 00:1F:20:3D:1E:75 Logitech K760
[bluetooth]# 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
[agent] Passkey: 454358
[agent] Passkey: 454358
[agent] Passkey: 454358
[agent] Passkey: 454358
[agent] Passkey: 454358
[agent] Passkey: 454358
[agent] Passkey: 454358
[CHG] Device 00:1F:20:3D:1E:75 Paired: yes
Pairing successful
[CHG] Device 00:1F:20:3D:1E:75 Connected: no
[bluetooth]# 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
[bluetooth]# quit
[DEL] Controller 00:02:72:C9:62:65 antec [default]
#


To install, make the following modifications to your skin:

--- 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;

Then install the following code in your extensions directory and include it with a require_once( "$IP/extensions/ConsoleOutput.php" ); in LocalSettings.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>";
}
?>