Commit 63524a57 authored by Corentin Bettiol's avatar Corentin Bettiol 💻
Browse files

add paging, small updates

parent 49c5a5f4
Loading
Loading
Loading
Loading
+56 −2
Original line number Original line Diff line number Diff line
@@ -89,13 +89,16 @@ h3 a:hover{
	margin: 10px;
	margin: 10px;
	text-decoration: none;
	text-decoration: none;
	background-color: #d9d9d9;
	background-color: #d9d9d9;
	transition: color 0.2s, background-color 0.2s;
	border-bottom: 0px solid #ccc;
	transition: color 0.2s, background-color 0.2s, padding 0.1s, border-bottom 0.1s;
}
}


#listMenu a:hover{
#listMenu a:hover{
	color: #47476b;
	color: #47476b;
	padding-bottom: 2px;
	border-bottom-width: 5px;
	background-color: #f0f0f0;
	background-color: #f0f0f0;
	transition: color 0.2s, background-color 0.2s;
	transition: color 0.2s, background-color 0.2s, padding 0.1s, border-bottom 0.1s;
}
}


article{
article{
@@ -103,6 +106,7 @@ article{
	padding: 5px 15px;
	padding: 5px 15px;
	background-color: #f0f0f0;
	background-color: #f0f0f0;
	border-bottom: 3px solid #ccc;
	border-bottom: 3px solid #ccc;
	overflow-wrap: anywhere;
}
}


#listMenu .selected{
#listMenu .selected{
@@ -257,6 +261,49 @@ form .small{
	background-color: #f0f0f0;
	background-color: #f0f0f0;
}
}


#paging{
	width: 80%;
	opacity: 0.8;
	display: flex;
	max-width: 400px;
	font-size: 1.5em;
	margin: 20px auto;
	font-family: monospace;
	justify-content: space-around;
}

#paging em, #paging a, #paging span{
	width: 30px;
}

#paging em, #paging a{
	margin: 3px;
	padding: 5px;
	text-align: center;
}

#paging a{
	text-decoration: none;
	background-color: #f0f0f0;
	border-bottom: 0px solid #ccc;
	transition: border-bottom 0.1s, padding-bottom 0.1s;
}

#paging a:hover{
	padding-bottom: 0;
	border-bottom-width: 5px;
	transition: border-bottom 0.1s, padding-bottom 0.1s;
}

#paging em{
	opacity: 0.6;
}

#paging .current{
	opacity: 1;
	background-color: #ccc;
}

