diff --git a/.idea/compiler.xml b/.idea/compiler.xml new file mode 100644 index 0000000..6e6ce76 --- /dev/null +++ b/.idea/compiler.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/hola.txt b/hola.txt new file mode 100644 index 0000000..8a6fe2b --- /dev/null +++ b/hola.txt @@ -0,0 +1 @@ +dss \ No newline at end of file diff --git a/src/main/java/com/example/demo/DemoApplication.java b/src/main/java/com/example/demo/DemoApplication.java new file mode 100644 index 0000000..9f5f81d --- /dev/null +++ b/src/main/java/com/example/demo/DemoApplication.java @@ -0,0 +1,13 @@ +package com.example.demo; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +/* Equivalente a : @Configuration + @EnableAutoConfiguration + @ComponentScan = @SpringBootApplication */ +@SpringBootApplication +public class DemoApplication { + + public static void main(String[] args) { + SpringApplication.run(DemoApplication.class, args); + } + +} diff --git a/src/main/java/com/example/demo/Dominio.java b/src/main/java/com/example/demo/Dominio.java new file mode 100644 index 0000000..746a7a8 --- /dev/null +++ b/src/main/java/com/example/demo/Dominio.java @@ -0,0 +1,111 @@ +package com.example.demo; + +import org.springframework.web.servlet.support.ServletUriComponentsBuilder; + +import java.net.InetAddress; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.UnknownHostException; + +import static java.net.IDN.toASCII; +import static java.net.IDN.toUnicode; + +public class Dominio { + + String host; + String protocolo; + String dominio; + String tld; + int puerto; + String addr; + byte[] address; + String canonnical; + String hostname; + String url; + String path; + String error; + String query; + + public Dominio() throws MalformedURLException { + + final String currentURL = ServletUriComponentsBuilder.fromCurrentContextPath().build().toUriString(); + URL requestURL = new URL(currentURL); + + this.puerto = requestURL.getPort(); + this.host = requestURL.getHost(); + this.protocolo = requestURL.getProtocol(); + this.path = requestURL.getPath(); + this.query = requestURL.getQuery(); + + /* información del servidor */ + InetAddress iaddr=null; + String hostnameCanonical=null; + String hostname=null; + byte[] address=null; + try { + iaddr = InetAddress.getByName(InetAddress.getLocalHost().getHostName()); + this.addr = iaddr.toString(); + this.canonnical = iaddr.getCanonicalHostName(); + this.address = iaddr.getAddress(); + this.hostname = iaddr.getHostName(); + } catch (UnknownHostException e) { + this.error="UnknownHostException"; + } + this.url = currentURL; + + //Eliminamos www si existen + this.url = url.replace("www.",""); + + //Buscamos el primer . (http://eldominio.****** + int y=url.indexOf('.'); + if (y==-1) { + this.dominio= "sin-dominio"; + this.tld = "sin-tld"; + } + else { + this.dominio = toUnicode(url.substring(url.indexOf("://")+3,y)); + this.tld = url.substring(y).replace(":"+this.puerto,""); + } + } + + public String getError() { + return error; + } + public String getAddr() { + return addr; + } + public byte[] getAddress() { + return address; + } + public String getCanonnical() { + return canonnical; + } + public String getHostname() { + return hostname; + } + public String getHost() { + return host; + } + public String getUrl() { + return url; + } + public String getPath() { + return path; + } + public String getQuery() { + return query; + } + public String getProtocolo() { + return protocolo; + } + public String getDominio() { + return dominio; + } + public String getTld() { + return tld; + } + public int getPuerto() { + return puerto; + } + +} diff --git a/src/main/java/com/example/demo/controllers/EmpleadoController.java b/src/main/java/com/example/demo/controllers/EmpleadoController.java new file mode 100644 index 0000000..135ab4a --- /dev/null +++ b/src/main/java/com/example/demo/controllers/EmpleadoController.java @@ -0,0 +1,46 @@ +package com.example.demo.controllers; + +import com.example.demo.models.Empleado; +import com.example.demo.services.EmpleadoServicio; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PostMapping; + +@Controller +public class EmpleadoController { + + @Autowired + private EmpleadoServicio servicio; + + @GetMapping({"empleado/list"}) + public String listado (Model model) { + + model.addAttribute("mensaje","Ramoncín esto es una prueba"); + model.addAttribute("dominio","dom.getDominio()"); + model.addAttribute("tld","dom.getTld()"); + model.addAttribute("pagina","list"); + model.addAttribute("listaEmpleados",servicio.findAll()); + return "index"; + } + @GetMapping({"empleado/alta"}) + public String alta (Model model) { + + model.addAttribute("mensaje","Ramoncín esto es una prueba"); + model.addAttribute("dominio","dom.getDominio()"); + model.addAttribute("tld","dom.getTld()"); + model.addAttribute("empleadoForm", new Empleado()); + model.addAttribute("pagina","alta"); + + return "index"; + } + + @PostMapping("/empleado/new/submit") + public String nuevoEmpleadoSubmit(@ModelAttribute("empleadoForm") Empleado nuevoEmpleado) { + servicio.add(nuevoEmpleado); + return "redirect:/empleado/list"; + } + +} diff --git a/src/main/java/com/example/demo/models/Director.java b/src/main/java/com/example/demo/models/Director.java new file mode 100644 index 0000000..60067c4 --- /dev/null +++ b/src/main/java/com/example/demo/models/Director.java @@ -0,0 +1,54 @@ +package com.example.demo.models; + +import java.util.Objects; + +public class Director { + + private long id; + private String name; + + public Director() {} + + public Director(long id, String name) { + this.id = id; + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Director director = (Director) o; + return id == director.id && Objects.equals(name, director.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + return "Director{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } + +} diff --git a/src/main/java/com/example/demo/models/Empleado.java b/src/main/java/com/example/demo/models/Empleado.java new file mode 100644 index 0000000..17dde2c --- /dev/null +++ b/src/main/java/com/example/demo/models/Empleado.java @@ -0,0 +1,74 @@ +package com.example.demo.models; + +import java.util.Objects; + +public class Empleado { + private long id; + private String nombre; + private String email; + private String telefono; + + public Empleado(){} + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Empleado empleado = (Empleado) o; + return getId() == empleado.getId() && getNombre().equals(empleado.getNombre()) && getEmail().equals(empleado.getEmail()) && getTelefono().equals(empleado.getTelefono()); + } + + @Override + public int hashCode() { + return Objects.hash(getId(), getNombre(), getEmail(), getTelefono()); + } + + public Empleado (long id, String nombre, String email, String telefono){ + this.id = id; + this.nombre = nombre; + this.email = email; + this.telefono = telefono; + } + + @Override + public String toString() { + return "Empleado{" + + "id=" + id + + ", nombre='" + nombre + '\'' + + ", email='" + email + '\'' + + ", telefono='" + telefono + '\'' + + '}'; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getNombre() { + return nombre; + } + + public void setNombre(String nombre) { + this.nombre = nombre; + } + + public String getEmail() { + return email; + } + + public void setEmail(String email) { + this.email = email; + } + + public String getTelefono() { + return telefono; + } + + public void setTelefono(String telefono) { + this.telefono = telefono; + } +} diff --git a/src/main/java/com/example/demo/models/Genre.java b/src/main/java/com/example/demo/models/Genre.java new file mode 100644 index 0000000..980db54 --- /dev/null +++ b/src/main/java/com/example/demo/models/Genre.java @@ -0,0 +1,54 @@ +package com.example.demo.models; + +import java.util.Objects; + +public class Genre { + + private long id; + private String name; + + public Genre(){} + + public Genre(long id, String name) { + this.id = id; + this.name = name; + } + + public long getId() { + return id; + } + + public void setId(long id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + Genre genre = (Genre) o; + return id == genre.id && Objects.equals(name, genre.name); + } + + @Override + public int hashCode() { + return Objects.hash(id, name); + } + + @Override + public String toString() { + return "Genre{" + + "id=" + id + + ", name='" + name + '\'' + + '}'; + } + +} diff --git a/src/main/java/com/example/demo/services/EmpleadoServicio.java b/src/main/java/com/example/demo/services/EmpleadoServicio.java new file mode 100644 index 0000000..b4471ef --- /dev/null +++ b/src/main/java/com/example/demo/services/EmpleadoServicio.java @@ -0,0 +1,36 @@ +package com.example.demo.services; + +import com.example.demo.models.Empleado; +import org.springframework.stereotype.Service; + +import javax.annotation.PostConstruct; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +@Service +public class EmpleadoServicio { + private List repositorio = new ArrayList<>(); + + public EmpleadoServicio() { + } + + public Empleado add(Empleado e){ + repositorio.add(e); + return e; + } + + public List findAll() { + return repositorio; + } + + @PostConstruct + public void init() { + repositorio.addAll( + Arrays.asList(new Empleado(1,"Juan","juan@juan.com","1111111111"), + new Empleado(2,"Perico","perico@perico.com","2222222222"), + new Empleado(3,"Andrés","andres@andres.com","3333333333")) + ); + } + +} diff --git a/src/main/resources/META-INF/resources/hola2.html b/src/main/resources/META-INF/resources/hola2.html new file mode 100644 index 0000000..3721a6b --- /dev/null +++ b/src/main/resources/META-INF/resources/hola2.html @@ -0,0 +1,10 @@ + + + + +Insert title here + + +hola 2 + + \ No newline at end of file diff --git a/src/main/resources/resources/hola.html b/src/main/resources/resources/hola.html new file mode 100644 index 0000000..24442dc --- /dev/null +++ b/src/main/resources/resources/hola.html @@ -0,0 +1,10 @@ + + + + +Insert title here + + +hola + + \ No newline at end of file diff --git a/src/main/resources/static/css/claro.css b/src/main/resources/static/css/claro.css new file mode 100644 index 0000000..7bf1afa --- /dev/null +++ b/src/main/resources/static/css/claro.css @@ -0,0 +1,4 @@ +@charset "UTF-8"; +body { + background-color: white; +} \ No newline at end of file diff --git a/src/main/resources/static/css/estilo.css b/src/main/resources/static/css/estilo.css new file mode 100644 index 0000000..504ec56 --- /dev/null +++ b/src/main/resources/static/css/estilo.css @@ -0,0 +1,8 @@ +@charset "UTF-8"; +body { + padding-bottom: 20px; +} + +.navbar { + margin-bottom: 20px; +} \ No newline at end of file diff --git a/src/main/resources/static/img/enterthevoid.png b/src/main/resources/static/img/enterthevoid.png new file mode 100644 index 0000000..1dabdb1 Binary files /dev/null and b/src/main/resources/static/img/enterthevoid.png differ diff --git a/src/main/resources/static/img/la_filmoteca_wordmark.png b/src/main/resources/static/img/la_filmoteca_wordmark.png new file mode 100644 index 0000000..a58a239 Binary files /dev/null and b/src/main/resources/static/img/la_filmoteca_wordmark.png differ diff --git a/src/main/resources/templates/empleado/form.html b/src/main/resources/templates/empleado/form.html new file mode 100644 index 0000000..ad1bae7 --- /dev/null +++ b/src/main/resources/templates/empleado/form.html @@ -0,0 +1,42 @@ +
+

Alta de empleados de la empresa

+
+ +
+
+
+

Nuevo empleado

+
+ + Errores +
+ +
+ +
+
+ + +
+
+ + +
+ +
+
+
+
+ + +
\ No newline at end of file diff --git a/src/main/resources/templates/error/error.html b/src/main/resources/templates/error/error.html new file mode 100644 index 0000000..e628f9d --- /dev/null +++ b/src/main/resources/templates/error/error.html @@ -0,0 +1,13 @@ + + + + Error page + + + + +

Ha habido un error...

+

Error java.lang.NullPointerException

+ Volver al inicio + + \ No newline at end of file diff --git a/src/main/resources/templates/foot/footer.html b/src/main/resources/templates/foot/footer.html new file mode 100644 index 0000000..77dadd2 --- /dev/null +++ b/src/main/resources/templates/foot/footer.html @@ -0,0 +1,60 @@ +
+ + + +
+
+
+ +
+
+

La Filmoteca

+
+

+ Acercamos de una manera intuitiva las mejores películas de la historia según nuestros expertos y las más + prestigiosas publicaciones de este arte. +

+
+ +
+
Contacta con nosotros
+

Gata de Gorgos

+

lafilmoteca@atencion.es

+

+ 96 234 567 88

+
+ +
+
+
+ +
+

2023 © La Filmoteca

+

Con la tecnologia de + MDBootstrap.com

+ Crear PDF +
+ + + +
\ No newline at end of file diff --git a/src/main/resources/templates/formularios/formulario.html b/src/main/resources/templates/formularios/formulario.html new file mode 100644 index 0000000..e69de29 diff --git a/src/main/resources/templates/head/head.html b/src/main/resources/templates/head/head.html new file mode 100644 index 0000000..388c007 --- /dev/null +++ b/src/main/resources/templates/head/head.html @@ -0,0 +1,10 @@ + + + + + Título de la página + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/hora.html b/src/main/resources/templates/hora.html new file mode 100644 index 0000000..5dda0c8 --- /dev/null +++ b/src/main/resources/templates/hora.html @@ -0,0 +1,14 @@ + + + + + + Hora + + +

Hola thymeleaf hoy es ...

+

+ + + diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html new file mode 100644 index 0000000..50c447b --- /dev/null +++ b/src/main/resources/templates/index.html @@ -0,0 +1,27 @@ + + + + Título de la página + + +
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+ + + + + + diff --git a/src/main/resources/templates/sections/escribir_resenya.html b/src/main/resources/templates/sections/escribir_resenya.html new file mode 100644 index 0000000..f2610bc --- /dev/null +++ b/src/main/resources/templates/sections/escribir_resenya.html @@ -0,0 +1,27 @@ + + + + Título de la página + + +
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+ + + + + + diff --git a/src/main/resources/templates/sections/genero_elegido.html b/src/main/resources/templates/sections/genero_elegido.html new file mode 100644 index 0000000..566549b --- /dev/null +++ b/src/main/resources/templates/sections/genero_elegido.html @@ -0,0 +1,10 @@ + + + + + Title + + + + + \ No newline at end of file diff --git a/src/main/resources/templates/sections/generos.html b/src/main/resources/templates/sections/generos.html new file mode 100644 index 0000000..3260d5e --- /dev/null +++ b/src/main/resources/templates/sections/generos.html @@ -0,0 +1,27 @@ + + + + Título de la página + + +
+ +
+
+
+
+
+
+
+
+
+
+
+ +
+ + + + + + \ No newline at end of file diff --git a/src/test/java/com/example/demo/DemoApplicationTests.java b/src/test/java/com/example/demo/DemoApplicationTests.java new file mode 100644 index 0000000..2778a6a --- /dev/null +++ b/src/test/java/com/example/demo/DemoApplicationTests.java @@ -0,0 +1,13 @@ +package com.example.demo; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class DemoApplicationTests { + + @Test + void contextLoads() { + } + +}