personalweb

Archived
git clone git://git.wimdupont.com/personalweb.git
Log | Files | Refs | README | LICENSE

commit 48e3cb6d8aed070b13d554c7acf32b8b2e1c68dc
Author: WimDupont <WimDupont@users.noreply.gitlab.com>
Date:   Sun, 20 Jun 2021 18:37:19 +0200

init

Diffstat:
A.gitignore | 36++++++++++++++++++++++++++++++++++++
A.mvn/wrapper/MavenWrapperDownloader.java | 117+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
A.mvn/wrapper/maven-wrapper.jar | 0
A.mvn/wrapper/maven-wrapper.properties | 2++
ALICENSE | 339+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Afeed.xml | 17+++++++++++++++++
Amvnw | 310+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Amvnw.cmd | 182+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Apom.xml | 133+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/PersonalWebApplication.java | 30++++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/api/AffirmationApi.java | 25+++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/api/dto/affirmation/Affirmation.java | 15+++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/config/RestTemplateConfig.java | 16++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/config/SecurityConfig.java | 18++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/config/ServerConfig.java | 41+++++++++++++++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/config/ThymeleafConfig.java | 44++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/controller/BlogController.java | 27+++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/controller/BookController.java | 37+++++++++++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/controller/FeedController.java | 20++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/controller/IndexController.java | 24++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/converter/BookToBookDtoConverter.java | 20++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/converter/Converter.java | 10++++++++++
Asrc/main/java/com/wimdupont/personalweb/model/dao/Book.java | 29+++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/model/dao/rss/Channel.java | 30++++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/model/dao/rss/Item.java | 31+++++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/model/dto/BookDto.java | 21+++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/model/dto/DTO.java | 4++++
Asrc/main/java/com/wimdupont/personalweb/repository/BookRepository.java | 10++++++++++
Asrc/main/java/com/wimdupont/personalweb/service/AdocConverter.java | 8++++++++
Asrc/main/java/com/wimdupont/personalweb/service/BookService.java | 10++++++++++
Asrc/main/java/com/wimdupont/personalweb/service/RSSFeedGenerator.java | 10++++++++++
Asrc/main/java/com/wimdupont/personalweb/service/impl/AdocConverterImpl.java | 31+++++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/service/impl/BookServiceImpl.java | 23+++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/service/impl/RSSFeedGeneratorImpl.java | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/java/com/wimdupont/personalweb/service/impl/RssFeedImpl.java | 52++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/resources/adoc/article1.adoc | 22++++++++++++++++++++++
Asrc/main/resources/adoc/article2.adoc | 5+++++
Asrc/main/resources/db/migration/V1_0__db-init.sql | 8++++++++
Asrc/main/resources/db/migration/repeatable/R__fill_book_table.sql | 41+++++++++++++++++++++++++++++++++++++++++
Asrc/main/resources/static/css/adoc.css | 9+++++++++
Asrc/main/resources/static/css/main.css | 131+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Asrc/main/resources/static/images/gitlab.png | 0
Asrc/main/resources/static/images/rssfeed.png | 0
Asrc/main/resources/templates/blog.html | 18++++++++++++++++++
Asrc/main/resources/templates/books.html | 29+++++++++++++++++++++++++++++
Asrc/main/resources/templates/home.html | 19+++++++++++++++++++
Asrc/main/resources/templates/navigation.html | 13+++++++++++++
Asrc/test/java/com/wimdupont/personalweb/PersonalWebApplicationTests.java | 13+++++++++++++
Asrc/test/java/com/wimdupont/personalweb/converter/BookToBookDtoConverterTest.java | 38++++++++++++++++++++++++++++++++++++++
49 files changed, 2124 insertions(+), 0 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -0,0 +1,36 @@ +HELP.md +target/ +!.mvn/wrapper/maven-wrapper.jar +!**/src/main/**/target/ +!**/src/test/**/target/ + +### STS ### +.apt_generated +.classpath +.factorypath +.project +.settings +.springBeans +.sts4-cache + +### IntelliJ IDEA ### +.idea +*.iws +*.iml +*.ipr + +### NetBeans ### +/nbproject/private/ +/nbbuild/ +/dist/ +/nbdist/ +/.nb-gradle/ +build/ +!**/src/main/**/build/ +!**/src/test/**/build/ + +### VS Code ### +.vscode/ + +/src/main/resources/keystore.* +/src/main/resources/application.properties diff --git a/.mvn/wrapper/MavenWrapperDownloader.java b/.mvn/wrapper/MavenWrapperDownloader.java @@ -0,0 +1,117 @@ +/* + * Copyright 2007-present the original author or authors. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +import java.net.*; +import java.io.*; +import java.nio.channels.*; +import java.util.Properties; + +public class MavenWrapperDownloader { + + private static final String WRAPPER_VERSION = "0.5.6"; + /** + * Default URL to download the maven-wrapper.jar from, if no 'downloadUrl' is provided. + */ + private static final String DEFAULT_DOWNLOAD_URL = "https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/" + + WRAPPER_VERSION + "/maven-wrapper-" + WRAPPER_VERSION + ".jar"; + + /** + * Path to the maven-wrapper.properties file, which might contain a downloadUrl property to + * use instead of the default one. + */ + private static final String MAVEN_WRAPPER_PROPERTIES_PATH = + ".mvn/wrapper/maven-wrapper.properties"; + + /** + * Path where the maven-wrapper.jar will be saved to. + */ + private static final String MAVEN_WRAPPER_JAR_PATH = + ".mvn/wrapper/maven-wrapper.jar"; + + /** + * Name of the property which should be used to override the default download url for the wrapper. + */ + private static final String PROPERTY_NAME_WRAPPER_URL = "wrapperUrl"; + + public static void main(String args[]) { + System.out.println("- Downloader started"); + File baseDirectory = new File(args[0]); + System.out.println("- Using base directory: " + baseDirectory.getAbsolutePath()); + + // If the maven-wrapper.properties exists, read it and check if it contains a custom + // wrapperUrl parameter. + File mavenWrapperPropertyFile = new File(baseDirectory, MAVEN_WRAPPER_PROPERTIES_PATH); + String url = DEFAULT_DOWNLOAD_URL; + if(mavenWrapperPropertyFile.exists()) { + FileInputStream mavenWrapperPropertyFileInputStream = null; + try { + mavenWrapperPropertyFileInputStream = new FileInputStream(mavenWrapperPropertyFile); + Properties mavenWrapperProperties = new Properties(); + mavenWrapperProperties.load(mavenWrapperPropertyFileInputStream); + url = mavenWrapperProperties.getProperty(PROPERTY_NAME_WRAPPER_URL, url); + } catch (IOException e) { + System.out.println("- ERROR loading '" + MAVEN_WRAPPER_PROPERTIES_PATH + "'"); + } finally { + try { + if(mavenWrapperPropertyFileInputStream != null) { + mavenWrapperPropertyFileInputStream.close(); + } + } catch (IOException e) { + // Ignore ... + } + } + } + System.out.println("- Downloading from: " + url); + + File outputFile = new File(baseDirectory.getAbsolutePath(), MAVEN_WRAPPER_JAR_PATH); + if(!outputFile.getParentFile().exists()) { + if(!outputFile.getParentFile().mkdirs()) { + System.out.println( + "- ERROR creating output directory '" + outputFile.getParentFile().getAbsolutePath() + "'"); + } + } + System.out.println("- Downloading to: " + outputFile.getAbsolutePath()); + try { + downloadFileFromURL(url, outputFile); + System.out.println("Done"); + System.exit(0); + } catch (Throwable e) { + System.out.println("- Error downloading"); + e.printStackTrace(); + System.exit(1); + } + } + + private static void downloadFileFromURL(String urlString, File destination) throws Exception { + if (System.getenv("MVNW_USERNAME") != null && System.getenv("MVNW_PASSWORD") != null) { + String username = System.getenv("MVNW_USERNAME"); + char[] password = System.getenv("MVNW_PASSWORD").toCharArray(); + Authenticator.setDefault(new Authenticator() { + @Override + protected PasswordAuthentication getPasswordAuthentication() { + return new PasswordAuthentication(username, password); + } + }); + } + URL website = new URL(urlString); + ReadableByteChannel rbc; + rbc = Channels.newChannel(website.openStream()); + FileOutputStream fos = new FileOutputStream(destination); + fos.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE); + fos.close(); + rbc.close(); + } + +} diff --git a/.mvn/wrapper/maven-wrapper.jar b/.mvn/wrapper/maven-wrapper.jar Binary files differ. diff --git a/.mvn/wrapper/maven-wrapper.properties b/.mvn/wrapper/maven-wrapper.properties @@ -0,0 +1,2 @@ +distributionUrl=https://repo.maven.apache.org/maven2/org/apache/maven/apache-maven/3.6.3/apache-maven-3.6.3-bin.zip +wrapperUrl=https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar diff --git a/LICENSE b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + PersonalWeb + Copyright (C) 2021 Wim Dupont + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + <signature of Ty Coon>, 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. diff --git a/feed.xml b/feed.xml @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<rss xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0"> + <channel> + <title>title</title> + <link>www.wimdupont.com/rss</link> + <description>World's greatest RSS feed</description> + <item> + <title>Wow</title> + <link>www.wimdupont.com/blog</link> + <description>Content Value</description> + <pubDate>Sun, 23 May 2021 19:52:39 GMT</pubDate> + <guid>www.wimdupont.com/blog</guid> + <dc:date>2021-05-23T19:52:39Z</dc:date> + </item> + </channel> +</rss> + diff --git a/mvnw b/mvnw @@ -0,0 +1,310 @@ +#!/bin/sh +# ---------------------------------------------------------------------------- +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. +# ---------------------------------------------------------------------------- + +# ---------------------------------------------------------------------------- +# Maven Start Up Batch script +# +# Required ENV vars: +# ------------------ +# JAVA_HOME - location of a JDK home dir +# +# Optional ENV vars +# ----------------- +# M2_HOME - location of maven2's installed home dir +# MAVEN_OPTS - parameters passed to the Java VM when running Maven +# e.g. to debug Maven itself, use +# set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +# MAVEN_SKIP_RC - flag to disable loading of mavenrc files +# ---------------------------------------------------------------------------- + +if [ -z "$MAVEN_SKIP_RC" ] ; then + + if [ -f /etc/mavenrc ] ; then + . /etc/mavenrc + fi + + if [ -f "$HOME/.mavenrc" ] ; then + . "$HOME/.mavenrc" + fi + +fi + +# OS specific support. $var _must_ be set to either true or false. +cygwin=false; +darwin=false; +mingw=false +case "`uname`" in + CYGWIN*) cygwin=true ;; + MINGW*) mingw=true;; + Darwin*) darwin=true + # Use /usr/libexec/java_home if available, otherwise fall back to /Library/Java/Home + # See https://developer.apple.com/library/mac/qa/qa1170/_index.html + if [ -z "$JAVA_HOME" ]; then + if [ -x "/usr/libexec/java_home" ]; then + export JAVA_HOME="`/usr/libexec/java_home`" + else + export JAVA_HOME="/Library/Java/Home" + fi + fi + ;; +esac + +if [ -z "$JAVA_HOME" ] ; then + if [ -r /etc/gentoo-release ] ; then + JAVA_HOME=`java-config --jre-home` + fi +fi + +if [ -z "$M2_HOME" ] ; then + ## resolve links - $0 may be a link to maven's home + PRG="$0" + + # need this for relative symlinks + while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG="`dirname "$PRG"`/$link" + fi + done + + saveddir=`pwd` + + M2_HOME=`dirname "$PRG"`/.. + + # make it fully qualified + M2_HOME=`cd "$M2_HOME" && pwd` + + cd "$saveddir" + # echo Using m2 at $M2_HOME +fi + +# For Cygwin, ensure paths are in UNIX format before anything is touched +if $cygwin ; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --unix "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --unix "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --unix "$CLASSPATH"` +fi + +# For Mingw, ensure paths are in UNIX format before anything is touched +if $mingw ; then + [ -n "$M2_HOME" ] && + M2_HOME="`(cd "$M2_HOME"; pwd)`" + [ -n "$JAVA_HOME" ] && + JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" +fi + +if [ -z "$JAVA_HOME" ]; then + javaExecutable="`which javac`" + if [ -n "$javaExecutable" ] && ! [ "`expr \"$javaExecutable\" : '\([^ ]*\)'`" = "no" ]; then + # readlink(1) is not available as standard on Solaris 10. + readLink=`which readlink` + if [ ! `expr "$readLink" : '\([^ ]*\)'` = "no" ]; then + if $darwin ; then + javaHome="`dirname \"$javaExecutable\"`" + javaExecutable="`cd \"$javaHome\" && pwd -P`/javac" + else + javaExecutable="`readlink -f \"$javaExecutable\"`" + fi + javaHome="`dirname \"$javaExecutable\"`" + javaHome=`expr "$javaHome" : '\(.*\)/bin'` + JAVA_HOME="$javaHome" + export JAVA_HOME + fi + fi +fi + +if [ -z "$JAVACMD" ] ; then + if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + else + JAVACMD="`which java`" + fi +fi + +if [ ! -x "$JAVACMD" ] ; then + echo "Error: JAVA_HOME is not defined correctly." >&2 + echo " We cannot execute $JAVACMD" >&2 + exit 1 +fi + +if [ -z "$JAVA_HOME" ] ; then + echo "Warning: JAVA_HOME environment variable is not set." +fi + +CLASSWORLDS_LAUNCHER=org.codehaus.plexus.classworlds.launcher.Launcher + +# traverses directory structure from process work directory to filesystem root +# first directory with .mvn subdirectory is considered project base directory +find_maven_basedir() { + + if [ -z "$1" ] + then + echo "Path not specified to find_maven_basedir" + return 1 + fi + + basedir="$1" + wdir="$1" + while [ "$wdir" != '/' ] ; do + if [ -d "$wdir"/.mvn ] ; then + basedir=$wdir + break + fi + # workaround for JBEAP-8937 (on Solaris 10/Sparc) + if [ -d "${wdir}" ]; then + wdir=`cd "$wdir/.."; pwd` + fi + # end of workaround + done + echo "${basedir}" +} + +# concatenates all lines of a file +concat_lines() { + if [ -f "$1" ]; then + echo "$(tr -s '\n' ' ' < "$1")" + fi +} + +BASE_DIR=`find_maven_basedir "$(pwd)"` +if [ -z "$BASE_DIR" ]; then + exit 1; +fi + +########################################################################################## +# Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +# This allows using the maven wrapper in projects that prohibit checking in binary data. +########################################################################################## +if [ -r "$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found .mvn/wrapper/maven-wrapper.jar" + fi +else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Couldn't find .mvn/wrapper/maven-wrapper.jar, downloading it ..." + fi + if [ -n "$MVNW_REPOURL" ]; then + jarUrl="$MVNW_REPOURL/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + else + jarUrl="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + fi + while IFS="=" read key value; do + case "$key" in (wrapperUrl) jarUrl="$value"; break ;; + esac + done < "$BASE_DIR/.mvn/wrapper/maven-wrapper.properties" + if [ "$MVNW_VERBOSE" = true ]; then + echo "Downloading from: $jarUrl" + fi + wrapperJarPath="$BASE_DIR/.mvn/wrapper/maven-wrapper.jar" + if $cygwin; then + wrapperJarPath=`cygpath --path --windows "$wrapperJarPath"` + fi + + if command -v wget > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found wget ... using wget" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + wget "$jarUrl" -O "$wrapperJarPath" + else + wget --http-user=$MVNW_USERNAME --http-password=$MVNW_PASSWORD "$jarUrl" -O "$wrapperJarPath" + fi + elif command -v curl > /dev/null; then + if [ "$MVNW_VERBOSE" = true ]; then + echo "Found curl ... using curl" + fi + if [ -z "$MVNW_USERNAME" ] || [ -z "$MVNW_PASSWORD" ]; then + curl -o "$wrapperJarPath" "$jarUrl" -f + else + curl --user $MVNW_USERNAME:$MVNW_PASSWORD -o "$wrapperJarPath" "$jarUrl" -f + fi + + else + if [ "$MVNW_VERBOSE" = true ]; then + echo "Falling back to using Java to download" + fi + javaClass="$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.java" + # For Cygwin, switch paths to Windows format before running javac + if $cygwin; then + javaClass=`cygpath --path --windows "$javaClass"` + fi + if [ -e "$javaClass" ]; then + if [ ! -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Compiling MavenWrapperDownloader.java ..." + fi + # Compiling the Java class + ("$JAVA_HOME/bin/javac" "$javaClass") + fi + if [ -e "$BASE_DIR/.mvn/wrapper/MavenWrapperDownloader.class" ]; then + # Running the downloader + if [ "$MVNW_VERBOSE" = true ]; then + echo " - Running MavenWrapperDownloader.java ..." + fi + ("$JAVA_HOME/bin/java" -cp .mvn/wrapper MavenWrapperDownloader "$MAVEN_PROJECTBASEDIR") + fi + fi + fi +fi +########################################################################################## +# End of extension +########################################################################################## + +export MAVEN_PROJECTBASEDIR=${MAVEN_BASEDIR:-"$BASE_DIR"} +if [ "$MVNW_VERBOSE" = true ]; then + echo $MAVEN_PROJECTBASEDIR +fi +MAVEN_OPTS="$(concat_lines "$MAVEN_PROJECTBASEDIR/.mvn/jvm.config") $MAVEN_OPTS" + +# For Cygwin, switch paths to Windows format before running java +if $cygwin; then + [ -n "$M2_HOME" ] && + M2_HOME=`cygpath --path --windows "$M2_HOME"` + [ -n "$JAVA_HOME" ] && + JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` + [ -n "$CLASSPATH" ] && + CLASSPATH=`cygpath --path --windows "$CLASSPATH"` + [ -n "$MAVEN_PROJECTBASEDIR" ] && + MAVEN_PROJECTBASEDIR=`cygpath --path --windows "$MAVEN_PROJECTBASEDIR"` +fi + +# Provide a "standardized" way to retrieve the CLI args that will +# work with both Windows and non-Windows executions. +MAVEN_CMD_LINE_ARGS="$MAVEN_CONFIG $@" +export MAVEN_CMD_LINE_ARGS + +WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +exec "$JAVACMD" \ + $MAVEN_OPTS \ + -classpath "$MAVEN_PROJECTBASEDIR/.mvn/wrapper/maven-wrapper.jar" \ + "-Dmaven.home=${M2_HOME}" "-Dmaven.multiModuleProjectDirectory=${MAVEN_PROJECTBASEDIR}" \ + ${WRAPPER_LAUNCHER} $MAVEN_CONFIG "$@" diff --git a/mvnw.cmd b/mvnw.cmd @@ -0,0 +1,182 @@ +@REM ---------------------------------------------------------------------------- +@REM Licensed to the Apache Software Foundation (ASF) under one +@REM or more contributor license agreements. See the NOTICE file +@REM distributed with this work for additional information +@REM regarding copyright ownership. The ASF licenses this file +@REM to you under the Apache License, Version 2.0 (the +@REM "License"); you may not use this file except in compliance +@REM with the License. You may obtain a copy of the License at +@REM +@REM https://www.apache.org/licenses/LICENSE-2.0 +@REM +@REM Unless required by applicable law or agreed to in writing, +@REM software distributed under the License is distributed on an +@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +@REM KIND, either express or implied. See the License for the +@REM specific language governing permissions and limitations +@REM under the License. +@REM ---------------------------------------------------------------------------- + +@REM ---------------------------------------------------------------------------- +@REM Maven Start Up Batch script +@REM +@REM Required ENV vars: +@REM JAVA_HOME - location of a JDK home dir +@REM +@REM Optional ENV vars +@REM M2_HOME - location of maven2's installed home dir +@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands +@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a keystroke before ending +@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven +@REM e.g. to debug Maven itself, use +@REM set MAVEN_OPTS=-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 +@REM MAVEN_SKIP_RC - flag to disable loading of mavenrc files +@REM ---------------------------------------------------------------------------- + +@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' +@echo off +@REM set title of command window +title %0 +@REM enable echoing by setting MAVEN_BATCH_ECHO to 'on' +@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% + +@REM set %HOME% to equivalent of $HOME +if "%HOME%" == "" (set "HOME=%HOMEDRIVE%%HOMEPATH%") + +@REM Execute a user defined script before this one +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPre +@REM check for pre script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" +if exist "%HOME%\mavenrc_pre.cmd" call "%HOME%\mavenrc_pre.cmd" +:skipRcPre + +@setlocal + +set ERROR_CODE=0 + +@REM To isolate internal variables from possible post scripts, we use another setlocal +@setlocal + +@REM ==== START VALIDATION ==== +if not "%JAVA_HOME%" == "" goto OkJHome + +echo. +echo Error: JAVA_HOME not found in your environment. >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +:OkJHome +if exist "%JAVA_HOME%\bin\java.exe" goto init + +echo. +echo Error: JAVA_HOME is set to an invalid directory. >&2 +echo JAVA_HOME = "%JAVA_HOME%" >&2 +echo Please set the JAVA_HOME variable in your environment to match the >&2 +echo location of your Java installation. >&2 +echo. +goto error + +@REM ==== END VALIDATION ==== + +:init + +@REM Find the project base dir, i.e. the directory that contains the folder ".mvn". +@REM Fallback to current working directory if not found. + +set MAVEN_PROJECTBASEDIR=%MAVEN_BASEDIR% +IF NOT "%MAVEN_PROJECTBASEDIR%"=="" goto endDetectBaseDir + +set EXEC_DIR=%CD% +set WDIR=%EXEC_DIR% +:findBaseDir +IF EXIST "%WDIR%"\.mvn goto baseDirFound +cd .. +IF "%WDIR%"=="%CD%" goto baseDirNotFound +set WDIR=%CD% +goto findBaseDir + +:baseDirFound +set MAVEN_PROJECTBASEDIR=%WDIR% +cd "%EXEC_DIR%" +goto endDetectBaseDir + +:baseDirNotFound +set MAVEN_PROJECTBASEDIR=%EXEC_DIR% +cd "%EXEC_DIR%" + +:endDetectBaseDir + +IF NOT EXIST "%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config" goto endReadAdditionalConfig + +@setlocal EnableExtensions EnableDelayedExpansion +for /F "usebackq delims=" %%a in ("%MAVEN_PROJECTBASEDIR%\.mvn\jvm.config") do set JVM_CONFIG_MAVEN_PROPS=!JVM_CONFIG_MAVEN_PROPS! %%a +@endlocal & set JVM_CONFIG_MAVEN_PROPS=%JVM_CONFIG_MAVEN_PROPS% + +:endReadAdditionalConfig + +SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" +set WRAPPER_JAR="%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.jar" +set WRAPPER_LAUNCHER=org.apache.maven.wrapper.MavenWrapperMain + +set DOWNLOAD_URL="https://repo.maven.apache.org/maven2/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + +FOR /F "tokens=1,2 delims==" %%A IN ("%MAVEN_PROJECTBASEDIR%\.mvn\wrapper\maven-wrapper.properties") DO ( + IF "%%A"=="wrapperUrl" SET DOWNLOAD_URL=%%B +) + +@REM Extension to allow automatically downloading the maven-wrapper.jar from Maven-central +@REM This allows using the maven wrapper in projects that prohibit checking in binary data. +if exist %WRAPPER_JAR% ( + if "%MVNW_VERBOSE%" == "true" ( + echo Found %WRAPPER_JAR% + ) +) else ( + if not "%MVNW_REPOURL%" == "" ( + SET DOWNLOAD_URL="%MVNW_REPOURL%/io/takari/maven-wrapper/0.5.6/maven-wrapper-0.5.6.jar" + ) + if "%MVNW_VERBOSE%" == "true" ( + echo Couldn't find %WRAPPER_JAR%, downloading it ... + echo Downloading from: %DOWNLOAD_URL% + ) + + powershell -Command "&{"^ + "$webclient = new-object System.Net.WebClient;"^ + "if (-not ([string]::IsNullOrEmpty('%MVNW_USERNAME%') -and [string]::IsNullOrEmpty('%MVNW_PASSWORD%'))) {"^ + "$webclient.Credentials = new-object System.Net.NetworkCredential('%MVNW_USERNAME%', '%MVNW_PASSWORD%');"^ + "}"^ + "[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; $webclient.DownloadFile('%DOWNLOAD_URL%', '%WRAPPER_JAR%')"^ + "}" + if "%MVNW_VERBOSE%" == "true" ( + echo Finished downloading %WRAPPER_JAR% + ) +) +@REM End of extension + +@REM Provide a "standardized" way to retrieve the CLI args that will +@REM work with both Windows and non-Windows executions. +set MAVEN_CMD_LINE_ARGS=%* + +%MAVEN_JAVA_EXE% %JVM_CONFIG_MAVEN_PROPS% %MAVEN_OPTS% %MAVEN_DEBUG_OPTS% -classpath %WRAPPER_JAR% "-Dmaven.multiModuleProjectDirectory=%MAVEN_PROJECTBASEDIR%" %WRAPPER_LAUNCHER% %MAVEN_CONFIG% %* +if ERRORLEVEL 1 goto error +goto end + +:error +set ERROR_CODE=1 + +:end +@endlocal & set ERROR_CODE=%ERROR_CODE% + +if not "%MAVEN_SKIP_RC%" == "" goto skipRcPost +@REM check for post script, once with legacy .bat ending and once with .cmd ending +if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" +if exist "%HOME%\mavenrc_post.cmd" call "%HOME%\mavenrc_post.cmd" +:skipRcPost + +@REM pause the script if MAVEN_BATCH_PAUSE is set to 'on' +if "%MAVEN_BATCH_PAUSE%" == "on" pause + +if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% + +exit /B %ERROR_CODE% diff --git a/pom.xml b/pom.xml @@ -0,0 +1,133 @@ +<?xml version="1.0" encoding="UTF-8"?> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> + <modelVersion>4.0.0</modelVersion> + <parent> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-parent</artifactId> + <version>2.3.5.RELEASE</version> + <relativePath/> <!-- lookup parent from repository --> + </parent> + <groupId>com.wimdupont</groupId> + <artifactId>personalweb</artifactId> + <version>0.0.1-SNAPSHOT</version> + <name>PersonalWeb</name> + <description>Wim Dupont's personal website</description> + + <properties> + <java.version>11</java.version> + </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> + </dependency> + <dependency> + <groupId>org.mariadb.jdbc</groupId> + <artifactId>mariadb-java-client</artifactId> + </dependency> + <dependency> + <groupId>org.projectlombok</groupId> + <artifactId>lombok</artifactId> + <optional>true</optional> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-thymeleaf</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <version>2.4.5</version> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-devtools</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-security</artifactId> + </dependency> + <dependency> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-starter-test</artifactId> + <scope>test</scope> + <exclusions> + <exclusion> + <artifactId>junit</artifactId> + <groupId>junit</groupId> + </exclusion> + <exclusion> + <artifactId>junit-vintage-engine</artifactId> + <groupId>org.junit.vintage</groupId> + </exclusion> + </exclusions> + </dependency> + <dependency> + <groupId>com.rometools</groupId> + <artifactId>rome</artifactId> + <version>1.8.0</version> + </dependency> + <dependency> + <groupId>com.fasterxml.jackson.dataformat</groupId> + <artifactId>jackson-dataformat-xml</artifactId> + </dependency> + <dependency> + <groupId>rome</groupId> + <artifactId>rome</artifactId> + <version>1.0</version> + </dependency> + <dependency> + <groupId>org.flywaydb</groupId> + <artifactId>flyway-core</artifactId> + </dependency> + <dependency> + <groupId>org.flywaydb</groupId> + <artifactId>flyway-maven-plugin</artifactId> + <version>7.9.0</version> + </dependency> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj</artifactId> + <version>2.5.1</version> + </dependency> + </dependencies> + + <build> + <plugins> + <plugin> + <groupId>org.springframework.boot</groupId> + <artifactId>spring-boot-maven-plugin</artifactId> + <executions> + <execution> + <goals> + <goal>repackage</goal> + </goals> + </execution> + </executions> + <configuration> + <requiresUnpack> + <dependency> + <groupId>org.asciidoctor</groupId> + <artifactId>asciidoctorj</artifactId> + </dependency> + </requiresUnpack> + </configuration> + </plugin> + <plugin> + <groupId>org.flywaydb</groupId> + <artifactId>flyway-maven-plugin</artifactId> + <version>7.9.0</version> + <configuration> + <url>jdbc:mariadb://localhost:3306/sxcyweb</url> + </configuration> + </plugin> + </plugins> + </build> + +</project> diff --git a/src/main/java/com/wimdupont/personalweb/PersonalWebApplication.java b/src/main/java/com/wimdupont/personalweb/PersonalWebApplication.java @@ -0,0 +1,30 @@ +package com.wimdupont.personalweb; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan +public class PersonalWebApplication { + + public static void main(String[] args) { + ApplicationContext context = SpringApplication.run(PersonalWebApplication.class, args); +// try { +// +// context.getBean(RSSFeedGenerator.class).generate(); +// +// +//// for (File article : articles) { +//// String result = context.getBean(AdocConverter.class).convert(article.getAbsolutePath()); +//// System.out.println(result); +//// } +// } catch (IOException e) { +// e.printStackTrace(); +// } catch (FeedException e) { +// e.printStackTrace(); +// } + } + +} diff --git a/src/main/java/com/wimdupont/personalweb/api/AffirmationApi.java b/src/main/java/com/wimdupont/personalweb/api/AffirmationApi.java @@ -0,0 +1,25 @@ +package com.wimdupont.personalweb.api; + +import com.wimdupont.personalweb.api.dto.affirmation.Affirmation; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Component; +import org.springframework.web.client.RestTemplate; + +import java.util.Optional; + +@Component +@RequiredArgsConstructor +public class AffirmationApi { + + private final RestTemplate restTemplate; + + private static final String AFFIRMATION_URL = "https://www.affirmations.dev/"; + + public Optional<Affirmation> getAffirmation(){ + try { + return Optional.ofNullable(restTemplate.getForObject(AFFIRMATION_URL, Affirmation.class)); + } catch (Exception e) { + return Optional.empty(); + } + } +} diff --git a/src/main/java/com/wimdupont/personalweb/api/dto/affirmation/Affirmation.java b/src/main/java/com/wimdupont/personalweb/api/dto/affirmation/Affirmation.java @@ -0,0 +1,15 @@ +package com.wimdupont.personalweb.api.dto.affirmation; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@Builder(toBuilder = true) +@AllArgsConstructor +@NoArgsConstructor +public class Affirmation { + + private String affirmation; +} diff --git a/src/main/java/com/wimdupont/personalweb/config/RestTemplateConfig.java b/src/main/java/com/wimdupont/personalweb/config/RestTemplateConfig.java @@ -0,0 +1,16 @@ +package com.wimdupont.personalweb.config; + +import org.springframework.boot.web.client.RestTemplateBuilder; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.springframework.web.client.RestTemplate; + +@Configuration +@SuppressWarnings("unused") +public class RestTemplateConfig { + + @Bean + public RestTemplate restTemplate(RestTemplateBuilder builder) { + return builder.build(); + } +} diff --git a/src/main/java/com/wimdupont/personalweb/config/SecurityConfig.java b/src/main/java/com/wimdupont/personalweb/config/SecurityConfig.java @@ -0,0 +1,18 @@ +package com.wimdupont.personalweb.config; + +import org.springframework.security.config.annotation.web.builders.HttpSecurity; +import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity; +import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter; + +@EnableWebSecurity +@SuppressWarnings("unused") +public class SecurityConfig extends WebSecurityConfigurerAdapter { + + @Override + protected void configure(HttpSecurity http) throws Exception { + http + .requiresChannel() + .anyRequest() + .requiresSecure(); + } +} diff --git a/src/main/java/com/wimdupont/personalweb/config/ServerConfig.java b/src/main/java/com/wimdupont/personalweb/config/ServerConfig.java @@ -0,0 +1,41 @@ +package com.wimdupont.personalweb.config; + +import org.apache.catalina.Context; +import org.apache.catalina.connector.Connector; +import org.apache.tomcat.util.descriptor.web.SecurityCollection; +import org.apache.tomcat.util.descriptor.web.SecurityConstraint; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; +import org.springframework.boot.web.servlet.server.ServletWebServerFactory; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; + +@Configuration +@SuppressWarnings("unused") +public class ServerConfig { + + @Bean + public ServletWebServerFactory servletContainer() { + TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() { + @Override + protected void postProcessContext(Context context) { + SecurityConstraint securityConstraint = new SecurityConstraint(); + securityConstraint.setUserConstraint("CONFIDENTIAL"); + SecurityCollection collection = new SecurityCollection(); + collection.addPattern("/*"); + securityConstraint.addCollection(collection); + context.addConstraint(securityConstraint); + } + }; + tomcat.addAdditionalTomcatConnectors(getHttpConnector()); + return tomcat; + } + + private Connector getHttpConnector() { + Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL); + connector.setScheme("http"); + connector.setPort(8081); + connector.setSecure(false); + connector.setRedirectPort(8443); + return connector; + } +} diff --git a/src/main/java/com/wimdupont/personalweb/config/ThymeleafConfig.java b/src/main/java/com/wimdupont/personalweb/config/ThymeleafConfig.java @@ -0,0 +1,44 @@ +package com.wimdupont.personalweb.config; + +import org.springframework.context.ApplicationContext; +import org.springframework.context.annotation.Bean; +import org.springframework.context.annotation.Configuration; +import org.thymeleaf.spring5.templateresolver.SpringResourceTemplateResolver; +import org.thymeleaf.templatemode.TemplateMode; + +@Configuration +@SuppressWarnings("unused") +public class ThymeleafConfig { + + @Bean(name = "htmlTemplateResolver") + SpringResourceTemplateResolver htmlTemplateResolver(ApplicationContext appCtx) { + SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); + + templateResolver.setApplicationContext(appCtx); + templateResolver.setPrefix("classpath:/templates/"); + templateResolver.setSuffix(".html"); + templateResolver.setTemplateMode(TemplateMode.HTML); + templateResolver.setCharacterEncoding("UTF-8"); + templateResolver.setOrder(0); + templateResolver.setCacheable(false); + templateResolver.setCheckExistence(true); + + return templateResolver; + } + + @Bean(name = "xmlTemplateResolver") + SpringResourceTemplateResolver xmlTemplateResolver(ApplicationContext appCtx) { + SpringResourceTemplateResolver templateResolver = new SpringResourceTemplateResolver(); + + templateResolver.setApplicationContext(appCtx); + templateResolver.setPrefix("classpath:/templates/"); + templateResolver.setSuffix(".xml"); + templateResolver.setTemplateMode("XML"); + templateResolver.setCharacterEncoding("UTF-8"); + templateResolver.setOrder(1); + templateResolver.setCacheable(false); + templateResolver.setCheckExistence(true); + + return templateResolver; + } +} diff --git a/src/main/java/com/wimdupont/personalweb/controller/BlogController.java b/src/main/java/com/wimdupont/personalweb/controller/BlogController.java @@ -0,0 +1,27 @@ +package com.wimdupont.personalweb.controller; + +import com.wimdupont.personalweb.service.AdocConverter; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.io.IOException; + +@Controller +@RequiredArgsConstructor +@RequestMapping("/blog") +public class BlogController { + + private final AdocConverter adocConverter; + + @GetMapping + @SuppressWarnings("unused") + public String getBlog(Model model) throws IOException { + model.addAttribute("article1", adocConverter.convert("/adoc/article1.adoc")); + + return "blog"; + } + +} diff --git a/src/main/java/com/wimdupont/personalweb/controller/BookController.java b/src/main/java/com/wimdupont/personalweb/controller/BookController.java @@ -0,0 +1,37 @@ +package com.wimdupont.personalweb.controller; + +import com.wimdupont.personalweb.converter.BookToBookDtoConverter; +import com.wimdupont.personalweb.model.dto.BookDto; +import com.wimdupont.personalweb.service.BookService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RequestMapping; + +import java.util.Comparator; +import java.util.List; +import java.util.stream.Collectors; + +@Controller +@RequiredArgsConstructor +@RequestMapping("/books") +public class BookController { + + private final BookToBookDtoConverter bookToBookDtoConverter; + private final BookService bookService; + + @GetMapping + @SuppressWarnings("unused") + public String getBooks(Model model) { + List<BookDto> bookDtoList = bookService.findAll().stream().map(bookToBookDtoConverter::convert).collect(Collectors.toList()); + bookDtoList = bookDtoList.stream().sorted(Comparator.comparing(BookDto::getCategory) + .thenComparing(BookDto::getAuthor) + .thenComparing(BookDto::getTitle) + ).collect(Collectors.toList()); + model.addAttribute("books", bookDtoList); + + return "books"; + } + +} diff --git a/src/main/java/com/wimdupont/personalweb/controller/FeedController.java b/src/main/java/com/wimdupont/personalweb/controller/FeedController.java @@ -0,0 +1,20 @@ +package com.wimdupont.personalweb.controller; + +import com.rometools.rome.feed.rss.Channel; +import com.wimdupont.personalweb.service.impl.RssFeedImpl; +import lombok.RequiredArgsConstructor; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.RestController; + +@RequiredArgsConstructor +@RestController +public class FeedController { + + private final RssFeedImpl rssFeed; + + @GetMapping(path = "/rss.xml") + @SuppressWarnings("unused") + public Channel getRss() { + return rssFeed.rss(); + } +} diff --git a/src/main/java/com/wimdupont/personalweb/controller/IndexController.java b/src/main/java/com/wimdupont/personalweb/controller/IndexController.java @@ -0,0 +1,24 @@ +package com.wimdupont.personalweb.controller; + +import com.wimdupont.personalweb.api.AffirmationApi; +import com.wimdupont.personalweb.api.dto.affirmation.Affirmation; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Controller; +import org.springframework.ui.Model; +import org.springframework.web.bind.annotation.GetMapping; + +@Controller +@RequiredArgsConstructor +public class IndexController { + + private final AffirmationApi affirmationApi; + + @GetMapping("/") + @SuppressWarnings("unused") + public String home(Model model) { + model.addAttribute("affirmation", affirmationApi.getAffirmation() + .orElseGet(() -> Affirmation.builder().affirmation("You're the best!").build())); + + return "home"; + } +} diff --git a/src/main/java/com/wimdupont/personalweb/converter/BookToBookDtoConverter.java b/src/main/java/com/wimdupont/personalweb/converter/BookToBookDtoConverter.java @@ -0,0 +1,20 @@ +package com.wimdupont.personalweb.converter; + +import com.wimdupont.personalweb.model.dao.Book; +import com.wimdupont.personalweb.model.dto.BookDto; +import org.springframework.stereotype.Component; + +@Component +public class BookToBookDtoConverter implements Converter<Book, BookDto> { + + @Override + public BookDto convert(Book entity) { + return BookDto.builder() + .id(entity.getId()) + .title(entity.getTitle()) + .author(entity.getAuthor()) + .isbn(entity.getIsbn()) + .category(entity.getCategory()) + .build(); + } +} diff --git a/src/main/java/com/wimdupont/personalweb/converter/Converter.java b/src/main/java/com/wimdupont/personalweb/converter/Converter.java @@ -0,0 +1,10 @@ +package com.wimdupont.personalweb.converter; + + +import com.wimdupont.personalweb.model.dto.DTO; + +public interface Converter<E, D extends DTO> { + + D convert(E entity); + +} diff --git a/src/main/java/com/wimdupont/personalweb/model/dao/Book.java b/src/main/java/com/wimdupont/personalweb/model/dao/Book.java @@ -0,0 +1,29 @@ +package com.wimdupont.personalweb.model.dao; + +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; +import org.hibernate.annotations.GenericGenerator; + +import javax.persistence.Entity; +import javax.persistence.GeneratedValue; +import javax.persistence.Id; + +@Entity +@Builder(toBuilder = true) +@Data +@NoArgsConstructor +@AllArgsConstructor +public class Book { + + @Id + @GeneratedValue(generator = "uuid") + @GenericGenerator(name="uuid", strategy = "uuid") + private String id; + + private String title; + private String author; + private String isbn; + private String category; +} diff --git a/src/main/java/com/wimdupont/personalweb/model/dao/rss/Channel.java b/src/main/java/com/wimdupont/personalweb/model/dao/rss/Channel.java @@ -0,0 +1,30 @@ +//package com.sxcy.sxcyweb.model.dao.rss; +// +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import lombok.NoArgsConstructor; +//import org.hibernate.annotations.GenericGenerator; +// +//import javax.persistence.Entity; +//import javax.persistence.GeneratedValue; +//import javax.persistence.Id; +// +//@Entity +//@Builder(toBuilder = true) +//@Data +//@NoArgsConstructor +//@AllArgsConstructor +////TODO +//public class Channel { +// +// @Id +// @GeneratedValue(generator = "uuid") +// @GenericGenerator(name="uuid", strategy = "uuid") +// private String guid; +// +// private String title; +// private String link; +// private String description; +// private String author; +//} diff --git a/src/main/java/com/wimdupont/personalweb/model/dao/rss/Item.java b/src/main/java/com/wimdupont/personalweb/model/dao/rss/Item.java @@ -0,0 +1,31 @@ +//package com.sxcy.sxcyweb.model.dao.rss; +// +//import lombok.AllArgsConstructor; +//import lombok.Builder; +//import lombok.Data; +//import lombok.NoArgsConstructor; +//import org.hibernate.annotations.GenericGenerator; +// +//import javax.persistence.Entity; +//import javax.persistence.GeneratedValue; +//import javax.persistence.Id; +//import java.time.LocalDateTime; +// +//@Entity +//@Builder(toBuilder = true) +//@Data +//@NoArgsConstructor +//@AllArgsConstructor +////TODO +//public class Item { +// +// @Id +// @GeneratedValue(generator = "uuid") +// @GenericGenerator(name="uuid", strategy = "uuid") +// private String guid; +// +// private String title; +// private String link; +// private LocalDateTime pubDate; +// private String description; +//} diff --git a/src/main/java/com/wimdupont/personalweb/model/dto/BookDto.java b/src/main/java/com/wimdupont/personalweb/model/dto/BookDto.java @@ -0,0 +1,21 @@ +package com.wimdupont.personalweb.model.dto; + +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import lombok.AllArgsConstructor; +import lombok.Builder; +import lombok.Data; +import lombok.NoArgsConstructor; + +@Data +@JsonSerialize +@Builder(toBuilder = true) +@AllArgsConstructor +@NoArgsConstructor +public class BookDto implements DTO{ + + private String id; + private String title; + private String author; + private String isbn; + private String category; +} diff --git a/src/main/java/com/wimdupont/personalweb/model/dto/DTO.java b/src/main/java/com/wimdupont/personalweb/model/dto/DTO.java @@ -0,0 +1,4 @@ +package com.wimdupont.personalweb.model.dto; + +public interface DTO { +} diff --git a/src/main/java/com/wimdupont/personalweb/repository/BookRepository.java b/src/main/java/com/wimdupont/personalweb/repository/BookRepository.java @@ -0,0 +1,10 @@ +package com.wimdupont.personalweb.repository; + +import com.wimdupont.personalweb.model.dao.Book; +import org.springframework.data.jpa.repository.JpaRepository; +import org.springframework.stereotype.Repository; + +@Repository +public interface BookRepository extends JpaRepository<Book, String> { + +} diff --git a/src/main/java/com/wimdupont/personalweb/service/AdocConverter.java b/src/main/java/com/wimdupont/personalweb/service/AdocConverter.java @@ -0,0 +1,8 @@ +package com.wimdupont.personalweb.service; + +import java.io.IOException; + +public interface AdocConverter { + + String convert(String filename) throws IOException; +} diff --git a/src/main/java/com/wimdupont/personalweb/service/BookService.java b/src/main/java/com/wimdupont/personalweb/service/BookService.java @@ -0,0 +1,10 @@ +package com.wimdupont.personalweb.service; + +import com.wimdupont.personalweb.model.dao.Book; + +import java.util.List; + +public interface BookService { + + List<Book> findAll(); +} diff --git a/src/main/java/com/wimdupont/personalweb/service/RSSFeedGenerator.java b/src/main/java/com/wimdupont/personalweb/service/RSSFeedGenerator.java @@ -0,0 +1,10 @@ +package com.wimdupont.personalweb.service; + +import com.sun.syndication.io.FeedException; + +import java.io.IOException; + +public interface RSSFeedGenerator { + + void generate() throws IOException, FeedException; +} diff --git a/src/main/java/com/wimdupont/personalweb/service/impl/AdocConverterImpl.java b/src/main/java/com/wimdupont/personalweb/service/impl/AdocConverterImpl.java @@ -0,0 +1,31 @@ +package com.wimdupont.personalweb.service.impl; + +import com.wimdupont.personalweb.service.AdocConverter; +import org.apache.commons.io.IOUtils; +import org.asciidoctor.Asciidoctor; +import org.asciidoctor.Options; +import org.asciidoctor.SafeMode; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.io.IOException; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; + +@Service +@Transactional +public class AdocConverterImpl implements AdocConverter { + + private static final Asciidoctor ASCIIDOCTOR = Asciidoctor.Factory.create(); + private static final Options OPTIONS = Options.builder().safe(SafeMode.UNSAFE).build(); + + @Override + public String convert(String filename) throws IOException { + return ASCIIDOCTOR.convert(adocToString(filename), OPTIONS); + } + + private String adocToString(String filename) throws IOException { + InputStream inputStream = getClass().getResourceAsStream(filename); + return IOUtils.toString(inputStream, StandardCharsets.UTF_8); + } +} diff --git a/src/main/java/com/wimdupont/personalweb/service/impl/BookServiceImpl.java b/src/main/java/com/wimdupont/personalweb/service/impl/BookServiceImpl.java @@ -0,0 +1,23 @@ +package com.wimdupont.personalweb.service.impl; + +import com.wimdupont.personalweb.model.dao.Book; +import com.wimdupont.personalweb.repository.BookRepository; +import com.wimdupont.personalweb.service.BookService; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.util.List; + +@Service +@Transactional +@RequiredArgsConstructor +public class BookServiceImpl implements BookService { + + private final BookRepository bookRepository; + + @Override + public List<Book> findAll() { + return bookRepository.findAll(); + } +} diff --git a/src/main/java/com/wimdupont/personalweb/service/impl/RSSFeedGeneratorImpl.java b/src/main/java/com/wimdupont/personalweb/service/impl/RSSFeedGeneratorImpl.java @@ -0,0 +1,56 @@ +package com.wimdupont.personalweb.service.impl; + +import com.sun.syndication.feed.synd.SyndContent; +import com.sun.syndication.feed.synd.SyndContentImpl; +import com.sun.syndication.feed.synd.SyndEntry; +import com.sun.syndication.feed.synd.SyndEntryImpl; +import com.sun.syndication.feed.synd.SyndFeed; +import com.sun.syndication.feed.synd.SyndFeedImpl; +import com.sun.syndication.io.FeedException; +import com.sun.syndication.io.SyndFeedOutput; +import com.wimdupont.personalweb.service.RSSFeedGenerator; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.io.FileWriter; +import java.io.IOException; +import java.io.Writer; +import java.util.Date; + +import static com.google.common.collect.Lists.newArrayList; + +@Service +@Transactional +@RequiredArgsConstructor +public class RSSFeedGeneratorImpl implements RSSFeedGenerator { + private static final String FEED_TYPE = "rss_2.0"; + private static final String FEED_NAME = "feed.xml"; + + @Override + public void generate() throws IOException, FeedException { + SyndFeed feed = new SyndFeedImpl(); + feed.setFeedType(FEED_TYPE); + + feed.setTitle("title"); + feed.setLink("www.wimdupont.com/rss"); + feed.setDescription("World's greatest RSS feed"); + + SyndEntry entry = new SyndEntryImpl(); + SyndContent content = new SyndContentImpl(); + + entry.setTitle("Wow"); + entry.setLink("www.wimdupont.com/blog"); + entry.setPublishedDate(new Date()); + + content.setType("text/plain"); + content.setValue("Content Value"); + entry.setDescription(content); + feed.setEntries(newArrayList(entry)); + + Writer writer = new FileWriter(FEED_NAME); + SyndFeedOutput output = new SyndFeedOutput(); + output.output(feed, writer); + writer.close(); + } +} diff --git a/src/main/java/com/wimdupont/personalweb/service/impl/RssFeedImpl.java b/src/main/java/com/wimdupont/personalweb/service/impl/RssFeedImpl.java @@ -0,0 +1,52 @@ +package com.wimdupont.personalweb.service.impl; + +import com.rometools.rome.feed.rss.Channel; +import com.rometools.rome.feed.rss.Description; +import com.rometools.rome.feed.rss.Guid; +import com.rometools.rome.feed.rss.Item; +import lombok.RequiredArgsConstructor; +import org.springframework.stereotype.Service; + +import javax.transaction.Transactional; +import java.util.Calendar; +import java.util.Collections; +import java.util.Date; +import java.util.GregorianCalendar; + +@Service +@Transactional +@RequiredArgsConstructor +public class RssFeedImpl { + + public Channel rss() { + Channel channel = new Channel(); + channel.setFeedType("rss_2.0"); + channel.setTitle("Wim Dupont"); + channel.setDescription("Updates from Wim Dupont"); + channel.setLink("https://wimdupont.com/rss.xml"); + channel.setUri("https://wimdupont.com/rss.xml"); + channel.setGenerator("Wim's Generatorâ„¢"); + + Date postDate = new GregorianCalendar(2021, Calendar.MAY, 23).getTime(); + channel.setPubDate(postDate); + + Item item = new Item(); + item.setAuthor("Wim Dupont"); + item.setLink("https://wimdupont.com/blog"); + item.setTitle("New blog feed!"); + item.setUri("https://wimdupont.com/blog"); + Guid guid = new Guid(); + guid.setValue("https://wimdupont.com/blog/firstpost"); + item.setGuid(guid); + + Description descr = new Description(); + descr.setValue( + "New blogging space!</br>" + + "The blog itself will be visible on <a rel=\"nofollow\" href=\"https://wimdupont.com/blog/>"); + item.setDescription(descr); + item.setPubDate(postDate); + + channel.setItems(Collections.singletonList(item)); + return channel; + } +} diff --git a/src/main/resources/adoc/article1.adoc b/src/main/resources/adoc/article1.adoc @@ -0,0 +1,21 @@ +== Article1 + +* This is Work +* in +* progress + +.Some Java code +[source,java] +---- +public class Main{ + public static void main(String... args){ + System.out.println("Hello World!"); + } +} +---- + +Back to normal text. + +=== h3 title + +text +\ No newline at end of file diff --git a/src/main/resources/adoc/article2.adoc b/src/main/resources/adoc/article2.adoc @@ -0,0 +1,4 @@ +== Article 2 + +. line1 +. anoter line +\ No newline at end of file diff --git a/src/main/resources/db/migration/V1_0__db-init.sql b/src/main/resources/db/migration/V1_0__db-init.sql @@ -0,0 +1,7 @@ +CREATE TABLE book ( + id VARCHAR(36) primary key NOT NULL, + title VARCHAR(200) NOT NULL, + author VARCHAR(500) NOT NULL, + isbn VARCHAR(100), + category VARCHAR(100) +) +\ No newline at end of file diff --git a/src/main/resources/db/migration/repeatable/R__fill_book_table.sql b/src/main/resources/db/migration/repeatable/R__fill_book_table.sql @@ -0,0 +1,40 @@ +DELETE FROM book; + +INSERT INTO book VALUES + (UUID(), "Effective Java, Second Edition", "Joshua Block", "9780321356680", "Java"), + (UUID(), "The Elements of Java", "Allan Vermeulen, Scott W. Ambler", "9780521777681", "Java"), + (UUID(), "Core Java for the Impatient", "Cay S. Horstmann", "9780321996329", "Java"), + (UUID(), "Java Concurrency in Practice", "Brian Goetz, Tim Peierls", "9780321349606", "Java"), + (UUID(), "Head First Design Patterns, 2nd Edition", "Eric Freeman, Elisabeth Robson", "9781492078005", "Java"), + (UUID(), "Java Generics", "Maurice Naftalin, Philip Wadler", "9780596527754", "Java"), + (UUID(), "Java How to Program, Seventh Edition", "Harvey M. Deitel, Paul J. Deitel", "9780132222204", "Java"), + + (UUID(), "Computer Networking: A Top-Down Approach, Seventh Edition", "James Kurose, Keith Ross", "9781292153599", "IT"), + + (UUID(), "Introduction to Probability, Second Edition", "Joseph K. Blitzstein, Jessica Hwang", "9781138369917", "Math"), + (UUID(), "Introduction to Linear Algebra, Fifth Edition", "Gilbert Strang", "9780980232776", "Math"), + + (UUID(), "How to Reassess Your Chess, 4th Edition", "Jeremy Silman", "9781890085131", "Chess"), + (UUID(), "Bobby Fischer Teaches Chess", "Bobby Fischer, Stuart Margulies", "9780553263152", "Chess"), + (UUID(), "My 60 Memorable Games", "Bobby Fischer", "9781906388300", "Chess"), + + (UUID(), "Man's Search For Meaning", "Viktor E. Frankl", "9781846041242", "Psychology"), + (UUID(), "The Happiness Trap : Stop Struggling, Start Living", "Russ Harris", "9781845298258", "Psychology"), + + (UUID(), "Echt Radmilo", "Radmilo Soda", "9789035141575", "Health"), + + (UUID(), "To Kill A Mockingbird", "Harper Lee", "9780099549482", "Fiction"), + (UUID(), "The Midnight Library", "Matt Haig", "9781786892720", "Fiction"), + (UUID(), "Of Mice and Men", "John Steinbeck", "9780141023571", "Fiction"), + (UUID(), "1984", "George Orwell", "9780141036144", "Fiction"), + (UUID(), "The Remains of the Day", "Kazuo Ishiguro", "9780679731726", "Fiction"), + (UUID(), "Lord of the Flies", "William Golding", "9780571273577", "Fiction"), + (UUID(), "The Heart Is a Lonely Hunter", "Carson Mc Cullers", "9780618526413", "Fiction"), + (UUID(), "Animal Farm", "George Orwell", "9780141036137", "Fiction"), + (UUID(), "The Unbearable Lightness of Being", "Milan Kundera", "9780571135394", "Fiction"), + (UUID(), "The Book Thief", "Markus Zusak", "9781784162122", "Fiction"), + (UUID(), "Slaughterhouse-Five", "Kurt Vonnegut", "9780440180296", "Fiction"), + (UUID(), "A Clockwork Orange", "Anthony Burgess", "9780241951446", "Fiction"), + (UUID(), "The Melody", "Jim Grace", "9781509841370", "Fiction"), + (UUID(), "Brave New World", "Aldous Huxley", "9780099477464", "Fiction") +; +\ No newline at end of file diff --git a/src/main/resources/static/css/adoc.css b/src/main/resources/static/css/adoc.css @@ -0,0 +1,8 @@ +.title { + color: orange; +} + +.language-java { + display: block; + background-color: #5555; +} +\ No newline at end of file diff --git a/src/main/resources/static/css/main.css b/src/main/resources/static/css/main.css @@ -0,0 +1,131 @@ +body { + background-color: #444; + color: #e4e4e4; +} + +.container { + max-width: 1000px; +} + +.wrapper { + max-width: 960px; + margin: 0 auto; +} + +header { + text-align: center; + margin: 40px; +} + +nav { + display: flex; + align-items: center; + flex-wrap: wrap; + border-bottom: 1px solid grey; +} + +nav a { + padding: 10px; +} + +.navimg { + padding: 2px; +} + +nav .right { + margin-left: auto; +} + +table { + font-family: arial, sans-serif; + border-collapse: collapse; + margin-left: auto; + margin-right: auto; +} + +td, th { + border: 1px solid #dddddd; + text-align: left; + padding: 8px; +} + +tr:nth-child(even) { + background-color: #2F4F4F; +} + +a { + text-decoration: none; + color: #e39777; +} + +img { + filter: grayscale(30%); +} + +a:hover { + text-decoration: underline; +} + +.nav-space-left { + padding-left: 80px; +} + +.subheader { + color: orange; + text-align: center; + margin: 30px; +} + +nav { + display: flex; + align-items: center; + flex-wrap: wrap; + border-bottom: 1px solid grey; +} + +nav a { + padding: 10px; +} + +nav .right { + margin-left: auto; +} + +table { + font-family: arial, sans-serif; + border-collapse: collapse; + margin-left: auto; + margin-right: auto; +} + +td, th { + border: 1px solid #dddddd; + text-align: left; + padding: 8px; +} + +tr:nth-child(even) { + background-color: #2F4F4F; +} + +a { + text-decoration: none; + color: #e39777; +} + +img { + filter: grayscale(30%); +} + +a:hover { + text-decoration: underline; +} + +.nav-space-left { + padding-left: 80px; +} + +.subheader { + color: orange; + text-align: center; +} diff --git a/src/main/resources/static/images/gitlab.png b/src/main/resources/static/images/gitlab.png Binary files differ. diff --git a/src/main/resources/static/images/rssfeed.png b/src/main/resources/static/images/rssfeed.png Binary files differ. diff --git a/src/main/resources/templates/blog.html b/src/main/resources/templates/blog.html @@ -0,0 +1,18 @@ +<!DOCTYPE html> +<html lang="en" xmlns:th="http://www.thymeleaf.org"> +<head> + <meta charset="UTF-8"> + <title>Blog</title> + <link href="/css/main.css" rel="stylesheet"> + <link href="/css/adoc.css" rel="stylesheet"> +</head> +<body> +<div class="container wrapper"> + <header> + <h1>Blog</h1> + <div th:insert="navigation"/> + </header> + <div class="adoc" th:utext="${article1}"/> +</div> +</body> +</html> diff --git a/src/main/resources/templates/books.html b/src/main/resources/templates/books.html @@ -0,0 +1,29 @@ +<!DOCTYPE html> +<html lang="en" xmlns:th="http://www.thymeleaf.org"> +<head> + <meta charset="UTF-8"> + <title>Book Collection</title> + <link href="/css/main.css" rel="stylesheet"> +</head> +<body> +<div class="container wrapper"> + <header> + <h1>Books</h1> + <div th:insert="navigation"/> + </header> + <table> + <tr> + <th>Title</th> + <th>Author</th> + <th>Category</th> + </tr> + <tr th:each="book : ${books}"> + <td><a th:target="_blank" + th:href="@{https://openlibrary.org/isbn/{isbn}(isbn=${book.isbn})}">[[${book.title}]]</a></td> + <td th:text="${book.author}"/> + <td th:text="${book.category}"/> + </tr> + </table> +</div> +</body> +</html> diff --git a/src/main/resources/templates/home.html b/src/main/resources/templates/home.html @@ -0,0 +1,19 @@ +<!DOCTYPE html> +<html lang="en" xmlns:th="http://www.thymeleaf.org"> +<head> + <meta charset="UTF-8"> + <title th:text="Homepage"></title> + <link href="/css/main.css" rel="stylesheet"> +</head> +<body> +<div class="container wrapper"> + <header> + <h1 class="home-title">Hello, World!</h1> + <div th:insert="navigation"/> + </header> + <div th:if="${affirmation != null}"> + <p class="subheader" th:text="${affirmation.affirmation}"/> + </div> +</div> +</body> +</html> diff --git a/src/main/resources/templates/navigation.html b/src/main/resources/templates/navigation.html @@ -0,0 +1,13 @@ +<nav> + <a href="/">Home</a> + <a href="/books">Books</a> + <a href="/blog">Blog</a> + <div class="right"> + <a class="navimg" target="_blank" href="https://gitlab.com/users/WimDupont/projects"> + <img alt="Gitlab" title="Gitlab" src="/images/gitlab.png" width="20" height="20"> + </a> + <a class="navimg" href="/rss.xml"> + <img alt="RSS Feed" title="RSS Feed" src="/images/rssfeed.png" width="20" height="20"> + </a> + </div> +</nav> diff --git a/src/test/java/com/wimdupont/personalweb/PersonalWebApplicationTests.java b/src/test/java/com/wimdupont/personalweb/PersonalWebApplicationTests.java @@ -0,0 +1,13 @@ +package com.wimdupont.personalweb; + +import org.junit.jupiter.api.Test; +import org.springframework.boot.test.context.SpringBootTest; + +@SpringBootTest +class PersonalWebApplicationTests { + + @Test + void contextLoads() { + } + +} diff --git a/src/test/java/com/wimdupont/personalweb/converter/BookToBookDtoConverterTest.java b/src/test/java/com/wimdupont/personalweb/converter/BookToBookDtoConverterTest.java @@ -0,0 +1,38 @@ +package com.wimdupont.personalweb.converter; + +import com.wimdupont.personalweb.model.dao.Book; +import com.wimdupont.personalweb.model.dto.BookDto; +import org.assertj.core.api.Assertions; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; + +class BookToBookDtoConverterTest { + + private static final String ID = "id"; + private static final String TITLE = "title"; + private static final String AUTHOR = "author"; + private static final String ISBN = "isbn"; + private static final String CATEGORY = "category"; + + private BookToBookDtoConverter converter; + private Book book; + + @BeforeEach + void setup() { + converter = new BookToBookDtoConverter(); + book = Book.builder() + .id(ID) + .title(TITLE) + .author(AUTHOR) + .isbn(ISBN) + .category(CATEGORY) + .build(); + } + + @Test + void convert() { + BookDto result = converter.convert(book); + Assertions.assertThat(result).usingRecursiveComparison().isEqualTo(book); + } + +}