Skip to content

Commit

Permalink
added message editor and message list
Browse files Browse the repository at this point in the history
  • Loading branch information
daniil-steperev committed May 6, 2020
1 parent fc54c97 commit 1fb6103
Show file tree
Hide file tree
Showing 44 changed files with 3,594 additions and 722 deletions.
499 changes: 245 additions & 254 deletions .idea/workspace.xml

Large diffs are not rendered by default.

679 changes: 679 additions & 0 deletions .idea/workspace_BACKUP_404.xml

Large diffs are not rendered by default.

730 changes: 730 additions & 0 deletions .idea/workspace_BASE_404.xml

Large diffs are not rendered by default.

650 changes: 650 additions & 0 deletions .idea/workspace_LOCAL_404.xml

Large diffs are not rendered by default.

888 changes: 888 additions & 0 deletions .idea/workspace_REMOTE_404.xml

Large diffs are not rendered by default.

17 changes: 0 additions & 17 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -72,23 +72,6 @@
<artifactId>flyway-core</artifactId>
</dependency>

<!-- JAXB -->
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-core</artifactId>
<version>2.3.0</version>
</dependency>
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.3.0</version>
</dependency>

<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
Expand Down
16 changes: 0 additions & 16 deletions src/main/java/com/example/sweater/config/EncriptionConfig.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ public class WebSecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
private PasswordEncoder passwordEncoder;

@Bean
public PasswordEncoder getPasswordEncoder() {
return new BCryptPasswordEncoder(8);
}

