From 6b13307fb447795714d01cdc029d6ed7ac087cf3 Mon Sep 17 00:00:00 2001
From: andi <andi@splitbrain.org>
Date: Sun, 6 Mar 2005 19:31:59 +0100
Subject: [PATCH] template support (incomplete, maybe broken)

darcs-hash:20050306183159-9977f-22dbb69831b5fa2e28bbf62448c65053d96a2cb9.gz
---
 conf/dokuwiki.php                             |   1 +
 doku.php                                      | 148 +---
 inc/actions.php                               | 192 +++++
 inc/common.php                                |   2 +-
 inc/html.php                                  |  17 +
 inc/init.php                                  |   6 +-
 inc/template.php                              | 314 +++++++++
 media.php                                     |   2 +-
 style.css                                     | 656 ------------------
 tpl/default/design.css                        | 562 +++++++++++++++
 {images => tpl/default/images}/bullet.gif     | Bin
 {images => tpl/default/images}/button-cc.gif  | Bin
 {images => tpl/default/images}/button-css.png | Bin
 .../default/images}/button-donate.gif         | Bin
 {images => tpl/default/images}/button-dw.png  | Bin
 {images => tpl/default/images}/button-php.gif | Bin
 {images => tpl/default/images}/button-rss.png | Bin
 .../default/images}/button-xhtml.png          | Bin
 {images => tpl/default/images}/closed.gif     | Bin
 {images => tpl/default/images}/link_icon.gif  | Bin
 {images => tpl/default/images}/mail_icon.gif  | Bin
 {images => tpl/default/images}/open.gif       | Bin
 {images => tpl/default/images}/tocdot2.gif    | Bin
 {images => tpl/default/images}/windows.gif    | Bin
 tpl/default/layout.css                        | 113 +++
 tpl/default/main.php                          | 110 +++
 print.css => tpl/default/print.css            |   0
 27 files changed, 1318 insertions(+), 805 deletions(-)
 create mode 100644 inc/actions.php
 create mode 100644 inc/template.php
 create mode 100644 tpl/default/design.css
 rename {images => tpl/default/images}/bullet.gif (100%)
 rename {images => tpl/default/images}/button-cc.gif (100%)
 rename {images => tpl/default/images}/button-css.png (100%)
 rename {images => tpl/default/images}/button-donate.gif (100%)
 rename {images => tpl/default/images}/button-dw.png (100%)
 rename {images => tpl/default/images}/button-php.gif (100%)
 rename {images => tpl/default/images}/button-rss.png (100%)
 rename {images => tpl/default/images}/button-xhtml.png (100%)
 rename {images => tpl/default/images}/closed.gif (100%)
 rename {images => tpl/default/images}/link_icon.gif (100%)
 rename {images => tpl/default/images}/mail_icon.gif (100%)
 rename {images => tpl/default/images}/open.gif (100%)
 rename {images => tpl/default/images}/tocdot2.gif (100%)
 rename {images => tpl/default/images}/windows.gif (100%)
 create mode 100644 tpl/default/layout.css
 create mode 100644 tpl/default/main.php
 rename print.css => tpl/default/print.css (100%)

diff --git a/conf/dokuwiki.php b/conf/dokuwiki.php
index 2204e7c05..bd9c4d4eb 100644
--- a/conf/dokuwiki.php
+++ b/conf/dokuwiki.php
@@ -23,6 +23,7 @@ $conf['uploadtypes'] = 'gif|jpe?g|png|zip|pdf|tar(\.gz)?|tgz'; //regexp of allow
 
 $conf['start']       = 'start';           //name of start page
 $conf['title']       = 'DokuWiki';        //what to show in the title
+$conf['template']    = 'default';         //see tpl directory
 $conf['fullpath']    = 0;                 //show full path of the document or relative to datadir only? 0|1
 $conf['recent']      = 20;                //how many entries to show in recent
 $conf['breadcrumbs'] = 10;                //how many recent visited pages to show
diff --git a/doku.php b/doku.php
index 5d706ab2e..24eeb94d5 100644
--- a/doku.php
+++ b/doku.php
@@ -14,6 +14,7 @@
   require_once(DOKU_INC.'lang/en/lang.php');
   require_once(DOKU_INC.'lang/'.$conf['lang'].'/lang.php');
   require_once(DOKU_INC.'inc/auth.php');
+  require_once(DOKU_INC.'inc/actions.php');
 
   //import variables
   $QUERY = trim($_REQUEST['id']);
@@ -58,152 +59,7 @@
   //make infos about the selected page available
   $INFO = pageinfo();
 
-  //already logged in?
-  if($_SERVER['REMOTE_USER'] && $ACT=='login') $ACT='show';
-  //handle logout
-  if($ACT=='logout'){
-    auth_logoff();
-    $ACT='login';
-  }
-
-  //handle register
-  if($ACT=='register' && register()){
-    $ACT='login';
-  }
-
-/*
-  //handle acl_admin stuff, add acl entry
-  if( ($ACT=='acl_admin_add') && (auth_quickaclcheck($ID) == AUTH_GRANT)){
-    acl_admin_change($ACL_SCOPE, $ACL_USER, "", $ACL_CHECKBOX);
-    # reload ACL into a global array
-    //$AUTH_ACL = file('conf/acl.auth');
-    $AUTH_ACL = load_acl_config();
-    $ACT='acl_admin';
-  }
-  
-  //handle acl_admin stuff, change acl entry
-  if( ($ACT=='acl_admin_change') && (auth_quickaclcheck($ID) == AUTH_GRANT)){
-    acl_admin_change($ACL_SCOPE, $ACL_USER, $ACL_LEVEL, $ACL_CHECKBOX);
-    # reload ACL into a global array
-    $AUTH_ACL = load_acl_config();
-    $ACT='acl_admin';
-  }
-  
-  //handle acl_admin_del stuff, remove acl entry
-  if( ($ACT=='acl_admin_del') && (auth_quickaclcheck($ID) == AUTH_GRANT)) {
-    acl_admin_del($ACL_SCOPE, $ACL_USER, $ACL_LEVEL);
-    # reload ACL into a global array
-    $AUTH_ACL = load_acl_config();
-    $ACT='acl_admin';
-  }
-*/
-
-  //do saving after spam- and conflictcheck
-  if($ACT == $lang['btn_save'] && auth_quickaclcheck($ID)){
-    if(checkwordblock()){
-      //spam detected
-      $ACT = 'wordblock';
-    }elseif($DATE != 0 && @filemtime(wikiFN($ID)) > $DATE ){
-      //newer version available -> ask what to do
-      $ACT = 'conflict';
-    }else{
-      //save it
-      saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM); //use pretty mode for con
-      //unlock it
-      unlock($id);
-      //show it
-      header("Location: ".wl($ID,'',true));
-      exit();
-    }
-  }
-
-  //Editing: check if locked by anyone - if not lock for my self
-  if(($ACT == 'edit' || $ACT == $lang['btn_preview']) && $INFO['editable']){
-    $lockedby = checklock($ID);
-    if($lockedby){
-      $ACT = 'locked';
-    }else{
-      lock($ID);
-    }
-  }else{
-    //try to unlock
-    unlock($ID);
-  }
-
-
-  //display some infos
-  if($ACT == 'check'){
-    check();
-    $ACT = 'show';
-  }
-
-  //check if searchword was given - else just show
-  if($ACT == 'search' && empty($QUERY)){
-    $ACT = 'show';
-  }
-
-  //check which permission is needed
-  if(in_array($ACT,array('preview','wordblock','conflict','lockedby'))){
-    if($INFO['exists']){
-      $permneed = AUTH_EDIT;
-    }else{
-      $permneed = AUTH_CREATE;
-    }
-  }elseif(in_array($ACT,array('login','register','search','recent'))){
-    $permneed = AUTH_NONE;
-  }else{
-    $permneed = AUTH_READ;
-  }
-
-  //start output
-  header('Content-Type: text/html; charset='.$lang['encoding']);
-  if(substr($ACT,0,6) != 'export') html_header();
-  if(html_acl($permneed)){
-    if($ACT == 'edit'){
-      html_edit();
-    }elseif($ACT == $lang['btn_preview']){
-      html_edit($TEXT);
-      html_show($TEXT);
-    }elseif($ACT == 'wordblock'){
-      html_edit($TEXT,'wordblock');
-    }elseif($ACT == 'search'){
-      html_search();
-    }elseif($ACT == 'revisions'){
-      html_revisions();
-    }elseif($ACT == 'diff'){
-      html_diff();
-    }elseif($ACT == 'recent'){
-      html_recent();
-    }elseif($ACT == 'index'){
-      html_index($IDX);
-    }elseif($ACT == 'backlink'){
-      html_backlinks();
-    }elseif($ACT == 'conflict'){
-      html_conflict(con($PRE,$TEXT,$SUF),$SUM);
-      html_diff(con($PRE,$TEXT,$SUF),false);
-    }elseif($ACT == 'locked'){
-      html_locked($lockedby);
-#    }elseif( ($ACT == 'acl_admin') && (auth_quickaclcheck($ID) == AUTH_GRANT)){
-#      html_acl_admin();
-    }elseif($ACT == 'login'){
-      html_login();
-    }elseif($ACT == 'register' && $conf['openregister']){
-      html_register();
-    }elseif($ACT == 'export_html'){
-      html_head();
-			print "<body>\n";
-			print parsedWiki($ID,$REV,false);
-			print "</body>\n</html>\n";
-		}elseif($ACT == 'export_raw'){
-			header("Content-Type: text/plain");
-      print rawWiki($ID,$REV);
-    }else{
-      $ACT='show';
-      html_show();
-    }
-  }
-  if(substr($ACT,0,6) != 'export') html_footer();
-
+  act_dispatch($ACT);
 
   //restore old umask
   umask($conf['oldumask']);
