Difference between pages "ConsoleOutput MediaWiki Extension" and "X Window System"

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, 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:
=== X.Org ===


* <tt>##b##</tt> - highlight the rest of the line in bold.
In order to use a graphical environment it's necessary to install X.Org, which is an implementation of the X Window system.  
* <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.


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.
Before we start it's a good idea to make sure that your system is configured correctly. If you've installed your kernel using the <code>binary</code> USE flag, chances are that your video card is already supported. See [[Video]] for more information onthis.


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:
You should also find your IP address, because if X freezes and you need to get out of it, the safest way is to SSH in from another computer/smartphone/tablet and issue
<console>
# ##i##killall X
</console>


In order for Portage to know which [[Video | video]] card(s) you want to support, you'll need to add a line to your <code>[[make.conf | make.conf]]</code>.
<console>
<console>
www@www-smw ~/public_html $ ##i##ls
# ##i##nano -w /etc/portage/make.conf
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
VIDEO_CARDS="intel"
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>


And here is how you might display a more detailed example of console output, using colors:
In the example above we're using Intel integrated graphics drivers. Examples of valid entries include <code>radeon</code> for AMD Radeon cards, and <code>nouveau</code> or <code>nvidia</code> for NVIDIA cards. If you haven't yet switched to the <code>desktop</code> profile it's a good idea to do it now.