@Override
protected void configure(HttpSecurity http) throws Exception {
http
Expand Down
7 changes: 1 addition & 6 deletions src/main/java/com/example/sweater/service/UserService.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.example.sweater.domain.User;
import com.example.sweater.repos.UserRepo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
Expand All @@ -26,9 +25,6 @@ public class UserService implements UserDetailsService {
@Autowired
private PasswordEncoder passwordEncoder;

@Value("${myhostname}")
private String hostname;

@Override
public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
User user = userRepo.findByUsername(username);
Expand Down Expand Up @@ -63,9 +59,8 @@ private void sendMessage(User user) {
if (!StringUtils.isEmpty(user.getEmail())) {
String message = String.format(
"Hello, %s! \n" +
"Welcome to Sweater. Please, visit next link: http://%s/activate/%s",
"Welcome to Sweater. Please, visit next link: http://localhost:8090/activate/%s",
user.getUsername(),
hostname,
user.getActivationCode()
);

Expand Down
29 changes: 0 additions & 29 deletions src/main/resources/application-dev.properties

This file was deleted.

10 changes: 5 additions & 5 deletions src/main/resources/application.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
server.port=8090
spring.datasource.url=jdbc:postgresql://localhost/sweater
spring.datasource.username=postgres
spring.datasource.password=1234
Expand All @@ -6,21 +7,20 @@ spring.jpa.show-sql=false
spring.jpa.hibernate.ddl-auto=validate

spring.freemarker.expose-request-attributes=true
spring.main.allow-bean-definition-overriding=true

spring.mail.host=smtp.yandex.ru
spring.mail.username[email protected]
spring.mail.password=KuKaS123
spring.mail.port=465
spring.mail.protocol=smtps
mail.debug=false
mail.debug=true

spring.jpa.properties.hibernate.jdbc.lob.non_contextual_creation=true

upload.path=/home/ec2-user/uploads
upload.path=/C:/Users/Zver/IdeaProjects/sweater/uploads

recaptcha.secret=6Ld5H-oUAAAAAFVpIcBbCt0QxU7W5pRt-rF5TeTw

spring.session.jdbc.initialize-schema=always
spring.session.jdbc.table-name=SPRING_SESSION

myhostname=3.10.190.24
spring.session.jdbc.table-name=SPRING_SESSION
32 changes: 15 additions & 17 deletions src/main/resources/db/migration/V1__Init_DB.sql
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
create sequence hibernate_sequence start 1 increment 1;

create table message (
id int8 not null,
filename varchar(255),
tag varchar(255),
text varchar(2048) not null,
user_id int8,
primary key (id)
id int8 not null,
filename varchar(255),
tag varchar(255),
text varchar(2048) not null,
user_id int8,
primary key (id)
);

create table user_role (
user_id int8 not null,
roles varchar(255)
user_id int8 not null,
roles varchar(255)
);

create table usr (
id int8 not null,
activation_code varchar(255),
active boolean not null,
email varchar(255),
password varchar(255) not null,
username varchar(255) not null,
primary key (id)
id int8 not null,
active boolean not null,
password varchar(255) not null,
username varchar(255) not null,
primary key (id)
);

alter table if exists message
add constraint message_user_fk
foreign key (user_id) references usr;

alter table if exists user_role
add constraint user_role_user_fk
foreign key (user_id) references usr;
add constraint user_role_user_fk
foreign key (user_id) references usr;
8 changes: 4 additions & 4 deletions src/main/resources/db/migration/V2__Add_admin.sql
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
insert into usr (id, username, password, active)
values (1, 'admin', '123', true);
INSERT INTO usr (id, username, password, active)
VALUES (1, 'admin', '123', true);

insert into user_role (user_id, roles)
values (1, 'USER'), (1, 'ADMIN');
INSERT INTO user_role (user_id, roles)
VALUES (1, 'USER'), (1, 'ADMIN');
2 changes: 1 addition & 1 deletion src/main/resources/db/migration/V3__Encode_passwords.sql
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
create extension if not exists pgcrypto;

update usr set password = crypt(password, gen_salt('bf', 8));
update usr set password = crypt(password, gen_salt('bf', 8))
4 changes: 2 additions & 2 deletions src/main/resources/templates/greeting.ftlh
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@

<@c.page>
<h5>Hello, guest</h5>
<div>This is a simple clone off Twitter</div>
</@c.page>
<div>This is a blog site of Stepyrev Daniil and Tetin Ilya</div>
</@c.page>
24 changes: 12 additions & 12 deletions src/main/resources/templates/login.ftlh
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<#import "parts/login.ftlh" as l>

<@c.page>
<#if Session?? && Session.SPRING_SECURITY_LAST_EXCEPTION??>
<div class="alert alert-danger" role="alert">
${Session.SPRING_SECURITY_LAST_EXCEPTION.message}
</div>
</#if>
<#if message??>
<div class="alert alert-${messageType}" role="alert">
${message}
</div>
</#if>
<@l.login "/login" false/>
</@c.page>
<#if Session?? && Session.SPRING_SECURITY_LAST_EXCEPTION??>
<div class="alert alert-danger" role="alert">
${Session.SPRING_SECURITY_LAST_EXCEPTION.message}
</div>
</#if>
<#if message??>
<div class="alert alert-${messageType}" role="alert">
${message}
</div>
</#if>
<@l.login "/login" false/>
</@c.page>
20 changes: 10 additions & 10 deletions src/main/resources/templates/main.ftlh
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<#import "parts/common.ftlh" as c>

<@c.page>
<div class="form-row">
<div class="form-group col-md-6">
<form method="get" action="/main" class="form-inline">
<input type="text" name="filter" class="form-control" value="${filter?ifExists}" placeholder="Search by tag">
<button type="submit" class="btn btn-primary ml-2">Search</button>
</form>
<div class="form-row">
<div class="form-group col-md-6">
<form method="get" action="/main" class="form-inline">
<input type="text" name="filter" class="form-control" value="${filter?ifExists}" placeholder="Search by tag">
<button type="submit" class="btn btn-primary ml-2">Search</button>
</form>
</div>
</div>
</div>

<#include "parts/messageEdit.ftlh" />
<#include "parts/messageEdit.ftlh" />

<#include "parts/messageList.ftlh" />
<#include "parts/messageList.ftlh" />

</@c.page>
</@c.page>
48 changes: 24 additions & 24 deletions src/main/resources/templates/parts/common.ftlh
Original file line number Diff line number Diff line change
@@ -1,27 +1,27 @@
<#macro page>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sweater</title>
<link rel="stylesheet" href="/static/style.css">
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Sweater</title>
<link rel="stylesheet" href="/static/style.css">

<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">

<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<#include "navbar.ftlh">
<div class="container mt-5">
<#nested>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
</body>
</html>
</#macro>
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/css/bootstrap.min.css" integrity="sha384-WskhaSGFgHYWDcbwN70/dfYBj47jz9qbsMId/iRN3ewGhXQFZCSftd1LZCfmhktB" crossorigin="anonymous">
<script src='https://www.google.com/recaptcha/api.js'></script>
</head>
<body>
<#include "navbar.ftlh">
<div class="container mt-5">
<#nested>
</div>
<!-- Optional JavaScript -->
<!-- jQuery first, then Popper.js, then Bootstrap JS -->
<script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js" integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49" crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.1/js/bootstrap.min.js" integrity="sha384-smHYKdLADwkXOn1EmN1qk/HfnUcbVRZyYmZ4qpPea6sjB/pTJ0euyQp0Mk8ck+5T" crossorigin="anonymous"></script>
</body>
</html>
</#macro>
Loading

0 comments on commit 1fb6103

Please sign in to comment.