Skip to content
Snippets Groups Projects
Commit 75fef672 authored by Valentin Degauchy's avatar Valentin Degauchy
Browse files

clean + easter egg

parent ee3b6984
No related branches found
No related tags found
No related merge requests found
Showing with 10 additions and 210 deletions
......@@ -20,11 +20,6 @@
</properties>
<dependencies>
<!-- <dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-data-jpa</artifactId>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
......@@ -68,12 +63,6 @@
<optional>true</optional>
</dependency>
<!-- <dependency>
<groupId>com.h2database</groupId>
<artifactId>h2</artifactId>
<scope>runtime</scope>
</dependency> -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
......
......@@ -45,4 +45,9 @@ public class SimpleController {
mav.addObject("dirfav", s );
return mav;
}
@RequestMapping("/ex5")
public ModelAndView exo5() {
return new ModelAndView("ex5");
}
}
package com.tpKotlin.glhf.tpkotlin.config
import org.springframework.boot.ApplicationRunner
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import com.tpKotlin.glhf.tpkotlin.repositories.*
import com.tpKotlin.glhf.tpkotlin.entity.*
//@Configuration
//open class BlogConfiguration {
//
// @Bean
// open fun databaseInitializer(
// userRepository: UserRepository,
// articleRepository: ArticleRepository
// ) = ApplicationRunner {
// val smaldini = userRepository.save(User("smaldini", "Stéphane", "Maldini"))
//
// articleRepository.save(
// Article(
// title = "Premier chaton cloné sacrifié en la gloire de...",
// headline = "Garlic, 7 ans, impressionne le Démon tant sa chair est tendre",
// content = "todo chaton",
// author = smaldini
// )
// )
// articleRepository.save(
// Article(
// title = "Un groupe de jeunes se réunissent pour invoqu...",
// headline = "Un groupe de jeunes adeptes s'entraînent dans le parc régional",
// content = "todo invoquer",
// author = smaldini
// )
// )
// }
//}
\ No newline at end of file
package com.tpKotlin.glhf.tpkotlin.controller
import org.springframework.stereotype.Controller
import org.springframework.ui.Model
import org.springframework.ui.set
import org.springframework.web.bind.annotation.*
import com.tpKotlin.glhf.tpkotlin.entity.*
import com.tpKotlin.glhf.tpkotlin.extension.*
//import com.tpKotlin.glhf.tpkotlin.repositories.ArticleRepository
import org.springframework.web.server.ResponseStatusException
import org.springframework.http.HttpStatus
//@Controller
//class HtmlController(private val repository: ArticleRepository) {
//
// @GetMapping("/")
// fun blog(model: Model): String {
// model["title"] = "Blog" //model.addAttribute("title", "tp kotlin");
// model["articles"] = repository.findAllByOrderByAddedAtDesc().map { it.render() }
// return "blog"
// }
//
// @GetMapping("/article/{slug}")
// fun article(@PathVariable slug: String, model: Model): String {
// val article = repository
// .findBySlug(slug)
// ?.render()
// ?: throw ResponseStatusException(HttpStatus.NOT_FOUND, "This article does not exist")
// model["title"] = article.title
// model["article"] = article
// return "article"
// }
//
// fun Article.render() = RenderedArticle(
// slug,
// title,
// headline,
// content,
// author,
// addedAt.format()
// )
//
// data class RenderedArticle(
// val slug: String,
// val title: String,
// val headline: String,
// val content: String,
// val author: User,
// val addedAt: String
// )
//
//}
\ No newline at end of file
package com.tpKotlin.glhf.tpkotlin.controller
//import com.tpKotlin.glhf.tpkotlin.repositories.ArticleRepository
//import com.tpKotlin.glhf.tpkotlin.repositories.UserRepository
import org.springframework.http.HttpStatus
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
import org.springframework.web.server.ResponseStatusException
//@RestController
//@RequestMapping("/api/article")
//class ArticleController(private val repository: ArticleRepository) {
//
// @GetMapping("/")
// fun findAll() = repository.findAllByOrderByAddedAtDesc()
//
// @GetMapping("/{slug}")
// fun findOne(@PathVariable slug: String) =
// repository.findBySlug(slug) ?: ResponseStatusException(HttpStatus.NOT_FOUND, "This article does not exist")
//
//}
//
//@RestController
//@RequestMapping("/api/user")
//class UserController(private val repository: UserRepository) {
//
// @GetMapping("/")
// fun findAll() = repository.findAll()
//
// @GetMapping("/{login}")
// fun findOne(@PathVariable login: String) =
// repository.findByLogin(login) ?: ResponseStatusException(HttpStatus.NOT_FOUND, "This user does not exist")
//}
\ No newline at end of file
package com.tpKotlin.glhf.tpkotlin.entity
//import javax.persistence.*
import java.time.LocalDateTime
import com.tpKotlin.glhf.tpkotlin.tools.FileManager
//import com.tpKotlin.glhf.tpkotlin.extension.toSlug
//@Entity
//open class Article(
// open var title: String = "default",
// open var headline: String = "default",
// open var content: String = "default",
// @ManyToOne open var author: User = User(),
// open var slug: String = title.toSlug(),
// open var addedAt: LocalDateTime = LocalDateTime.now(),
// @Id @GeneratedValue open var id: Long? = null
//)
//
//@Entity
//open class User(
// open var login: String = "default",
// open var firstname: String = "default",
// open var lastname: String = "default",
// open var description: String? = null,
// @Id @GeneratedValue open var id: Long? = null
//)
//
//@Entity
//open class Bidon(open var nom: String, @Id @GeneratedValue open var id: Long? = null)
object FavDir {
val list: MutableList<Meme> = mutableListOf()
......
package com.tpKotlin.glhf.tpkotlin.extension
import java.time.LocalDateTime
import java.time.format.DateTimeFormatterBuilder
import java.time.temporal.ChronoField
import java.util.Locale
//fun LocalDateTime.format() = this.format(englishDateFormatter)
//
//private val daysLookup = (1..31).associate { it.toLong() to getOrdinal(it) }
//
//private val englishDateFormatter = DateTimeFormatterBuilder()
// .appendPattern("yyyy-MM-dd")
// .appendLiteral(" ")
// .appendText(ChronoField.DAY_OF_MONTH, daysLookup)
// .appendLiteral(" ")
// .appendPattern("yyyy")
// .toFormatter(Locale.ENGLISH)
//
//private fun getOrdinal(n: Int) = when {
// n in 11..13 -> "${n}th"
// n % 10 == 1 -> "${n}st"
// n % 10 == 2 -> "${n}nd"
// n % 10 == 3 -> "${n}rd"
// else -> "${n}th"
//}
//
//fun String.toSlug() = toLowerCase()
// .replace("\n", " ")
// .replace("[^a-z\\d\\s]".toRegex(), " ")
// .split(" ")
// .joinToString("-")
// .replace("-+".toRegex(), "-")
\ No newline at end of file
package com.tpKotlin.glhf.tpkotlin.repositories
//import org.springframework.data.repository.CrudRepository
//import com.tpKotlin.glhf.tpkotlin.entity.Article
//import com.tpKotlin.glhf.tpkotlin.entity.User
//interface ArticleRepository : CrudRepository<Article, Long> {
// fun findBySlug(slug: String): Article?
// fun findAllByOrderByAddedAtDesc(): Iterable<Article>
//}
//
//interface UserRepository : CrudRepository<User, Long> {
// fun findByLogin(login: String): User?
//}
\ No newline at end of file
......@@ -9,8 +9,10 @@
<title>Exercice 5</title>
</head>
<body>
<c:import url="/WEB-INF/jsp/footer.jsp" />
<br><br><br><br>
<h1 class="center">PRANKED
<br><br>
<img src="https://media1.tenor.com/images/04017b0c56665c471ec3dc1d84e15c23/tenor.gif?itemid=5132217"/>
</h1>
</body>
</html>
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment