add first news

This commit is contained in:
Anton Romanov 2022-03-07 17:26:00 +04:00
parent 4a290142ac
commit bc0646982f
7 changed files with 51 additions and 4 deletions

View File

@ -9,14 +9,20 @@ package ru.ulstu.controller;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import ru.ulstu.model.News;
import java.io.IOException;
import java.util.Arrays;
import java.util.GregorianCalendar;
import java.util.List;
@Controller
public class IndexController {
@GetMapping("/")
public String index(Model model) throws IOException {
public String index(Model model) {
model.addAttribute("news", List.of(new News("Открытие семинара", new GregorianCalendar(2022, 4, 1).getTime(),
"На кафере \"Информационные системы\" Ульяновского государственного технического университета состоится открытие постоянно действующего семинара \"Анализ данных и процессов\". Семинар планируется проводить ежемесячно.")));
return "index";
}
}

View File

@ -0,0 +1,34 @@
package ru.ulstu.model;
import java.util.Date;
public class News {
private final static int MAX_NEWS_TEXT_PREVIEW_LENGTH = 100;
private final String title;
private final Date date;
private final String text;
public News(String title, Date date, String text) {
this.title = title;
this.date = date;
this.text = text;
}
public String getTitle() {
return title;
}
public Date getDate() {
return date;
}
public String getText() {
return text;
}
public String getPreview() {
return text.length() > MAX_NEWS_TEXT_PREVIEW_LENGTH
? text.substring(0, MAX_NEWS_TEXT_PREVIEW_LENGTH) + "..."
: text;
}
}

View File

@ -4,4 +4,5 @@
#
#
messages.app-name=C?????? Ť?????? ?????? ? ?????????ť. ?????
messages.logo-title=C?????? «?????? ?????? ? ?????????»
messages.menu.home=Main

View File

@ -4,4 +4,5 @@
#
#
messages.app-name=Seminar "Analysis of data and processes". UlSTU
messages.logo-title=Seminar "Analysis of data and processes"
messages.menu.home=Main

View File

@ -4,4 +4,5 @@
#
#
messages.app-name=Cеминар «Анализ данных и процессов». УлГТУ
messages.logo-title=Cеминар «Анализ данных и процессов»
messages.menu.home=На главную

View File

@ -10,7 +10,7 @@
<head>
<meta charset="UTF-8"/>
<title th:text="#{messages.app-name}">app-name</title>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<script type="text/javascript" src="/webjars/jquery/3.6.0/jquery.min.js"></script>
<script type="text/javascript" src="/webjars/bootstrap/4.6.0/js/bootstrap.bundle.min.js"></script>
<script type="text/javascript" src="/webjars/bootstrap-select/1.13.8/js/bootstrap-select.min.js"></script>
@ -21,8 +21,8 @@
<body>
<nav class="navbar navbar-expand-lg navbar-light bg-white">
<a class="navbar-brand" href="/">
<img src="img/logo.svg" width="180" height="60" alt="">
<div class="navbar-text" th:text="#{messages.app-name}"></div>
<img src="img/logo.svg" width="50px">
<div class="navbar-text" th:text="#{messages.logo-title}" style="font-size: 16px"></div>
</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>

View File

@ -13,5 +13,9 @@
<meta name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<div class="container" layout:fragment="content">
<div th:each="n : ${news}">
<h5 th:text="${n.title}"/>
<div th:text="${n.preview}"></div>
</div>
</div>
</html>