Permalink
Browse files

simplified implementation; user buttons (resolved #18 & #19); dom pri…

…nter class
  • Loading branch information...
1 parent e6c8d7e commit b3389ee1db9afcf1b73d334cc7d0982a1e47b665 @mtyeh411 committed Mar 5, 2013
Showing with 393 additions and 437 deletions.
  1. +213 −437 Bootstrap.renderer.php
  2. +36 −0 DOMDebugPrinter.php
  3. +1 −0 bootstrap.php
  4. +43 −0 xsl/dropdown.xsl
  5. +24 −0 xsl/entities.dtd
  6. +18 −0 xsl/footer.xsl
  7. +38 −0 xsl/navbar.xsl
  8. +20 −0 xsl/sidebar.xsl
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -0,0 +1,36 @@
+<?php
+
+/**
+* @file
+* @ingroup Skins
+*/
+class DOMDebugPrinter {
+
+ public static function printDoc( $domDoc ) {
+ $root = $domDoc->documentElement;
+ foreach( $root->childNodes as $node ) {
+ print( $node->nodeName." => ".$node->nodeValue );
+ }
+ }
+
+ /**
+ * Print a DOM node (for debugging).
+ * @param DOMNode
+ * @return String
+ * @ingroup Skins
+ */
+ public static function printNode( $node ) {
+ if( $node instanceof DOMNode ) {
+ $string = '<br/><span style="color:blue">' . $node->getNodePath() . '</span>: ' . $node->nodeValue;
+ if( $node->hasChildNodes() ) {
+ foreach( $node->childNodes as $child ) {
+ $string .= '<br/>' . BootstrapRenderer::NodeToString( $child );
+ }
+ }
+ return $string;
+ } else {
+ return "Not a DOMNode";
+ }
+ }
+
+}
View
@@ -21,6 +21,7 @@
$wgValidSkinNames['bootstrap'] = 'Bootstrap';
$wgAutoloadClasses['SkinBootstrap'] = dirname( __FILE__ ).'/Bootstrap.skin.php';
$wgAutoloadClasses['BootstrapRenderer'] = dirname( __FILE__ ).'/Bootstrap.renderer.php';
+ $wgAutoloadClasses['DOMDebugPrinter'] = dirname( __FILE__ ).'/DOMDebugPrinter.php';
$wgExtensionMessagesFiles['Bootstrap'] = dirname( __FILE__ ).'/Bootstrap.i18n.php';
$skinDirParts = explode( "/", dirname( __FILE__ ) );
View
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xsl:stylesheet [
+ <!ENTITY % entities SYSTEM "entities.dtd">
+ %entities;
+]>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+ <!-- ul templates -->
+ <xsl:template match="ul" mode="topLevel">
+ <xsl:param name="class"></xsl:param>
+ <xsl:copy>
+ <xsl:attribute name="class">
+ <xsl:value-of select="$class"/>
+ </xsl:attribute>
+ <xsl:apply-templates select="li"/>
+ </xsl:copy>
+ </xsl:template>
+ <xsl:template match="ul" mode="dropdown">
+ <xsl:copy>
+ <xsl:attribute name="class">&dropdown-menu-class;</xsl:attribute>
+ <xsl:copy-of select="*"/>
+ </xsl:copy>
+ </xsl:template>
+
+ <!-- li templates -->
+ <xsl:template match="li[child::ul]">
+ <xsl:copy>
+ <xsl:attribute name="class">&dropdown-class;</xsl:attribute>
+ <a class="&dropdown-toggle-class;" data-toggle="&dropdown-data-toggle;" href="#">
+ <!-- content -->
+ <xsl:copy-of select="*[not(self::ul)] | text()"/>
+
+ <i class="&icon-caret-class;"></i>
+ </a>
+ <xsl:apply-templates select="ul" mode="dropdown"/>
+ </xsl:copy>
+ </xsl:template>
+ <xsl:template match="li">
+ <xsl:copy-of select="."/>
+ </xsl:template>
+
+</xsl:stylesheet>
View
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- nav entities -->
+<!ENTITY nav-collapse-class "nav-collapse">
+<!ENTITY nav-class "nav">
+<!ENTITY nav-stacked-class "nav-stacked">
+<!ENTITY nav-pills-class "nav-pills">
+<!ENTITY nav-list-class "nav-list">
+<!ENTITY nav-tabs-class "nav-tabs">
+
+<!-- dropdown entities -->
+<!ENTITY dropdown-class "dropdown">
+<!ENTITY dropdown-menu-class "dropdown-menu">
+<!ENTITY dropdown-toggle-class "dropdown-toggle">
+<!ENTITY dropdown-data-toggle "dropdown">
+<!ENTITY collapse-data-toggle "dropdown">
+
+<!-- icon entities -->
+<!ENTITY icon-caret-class "caret">
+<!ENTITY icon-bar-class "icon-bar">
+
+<!-- shortcuts -->
+<!ENTITY sidebar-nav "&nav-class; &nav-stacked-class;">
+<!ENTITY navbar-nav "&nav-class;">
+<!ENTITY site-tool-group "pull-right btn-group">
View
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xsl:stylesheet [
+ <!ENTITY % entities SYSTEM "entities.dtd">
+ %entities;
+]>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+ <!-- add nav class to root ul element -->
+ <xsl:template match="/">
+ <xsl:apply-templates select="ul[1]" mode="topLevel">
+ <xsl:with-param name="class">horizontal</xsl:with-param>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:include href="dropdown.xsl"/>
+
+</xsl:stylesheet>
View
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xsl:stylesheet [
+ <!ENTITY % entities SYSTEM "entities.dtd">
+ %entities;
+]>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+ <!-- add nav class to root ul element -->
+ <xsl:template match="/">
+ <nav class="navbar">
+ <div class="navbar-inner">
+ <div class="container">
+ <a class="btn btn-navbar" data-toggle="&collapse-data-toggle;" data-target="&nav-collapse-class;">
+ <span class="&icon-bar-class;"></span>
+ <span class="&icon-bar-class;"></span>
+ <span class="&icon-bar-class;"></span>
+ </a>
+
+ <a class="brand"></a>
+
+ <div class="&nav-collapse-class;">
+ <xsl:apply-templates select="ul[1]" mode="topLevel">
+ <xsl:with-param name="class">&navbar-nav;</xsl:with-param>
+ </xsl:apply-templates>
+ </div>
+
+ <div id="page" class="&site-tool-group;"></div>
+
+ <div id="user" class="&site-tool-group;"></div>
+ </div>
+ </div>
+ </nav>
+ </xsl:template>
+
+ <xsl:include href="dropdown.xsl"/>
+
+</xsl:stylesheet>
View
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE xsl:stylesheet [
+ <!ENTITY % entities SYSTEM "entities.dtd">
+ %entities;
+]>
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+ version="1.0">
+
+ <xsl:param name="nav-type">&nav-pills-class;</xsl:param>
+
+ <!-- add nav class to root ul element -->
+ <xsl:template match="/">
+ <xsl:apply-templates select="ul[1]" mode="topLevel">
+ <xsl:with-param name="class">&sidebar-nav; <xsl:value-of select="$nav-type"/></xsl:with-param>
+ </xsl:apply-templates>
+ </xsl:template>
+
+ <xsl:include href="dropdown.xsl"/>
+
+</xsl:stylesheet>

0 comments on commit b3389ee

Please sign in to comment.