Index: themes/ductile/_config.php
===================================================================
--- themes/ductile/_config.php	(revision 2566)
+++ themes/ductile/_config.php	(revision 2658)
@@ -78,16 +78,4 @@
 );
 
-function adjustFontSize($s)
-{
-	if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$s,$m)) {
-		if (empty($m[2])) {
-			$m[2] = 'em';
-		}
-		return $m[1].$m[2];
-	}
-
-	return null;
-}
-
 $font_families = array(
 	// Theme standard
@@ -117,115 +105,4 @@
 
 	return isset($font_families[$c]) ? '<span style="position:absolute;top:0;left:32em;">'.$font_families[$c].'</span>' : '';
-}
-
-function adjustColor($c)
-{
-	if ($c === '') {
-		return '';
-	}
-
-	$c = strtoupper($c);
-
-	if (preg_match('/^[A-F0-9]{3,6}$/',$c)) {
-		$c = '#'.$c;
-	}
-
-	if (preg_match('/^#[A-F0-9]{6}$/',$c)) {
-		return $c;
-	}
-
-	if (preg_match('/^#[A-F0-9]{3,}$/',$c)) {
-		return '#'.substr($c,1,1).substr($c,1,1).substr($c,2,1).substr($c,2,1).substr($c,3,1).substr($c,3,1);
-	}
-
-	return '';
-}
-
-function computeContrastRatio($color,$background)
-{
-	// Compute contrast ratio between two colors
-
-	$color = adjustColor($color);
-	if (($color == '') || (strlen($color) != 7)) return 0;
-	$background = adjustColor($background);
-	if (($background == '') || (strlen($background) != 7)) return 0;
-
-	$l1 = (0.2126 * pow(hexdec(substr($color,1,2))/255,2.2)) +
-		(0.7152 * pow(hexdec(substr($color,3,2))/255,2.2)) +
-		(0.0722 * pow(hexdec(substr($color,5,2))/255,2.2));
-
-	$l2 = (0.2126 * pow(hexdec(substr($background,1,2))/255,2.2)) +
-	 	(0.7152 * pow(hexdec(substr($background,3,2))/255,2.2)) +
-		(0.0722 * pow(hexdec(substr($background,5,2))/255,2.2));
-
-	if ($l1 > $l2) {
-		$ratio = ($l1 + 0.05) / ($l2 + 0.05);
-	} else {
-		$ratio = ($l2 + 0.05) / ($l1 + 0.05);
-	}
-	return $ratio;
-}
-
-function contrastRatioLevel($ratio,$size,$bold)
-{
-	if ($size == '') {
-		return '';
-	}
-
-	// Eval font size in em (assume base font size in pixels equal to 16)
-	if (preg_match('/^([0-9.]+)\s*(%|pt|px|em|ex)?$/',$size,$m)) {
-		if (empty($m[2])) {
-			$m[2] = 'em';
-		}
-	} else {
-		return '';
-	}
-	switch ($m[2]) {
-		case '%':
-			$s = (float) $m[1] / 100;
-			break;
-		case 'pt':
-			$s = (float) $m[1] / 12;
-			break;
-		case 'px':
-			$s = (float) $m[1] / 16;
-			break;
-		case 'em':
-			$s = (float) $m[1];
-			break;
-		case 'ex':
-			$s = (float) $m[1] / 2;
-			break;
-		default:
-			return '';
-	}
-
-	$large = ((($s > 1.5) && ($bold == false)) || (($s > 1.2) && ($bold == true)));
-
-	// Check ratio
-	if ($ratio > 7) {
-		return 'AAA';
-	} elseif (($ratio > 4.5) && $large) {
-		return 'AAA';
-	} elseif ($ratio > 4.5) {
-		return 'AA';
-	} elseif (($ratio > 3) && $large) {
-		return 'AA';
-	}
-	return '';
-}
-
-function contrastRatio($color,$background,$size='',$bold=false)
-{
-	if (($color != '') && ($background != '')) {
-		$ratio = computeContrastRatio($color,$background);
-		$level = contrastRatioLevel($ratio,$size,$bold);
-		return
-			'<span style="position:absolute;top:0;left:23em;">'.
-			sprintf(__('ratio %.1f'),$ratio).
-			($level != '' ? ' '.sprintf(__('(%s)'),$level) : '').
-			'</span>';
-	}
-	return '';
 }
 