/*
/*
====
====
Media Queries
Media Queries
@@ -309,6 +356,13 @@ Media Queries
		width: 90%;
		width: 90%;
		margin: 2px auto;
		margin: 2px auto;
		text-align: center;
		text-align: center;
		padding: 0;
	}
	#listMenu a{
		padding-bottom: 5px;
	}
	#listMenu a:hover{
		padding-bottom: 0;
	}
	}
}
}


+3 −0
Original line number Original line Diff line number Diff line
@@ -9,6 +9,9 @@ require_once('site/controller/mainController.php');
// le moins gros controlleur (oui c'est un morceau)
// le moins gros controlleur (oui c'est un morceau)
require_once('site/controller/adminController.php');
require_once('site/controller/adminController.php');


// on récupère le nom de la page ici (avant d'inclure le layout)
$pageName = getPageName();

// afficher le contenu (qui va switcher sur le contenu dynamique à afficher)
// afficher le contenu (qui va switcher sur le contenu dynamique à afficher)
require_once('site/layout/layout.php');
require_once('site/layout/layout.php');
?>
?>
 No newline at end of file
+41 −21
Original line number Original line Diff line number Diff line
@@ -13,11 +13,18 @@ require_once('site/model/BlogManager.php');
require_once('site/model/ProjectsManager.php');
require_once('site/model/ProjectsManager.php');


// récupérer le nom de la page en fonction de l'url
// récupérer le nom de la page en fonction de l'url
// premier texte = affiché dans l'onglet (title), second texte = voir le switch dans site/layout/layout.php
// premier texte = affiché dans l'onglet (title), second texte = voir le switch dans site/layout/layout.php :
// 	c'est LA valeur utilisée pour savoir quoi faire depuis le layout
function getPageName(){
function getPageName(){
	// si on a une url personnalisée
	// si on a une url personnalisée
	if(isset($_GET['action'])){
	if(isset($_GET['action'])){
		switch ($_GET['action']) {
		switch ($_GET['action']) {
		case 'blog' : // le blog
			if(isset($_GET['page']))
				return ['Blog – page '. $_GET['page'], 'blog'];
			else
				return ['Blog', 'blog'];
			break;
		case 'contact': // contact
		case 'contact': // contact
			return ['Contact', 'contact'];
			return ['Contact', 'contact'];
			break;
			break;
@@ -34,7 +41,7 @@ function getPageName(){
			return ['Changelog', 'changelog'];
			return ['Changelog', 'changelog'];
			break;
			break;
		case 'eplucher': // déconnexion (la première valeur n'est jamais utilisée)
		case 'eplucher': // déconnexion (la première valeur n'est jamais utilisée)
			return ['COUCOU AHAH', 'eplucher'];
			return ['POIL AU NEZ', 'eplucher'];
			break;
			break;
		case 'rss': // rss
		case 'rss': // rss
			return ['Rss', 'rss'];
			return ['Rss', 'rss'];
@@ -45,7 +52,7 @@ function getPageName(){
		case 'patate': // administration
		case 'patate': // administration
			return ['Administration', 'administration'];
			return ['Administration', 'administration'];
			break;
			break;
		default: // si l'argument n'est pas compris on affiche le blog
		default: // si l'argument n'est pas compris et qu'il passe les rewriterules d'apache on affiche le blog (ne devrait jamais se produire)
			return ['Blog', 'blog'];
			return ['Blog', 'blog'];
			break;
			break;
		}
		}
@@ -62,24 +69,24 @@ function writeMenu($pageName){
	<input id="toggle" type="checkbox" />
	<input id="toggle" type="checkbox" />
	<ul id='listMenu'>
	<ul id='listMenu'>
		<?php
		<?php
			if($pageName == 'Administration'){ ?>
			if($pageName == 'administration'){ ?>
				<li><h2><a href="/eplucher" class="selected">🔧</a></h2></li>
				<li><h2><a href="/eplucher" class="selected">🔧</a></h2></li>
		<?php }
		<?php }
			else if(isset($_SESSION['user'])){ ?>
			else if(isset($_SESSION['user'])){ ?>
				<li><h2><a href="/patate" >🔧</a></h2></li>
				<li><h2><a href="/patate" >🔧</a></h2></li>
		<?php }
		<?php }
			if($pageName == 'Changelog'){ ?>
			if($pageName == 'changelog'){ ?>
				<li><h2><a href="/changelog" class="selected">Changelog</a></h2></li>
				<li><h2><a href="/changelog" class="selected">Changelog</a></h2></li>
		<?php } ?>
		<?php } ?>
		<li><h2><a href="/" title="Blog" <?php if($pageName == 'Blog'){ ?>class="selected"<?php } ?>>Blog</a></h2></li>
		<li><h2><a href="/" title="Blog" <?php if($pageName == 'blog'){ ?>class="selected"<?php } ?>>Blog</a></h2></li>
		<li><h2><a href="/about" title="À propos" <?php if($pageName == 'À Propos'){ ?>class="selected"<?php } ?>>À propos</a></h2></li>
		<li><h2><a href="/about" title="À propos" <?php if($pageName == 'about'){ ?>class="selected"<?php } ?>>À propos</a></h2></li>
		<li><h2><a href="/projects" title="Projets" <?php if($pageName == 'Projets' || $pageName == 'Projet'){ ?>class="selected"<?php } ?>>Projets</a></h2></li>
		<li><h2><a href="/projects" title="Projets" <?php if($pageName == 'project'){ ?>class="selected"<?php } ?>>Projets</a></h2></li>
		<li><h2><a href="/contact" title="Contact" <?php if($pageName == 'Contact'){ ?>class="selected"<?php } ?>>Contact</a></h2></li>
		<li><h2><a href="/contact" title="Contact" <?php if($pageName == 'contact'){ ?>class="selected"<?php } ?>>Contact</a></h2></li>
	</ul>
	</ul>
	<label class="nav-label" for="toggle"></label>
	<label class="nav-label" for="toggle"></label>
<?php }
<?php }


// affiche la page du blog
// affiche la page du blog (accueil par défaut)
function writeBlogPage($pageName){
function writeBlogPage($pageName){
	// si on n'accède pas au fichier mais bien au site (var définie)
	// si on n'accède pas au fichier mais bien au site (var définie)
	if($pageName[1] == 'blog'){
	if($pageName[1] == 'blog'){
@@ -88,16 +95,32 @@ function writeBlogPage($pageName){
		
		
		// si on affiche un post en particulier
		// si on affiche un post en particulier
		if(isset($_GET['title'])){
		if(isset($_GET['title'])){
			$title = urldecode($_GET['title']);
			$blogpost = $blog->get($_GET['title']);
			$blogpost = $blog->get($title);
			if($blogpost != false){
			if($blogpost != false)

				// articles précédant/suivant
				//$paging = $blog->pagingSingle($_GET['title']);
				//require('site/view/publie/blogPostPagingView.php')

				require('site/view/public/blogPostView.php');
				require('site/view/public/blogPostView.php');
			}
			else
			else
				header('Location:/404');
				header('Location:/404');
		}
		}
		// si on affiche la liste des posts
		// si on affiche la liste des posts
		else{
		else{
			$blogposts = $blog->getPage(0);

			$page = 1;
			if(isset($_GET['page']))
				// normalement via le rewriterule on envoie forcément un int, mais un cast ça coûte pas grand chose donc bon
				$page = (int)$_GET['page'];

			// liste des pages
			$paging = $blog->pagingList($page);
			require('site/view/public/blogPagingView.php');

			// liste des articles de la page
			$blogposts = $blog->getPage($page);
			require('site/view/public/blogView.php');
			require('site/view/public/blogView.php');
		}
		}
	}
	}
@@ -105,12 +128,12 @@ function writeBlogPage($pageName){


// affiche la liste des projets
// affiche la liste des projets
function writeProjectPage($pageName){
function writeProjectPage($pageName){
	$project = new ProjectManager(NULL, NULL, NULL, NULL, NULL);

	$project = new ProjectManager(NULL, NULL, NULL, NULL, NULL); // on a un projectmanager


	// si on affiche un projet en particulier
	// si on affiche un projet en particulier
	if(isset($_GET['title'])){
	if(isset($_GET['title'])){
		$title = urldecode($_GET['title']);
		$project = $project->get($_GET['title']);
		$project = $project->get($title);
		if($project != false){
		if($project != false){
			require('site/view/public/projectView.php');
			require('site/view/public/projectView.php');
		}
		}
@@ -123,6 +146,3 @@ function writeProjectPage($pageName){
		require('site/view/public/projectsView.php');
		require('site/view/public/projectsView.php');
	}
	}
}
}
 No newline at end of file

// on récupère le nom de la page ici (avant d'inclure le layout)
$pageName = getPageName();
 No newline at end of file
+12 −5
Original line number Original line Diff line number Diff line
@@ -4,10 +4,9 @@
	<meta charset="utf-8" />
	<meta charset="utf-8" />
	<meta name="description" content="Site perso de Corentin Bettiol." />
	<meta name="description" content="Site perso de Corentin Bettiol." />
	<meta name="viewport" content="width=device-width" />
	<meta name="viewport" content="width=device-width" />
	<title>l3m website - <?php echo $pageName[0]; // voir getPageName() dans mainController ?></title>
	<title>l3m website &ndash; <?php echo $pageName[0]; // voir getPageName() dans mainController ?></title>
	<link rel="stylesheet" href="/css/design.css" />
	<link rel="stylesheet" href="/css/design.css" />
	<?php
	<?php if($pageName[1] == 404){ // le css pour la page 404 ?>
	if($pageName[1] == 404){ // le css pour la page 404 ?>
	<link rel="stylesheet" href="/css/404.css" />
	<link rel="stylesheet" href="/css/404.css" />
	<?php } ?>
	<?php } ?>
	<link rel="icon" type="image/png" href="img/icon.png" />
	<link rel="icon" type="image/png" href="img/icon.png" />
@@ -17,6 +16,11 @@
		}
		}
		#listMenu a{
		#listMenu a{
			background-color: #e3e3e3;
			background-color: #e3e3e3;
			padding: 7px;
		}
		#listMenu .selected{
			padding-bottom: 2px;
			border-bottom: 5px solid #ccc;
		}
		}
	</style>
	</style>
</head>
</head>
@@ -29,7 +33,7 @@
			--><h1 id="title">l3m website</h1>
			--><h1 id="title">l3m website</h1>
		</header>
		</header>
		<nav id="menu">
		<nav id="menu">
			<?php writeMenu($pageName[0]); // voir mainController ?>
			<?php writeMenu($pageName[1]); // voir mainController ?>
		</nav>
		</nav>
	</header>
	</header>


@@ -76,7 +80,10 @@


	<footer id="footer">
	<footer id="footer">
		<p>
		<p>
			Site en vanilla html5/css3/php7, fait avec ♥ - <a href="/changelog" title="changelog">Changelog</a> - <a href="/rss" title="rss">RSS</a> - v5
			Site en vanilla html5/css3/php7, fait avec ♥
		</p>
		<p>
			<a href="/changelog" title="changelog">Changelog</a> - <a href="/rss" title="rss">RSS</a> - v5
		</p>
		</p>
	</footer>
	</footer>


+3 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,9 @@ class Base
		$slug = preg_replace('/-$/', '', $slug);
		$slug = preg_replace('/-$/', '', $slug);
		$slug = preg_replace('/[^a-z0-9-]+/', '', $slug);
		$slug = preg_replace('/[^a-z0-9-]+/', '', $slug);


		if($slug == "")
			$slug = "default";

		// check if the slug already exist
		// check if the slug already exist
		$i = 1;
		$i = 1;
		$old = $slug;
		$old = $slug;
Loading