Просмотр исходного кода

This should have been in the previous commit too...

Taddeus Kroes 14 лет назад
Родитель
Сommit
34bf3f2e94
3 измененных файлов с 96 добавлено и 46 удалено
  1. 27 24
      css/main.css
  2. 57 17
      index.php
  3. 12 5
      templates/layout.tpl

+ 27 - 24
css/main.css

@@ -49,29 +49,32 @@ a, input {
 	padding: 41px 10px 41px 0;
 	border-right: 1px solid #c5c5c5;
 	font: normal 21px/23px BebasNeueRegular;
-	color: #7e7e7e;
 	list-style: none;
-}
-
-#menu li {
-	position: relative;
-	width: 138px;
-	height: 31px;
-	padding: 10px 40px 0 12px;
-	cursor: pointer;
-}
-#menu li:hover {
-	background-color: #e9e9e9;
-}
-#menu .active {
-	background-color: #9b9b9b !important;
-	color: #fff;
-}
-
-#menu .icon {
-	position: absolute;
-	top: 14px;
-	right: 12px;
-	width: 16px;
-	height: 14px;
+	
+	a {
+		position: relative;
+		display: block;
+		width: 138px;
+		height: 31px;
+		padding: 10px 40px 0 12px;
+		color: #7e7e7e;
+		text-decoration: none;
+		
+		self:hover {
+			background-color: #e9e9e9;
+		}
+	}
+	
+	.active {
+		background-color: #9b9b9b !important;
+		color: #fff;
+	}
+	
+	.icon {
+		position: absolute;
+		top: 14px;
+		right: 12px;
+		width: 16px;
+		height: 14px;
+	}
 }

+ 57 - 17
index.php

@@ -1,29 +1,69 @@
 <?php
 
+//include_once '../debug.php';
 include_once 'pquery.config.php';
 include_once PQUERY_ROOT.'pquery.php';
 
-__p::require_plugins('template', 'sql');
+__p::require_plugins('template', 'sql', 'url', 'js', 'css');
 
 __tpl::set_root('templates');
 
-$menu = array(
-	array('Pagina\'s', 'pages'),
-	array('Nieuws', 'news'),
-	array('Foto\'s', 'photos'),
-	array('Accounts', 'accounts'),
-	array('Instellingen', 'settings'),
-	array('Uitloggen', 'logout')
-);
-
-$layout = _tpl('layout');
-
-foreach( $menu as $i => $item ) {
-	list($title, $icon) = $item;
-	$item = $layout->data->add('menu')->set(array('title' => $title, 'icon' => $icon));
-	$i || $item->set('active', 'active');
+__url::add_handlers(array(
+	'css/(.*)' => 'css_handler',
+	'js/(.*)' => 'js_handler',
+	'' => 'layout',
+	'(.*)' => 'content'
+));
+
+header('Vary: Accept-Encoding');
+
+$handler = strstr($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip') !== false ? 'ob_gzhandler' : '';
+
+ob_start($handler);
+_url($_SERVER['QUERY_STRING'])->handler();
+ob_end_flush();
+
+/**
+ * 
+ * 
+ * @param string $files One or more scripts separated by commas (',').
+ */
+function js_handler($files) {
+	$prepend_folder = create_function('$x', 'return "js/$x";');
+	_js(array_map($prepend_folder, explode(',', $files)))->output();
+}
+
+function css_handler($files) {
+	$prepend_folder = create_function('$x', 'return "css/$x";');
+	_css(array_map($prepend_folder, explode(',', $files)))->output();
+}
+
+function content() {
+	header('Content-Type: text/html; charset=utf-8');
+	
+	echo 'content';
 }
 
-echo $layout->parse();
+function layout() {
+	header('Content-Type: text/html; charset=utf-8');
+	
+	$menu = array(
+		array('Pagina\'s', 'pages'),
+		array('Nieuws', 'news'),
+		array('Foto\'s', 'photos'),
+		array('Accounts', 'accounts'),
+		array('Instellingen', 'settings'),
+		array('Uitloggen', 'logout')
+	);
+	$layout = _tpl('layout');
+	
+	foreach( $menu as $i => $item ) {
+		list($title, $icon) = $item;
+		$item = $layout->data->add('menu')->set(array('title' => $title, 'icon' => $icon));
+		$i || $item->set('active', 'active');
+	}
+
+	echo $layout->parse();
+}
 
 ?>

+ 12 - 5
templates/layout.tpl

@@ -3,19 +3,26 @@
 <head>
 	<title>Tcms</title>
 	<meta charset="utf-8" />
-	<link href="css/main.css" rel="stylesheet" />	
+	<link href="css/main" rel="stylesheet" />
+	<script async type="text/javascript" src="js/jquery-1.7.min,menu,list"></script>
+	<!--
+	<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js"></script>
+	<script type="text/javascript">
+		$.getScript('js/menu,list');
+	</script>
+	-->
 </head>
 <body>
 
 <div id="wrapper">
-	<ul id="menu">
+	<div id="menu">
 		{block:menu}
-		<li class="{active}">
+		<a href="#{icon}" class="{active}">
 			{title}
 			<div class="icon {icon}"></div>
-		</li>
+		</a>
 		{end}
-	</ul>
+	</div>
 </div>
 
 </body>