{{console|body=
Next comes the actual installation:
# ##i##bluetoothctl
<console>
[##g##NEW##!g##] Controller 00:02:72:C9:62:65 antec [default]
# ##i##emerge xorg-x11
##bl##[bluetooth]##!bl### ##i##power on
</console>
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 install, make the following modifications to your skin:
Now we need to test to make sure X.Org is working properly. To test it we will install twm, a simple window manager which has traditionally served as the standard window manager for X.Org. In Funtoo Linux it is included in the core X.Org meta-package <code>x11-apps/xinit</code>, but is not installed by default.


<syntaxhighlight lang="css">
It is possible to install twm directly by merging <code>x11-wm/twm</code> but for the sake of this tutorial we will install the meta-package, which includes a few extra utilities which may come in handy. There are two ways to do this depending on whether you want it to be installed temporarily or permanently. If you just want it to test X.Org use the following command:
--- mediawiki-1.19.1/skins/vector/screen.css    2012-06-13 18:22:39.000000000 +0000
<console>
+++ public_html/skins/vector/screen.css 2012-08-27 04:34:47.507912892 +0000
# ##i##USE="-minimal" emerge -1 xinit
@@ -683,10 +683,47 @@
</console>
        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>:
The <code>minimal</code> USE flag is used in some ebuilds to install the bare minimum needed to get a working system. By passing <code>USE="-minimal"</code> to the command line before <code>emerge</code>, we are telling Portage to disable the flag and install the complete package. The <code>-1</code> (<code>--oneshot</code>) following <code>emerge</code> tells Portage not to add the package to [[#Updating your system|<code>world</code>]]. This is useful when installing packages which are automatically pulled in as dependencies by other packages.


<syntaxhighlight lang="php">
If you want the package installed permanently you will need to add a line to <code>package.use</code>:
<?php
<console>
$wgExtensionCredits['validextensionclass'][] = array(
# ##i##echo 'x11-apps/xinit -minimal' >> /etc/portage/package.use
    'name' => 'ConsoleOutput',
</console>
    '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' ) ) {
Next we reinstall <code>x11-apps/xinit</code>:
        $wgHooks['ParserFirstCallInit'][] = 'consoleOutputSetup';
<console>
} else {
# ##i##emerge -1N xinit
        $wgExtensionFunctions[] = 'consoleOutputSetup';
</console>
}


function consoleOutputSetup( $data )
Once that's done, we're able to finally test X.Org:
{
    global $wgParser;
    $wgParser->setHook('console', 'consoleRender');
    return true;
}


function consoleRender($input, $args, $parser)
<console>
{
# ##i##startx
    if (count($args))
</console>
    {
        return "<strong class='error'>" .
              "ConsoleOutput: arguments not supported" .
              "</strong>";
    }


    # Display < and > as literals, so escape them:
If everything is well, a simple GUI along with an analog clock and a terminal will appear.


    $input = preg_replace('/>/','&gt;', $input);
====Keyboard/Mouse====
    $input = preg_replace('/</','&lt;', $input);


    # http://www.perlmonks.org/?node_id=518444
If you have no keyboard/mouse input in x11, check if your kernel supports dev
    # See "Matching a pattern that doesn't include another pattern:
<console>
 
# ##i##zcat /proc/config.gz | grep EVDEV
    $input = preg_replace('/##i##((?:(?!##!i##).)*)##!i##/','<span class="code_input">$1</span>', $input);
</console>
    $input = preg_replace('/##i##(.*)/','<span class="code_input">$1</span>', $input);
if your output is:
    $input = preg_replace('/##b##((?:(?!##!b##).)*)##!b##/','<b>$1</b>', $input);
<console>
    $input = preg_replace('/##b##(.*)/','<b>$1</b>', $input);
CONFIG_INPUT_EVDEV=y
    return "<pre class=\"code\">" . $input . "&lt;/pre>";
</console>  
}
Install xf86-input-evdev
?>
<console>
</syntaxhighlight>
# ##i##emerge xf86-input-evdev
</console>


[[Category:MediaWiki Hacks]]
[[Category:First Steps]]

Revision as of 19:24, January 12, 2015

X.Org

In order to use a graphical environment it's necessary to install X.Org, which is an implementation of the X Window system.

Before we start it's a good idea to make sure that your system is configured correctly. If you've installed your kernel using the binary USE flag, chances are that your video card is already supported. See Video for more information onthis.

You should also find your IP address, because if X freezes and you need to get out of it, the safest way is to SSH in from another computer/smartphone/tablet and issue

root # killall X

In order for Portage to know which video card(s) you want to support, you'll need to add a line to your make.conf.

root # nano -w /etc/portage/make.conf
...
VIDEO_CARDS="intel"

In the example above we're using Intel integrated graphics drivers. Examples of valid entries include radeon for AMD Radeon cards, and nouveau or nvidia for NVIDIA cards. If you haven't yet switched to the desktop profile it's a good idea to do it now.

Next comes the actual installation:

root # emerge xorg-x11

Now we need to test to make sure X.Org is working properly. To test it we will install twm, a simple window manager which has traditionally served as the standard window manager for X.Org. In Funtoo Linux it is included in the core X.Org meta-package x11-apps/xinit, but is not installed by default.

It is possible to install twm directly by merging x11-wm/twm but for the sake of this tutorial we will install the meta-package, which includes a few extra utilities which may come in handy. There are two ways to do this depending on whether you want it to be installed temporarily or permanently. If you just want it to test X.Org use the following command:

root # USE="-minimal" emerge -1 xinit

The minimal USE flag is used in some ebuilds to install the bare minimum needed to get a working system. By passing USE="-minimal" to the command line before emerge, we are telling Portage to disable the flag and install the complete package. The -1 (--oneshot) following emerge tells Portage not to add the package to world. This is useful when installing packages which are automatically pulled in as dependencies by other packages.

If you want the package installed permanently you will need to add a line to package.use:

root # echo 'x11-apps/xinit -minimal' >> /etc/portage/package.use

Next we reinstall x11-apps/xinit:

root # emerge -1N xinit

Once that's done, we're able to finally test X.Org:

root # startx

If everything is well, a simple GUI along with an analog clock and a terminal will appear.

Keyboard/Mouse

If you have no keyboard/mouse input in x11, check if your kernel supports dev

root # zcat /proc/config.gz | grep EVDEV 

if your output is:

CONFIG_INPUT_EVDEV=y 

Install xf86-input-evdev

root # emerge xf86-input-evdev