diff --git a/inc/actions.php b/inc/actions.php
new file mode 100644
index 000000000..345ef8e37
--- /dev/null
+++ b/inc/actions.php
@@ -0,0 +1,192 @@
+<?php
+/**
+ * DokuWiki Actions
+ *
+ * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author     Andreas Gohr <andi@splitbrain.org>
+ */
+
+  if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
+  require_once(DOKU_INC.'inc/template.php');
+
+/**
+ * Call the needed action handlers
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function act_dispatch(){
+  global $INFO;
+  global $ACT;
+  global $ID;
+  global $QUERY;
+  global $lang;
+  global $conf;
+
+  //check permissions
+  $ACT = act_permcheck($ACT);
+
+  //login stuff
+  if(in_array($ACT,array('login','logout','register')))
+    $ACT = act_login($ACT);
+ 
+  //save
+  if($ACT == 'save')
+    $ACT = act_save($ACT);
+
+  //edit
+  if(($ACT == 'edit' || $ACT == $lang['btn_preview']) && $INFO['editable']){
+    $ACT = act_save($ACT);
+  }else{
+    unlock($ID); //try to unlock 
+  }
+
+  //handle export
+  if(substr($ACT,0,6) == 'export')
+    $ACT = act_export($ACT);
+
+  //display some infos
+  if($ACT == 'check'){
+    check();
+    $ACT = 'show';
+  }
+
+  //check if searchword was given - else just show
+  if($ACT == 'search' && empty($QUERY)){
+    $ACT = 'show';
+  }
+
+  //fixme sanitize $ACT
+ 
+  //call template FIXME: all needed vars available?
+  header('Content-Type: text/html; charset=utf-8'); 
+  include(DOKU_INC.'tpl/'.$conf['template'].'/main.php');
+}
+
+/**
+ * Run permissionchecks
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function act_permcheck($act){
+  if(in_array($act,array('save','preview','edit'))){
+    if($INFO['exists']){
+      $permneed = AUTH_EDIT;
+    }else{
+      $permneed = AUTH_CREATE;
+    }
+  }elseif(in_array($act,array('login','register','search','recent'))){
+    $permneed = AUTH_NONE;
+  }else{
+    $permneed = AUTH_READ;
+  }
+  if(! auth_quickaclcheck($ID) >= $permneed){
+    return 'denied';
+  }
+
+  return $act;
+}
+
+/**
+ * Handle 'save'
+ *
+ * Checks for spam and conflicts and saves the page.
+ * Does a redirect to show the page afterwards or
+ * returns a new action.
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function act_save($act){
+  global $ID;
+  global $DATE;
+  global $PRE;
+  global $TEXT;
+  global $SUF;
+  global $SUM;
+
+  //spam check
+  if(checkwordblock())
+    return 'wordblock';
+  //conflict check //FIXME use INFO
+  if($DATE != 0 && @filemtime(wikiFN($ID)) > $DATE )
+    return 'conflict';
+
+  //save it
+  saveWikiText($ID,con($PRE,$TEXT,$SUF,1),$SUM); //use pretty mode for con
+  //unlock it
+  unlock($ID);
+      
+  //show it
+  session_write_close();
+  header("Location: ".wl($ID,'',true));
+  exit();
+}
+
+/**
+ * Handle 'login', 'logout', 'register'
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function act_auth($act){
+  //already logged in?
+  if($_SERVER['REMOTE_USER'] && $act=='login')
+    return 'show';
+
+  //handle logout
+  if($act=='logout'){
+    auth_logoff();
+    return 'login';
+  }
+
+  //handle register
+  if($act=='register' && register()){
+    $act='login';
+  }
+
+  return $act;
+}
+
+/**
+ * Handle 'edit', 'preview'
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function act_edit($act){
+  //check if locked by anyone - if not lock for my self
+  $lockedby = checklock($ID);
+  if($lockedby) return 'locked';
+
+  lock($ID);
+  return $act;
+}
+
+/**
+ * Handle 'edit', 'preview'
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function act_export($act){
+  global $ID;
+  global $REV;
+
+  if($act == 'export_html'){
+    header('Content-Type: text/html; charset=utf-8');
+    ptln('<html>');
+    ptln('<head>');
+    tpl_metaheaders();
+    ptln('</head>');
+    ptln('<body>');
+    print parsedWiki($ID,$REV,false);
+    ptln('</body>');
+    ptln('</html>');
+    exit;
+  }
+
+  if($act == 'export_raw'){
+    header('Content-Type: text/plain; charset=utf-8');
+    print rawWiki($ID,$REV);
+    exit;
+  }
+
+  return 'show';
+}
+?>
diff --git a/inc/common.php b/inc/common.php
index b06896f4d..482bb1e2d 100644
--- a/inc/common.php
+++ b/inc/common.php
@@ -369,7 +369,6 @@ function cleanID($id){
   if($conf['deaccent']) $id = utf8_deaccent($id,-1);
 
   //remove specials
-  //$id = preg_replace('#[\x00-\x20 ¡!"§$%&()\[\]{}¿\\?`\'\#~*+=,<>\|^°@µ¹²³¼½¬]#u','_',$id);
   $id = utf8_stripspecials($id,'_','_:.-');
 
   //clean up
@@ -815,6 +814,7 @@ function download($url,$file){
 /**
  * extracts the query from a google referer
  *
+ * @todo   should be more generic and support yahoo et al
  * @author Andreas Gohr <andi@splitbrain.org>
  */
 function getGoogleQuery(){
diff --git a/inc/html.php b/inc/html.php
index 36bd25e2f..85e3189ea 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -147,6 +147,7 @@ function html_secedit($text,$show=true){
 /**
  * displays the breadcrumbs trace
  *
+ * @deprecated
  * @author Andreas Gohr <andi@splitbrain.org>
  */
 function html_breadcrumbs(){
@@ -169,6 +170,7 @@ function html_breadcrumbs(){
 /**
  * display the HTML head and metadata
  *
+ * @deprecated -> tpl_metaheaders()
  * @author Andreas Gohr <andi@splitbrain.org>
  */
 function html_head(){
@@ -230,6 +232,21 @@ function html_head(){
 <?
 }
 
+/**
+ * Just the back to top button (in it's own form)
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function html_topbtn(){
+  global $lang;
+
+  $ret  = '';
+  $ret .= '<form class="button" method="get" action="#top" onsubmit="return svchk()">';
+  $ret .= '<input type="submit" value="'.htmlspecialchars($lang['btn_top']).'" class="button" ';
+  $ret .= '</form>';
+  return $ret;
+}
+
 /**
  * Displays a button (using it's own form)
  *
diff --git a/inc/init.php b/inc/init.php
index 46046ab29..abedbfbbf 100644
--- a/inc/init.php
+++ b/inc/init.php
@@ -20,6 +20,10 @@
   // define main script
   if(!defined('DOKU_SCRIPT')) define('DOKU_SCRIPT','doku.php');
 
+  // define Template baseURL
+  if(!defined('DOKU_TPL')) define('DOKU_TPL',
+                                  DOKU_BASE.'tpl/'.$conf['template'].'/');
+
   // set up error reporting to sane values
   error_reporting(E_ALL ^ E_NOTICE);
 
@@ -28,7 +32,7 @@
 
   // init session
   session_name("DokuWiki");
-  session_start();
+  if (!headers_sent()) session_start();
 
   // kill magic quotes
   if (get_magic_quotes_gpc()) {
diff --git a/inc/template.php b/inc/template.php
new file mode 100644
index 000000000..00de7ad67
--- /dev/null
+++ b/inc/template.php
@@ -0,0 +1,314 @@
+<?php
+/**
+ * DokuWiki template functions
+ *
+ * @license    GPL 2 (http://www.gnu.org/licenses/gpl.html)
+ * @author     Andreas Gohr <andi@splitbrain.org>
+ */
+
+  if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__).'/../').'/');
+  require_once(DOKU_INC.'conf/dokuwiki.php');
+
+/**
+ * Wrapper around htmlspecialchars()
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @see    htmlspecialchars()
+ */
+function hsc($string){
+  return htmlspecialchars($string);
+}
+
+/**
+ * print a newline terminated string
+ *
+ * You can give an indention as optional parameter
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function ptln($string,$intend=0){
+  for($i=0; $i<$intend; $i++) print ' ';
+  print"$string\n";
+}
+
+/**
+ * Print the content
+ *
+ * This function is used for printing all the usual content
+ * (defined by the global $ACT var) by calling the appropriate
+ * outputfunction(s) from html.php
+ *
+ * Everything that doesn't use the default template isn't
+ * handled by this function. ACL stuff is not done either.
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function tpl_content(){
+  global $ACT;
+  global $TEXT;
+  global $PRE;
+  global $SUF;
+  global $SUM;
+  global $IDX;
+  global $lang;
+
+  switch($ACT){
+    case 'show':
+      html_show();
+      break;
+    case $lang['btn_preview']:
+      html_edit($TEXT);
+      html_show($TEXT);
+      break;
+    case 'edit':
+      html_edit();
+      break;
+    case 'wordblock':
+      html_edit($TEXT,'wordblock');
+      break;
+    case 'search':
+      html_search();
+      break;
+    case 'revisions':
+      html_revisions();
+      break;
+    case 'diff':
+      html_diff();
+      break;
+    case 'recent':
+      html_recent();
+      break;
+    case 'index':
+      html_index($IDX); #FIXME can this be pulled from globals? is it sanitized correctly?
+      break;
+    case 'backlink':
+      html_backlinks();
+      break;
+    case 'conflict':
+      html_conflict(con($PRE,$TEXT,$SUF),$SUM);
+      html_diff(con($PRE,$TEXT,$SUF),false);
+      break;
+    case 'locked':
+      html_locked($lockedby);
+      break;
+    case 'login':
+      html_login();
+      break;
+    case 'register':
+      #FIXME check for $conf['openregister']) needs to be done first!!
+      html_register();
+      break;
+    default:
+      print "Uhm... Where am I? This shouldn't happen";
+  }
+}
+
+
+
+/**
+ * Print the correct HTML meta headers
+ *
+ * This has to go into the head section of your template.
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function tpl_metaheaders(){
+  global $ID;
+  global $INFO;
+  global $ACT;
+  global $lang;
+  $it=2;
+
+  // the usual stuff
+  ptln('<meta name="generator" content="DokuWiki '.getVersion().'" />',$it);
+  ptln('<link rel="start" href="'.DOKU_BASE.'" />',$it);
+  ptln('<link rel="contents" href="'.wl($ID,'do=index').'" title="'.$lang['index'].'" />',$it);
+  ptln('<link rel="alternate" type="application/rss+xml" title="Recent Changes" href="'.DOKU_BASE.'feed.php" />',$it);
+  ptln('<link rel="alternate" type="application/rss+xml" title="Current Namespace" href="'.DOKU_BASE.'feed.php?mode=list&amp;ns='.$INFO['namespace'].'" />',$it);
+  ptln('<link rel="alternate" type="text/html" title="Plain HTML" href="'.wl($ID,'do=export_html').'" />',$it);
+  ptln('<link rel="alternate" type="text/plain" title="Wiki Markup" href="'.wl($ID, 'do=export_raw').'" />',$it);
+  ptln('<link rel="stylesheet" media="screen" type="text/css" href="'.DOKU_BASE.'style.css" />',$it);
+
+  // setup robot tags apropriate for different modes
+  if( ($ACT=='show' || $ACT=='export_html') && !$REV){
+    if($INFO['exists']){
+      ptln('<meta name="date" content="'.date('Y-m-d\TH:i:sO',$INFO['lastmod']).'" />',$it);
+      //delay indexing:
+      if((time() - $INFO['lastmod']) >= $conf['indexdelay']){
+        ptln('<meta name="robots" content="index,follow" />',$it);
+      }else{
+        ptln('<meta name="robots" content="noindex,nofollow" />',$it);
+      }
+    }else{
+      ptln('<meta name="robots" content="noindex,follow" />',$it);
+    }
+  }else{
+    ptln('<meta name="robots" content="noindex,nofollow" />',$it);
+  }
+
+  // include some JavaScript language strings
+  ptln('<script language="JavaScript" type="text/javascript">',$it);
+  ptln("  var alertText   = '".$lang['qb_alert']."'",$it);
+  ptln("  var notSavedYet = '".$lang['notsavedyet']."'",$it);
+  ptln("  var DOKU_BASE   = '".DOKU_BASE."'",$it);
+  ptln('</script>',$it);
+ 
+  // load the default JavaScript file
+  ptln('<script language="JavaScript" type="text/javascript" src="'.DOKU_BASE.'script.js"></script>',$it);
+
+
+  //FIXME include some default CSS ? IE FIX?
+}
+
+/**
+ * Print a link
+ *
+ * Just builds a link but adds additional JavaScript needed for
+ * the unsaved data check needed in the edit form.
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function tpl_link($url,$name,$more=''){
+  print '<a href="'.$url.'" onclick="return svchk()" onkeypress="return svchk()"';
+  if ($more) print ' '.$more;
+  print ">$name</a>";
+}
+
+/**
+ * Print one of the buttons
+ *
+ * Available Buttons are
+ *
+ *  edit    - edit/create/show button
+ *  history - old revisions
+ *  recent  - recent changes
+ *  login   - login/logout button - if ACL enabled
+ *  index   - The index
+ *  top     - a back to top button
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function tpl_button($type){
+  global $ID;
+  global $conf;
+
+  switch($type){
+    case 'edit':
+      print html_editbutton();
+      break;
+    case 'history':
+      print html_btn(revs,$ID,'o',array('do' => 'revisions'));
+      break;
+    case 'recent':
+      print html_btn(recent,'','r',array('do' => 'recent'));
+      break;
+    case 'index':
+      print html_btn(index,$ID,'x',array('do' => 'index'));
+      break;
+    case 'top':
+      print html_topbtn();
+      break;
+    case 'login':
+      if($conf['useacl']){
+        if($_SERVER['REMOTE_USER']){
+          print html_btn('logout',$ID,'',array('do' => 'logout',));
+        }else{
+          print html_btn('login',$ID,'',array('do' => 'login'));
+        }
+      }
+      break;
+  }
+}
+
+/**
+ * Print the search form
+ *
+ * @todo   svcheck missing
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function tpl_searchform(){
+  global $lang;
+  print '<form action="'.wl().'" accept-charset="utf-8" class="search">';
+  print '<input type="hidden" name="do" value="search" />';
+  print '<input type="text" accesskey="f" name="id" class="edit" />';
+  print '<input type="submit" value="'.$lang['btn_search'].'" class="button" />';
+  print '</form>';
+}
+
+/**
+ * Print the breadcrumbs trace
+ *
+ * @todo   add a hierachical breadcrumb function
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function tpl_breadcrumbs(){
+  global $lang;
+  global $conf;
+
+  //check if enabled
+  if(!$conf['breadcrumbs']) return;
+
+  $crumbs = breadcrumbs(); //setup crumb trace
+  print $lang['breadcrumb'].':';
+  foreach ($crumbs as $crumb){
+    print ' &raquo; ';
+    tpl_link(wl($crumb),noNS($crumb),'class="breadcrumbs" title="'.$crumb.'"');
+  }
+}
+
+/**
+ * Print info if the user is logged in
+ *
+ * Could be enhanced with a profile link in future?
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function tpl_userinfo(){
+  global $lang;
+  if($_SERVER['REMOTE_USER'])
+    print $lang['loggedinas'].': '.$_SERVER['REMOTE_USER'];
+}
+
+/**
+ * Print some info about the current page
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+function tpl_pageinfo(){
+  global $conf;
+  global $lang;
+  global $INFO;
+  global $REV;
+
+  // prepare date and path
+  $fn = $INFO['filepath'];
+  if(!$conf['fullpath']){
+    if($REV){
+      $fn = str_replace(realpath($conf['olddir']).DIRECTORY_SEPARATOR,'',$fn);
+    }else{
+      $fn = str_replace(realpath($conf['datadir']).DIRECTORY_SEPARATOR,'',$fn);
+    }
+  }
+  $date = date($conf['dformat'],$INFO['lastmod']);
+
+  // print it
+  if($INFO['exists']){
+    print $fn;
+    print ' &middot; ';
+    print $lang['lastmod'];
+    print ': ';
+    print $date;
+    if($INFO['editor']){
+      print ' '.$lang['by'].' ';
+      print $INFO['editor'];
+    }
+    if($INFO['locked']){
+      print ' &middot; ';
+      print $lang['lockedby'];
+      print ': ';
+      print $INFO['locked'];
+    }
+  }
+}
+
+?>
diff --git a/media.php b/media.php
index 7413a2b7a..7d67f971e 100644
--- a/media.php
+++ b/media.php
@@ -1,6 +1,6 @@
 <?php
   if(!defined('DOKU_INC')) define('DOKU_INC',realpath(dirname(__FILE__)).'/');
-  require_once(DOKU_INC.'conf/init.php');
+  require_once(DOKU_INC.'inc/init.php');
   require_once(DOKU_INC.'inc/common.php');
   require_once(DOKU_INC.'lang/en/lang.php');
   require_once(DOKU_INC.'lang/'.$conf['lang'].'/lang.php');
diff --git a/style.css b/style.css
index 516328c50..4e19909bf 100644
--- a/style.css
+++ b/style.css
@@ -1,169 +1,5 @@
-body {
-  font: 80% "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif;
-  background-color: White;
-  color: Black;
-  margin: 0;
-  padding: 0;
-}
-
 div.clearer {clear: both; line-height: 0; height: 0;}
 
-table {
-  font-size: 100%;
-  padding:0;
-  margin:0;
-}
-
-tr,td,th {padding:0; margin:0;}
-
-img {border:0}
-
-p {padding:0; margin: 0 0 1.0em 0;}
-
-hr {
-  border: 0px;
-  border-top: 1px solid #8cacbb;
-  text-align:center;
-  height: 0px;
-}
-
-form {
-  border: none;
-  margin: 0;
-  display: inline;
-}
-
-label {
-  display: block;
-  text-align: right;
-  font-weight: bold;
-}
-
-label.simple {
-  text-align: left;
-  font-weight: normal;
-}
-
-label input.edit {
-  width: 50%;
-}
-
-fieldset {
-  width: 300px;
-  text-align: center;
-  border: 1px solid #8cacbb;
-  padding: 0.5em;
-}
-
-
-a {
-  color:#436976;
-  text-decoration:none;
-}
-a:hover {
-  color:#000000;
-  text-decoration:underline;
-}
-
-textarea.edit {
-  font-family:monospace;
-  border: 1px solid #8cacbb;  
-  color: Black;
-  background-color: white;
-  font-size:14px;
-  padding: 3px;
-  width:100%;
-}
-
-input.edit {
-  font-size: 100%;
-  border: 1px solid #8cacbb;
-  height: 22px ! important;
-  max-height: 22px ! important;
-  min-height: 22px ! important;
-  color: Black;
-  background-color: white;
-  vertical-align: middle;
-  padding: 1px;
-  display: inline;
-}
-
-input.missing {
-  font-size: 100%;
-  border: 1px solid #8cacbb;
-  height: 22px ! important;
-  max-height: 22px ! important;
-  min-height: 22px ! important;
-  color: Black;
-  background-color: #ffcccc;
-  vertical-align: middle;
-  padding: 1px;
-  display: inline;
-}
-
-input.button {
-  border: 1px solid #8cacbb;  
-  color: Black;
-  background-color: white;
-  vertical-align: middle;
-  text-decoration:none;
-  font-size: 100%;
-  cursor: pointer;
-  height: 22px ! important;
-  max-height: 22px ! important;
-  min-height: 22px ! important;
-  margin: 1px;
-  display: inline;
-}
-
-div.secedit input.button {
-  border: 1px solid #8cacbb;
-  color: Black;
-  background-color: white;
-  vertical-align: middle;
-  text-decoration:none;
-  margin: 0px;
-  padding: 0px;
-  font-size: 10px;
-  cursor: pointer;
-  height: 15px;
-  max-height: 15px ! important;
-  min-height: 15px ! important;
-  float:right;
-  display: inline;
-}
-
-div.meta {
-  clear: both;
-  margin-top: 1em;
-  color:#436976;
-  font-size:70%;
-  text-align:right;
-}
-
-div.user {
-  float:left;
-}
-
-div.preview{
-  background:#f7f9fa;
-  margin-left:2em;
-  padding: 4px;
-  border: 1px dashed #000000;
-}
-
-div.breadcrumbs{
-  background-color: #f5f5f5;
-  font-size:80%;
-  color: #666666;
-  padding-left: 4px;
-}
-
-span.user{
-  color: #cccccc;
-  font-size: 90%;
-}
-
 div.error{
   background: #ff6666 url(images/error.png) 0.5em 0px no-repeat;
   font-size: 90%;
@@ -185,497 +21,6 @@ div.success{
   padding-left: 3em;
 }
 
-/* ---------------------------- Diff rendering --------------------------*/
-table.diff { background:white; }
-td.diff-blockheader {font-weight:bold}
-td.diff-header {
-  border-bottom: 1px solid #8cacbb;
-  font-size:120%;
-}
-td.diff-addedline {
-    background:#ddffdd;
-    font-family: monospace;
-    font-size: 100%;
-}
-td.diff-deletedline { 
-    background:#ffffbb;
-    font-family: monospace;    
-    font-size: 100%;
-}
-td.diff-context {
-    background:#f7f9fa;
-    font-family: monospace;
-    font-size: 100%;
-}
-span.diffchange { color: red; }
-
-
-
-/* --------------------- Text formatting -------------------------------- */
-
-/* external link */
-a.urlextern{
-    background: transparent url(images/link_icon.gif) 0px 1px no-repeat;
-    padding: 1px 0px 1px 16px;
-    color:#436976;
-    text-decoration:none;
-}
-a.urlextern:visited {
-  color:Purple;
-}
-a.urlextern:hover {
-  text-decoration:underline;
-}
-
-/* windows share */
-a.windows{
-    background: transparent url(images/windows.gif) 0px 1px no-repeat;
-    padding: 1px 0px 1px 16px;
-    color:#436976;
-    text-decoration:none;
-} 
-a.windows:visited {
-  color:Purple;
-}
-a.windows:hover { 
-  text-decoration:underline;
-}
-
-/* interwiki link */
-a.interwiki{
-    background: transparent url(images/interwiki.png) 0px 1px no-repeat;
-    padding: 1px 0px 1px 16px;
-    color:#436976;
-    text-decoration:none;
-}
-a.interwiki:visited {
-  color:Purple;
-}
-a.interwiki:hover {
-  text-decoration:underline;
-}
-
-/* link to some embedded media */
-a.media {
-  color:#436976;
-  text-decoration:none;
-}
-a.media:hover {
-  color:#436976;
-  text-decoration:underline
-}
-
-/* embedded images */
-img.media {
-  margin: 3px;
-}
-
-img.medialeft {
-  border: 0;
-  float: left;
-  margin: 0 1.5em 0 0;
-}
-
-img.mediaright {
-  border: 0;
-  float: right;
-  margin: 0 0 0 1.5em;
-}
-
-/* email link */
-a.mail {
-  background: transparent url(images/mail_icon.gif) 0px 1px no-repeat;
-  padding: 1px 0px 1px 16px;
-  color:#436976;
-  text-decoration:none;
-}
-a.mail:hover {
-  text-decoration:underline;
-}
-
-/* existing wikipage */
-a.wikilink1:link    { color:#009900; text-decoration:none }
-a.wikilink1:visited { color:#009900; text-decoration:none }
-a.wikilink1:hover   { color:#009900; text-decoration:underline }
-
-/* not exisitng wikipage */
-a.wikilink2:link    { color:#FF3300; text-decoration:none }
-a.wikilink2:visited { color:#FF3300; text-decoration:none }
-a.wikilink2:hover   { color:#FF3300; text-decoration:underline }
-
-acronym {
-  cursor: help;
-  border-bottom: 1px dotted #000;
-}
-
-/* the document */
-div.page {
-  margin-top: 4px;
-  margin-left:  1em;
-  margin-right: 2em;
-  text-align: justify;
-}
-
-/* general headline setup */
-h1, h2, h3, h4, h5 {
-    color: Black;
-    background-color: transparent;
-    font-family: "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif;
-    font-size: 100%;
-    font-weight: normal;
-    margin-left:    0;
-    margin-right:   0;
-    margin-top:     0;
-    margin-bottom:  1em;
-    padding-left:   0;
-    padding-right:  0;
-    padding-top:    0.5em;
-    padding-bottom: 0;
-    border-bottom: 1px solid #8cacbb;
-    clear: left;
-}
-
-/* special headlines */
-h1 {font-size: 160%; margin-left: 0px; font-weight: bold;}
-h2 {font-size: 150%; margin-left: 20px;}
-h3 {font-size: 140%; margin-left: 40px; border-bottom: none; font-weight: bold;}
-h4 {font-size: 120%; margin-left: 60px; border-bottom: none; font-weight: bold;}
-h5 {font-size: 100%; margin-left: 80px; border-bottom: none; font-weight: bold;}
-
-/* indent different sections */
-div.level1 {margin-left: 3px;}
-div.level2 {margin-left: 23px;}
-div.level3 {margin-left: 43px;}
-div.level4 {margin-left: 63px;}
-div.level5 {margin-left: 83px;}
-
-/* unordered lists */
-ul { 
-  line-height: 1.5em;
-  list-style-type: square;
-  margin: 0.5em 0 0.5em 1.5em;
-  padding: 0;
-  list-style-image: url(images/bullet.gif);
-}
-
-/* ordered lists */
-ol {
-  line-height: 1.5em;
-  margin: 0.5em 0 0.5em 1.5em;
-  padding: 0;
-  color: #638c9c;
-  font-weight: bold;
-  list-style-image: none;
-}
-
-/* the list items overriding the ol definition */
-span.li {
-  color: #000000;
-  font-weight: normal;
-}
-
-li.open {
-  list-style-image: url(images/open.gif);
-}
-
-li.closed {
-  list-style-image: url(images/closed.gif);
-}
-
-.quote {
-  border-left: 2px solid #8cacbb;
-  padding-left: 3px;
-}
-
-/* code blocks by indention */
-pre.pre {
-  font-size: 120%;
-  padding: 0.5em;
-  border: 1px dashed #8cacbb;
-  color: Black;
-  background-color: #f7f9fa;
-  overflow: auto;
-}
-
-/* code blocks by code tag */
-pre.code {
-  font-size: 120%;
-  padding: 0.5em;
-  border: 1px dashed #8cacbb;
-  color: Black;
-  background-color: #f7f9fa;
-  overflow: auto;
-}
-
-/* code highlighting is at bottom of file */
-
-/* inline code words */
-code {
-  font-size: 120%;
-}
-
-/* code blocks by file tag */
-pre.file {
-  font-size: 120%;
-  padding: 0.5em;
-  border: 1px dashed #8cacbb;
-  color: Black;
-  background-color: #dee7ec;
-  overflow: auto;
-}
-
-/* footnotes */
-div.footnotes{
-  clear:both;
-  border-top: 1px solid #8cacbb;
-  padding-left: 1em;
-  margin-top: 1em;
-}
-
-div.fn{
-  font-size:90%;
-}
-
-a.fn_top{
-  vertical-align:super;
-  font-size:80%;
-}
-
-a.fn_bot{
-  vertical-align:super;
-  font-size:80%;
-  font-weight:bold;
-}
-
-/* inline tables */
-table.inline {
-  background-color: #ffffff;
-  border-spacing: 0px;
-  border-collapse: collapse;
-}
-
-table.inline th {
-  padding: 3px;
-  border: 1px solid #8cacbb;
-  background-color: #dee7ec;
-}
-
-table.inline td {
-  padding: 3px;
-  border: 1px solid #8cacbb;
-}
-
-.leftalign{
-  text-align: left;
-}
-
-.centeralign{
-  text-align: center;
-}
-
-.rightalign{
-  text-align: right;
-}
-
-/* ---------- table of contents ------------------- */
-
-div.toc {
-  margin-left: 2em;
-  margin-top: 1.2em;
-  margin-bottom: 0;
-  float:right;
-  width: 200px;
-  font-size: 80%;
-  clear:both;
-}
-
-div.tocheader {
-  padding: 3px;
-  border: 1px solid #8cacbb;
-  background-color: #dee7ec;
-  text-align: left;
-  font-weight:bold;
-  margin-bottom: 2px;
-}
-
-#tocinside {
-  border: 1px solid #8cacbb;
-  background-color: #ffffff;
-  text-align: left;
-  padding-top: 0.5em;
-  padding-bottom: 0.7em;
-}
-
-ul.toc {
-  list-style-type: none;
-  list-style-image: none;
-  line-height: 1.2em;
-  margin: 0;
-  padding: 0;
-  padding-left: 1em;
-}
-
-ul.toc li {
-  background: transparent url(images/tocdot2.gif) 0 0.6em no-repeat;
-  padding-left:0.4em;
-}
-
-ul.toc li.clear {
-/*  background: transparent url(images/blank.gif) 0 0.6em no-repeat;*/
-  background-image: none;
-  padding-left:0.4em;
-}
-
-a.toc {
-  color: #436976;
-  text-decoration:none;
-}
-
-a.toc:hover {
-  color: #000000;
-  text-decoration:underline; 
-}
-
-/* --------------- search result formating --------------- */
-.search_result{
-  margin-bottom: 6px;
-  padding-left: 30px;
-  padding-right: 10px;
-}
-
-.search_snippet{
-  color: #999999;
-  font-size: 12px;
-  margin-left: 20px;
-}
-
-.search_sep{
-  color: #000000;
-}
-
-.search_hit{
-  color: #000000;
-  background: #FFFF99;
-}
-
-div.search_quickresult{
-  margin-bottom: 15px;
-  padding-bottom: 5px;
-  border-bottom: 1px dashed #8cacbb;
-  margin-left: 30px;
-  padding-right: 10px;
-}
-
-div.search_quickhits {
-  margin-left: 1em;
-  float:left;
-  background: transparent url(images/bullet.gif) 0px 1px no-repeat;
-  padding: 1px 0px 1px 8px;
-  width: 30%;
-}
-
-/* debug */
-pre.dbg{
-  background-color:#ffffff;
-  font-size: 120%;
-}
-
-/* Tableless Headers and Footers */
-/* Thanks to "moraes" <moraes@tipos.com.br> */
-
-.header {
-	height:35px;
-	padding:3px 0 2px 2px;
-}
-
-.pagename {
-	height:25px;
-	float:left;
-	font-size:200%;
-	font-weight:bolder;
-	color:#DEE7EC;
-	text-align:left;
-	vertical-align:middle;
-	padding:1px 0 0 1px;
-}
-
-.pagename a:link, .pagename a:visited {
-  color:#436976;
-  text-decoration:none;
-}
-
-.pagename a:hover, .pagename a:active {
-  color:#FF9933;
-}
-
-.logo {
-	float:right;
-	font-size:220%;
-	font-weight:bolder;
-	text-align:right;
-	vertical-align:middle;
-}
-
-.logo a:link, .logo a:visited, .logo a:hover, .logo a:active {
-	color:#dee7ec;
-	text-decoration:none;
-	font-variant:small-caps;
-	letter-spacing:2pt;
-}
-
-.bar {
-	height:25px;
-	border-top:1px solid #8CACBB;
-	border-bottom:1px solid #8CACBB;
-	background:#DEE7EC;
-	padding:2px;
-	margin:0;
-}
-
-.bar-left {
-	float:left;
-  width:50%;
-}
-
-.bar-right {
-	float:right;
-  width:50%;
-  text-align:right;
-}
-
-#bar_bottom {
-  margin-bottom:3px;
-}
-
-.mediaselect-left {
-  float:left;
-  padding: 0.5em;
-  height:230px;
-  overflow:auto;
-}
-
-.mediaselect-right {
-  float:right;
-  border-left: 1px solid #8cacbb;
-  padding: 0.5em;
-  width:350px;
-  height:230px;
-  overflow:auto;
-}
-
-div.uploadform {
-  margin-top: 0.5em;
-  border-top: 1px solid #8cacbb;
-}
-
-.footerinc a img {
-    opacity: 0.5;
-}
-
-.footerinc a:hover img {
-    opacity: 1;
-}
-
 /* syntax highlighting code */
 .code .br0	{ color: #66cc66; }
 .code .co1	{ color: #808080; font-style: italic; }
@@ -697,4 +42,3 @@ div.uploadform {
 .code .sc1	{ color: #ddbb00; }
 .code .sc2	{ color: #009900; }
 .code .st0	{ color: #ff0000; }
-
diff --git a/tpl/default/design.css b/tpl/default/design.css
new file mode 100644
index 000000000..2a428a1e5
--- /dev/null
+++ b/tpl/default/design.css
@@ -0,0 +1,562 @@
+/**
+ * Design elements for default Template
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @author Anika Henke <henke@cosmocode.de>
+ */
+
+/* -------------- general elements --------------- */
+
+body {
+  font: 80% "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif;
+  background-color: White;
+  color: Black;
+  margin: 0;
+  padding: 0;
+}
+
+/* the document */
+div.page {
+  margin-top: 4px;
+  margin-left:  1em;
+  margin-right: 2em;
+  text-align: justify;
+}
+
+table {
+  font-size: 100%;
+  padding:0;
+  margin:0;
+}
+
+tr,td,th {padding:0; margin:0;}
+
+img {border:0}
+
+p {padding:0; margin: 0 0 1.0em 0;}
+
+hr {
+  border: 0px;
+  border-top: 1px solid #8cacbb;
+  text-align:center;
+  height: 0px;
+}
+
+/* ---------------- forms ------------------------ */
+
+form {
+  border: none;
+  margin: 0;
+  display: inline;
+}
+
+label {
+  display: block;
+  text-align: right;
+  font-weight: bold;
+}
+
+label.simple {
+  text-align: left;
+  font-weight: normal;
+}
+
+label input.edit {
+  width: 50%;
+}
+
+fieldset {
+  width: 300px;
+  text-align: center;
+  border: 1px solid #8cacbb;
+  padding: 0.5em;
+}
+
+textarea.edit {
+  font-family:monospace;
+  border: 1px solid #8cacbb;  
+  color: Black;
+  background-color: white;
+  font-size:14px;
+  padding: 3px;
+  width:100%;
+}
+
+input.edit {
+  font-size: 100%;
+  border: 1px solid #8cacbb;
+  height: 22px !important;
+  max-height: 22px !important;
+  min-height: 22px !important;
+  color: Black;
+  background-color: white;
+  vertical-align: middle;
+  padding: 1px;
+  display: inline;
+}
+
+input.missing {
+  font-size: 100%;
+  border: 1px solid #8cacbb;
+  height: 22px !important;
+  max-height: 22px !important;
+  min-height: 22px !important;
+  color: Black;
+  background-color: #ffcccc;
+  vertical-align: middle;
+  padding: 1px;
+  display: inline;
+}
+
+/* --------- buttons ------------------- */
+
+
+input.button {
+  border: 1px solid #8cacbb;  
+  color: Black;
+  background-color: white;
+  vertical-align: middle;
+  text-decoration:none;
+  font-size: 100%;
+  cursor: pointer;
+  height: 22px !important;
+  max-height: 22px !important;
+  min-height: 22px !important;
+  margin: 1px;
+  display: inline;
+}
+
+div.secedit input.button {
+  border: 1px solid #8cacbb;
+  color: Black;
+  background-color: white;
+  vertical-align: middle;
+  text-decoration:none;
+  margin: 0px;
+  padding: 0px;
+  font-size: 10px;
+  cursor: pointer;
+  height: 15px;
+  max-height: 15px !important;
+  min-height: 15px !important;
+  float:right;
+  display: inline;
+}
+
+/* --------------- Links ------------------ */
+
+a {
+  color:#436976;
+  text-decoration:none;
+}
+a:hover {
+  color:#000000;
+  text-decoration:underline;
+}
+
+/* external link */
+a.urlextern{
+    background: transparent url(images/link_icon.gif) 0px 1px no-repeat;
+    padding: 1px 0px 1px 16px;
+    color:#436976;
+    text-decoration:none;
+}
+a.urlextern:visited {
+  color:Purple;
+}
+a.urlextern:hover {
+  text-decoration:underline;
+}
+
+/* windows share */
+a.windows{
+    background: transparent url(images/windows.gif) 0px 1px no-repeat;
+    padding: 1px 0px 1px 16px;
+    color:#436976;
+    text-decoration:none;
+} 
+a.windows:visited {
+  color:Purple;
+}
+a.windows:hover { 
+  text-decoration:underline;
+}
+
+/* interwiki link */
+a.interwiki{
+    background: transparent url(images/interwiki.png) 0px 1px no-repeat;
+    padding: 1px 0px 1px 16px;
+    color:#436976;
+    text-decoration:none;
+}
+a.interwiki:visited {
+  color:Purple;
+}
+a.interwiki:hover {
+  text-decoration:underline;
+}
+
+/* link to some embedded media */
+a.media {
+  color:#436976;
+  text-decoration:none;
+}
+a.media:hover {
+  color:#436976;
+  text-decoration:underline
+}
+
+/* email link */
+a.mail {
+  background: transparent url(images/mail_icon.gif) 0px 1px no-repeat;
+  padding: 1px 0px 1px 16px;
+  color:#436976;
+  text-decoration:none;
+}
+a.mail:hover {
+  text-decoration:underline;
+}
+
+/* existing wikipage */
+a.wikilink1:link    { color:#009900; text-decoration:none }
+a.wikilink1:visited { color:#009900; text-decoration:none }
+a.wikilink1:hover   { color:#009900; text-decoration:underline }
+
+/* not existing wikipage */
+a.wikilink2:link    { color:#FF3300; text-decoration:none }
+a.wikilink2:visited { color:#FF3300; text-decoration:none }
+a.wikilink2:hover   { color:#FF3300; text-decoration:underline }
+
+
+/* ------------- Page elements ----------------- */
+
+div.preview{
+  background:#f7f9fa;
+  margin-left:2em;
+  padding: 4px;
+  border: 1px dashed #000000;
+}
+
+div.breadcrumbs{
+  background-color: #f5f5f5;
+  font-size:80%;
+  color: #666666;
+  padding-left: 4px;
+}
+
+span.user{
+  color: #cccccc;
+  font-size: 90%;
+}
+
+/* embedded images */
+img.media {
+  margin: 3px;
+}
+
+img.medialeft {
+  border: 0;
+  float: left;
+  margin: 0 1.5em 0 0;
+}
+
+img.mediaright {
+  border: 0;
+  float: right;
+  margin: 0 0 0 1.5em;
+}
+
+acronym {
+  cursor: help;
+  border-bottom: 1px dotted #000;
+}
+
+/* general headline setup */
+h1, h2, h3, h4, h5 {
+    color: Black;
+    background-color: transparent;
+    font-family: "Lucida Grande", Verdana, Lucida, Helvetica, Arial, sans-serif;
+    font-size: 100%;
+    font-weight: normal;
+    margin-left:    0;
+    margin-right:   0;
+    margin-top:     0;
+    margin-bottom:  1em;
+    padding-left:   0;
+    padding-right:  0;
+    padding-top:    0.5em;
+    padding-bottom: 0;
+    border-bottom: 1px solid #8cacbb;
+    clear: left;
+}
+
+/* special headlines */
+h1 {font-size: 160%; margin-left: 0px; font-weight: bold;}
+h2 {font-size: 150%; margin-left: 20px;}
+h3 {font-size: 140%; margin-left: 40px; border-bottom: none; font-weight: bold;}
+h4 {font-size: 120%; margin-left: 60px; border-bottom: none; font-weight: bold;}
+h5 {font-size: 100%; margin-left: 80px; border-bottom: none; font-weight: bold;}
+
+/* indent different sections */
+div.level1 {margin-left: 3px;}
+div.level2 {margin-left: 23px;}
+div.level3 {margin-left: 43px;}
+div.level4 {margin-left: 63px;}
+div.level5 {margin-left: 83px;}
+
+/* unordered lists */
+ul { 
+  line-height: 1.5em;
+  list-style-type: square;
+  margin: 0.5em 0 0.5em 1.5em;
+  padding: 0;
+  list-style-image: url(images/bullet.gif);
+}
+
+/* ordered lists */
+ol {
+  line-height: 1.5em;
+  margin: 0.5em 0 0.5em 1.5em;
+  padding: 0;
+  color: #638c9c;
+  font-weight: bold;
+  list-style-image: none;
+}
+
+/* the list items overriding the ol definition */
+span.li {
+  color: #000000;
+  font-weight: normal;
+}
+
+li.open {
+  list-style-image: url(images/open.gif);
+}
+
+li.closed {
+  list-style-image: url(images/closed.gif);
+}
+
+.quote {
+  border-left: 2px solid #8cacbb;
+  padding-left: 3px;
+}
+
+/* code blocks by indention */
+pre.pre {
+  font-size: 120%;
+  padding: 0.5em;
+  border: 1px dashed #8cacbb;
+  color: Black;
+  background-color: #f7f9fa;
+  overflow: auto;
+}
+
+/* code blocks by code tag */
+pre.code {
+  font-size: 120%;
+  padding: 0.5em;
+  border: 1px dashed #8cacbb;
+  color: Black;
+  background-color: #f7f9fa;
+  overflow: auto;
+}
+
+/* inline code words */
+code {
+  font-size: 120%;
+}
+
+/* code blocks by file tag */
+pre.file {
+  font-size: 120%;
+  padding: 0.5em;
+  border: 1px dashed #8cacbb;
+  color: Black;
+  background-color: #dee7ec;
+  overflow: auto;
+}
+
+/* inline tables */
+table.inline {
+  background-color: #ffffff;
+  border-spacing: 0px;
+  border-collapse: collapse;
+}
+
+table.inline th {
+  padding: 3px;
+  border: 1px solid #8cacbb;
+  background-color: #dee7ec;
+}
+
+table.inline td {
+  padding: 3px;
+  border: 1px solid #8cacbb;
+}
+
+.leftalign{
+  text-align: left;
+}
+
+.centeralign{
+  text-align: center;
+}
+
+.rightalign{
+  text-align: right;
+}
+
+/* ---------- table of contents ------------------- */
+
+div.toc {
+  margin-left: 2em;
+  margin-top: 1.2em;
+  margin-bottom: 0;
+  float:right;
+  width: 200px;
+  font-size: 80%;
+  clear:both;
+}
+
+div.tocheader {
+  padding: 3px;
+  border: 1px solid #8cacbb;
+  background-color: #dee7ec;
+  text-align: left;
+  font-weight:bold;
+  margin-bottom: 2px;
+}
+
+#tocinside {
+  border: 1px solid #8cacbb;
+  background-color: #ffffff;
+  text-align: left;
+  padding-top: 0.5em;
+  padding-bottom: 0.7em;
+}
+
+ul.toc {
+  list-style-type: none;
+  list-style-image: none;
+  line-height: 1.2em;
+  margin: 0;
+  padding: 0;
+  padding-left: 1em;
+}
+
+ul.toc li {
+  background: transparent url(images/tocdot2.gif) 0 0.6em no-repeat;
+  padding-left:0.4em;
+}
+
+ul.toc li.clear {
+  background-image: none;
+  padding-left:0.4em;
+}
+
+a.toc {
+  color: #436976;
+  text-decoration:none;
+}
+
+a.toc:hover {
+  color: #000000;
+  text-decoration:underline; 
+}
+
+/* ---------------------------- Diff rendering --------------------------*/
+table.diff { background:white; }
+td.diff-blockheader {font-weight:bold}
+td.diff-header {
+  border-bottom: 1px solid #8cacbb;
+  font-size:120%;
+}
+td.diff-addedline {
+    background:#ddffdd;
+    font-family: monospace;
+    font-size: 100%;
+}
+td.diff-deletedline { 
+    background:#ffffbb;
+    font-family: monospace;    
+    font-size: 100%;
+}
+td.diff-context {
+    background:#f7f9fa;
+    font-family: monospace;
+    font-size: 100%;
+}
+span.diffchange { color: red; }
+
+/* --------------------- footnotes -------------------------------- */
+
+div.footnotes{
+  clear:both;
+  border-top: 1px solid #8cacbb;
+  padding-left: 1em;
+  margin-top: 1em;
+}
+
+div.fn{
+  font-size:90%;
+}
+
+a.fn_top{
+  vertical-align:super;
+  font-size:80%;
+}
+
+a.fn_bot{
+  vertical-align:super;
+  font-size:80%;
+  font-weight:bold;
+}
+
+
+/* --------------- search result formating --------------- */
+.search_result{
+  margin-bottom: 6px;
+  padding-left: 30px;
+  padding-right: 10px;
+}
+
+.search_snippet{
+  color: #999999;
+  font-size: 12px;
+  margin-left: 20px;
+}
+
+.search_sep{
+  color: #000000;
+}
+
+.search_hit{
+  color: #000000;
+  background: #FFFF99;
+}
+
+div.search_quickresult{
+  margin-bottom: 15px;
+  padding-bottom: 5px;
+  border-bottom: 1px dashed #8cacbb;
+  margin-left: 30px;
+  padding-right: 10px;
+}
+
+div.search_quickhits {
+  margin-left: 1em;
+  float:left;
+  background: transparent url(images/bullet.gif) 0px 1px no-repeat;
+  padding: 1px 0px 1px 8px;
+  width: 30%;
+}
+
+/* ------------------ Additional ---------------------- */
+.footerinc a img {
+    opacity: 0.5;
+}
+
+.footerinc a:hover img {
+    opacity: 1;
+}
diff --git a/images/bullet.gif b/tpl/default/images/bullet.gif
similarity index 100%
rename from images/bullet.gif
rename to tpl/default/images/bullet.gif
diff --git a/images/button-cc.gif b/tpl/default/images/button-cc.gif
similarity index 100%
rename from images/button-cc.gif
rename to tpl/default/images/button-cc.gif
diff --git a/images/button-css.png b/tpl/default/images/button-css.png
similarity index 100%
rename from images/button-css.png
rename to tpl/default/images/button-css.png
diff --git a/images/button-donate.gif b/tpl/default/images/button-donate.gif
similarity index 100%
rename from images/button-donate.gif
rename to tpl/default/images/button-donate.gif
diff --git a/images/button-dw.png b/tpl/default/images/button-dw.png
similarity index 100%
rename from images/button-dw.png
rename to tpl/default/images/button-dw.png
diff --git a/images/button-php.gif b/tpl/default/images/button-php.gif
similarity index 100%
rename from images/button-php.gif
rename to tpl/default/images/button-php.gif
diff --git a/images/button-rss.png b/tpl/default/images/button-rss.png
similarity index 100%
rename from images/button-rss.png
rename to tpl/default/images/button-rss.png
diff --git a/images/button-xhtml.png b/tpl/default/images/button-xhtml.png
similarity index 100%
rename from images/button-xhtml.png
rename to tpl/default/images/button-xhtml.png
diff --git a/images/closed.gif b/tpl/default/images/closed.gif
similarity index 100%
rename from images/closed.gif
rename to tpl/default/images/closed.gif
diff --git a/images/link_icon.gif b/tpl/default/images/link_icon.gif
similarity index 100%
rename from images/link_icon.gif
rename to tpl/default/images/link_icon.gif
diff --git a/images/mail_icon.gif b/tpl/default/images/mail_icon.gif
similarity index 100%
rename from images/mail_icon.gif
rename to tpl/default/images/mail_icon.gif
diff --git a/images/open.gif b/tpl/default/images/open.gif
similarity index 100%
rename from images/open.gif
rename to tpl/default/images/open.gif
diff --git a/images/tocdot2.gif b/tpl/default/images/tocdot2.gif
similarity index 100%
rename from images/tocdot2.gif
rename to tpl/default/images/tocdot2.gif
diff --git a/images/windows.gif b/tpl/default/images/windows.gif
similarity index 100%
rename from images/windows.gif
rename to tpl/default/images/windows.gif
diff --git a/tpl/default/layout.css b/tpl/default/layout.css
new file mode 100644
index 000000000..c4208c2c6
--- /dev/null
+++ b/tpl/default/layout.css
@@ -0,0 +1,113 @@
+/**
+ * Tableless Layout for default template
+ *
+ * @author Andreas Gohr <andi@splitbrain.org>
+ * @author moraes <moraes@tipos.com.br>
+ */
+
+
+/* -------------- top row --------------- */
+.header {
+	height:35px;
+	padding:3px 0 2px 2px;
+}
+
+.pagename {
+	height:25px;
+	float:left;
+	font-size:200%;
+	font-weight:bolder;
+	color:#DEE7EC;
+	text-align:left;
+	vertical-align:middle;
+	padding:1px 0 0 1px;
+}
+
+.pagename a:link, .pagename a:visited {
+  color:#436976;
+  text-decoration:none;
+}
+
+.pagename a:hover, .pagename a:active {
+  color:#FF9933;
+}
+
+.logo {
+	float:right;
+	font-size:220%;
+	font-weight:bolder;
+	text-align:right;
+	vertical-align:middle;
+}
+
+.logo a:link, .logo a:visited, .logo a:hover, .logo a:active {
+	color:#dee7ec;
+	text-decoration:none;
+	font-variant:small-caps;
+	letter-spacing:2pt;
+}
+
+/* ---------------  top and bottom bar ---------------- */
+.bar {
+	height:25px;
+	border-top:1px solid #8CACBB;
+	border-bottom:1px solid #8CACBB;
+	background:#DEE7EC;
+	padding:2px;
+	margin:0;
+}
+
+.bar-left {
+	float:left;
+  width:50%;
+}
+
+.bar-right {
+	float:right;
+  width:50%;
+  text-align:right;
+}
+
+#bar_bottom {
+  margin-bottom:3px;
+}
+
+/* ------------- File Metadata ----------------------- */
+
+div.meta {
+  clear: both;
+  margin-top: 1em;
+  color:#436976;
+  font-size:70%;
+}
+
+div.meta div.user {
+  float:left;
+}
+
+div.meta div.doc{
+  text-align:right;
+}
+
+/* ---------------  Media Selection  ----------------- */
+
+div.uploadform {
+  margin-top: 0.5em;
+  border-top: 1px solid #8cacbb;
+}
+
+.mediaselect-left {
+  float:left;
+  padding: 0.5em;
+  height:230px;
+  overflow:auto;
+}
+
+.mediaselect-right {
+  float:right;
+  border-left: 1px solid #8cacbb;
+  padding: 0.5em;
+  width:350px;
+  height:230px;
+  overflow:auto;
+}
diff --git a/tpl/default/main.php b/tpl/default/main.php
new file mode 100644
index 000000000..a19ee3217
--- /dev/null
+++ b/tpl/default/main.php
@@ -0,0 +1,110 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
+<?
+/**
+ * DokuWiki Default Template
+ *
+ * This is the template you need to change for the overall look
+ * of DokuWiki.
+ *
+ * You should leave the doctype at the very top - It should
+ * always be the very first line of a document.
+ *
+ * @todo   read the include hooks, add the CSS!
+ * @link   http://wiki.splitbrain.org/wiki:tpl:templates
+ * @author Andreas Gohr <andi@splitbrain.org>
+ */
+?>
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?=$conf['lang']?>" lang="<?=$conf['lang']?>" dir="ltr">
+<head>
+  <title><?=$ID?> [<?=hsc($conf['title'])?>]</title>
+  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+
+  <?tpl_metaheaders()?>
+
+  <link rel="shortcut icon" href="<?=DOKU_BASE?>images/favicon.ico" />
+  <link rel="stylesheet" media="screen" type="text/css" href="<?=DOKU_TPL?>layout.css" />
+  <link rel="stylesheet" media="screen" type="text/css" href="<?=DOKU_TPL?>design.css" />
+  <link rel="stylesheet" media="print" type="text/css" href="<?=DOKU_TPL?>print.css" />
+
+  <!--[if gte IE 5]>
+  <style type="text/css">
+    /* that IE 5+ conditional comment makes this only visible in IE 5+ */
+    /* IE bugfix for transparent PNGs */
+    img { behavior: url("<?=DOKU_BASE?>/pngbehavior.htc"); }
+  </style>
+  <![endif]-->
+</head>
+
+<body>
+<div class="dokuwiki">
+  <?html_msgarea()?>
+
+  <div class="stylehead">
+
+    <div class="header">
+      <div class="pagename">
+        [[<?tpl_link(wl($ID,'do=backlink'),$ID)?>]]
+      </div>
+      <div class="logo">
+        <?tpl_link(wl(),$conf['title'],'name="top" accesskey="h" title="[ALT+H]"')?>
+      </div>
+    </div>
+
+    <div class="bar" id="bar_top">
+      <div class="bar-left" id="bar_topleft">
+        <?tpl_button('edit')?>
+        <?tpl_button('history')?>
+      </div>
+  
+      <div class="bar-right" id="bar_topright">
+        <?tpl_button('recent')?>
+        <?tpl_searchform()?>&nbsp;
+      </div>
+    </div>
+
+    <?if($conf['breadcrumbs']){?>
+    <div class="breadcrumbs">
+      <?tpl_breadcrumbs()?>
+    </div>
+    <?}?>
+
+  </div>
+  <?flush()?>
+
+  <div class="page">
+    <!-- wikipage start -->
+    <?tpl_content()?>
+    <!-- wikipage stop -->
+  </div>
+
+  <div class="clearer">&nbsp;</div>
+
+  <?flush()?>
+
+  <div class="stylefoot">
+
+    <div class="meta">
+      <div class="user">
+        <?tpl_userinfo()?>
+      </div>
+      <div class="doc">
+        <?tpl_pageinfo()?>
+      </div>
+    </div>
+
+    <div class="bar" id="bar_bottom">
+      <div class="bar-left" id="bar_bottomleft">
+        <?tpl_button('edit')?>
+        <?tpl_button('history')?>
+      </div>
+      <div class="bar-right" id="bar_bottomright">
+        <?tpl_button('login')?>
+        <?tpl_button('index')?>
+        <?tpl_button('top')?>&nbsp;
+      </div>
+    </div>
+
+  </div>
+
+</div>
+</body>
diff --git a/print.css b/tpl/default/print.css
similarity index 100%
rename from print.css
rename to tpl/default/print.css
-- 
GitLab