remove obsolete kontor.py
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
package de.thpeetz.kontor
|
||||
|
||||
import org.springframework.boot.Banner
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties
|
||||
import org.springframework.boot.runApplication
|
||||
|
||||
@SpringBootApplication
|
||||
@EnableConfigurationProperties(KontorProperties::class)
|
||||
class KontorApplication
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
runApplication<KontorApplication>(*args) {
|
||||
setBannerMode(Banner.Mode.OFF)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package de.thpeetz.kontor
|
||||
|
||||
import de.thpeetz.kontor.comics.*
|
||||
import org.springframework.boot.ApplicationRunner
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Configuration
|
||||
class KontorConfiguration {
|
||||
@Bean
|
||||
fun databaseInitializer(artistRepository: ArtistRepository,
|
||||
publisherRepository: PublisherRepository,
|
||||
comicRepository: ComicRepository,
|
||||
issueRepository: IssueRepository
|
||||
) = ApplicationRunner {
|
||||
|
||||
artistRepository.save(Artist("Turner, Michael"))
|
||||
artistRepository.save(Artist("Bendis, Brian Michael"))
|
||||
artistRepository.save(Artist("Land, Greg"))
|
||||
artistRepository.save(Artist("Whedon, Joss"))
|
||||
val marvel = publisherRepository.save(Publisher("Marvel"))
|
||||
val aspen = publisherRepository.save(Publisher("Aspen"))
|
||||
publisherRepository.save(Publisher("DC"))
|
||||
val de = publisherRepository.save(Publisher("Dynamite Entertainment"))
|
||||
val wildstorm = publisherRepository.save(Publisher("WildStorm"))
|
||||
val bongo = publisherRepository.save(Publisher("Bongo"))
|
||||
val image = publisherRepository.save(Publisher("Image"))
|
||||
val darkHorse = publisherRepository.save(Publisher("Dark Horse Comics"))
|
||||
val cliffhanger = publisherRepository.save(Publisher("Cliffhanger"))
|
||||
comicRepository.save(Comic(title = "X-Men", publisher = marvel, currentOrder = false, completed = false))
|
||||
val redSonja = comicRepository.save(Comic(title = "Red Sonja", publisher = de, currentOrder = false, completed = false))
|
||||
val x23 = comicRepository.save(Comic(title = "X-23", publisher = marvel, currentOrder = false, completed = false))
|
||||
comicRepository.save(Comic(title = "Simpsons Comics", publisher = bongo, currentOrder = false, completed = false))
|
||||
comicRepository.save(Comic(title = "Futurama Comics", publisher = bongo, currentOrder = false, completed = false))
|
||||
comicRepository.save(Comic(title = "Bomb Queen III: The Good, The Bad and The Lovely", publisher = image, currentOrder = false, completed = false))
|
||||
comicRepository.save(Comic(title = "Bomb Queen IV: Suicide Bomber", publisher = image, currentOrder = false, completed = false))
|
||||
comicRepository.save(Comic(title = "Gen13", publisher = wildstorm, currentOrder = false, completed = false))
|
||||
val bombqueen = comicRepository.save(Comic(title = "Bomb Queen II: Queen of Hearts", publisher = image, currentOrder = false, completed = false))
|
||||
comicRepository.save(Comic(title = "Iron & The Maiden",publisher = aspen,currentOrder = false,completed = false))
|
||||
comicRepository.save(Comic(title = "Fathom",publisher = aspen,currentOrder = false,completed = false))
|
||||
comicRepository.save(Comic(title = "Soulfire",publisher = aspen,currentOrder = false,completed = false))
|
||||
comicRepository.save(Comic(title = "Star Wars: Rebellion",publisher = darkHorse,currentOrder = false,completed = false))
|
||||
comicRepository.save(Comic(title = "Star Wars: Rebellion",publisher = darkHorse,currentOrder = false,completed = false))
|
||||
comicRepository.save(Comic(title = "Star Wars: Knights of the Old Republic",publisher = darkHorse,currentOrder = false,completed = false))
|
||||
comicRepository.save(Comic(title = "Star Wars: Legacy",publisher = darkHorse,currentOrder = false,completed = false))
|
||||
comicRepository.save(Comic(title = "Star Wars: Dark Times", publisher = darkHorse, currentOrder = false, completed = false))
|
||||
comicRepository.save(Comic(title = "Samurai: Heaven and Earth", publisher = darkHorse, currentOrder = false, completed = false))
|
||||
val battlpope = comicRepository.save(Comic(title = "Battle Pope", publisher = image,currentOrder = false, completed = false))
|
||||
comicRepository.save(Comic(title = "Danger Girl", publisher = cliffhanger, currentOrder = false, completed = false))
|
||||
val marville = comicRepository.save(Comic(title = "Marville", publisher = marvel, currentOrder = false, completed = false))
|
||||
issueRepository.save(Issue(number = "0", comic = redSonja, gelesen = true))
|
||||
issueRepository.save(Issue(number = "1", comic = redSonja, gelesen = true))
|
||||
issueRepository.save(Issue(number = "2", comic = redSonja, gelesen = true))
|
||||
issueRepository.save(Issue(number = "1", comic = x23, gelesen = false))
|
||||
issueRepository.save(Issue(number = "1", comic = bombqueen, gelesen = false))
|
||||
issueRepository.save(Issue(number = "2", comic = bombqueen, gelesen = false))
|
||||
issueRepository.save(Issue(number = "3", comic = bombqueen, gelesen = false))
|
||||
issueRepository.save(Issue(number = "4", comic = bombqueen, gelesen = false))
|
||||
issueRepository.save(Issue(number = "1", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "2", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "3", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "4", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "5", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "6", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "7", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "8", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "9", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "10", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "11", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "12", comic = battlpope, gelesen = false))
|
||||
issueRepository.save(Issue(number = "1", comic = marville, gelesen = false))
|
||||
issueRepository.save(Issue(number = "2", comic = marville, gelesen = false))
|
||||
issueRepository.save(Issue(number = "3", comic = marville, gelesen = false))
|
||||
issueRepository.save(Issue(number = "4", comic = marville, gelesen = false))
|
||||
issueRepository.save(Issue(number = "5", comic = marville, gelesen = false))
|
||||
issueRepository.save(Issue(number = "6", comic = marville, gelesen = false))
|
||||
issueRepository.save(Issue(number = "7", comic = marville, gelesen = false))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package de.thpeetz.kontor
|
||||
|
||||
import de.thpeetz.kontor.KontorProperties
|
||||
import de.thpeetz.kontor.Navigation
|
||||
import org.springframework.stereotype.Controller
|
||||
import org.springframework.ui.Model
|
||||
import org.springframework.ui.set
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/")
|
||||
class KontorController(val properties: KontorProperties, val navigation: Navigation) {
|
||||
@GetMapping("/")
|
||||
fun blog(model: Model): String {
|
||||
model["title"] = properties.title
|
||||
model["title"] = "Kontor"
|
||||
model["banner"] = properties.banner
|
||||
model["version"] = properties.version
|
||||
model["navigation"] = navigation.links()
|
||||
model["login"] = navigation.login()
|
||||
return "kontor"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package de.thpeetz.kontor
|
||||
|
||||
import org.springframework.boot.context.properties.ConfigurationProperties
|
||||
import org.springframework.boot.context.properties.ConstructorBinding
|
||||
|
||||
@ConstructorBinding
|
||||
@ConfigurationProperties("kontor")
|
||||
data class KontorProperties(var title: String, var version: String = "unknown", val banner: Banner) {
|
||||
data class Banner(val title: String? = null, val content: String)
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package de.thpeetz.kontor
|
||||
|
||||
import org.springframework.context.annotation.Bean
|
||||
import org.springframework.context.annotation.Configuration
|
||||
|
||||
@Configuration
|
||||
class Navigation {
|
||||
|
||||
@Bean
|
||||
fun links(): Iterable<Link> = listOf(
|
||||
Link("/comics", "Comics"),
|
||||
Link("/library","Library"),
|
||||
Link("/office", "HomeOffice"),
|
||||
Link("/tradingcards", "Trading Cards"),
|
||||
Link("/tysc","TradeYourSportsCards"),
|
||||
Link("/user/login", "<span class=\"glyphicon glyphicon-off\" aria-hidden=\"true\"></span>"),
|
||||
Link("/admin/","Admin")
|
||||
)
|
||||
|
||||
@Bean
|
||||
fun login(): Iterable<Link> = listOf(Link("/user/login", "Login"))
|
||||
}
|
||||
|
||||
data class Link(val link: String, val title: String)
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.thpeetz.kontor
|
||||
|
||||
import org.slf4j.LoggerFactory
|
||||
import javax.servlet.Filter
|
||||
import org.springframework.stereotype.Component
|
||||
import javax.servlet.FilterChain
|
||||
import javax.servlet.ServletRequest
|
||||
import javax.servlet.ServletResponse
|
||||
|
||||
@Component
|
||||
class RequestLoggingFilter: Filter {
|
||||
val loggerFactory = LoggerFactory.getLogger("Kontor Logger")
|
||||
|
||||
override fun doFilter(
|
||||
request: ServletRequest,
|
||||
response: ServletResponse,
|
||||
filterChain: FilterChain
|
||||
) {
|
||||
val requestString = request.servletContext.contextPath.toString()
|
||||
//val attributeNames = request.attributeNames
|
||||
//attributeNames.toList().forEach { loggerFactory.info("Attribute: ${it.toString()}") }
|
||||
loggerFactory.info("Logging request: $requestString")
|
||||
filterChain.doFilter(request, response)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package de.thpeetz.kontor.comics
|
||||
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
import org.springframework.web.bind.annotation.RestController
|
||||
|
||||
@RestController
|
||||
@RequestMapping("api/")
|
||||
class ComicsApiController(val artistRepository: ArtistRepository,
|
||||
val publisherRepository: PublisherRepository,
|
||||
val comicRepository: ComicRepository,
|
||||
val issueRepository: IssueRepository) {
|
||||
|
||||
@GetMapping("/artist")
|
||||
fun artistList() = artistRepository.findAll()
|
||||
|
||||
@GetMapping("/publisher")
|
||||
fun publisherList() = publisherRepository.findAll()
|
||||
|
||||
@GetMapping("/comics")
|
||||
fun comicsList() = comicRepository.findAll()
|
||||
|
||||
@GetMapping("/issues")
|
||||
fun issuesList() = issueRepository.findAll()
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package de.thpeetz.kontor.comics
|
||||
|
||||
import de.thpeetz.kontor.KontorProperties
|
||||
import de.thpeetz.kontor.Navigation
|
||||
import org.springframework.stereotype.Controller
|
||||
import org.springframework.ui.Model
|
||||
import org.springframework.ui.set
|
||||
import org.springframework.web.bind.annotation.GetMapping
|
||||
import org.springframework.web.bind.annotation.RequestMapping
|
||||
|
||||
@Controller
|
||||
@RequestMapping("/comics")
|
||||
class ComicsController(private val properties: KontorProperties,
|
||||
val navigation: Navigation,
|
||||
val comicRepository: ComicRepository
|
||||
) {
|
||||
|
||||
@GetMapping("/")
|
||||
fun blog(model: Model): String {
|
||||
model["title"] = properties.title
|
||||
model["title"] = "Comics"
|
||||
model["banner"] = properties.banner
|
||||
model["navigation"] = navigation.links()
|
||||
model["comics"] = comicRepository.findAll().map { it }
|
||||
return "comics"
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package de.thpeetz.kontor.comics
|
||||
|
||||
import javax.persistence.Entity
|
||||
import javax.persistence.GeneratedValue
|
||||
import javax.persistence.Id
|
||||
import javax.persistence.ManyToOne
|
||||
|
||||
|
||||
@Entity
|
||||
class Artist(
|
||||
val name: String,
|
||||
@Id @GeneratedValue val id: Long? = null
|
||||
)
|
||||
|
||||
@Entity
|
||||
class Publisher(
|
||||
val name: String,
|
||||
@Id @GeneratedValue val id: Long? = null
|
||||
)
|
||||
|
||||
@Entity
|
||||
class Comic(
|
||||
val title: String,
|
||||
@ManyToOne val publisher: Publisher,
|
||||
val currentOrder: Boolean,
|
||||
val completed: Boolean,
|
||||
@Id @GeneratedValue val id: Long? = null
|
||||
)
|
||||
|
||||
@Entity
|
||||
class Issue(
|
||||
val number: String,
|
||||
@ManyToOne val comic: Comic,
|
||||
val gelesen: Boolean,
|
||||
@Id @GeneratedValue val id: Long? = null
|
||||
)
|
||||
@@ -0,0 +1,22 @@
|
||||
package de.thpeetz.kontor.comics
|
||||
|
||||
import org.springframework.data.repository.CrudRepository
|
||||
|
||||
interface ArtistRepository: CrudRepository<Artist, String> {
|
||||
|
||||
override fun findAll(): Iterable<Artist>
|
||||
}
|
||||
|
||||
interface PublisherRepository: CrudRepository<Publisher, String> {
|
||||
override fun findAll(): Iterable<Publisher>
|
||||
}
|
||||
|
||||
interface ComicRepository: CrudRepository<Comic, String> {
|
||||
|
||||
override fun findAll(): Iterable<Comic>
|
||||
}
|
||||
|
||||
interface IssueRepository: CrudRepository<Issue, String> {
|
||||
|
||||
override fun findAll(): Iterable<Issue>
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
spring.jpa.properties.hibernate.globally_quoted_identifiers=true
|
||||
spring.jpa.properties.hibernate.globally_quoted_identifiers_skip_column_definitions = true
|
||||
kontor.title=Kontor
|
||||
kontor.version=1.0.0-SNAPSHOT
|
||||
kontor.banner.title=Warning
|
||||
kontor.banner.content=The blog will be down tomorrow.
|
||||
@@ -0,0 +1,23 @@
|
||||
{{> header}}
|
||||
|
||||
{{> menu}}
|
||||
<ul class="nav nav-tabs">
|
||||
<li role="presentation" class="active"><a href="/comics/comic">Comics</a></li>
|
||||
<li role="presentation"><a href="/comics/publisher">Publishers</a></li>
|
||||
<li role="presentation"><a href="/comics/artist">Artists</a></li>
|
||||
</ul>
|
||||
|
||||
<div class="panel panel-default">
|
||||
<table class="table">
|
||||
<caption>List of Comics</caption>
|
||||
<tr><th scope="col">Name</th></tr>
|
||||
{{#comics}}
|
||||
<tr><td><a href="/comics/comic/view/{{id}}">{{title}}</a></td></tr>
|
||||
{{/comics}}
|
||||
</table>
|
||||
<div class="panel-body">
|
||||
<a href="/comics/comic/create">Add entry</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{> footer}}
|
||||
@@ -0,0 +1,22 @@
|
||||
<nav class="navbar navbar-default navbar-fixed-bottom">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<p class="col-lg-12">
|
||||
<ul class="list-inline">
|
||||
<li><a href="/">Kontor</a></li>
|
||||
<li class="footer-menu-divider">⋅</li>
|
||||
{{#login}}
|
||||
<li><a href="{{link}}">{{title}}</a></li>
|
||||
{{/login}}
|
||||
{{^login}}
|
||||
<li><a href="/user/logout">Logout</a></li>
|
||||
{{/login}}
|
||||
</ul>
|
||||
<p class="copyright text-muted small">Version {{version}} Copyright © 2018. All Rights Reserved</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
@@ -0,0 +1,15 @@
|
||||
<!doctype html>
|
||||
<html lang="de">
|
||||
<head>
|
||||
<!--Use the `title` variable to set the title of the page-->
|
||||
<title>{{title}}</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="UTF-8">
|
||||
|
||||
<!--Use bootstrap to make the application look decent-->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous">
|
||||
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
|
||||
<script async src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js" integrity="sha384-0mSbJDEHialfmuBBQP6A4Qrprq5OVfW37PRR3j5ELqxss1yVqOtnepnHVP9aJ7xS" crossorigin="anonymous"></script>
|
||||
</head>
|
||||
|
||||
<body class="container">
|
||||
@@ -0,0 +1,18 @@
|
||||
{{> header}}
|
||||
|
||||
{{> menu}}
|
||||
|
||||
<div>
|
||||
{{#banner.title}}
|
||||
<section>
|
||||
<header class="banner">
|
||||
<h2 class="banner-title">{{banner.title}}</h2>
|
||||
</header>
|
||||
<div class="banner-content">
|
||||
{{banner.content}}
|
||||
</div>
|
||||
</section>
|
||||
{{/banner.title}}
|
||||
</div>
|
||||
|
||||
{{> footer}}
|
||||
@@ -0,0 +1,23 @@
|
||||
<nav class="navbar navbar-default">
|
||||
<div class="container-fluid">
|
||||
<!-- Brand and toggle get grouped for better mobile display -->
|
||||
<div class="navbar-header">
|
||||
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false">
|
||||
<span class="sr-only">Toggle navigation</span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</button>
|
||||
<a class="navbar-brand" href="/">Kontor</a>
|
||||
</div>
|
||||
|
||||
<!-- Collect the nav links, forms, and other content for toggling -->
|
||||
<div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1">
|
||||
<ul class="nav navbar-nav navbar-right">
|
||||
{{#navigation}}
|
||||
<li><a href="{{link}}">{{title}}</a></li>
|
||||
{{/navigation}}
|
||||
</ul>
|
||||
</div><!-- /.navbar-collapse -->
|
||||
</div><!-- /.container-fluid -->
|
||||
</nav>
|
||||
Reference in New Issue
Block a user