@@ -273,4 +150,5 @@
 $ductile_counts_base = array(
 	'default' => null,
+	'default-page' => null,
 	'category' => null,
 	'tag' => null,
@@ -290,4 +168,5 @@
 	$ductile_lists = $ductile_lists_base;
 }
+$ductile_lists = array_merge($ductile_lists_base,$ductile_lists);
 
 $ductile_counts = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_entries_counts');
@@ -296,4 +175,5 @@
 	$ductile_counts = $ductile_counts_base;
 }
+$ductile_counts = array_merge($ductile_counts_base,$ductile_counts);
 
 $ductile_stickers = $core->blog->settings->themes->get($core->blog->settings->system->theme.'_stickers');
@@ -395,24 +275,24 @@
 
 			$ductile_user['blog_title_w'] = (integer) !empty($_POST['blog_title_w']);
-			$ductile_user['blog_title_s'] = adjustFontSize($_POST['blog_title_s']);
-			$ductile_user['blog_title_c'] = adjustColor($_POST['blog_title_c']);
+			$ductile_user['blog_title_s'] = dcThemeConfig::adjustFontSize($_POST['blog_title_s']);
+			$ductile_user['blog_title_c'] = dcThemeConfig::adjustColor($_POST['blog_title_c']);
 
 			$ductile_user['post_title_w'] = (integer) !empty($_POST['post_title_w']);
-			$ductile_user['post_title_s'] = adjustFontSize($_POST['post_title_s']);
-			$ductile_user['post_title_c'] = adjustColor($_POST['post_title_c']);
+			$ductile_user['post_title_s'] = dcThemeConfig::adjustFontSize($_POST['post_title_s']);
+			$ductile_user['post_title_c'] = dcThemeConfig::adjustColor($_POST['post_title_c']);
 
 			$ductile_user['post_link_w'] = (integer) !empty($_POST['post_link_w']);
-			$ductile_user['post_link_v_c'] = adjustColor($_POST['post_link_v_c']);
-			$ductile_user['post_link_f_c'] = adjustColor($_POST['post_link_f_c']);
-
-			$ductile_user['post_simple_title_c'] = adjustColor($_POST['post_simple_title_c']);
+			$ductile_user['post_link_v_c'] = dcThemeConfig::adjustColor($_POST['post_link_v_c']);
+			$ductile_user['post_link_f_c'] = dcThemeConfig::adjustColor($_POST['post_link_f_c']);
+
+			$ductile_user['post_simple_title_c'] = dcThemeConfig::adjustColor($_POST['post_simple_title_c']);
 
 			$ductile_user['blog_title_w_m'] = (integer) !empty($_POST['blog_title_w_m']);
-			$ductile_user['blog_title_s_m'] = adjustFontSize($_POST['blog_title_s_m']);
-			$ductile_user['blog_title_c_m'] = adjustColor($_POST['blog_title_c_m']);
+			$ductile_user['blog_title_s_m'] = dcThemeConfig::adjustFontSize($_POST['blog_title_s_m']);
+			$ductile_user['blog_title_c_m'] = dcThemeConfig::adjustColor($_POST['blog_title_c_m']);
 
 			$ductile_user['post_title_w_m'] = (integer) !empty($_POST['post_title_w_m']);
-			$ductile_user['post_title_s_m'] = adjustFontSize($_POST['post_title_s_m']);
-			$ductile_user['post_title_c_m'] = adjustColor($_POST['post_title_c_m']);
+			$ductile_user['post_title_s_m'] = dcThemeConfig::adjustFontSize($_POST['post_title_s_m']);
+			$ductile_user['post_title_c_m'] = dcThemeConfig::adjustColor($_POST['post_title_c_m']);
 		}
 
@@ -580,5 +460,5 @@
 '<p class="field picker"><label for="blog_title_c">'.__('Color:').'</label> '.
 form::field('blog_title_c',7,7,$ductile_user['blog_title_c'],'colorpicker').
-contrastRatio($ductile_user['blog_title_c'],'#ffffff',
+dcThemeConfig::contrastRatio($ductile_user['blog_title_c'],'#ffffff',
 	(!empty($ductile_user['blog_title_s']) ? $ductile_user['blog_title_s'] : '2em'),
 	$ductile_user['blog_title_w']).
@@ -597,5 +477,5 @@
 '<p class="field picker"><label for="post_title_c">'.__('Color:').'</label> '.
 form::field('post_title_c',7,7,$ductile_user['post_title_c'],'colorpicker').
-contrastRatio($ductile_user['post_title_c'],'#ffffff',
+dcThemeConfig::contrastRatio($ductile_user['post_title_c'],'#ffffff',
 	(!empty($ductile_user['post_title_s']) ? $ductile_user['post_title_s'] : '2.5em'),
 	$ductile_user['post_title_w']).
@@ -609,5 +489,5 @@
 '<p class="field picker"><label for="post_simple_title_c">'.__('Color:').'</label> '.
 form::field('post_simple_title_c',7,7,$ductile_user['post_simple_title_c'],'colorpicker').
-contrastRatio($ductile_user['post_simple_title_c'],'#ffffff',
+dcThemeConfig::contrastRatio($ductile_user['post_simple_title_c'],'#ffffff',
 	'1.1em',	// H5 minimum size
 	false).
@@ -620,5 +500,5 @@
 '<p class="field picker"><label for="post_link_v_c">'.__('Normal and visited links color:').'</label> '.
 form::field('post_link_v_c',7,7,$ductile_user['post_link_v_c'],'colorpicker').
-contrastRatio($ductile_user['post_link_v_c'],'#ffffff',
+dcThemeConfig::contrastRatio($ductile_user['post_link_v_c'],'#ffffff',
 	'1em',
 	$ductile_user['post_link_w']).
@@ -627,5 +507,5 @@
 '<p class="field picker"><label for="post_link_f_c">'.__('Active, hover and focus links color:').'</label> '.
 form::field('post_link_f_c',7,7,$ductile_user['post_link_f_c'],'colorpicker').
-contrastRatio($ductile_user['post_link_f_c'],'#ebebee',
+dcThemeConfig::contrastRatio($ductile_user['post_link_f_c'],'#ebebee',
 	'1em',
 	$ductile_user['post_link_w']).
@@ -646,5 +526,5 @@
 '<p class="field picker"><label for="blog_title_c_m">'.__('Color:').'</label> '.
 form::field('blog_title_c_m',7,7,$ductile_user['blog_title_c_m'],'colorpicker').
-contrastRatio($ductile_user['blog_title_c_m'],'#d7d7dc',
+dcThemeConfig::contrastRatio($ductile_user['blog_title_c_m'],'#d7d7dc',
 	(!empty($ductile_user['blog_title_s_m']) ? $ductile_user['blog_title_s_m'] : '1.8em'),
 	$ductile_user['blog_title_w_m']).
@@ -663,5 +543,5 @@
 '<p class="field picker"><label for="post_title_c_m">'.__('Color:').'</label> '.
 form::field('post_title_c_m',7,7,$ductile_user['post_title_c_m'],'colorpicker').
-contrastRatio($ductile_user['post_title_c_m'],'#ffffff',
+dcThemeConfig::contrastRatio($ductile_user['post_title_c_m'],'#ffffff',
 	(!empty($ductile_user['post_title_s_m']) ? $ductile_user['post_title_s_m'] : '1.5em'),
 	$ductile_user['post_title_w_m']).
Index: themes/ductile/_define.php
===================================================================
--- themes/ductile/_define.php	(revision 2566)
+++ themes/ductile/_define.php	(revision 2581)
@@ -15,5 +15,5 @@
 	/* Description*/		"Mediaqueries compliant elegant theme",
 	/* Author */			"Dotclear Team",
-	/* Version */			'1.3.1',
+	/* Version */			'1.4',
 	/* Properties */		array(
 								'standalone_config' => true,
Index: themes/ductile/_prepend.php
===================================================================
--- themes/ductile/_prepend.php	(revision 2566)
+++ themes/ductile/_prepend.php	(revision 2567)
@@ -26,5 +26,6 @@
 		if (!$core->auth->user_prefs->accessibility->nodragdrop) {
 			echo
-				dcPage::jsLoad('js/jquery/jquery-ui.custom.js');
+				dcPage::jsLoad('js/jquery/jquery-ui.custom.js').
+				dcPage::jsLoad('js/jquery/jquery.ui.touch-punch.js');
 				echo <<<EOT
 <script type="text/javascript">
Index: themes/ductile/_public.php
===================================================================
--- themes/ductile/_public.php	(revision 2566)
+++ themes/ductile/_public.php	(revision 2658)
@@ -36,30 +36,43 @@
 		global $_ctx;
 
-		$nb = 0;
+		$nb_other = $nb_first = 0;
+
 		$s = $GLOBALS['core']->blog->settings->themes->get($GLOBALS['core']->blog->settings->system->theme.'_entries_counts');
 		if ($s !== null) {
 			$s = @unserialize($s);
 			if (is_array($s)) {
-				if (isset($s[$GLOBALS['core']->url->type])) {
-					// Nb de billets par page défini par la config du thème
-					$nb = (integer) $s[$GLOBALS['core']->url->type];
-				} else {
-					if (($GLOBALS['core']->url->type == 'default-page') && (isset($s['default']))) {
-						// Les pages 2 et suivantes de la home ont le même nombre de billet que la première page
-						$nb = (integer) $s['default'];
-					}
-				}
-			}
-		}
-
-		if ($nb == 0) {
+				switch ($GLOBALS['core']->url->type) {
+					case 'default':
+					case 'default-page':
+						if (isset($s['default'])) {
+							$nb_first = $nb_other = (integer) $s['default'];
+						}
+						if (isset($s['default-page'])) {
+							$nb_other = (integer) $s['default-page'];
+						}
+						break;
+					default:
+						if (isset($s[$GLOBALS['core']->url->type])) {
+							// Nb de billets par page défini par la config du thème
+							$nb_first = $nb_other = (integer) $s[$GLOBALS['core']->url->type];
+						}
+						break;
+				}
+			}
+		}
+
+		if ($nb_other == 0) {
 			if (!empty($attr['nb'])) {
 				// Nb de billets par page défini par défaut dans le template
-				$nb = (integer) $attr['nb'];
-			}
-		}
-
-		if ($nb > 0)
-			$_ctx->nb_entry_per_page = $nb;
+				$nb_other = $nb_first = (integer) $attr['nb'];
+			}
+		}
+
+		if ($nb_other > 0) {
+			$_ctx->nb_entry_per_page = $nb_other;
+		}
+		if ($nb_first > 0) {
+			$_ctx->nb_entry_first_page = $nb_first;
+		}
 	}
 
@@ -301,5 +314,5 @@
 				# Main font
 				$selectors = 'body, .supranav li a span, #comments.me, a.comment-number';
-				self::prop($css,$selectors,'font-family',$s['body_webfont_family']);
+				dcThemeConfig::prop($css,$selectors,'font-family',$s['body_webfont_family']);
 			}
 		}
@@ -319,5 +332,5 @@
 				# Secondary font
 				$selectors = '#blogdesc, .supranav, #content-info, #subcategories, #comments-feed, #sidebar h2, #sidebar h3, #footer';
-				self::prop($css,$selectors,'font-family',$s['alternate_webfont_family']);
+				dcThemeConfig::prop($css,$selectors,'font-family',$s['alternate_webfont_family']);
 			}
 		}
@@ -357,25 +370,25 @@
 		# Blog description
 		$selectors = '#blogdesc';
-		if (isset($s['subtitle_hidden'])) self::prop($css,$selectors,'display',($s['subtitle_hidden'] ? 'none' : null));
+		if (isset($s['subtitle_hidden'])) dcThemeConfig::prop($css,$selectors,'display',($s['subtitle_hidden'] ? 'none' : null));
 
 		# Main font
 		$selectors = 'body, .supranav li a span, #comments.me, a.comment-number';
-		if (isset($s['body_font'])) self::prop($css,$selectors,'font-family',self::fontDef($s['body_font']));
+		if (isset($s['body_font'])) dcThemeConfig::prop($css,$selectors,'font-family',self::fontDef($s['body_font']));
 
 		# Secondary font
 		$selectors = '#blogdesc, .supranav, #content-info, #subcategories, #comments-feed, #sidebar h2, #sidebar h3, #footer';
-		if (isset($s['alternate_font'])) self::prop($css,$selectors,'font-family',self::fontDef($s['alternate_font']));
+		if (isset($s['alternate_font'])) dcThemeConfig::prop($css,$selectors,'font-family',self::fontDef($s['alternate_font']));
 
 		# Inside posts links font weight
 		$selectors = '.post-excerpt a, .post-content a';
-		if (isset($s['post_link_w'])) self::prop($css,$selectors,'font-weight',($s['post_link_w'] ? 'bold' : 'normal'));
+		if (isset($s['post_link_w'])) dcThemeConfig::prop($css,$selectors,'font-weight',($s['post_link_w'] ? 'bold' : 'normal'));
 
 		# Inside posts links colors (normal, visited)
 		$selectors = '.post-excerpt a:link, .post-excerpt a:visited, .post-content a:link, .post-content a:visited';
-		if (isset($s['post_link_v_c'])) self::prop($css,$selectors,'color',$s['post_link_v_c']);
+		if (isset($s['post_link_v_c'])) dcThemeConfig::prop($css,$selectors,'color',$s['post_link_v_c']);
 
 		# Inside posts links colors (hover, active, focus)
 		$selectors = '.post-excerpt a:hover, .post-excerpt a:active, .post-excerpt a:focus, .post-content a:hover, .post-content a:active, .post-content a:focus';
-		if (isset($s['post_link_f_c'])) self::prop($css,$selectors,'color',$s['post_link_f_c']);
+		if (isset($s['post_link_f_c'])) dcThemeConfig::prop($css,$selectors,'color',$s['post_link_f_c']);
 
 		# Style directives
@@ -394,29 +407,29 @@
 		# Blog title font weight
 		$selectors = 'h1, h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
-		if (isset($s['blog_title_w'])) self::prop($css_large,$selectors,'font-weight',($s['blog_title_w'] ? 'bold' : 'normal'));
+		if (isset($s['blog_title_w'])) dcThemeConfig::prop($css_large,$selectors,'font-weight',($s['blog_title_w'] ? 'bold' : 'normal'));
 
 		# Blog title font size
 		$selectors = 'h1';
-		if (isset($s['blog_title_s'])) self::prop($css_large,$selectors,'font-size',$s['blog_title_s']);
+		if (isset($s['blog_title_s'])) dcThemeConfig::prop($css_large,$selectors,'font-size',$s['blog_title_s']);
 
 		# Blog title color
 		$selectors = 'h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
-		if (isset($s['blog_title_c'])) self::prop($css_large,$selectors,'color',$s['blog_title_c']);
+		if (isset($s['blog_title_c'])) dcThemeConfig::prop($css_large,$selectors,'color',$s['blog_title_c']);
 
 		# Post title font weight
 		$selectors = 'h2.post-title, h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
-		if (isset($s['post_title_w'])) self::prop($css_large,$selectors,'font-weight',($s['post_title_w'] ? 'bold' : 'normal'));
+		if (isset($s['post_title_w'])) dcThemeConfig::prop($css_large,$selectors,'font-weight',($s['post_title_w'] ? 'bold' : 'normal'));
 
 		# Post title font size
 		$selectors = 'h2.post-title';
-		if (isset($s['post_title_s'])) self::prop($css_large,$selectors,'font-size',$s['post_title_s']);
+		if (isset($s['post_title_s'])) dcThemeConfig::prop($css_large,$selectors,'font-size',$s['post_title_s']);
 
 		# Post title color
 		$selectors = 'h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
-		if (isset($s['post_title_c'])) self::prop($css_large,$selectors,'color',$s['post_title_c']);
+		if (isset($s['post_title_c'])) dcThemeConfig::prop($css_large,$selectors,'color',$s['post_title_c']);
 
 		# Simple title color (title without link)
 		$selectors = '#content-info h2, .post-title, .post h3, .post h4, .post h5, .post h6, .arch-block h3';
-		if (isset($s['post_simple_title_c'])) self::prop($css_large,$selectors,'color',$s['post_simple_title_c']);
+		if (isset($s['post_simple_title_c'])) dcThemeConfig::prop($css_large,$selectors,'color',$s['post_simple_title_c']);
 
 		# Style directives for large screens
@@ -438,25 +451,25 @@
 		# Blog title font weight
 		$selectors = 'h1, h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
-		if (isset($s['blog_title_w_m'])) self::prop($css_small,$selectors,'font-weight',($s['blog_title_w_m'] ? 'bold' : 'normal'));
+		if (isset($s['blog_title_w_m'])) dcThemeConfig::prop($css_small,$selectors,'font-weight',($s['blog_title_w_m'] ? 'bold' : 'normal'));
 
 		# Blog title font size
 		$selectors = 'h1';
-		if (isset($s['blog_title_s_m'])) self::prop($css_small,$selectors,'font-size',$s['blog_title_s_m']);
+		if (isset($s['blog_title_s_m'])) dcThemeConfig::prop($css_small,$selectors,'font-size',$s['blog_title_s_m']);
 
 		# Blog title color
 		$selectors = 'h1 a:link, h1 a:visited, h1 a:hover, h1 a:visited, h1 a:focus';
-		if (isset($s['blog_title_c_m'])) self::prop($css_small,$selectors,'color',$s['blog_title_c_m']);
+		if (isset($s['blog_title_c_m'])) dcThemeConfig::prop($css_small,$selectors,'color',$s['blog_title_c_m']);
 
 		# Post title font weight
 		$selectors = 'h2.post-title, h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
-		if (isset($s['post_title_w_m'])) self::prop($css_small,$selectors,'font-weight',($s['post_title_w_m'] ? 'bold' : 'normal'));
+		if (isset($s['post_title_w_m'])) dcThemeConfig::prop($css_small,$selectors,'font-weight',($s['post_title_w_m'] ? 'bold' : 'normal'));
 
 		# Post title font size
 		$selectors = 'h2.post-title';
-		if (isset($s['post_title_s_m'])) self::prop($css_small,$selectors,'font-size',$s['post_title_s_m']);
+		if (isset($s['post_title_s_m'])) dcThemeConfig::prop($css_small,$selectors,'font-size',$s['post_title_s_m']);
 
 		# Post title color
 		$selectors = 'h2.post-title a:link, h2.post-title a:visited, h2.post-title a:hover, h2.post-title a:visited, h2.post-title a:focus';
-		if (isset($s['post_title_c_m'])) self::prop($css_small,$selectors,'color',$s['post_title_c_m']);
+		if (isset($s['post_title_c_m'])) dcThemeConfig::prop($css_small,$selectors,'color',$s['post_title_c_m']);
 
 		# Style directives for small screens
@@ -502,10 +515,3 @@
 		return isset(self::$fonts[$c]) ? self::$fonts[$c] : null;
 	}
-
-	protected static function prop(&$css,$selector,$prop,$value)
-	{
-		if ($value) {
-			$css[$selector][$prop] = $value;
-		}
-	}
 }
