added docker dev environment and fixed some bugs
This commit is contained in:
parent
1a907de8ba
commit
99c67eaaba
16 changed files with 1897 additions and 34 deletions
|
|
@ -3,7 +3,7 @@
|
|||
<Context reloadable="true">
|
||||
|
||||
<Environment type="java.lang.String" name="WEBSITE_NAME" value="Gallery" />
|
||||
<Environment type="java.lang.String" name="WEBSITE_URL" value="http://example.com/Zallery/" />
|
||||
<Environment type="java.lang.String" name="WEBSITE_URL" value="http://localhost:8080/zallery" />
|
||||
<Environment type="java.lang.String" name="ADMIN_EMAIL" value="admin@example.com" />
|
||||
<Environment type="java.lang.String" name="ADMIN_EMAIL_NICE" value="Example.com Admin" />
|
||||
<Environment type="java.lang.String" name="SMTP_HOST" value="127.0.0.1" />
|
||||
|
|
@ -13,10 +13,10 @@
|
|||
name="jdbc/mysql"
|
||||
auth="Container"
|
||||
type="javax.sql.DataSource"
|
||||
username="username"
|
||||
username="zallery"
|
||||
password="password"
|
||||
driverClassName="com.mysql.jdbc.Driver"
|
||||
url="jdbc:mysql://host:3306/database"
|
||||
url="jdbc:mysql://db:3306/zallery"
|
||||
maxActive="8"
|
||||
maxIdle="4"
|
||||
validationQuery="SELECT 1"
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@ body{
|
|||
margin-bottom: 200px;
|
||||
}
|
||||
|
||||
/***** Nav *******/
|
||||
|
||||
.navbar {
|
||||
margin-top: 20px;
|
||||
margin-bottom: 0px;
|
||||
|
|
@ -10,6 +12,17 @@ body{
|
|||
color: #5a5ada !important;
|
||||
}
|
||||
|
||||
.navbar .divider-vertical {
|
||||
height: 40px;
|
||||
margin: 5px 14px;
|
||||
border-right: 2px solid #ffffff;
|
||||
border-left: 2px solid #f2f2f2;
|
||||
}
|
||||
.navbar-inverse .divider-vertical {
|
||||
border-right-color: #222222;
|
||||
border-left-color: #111111;
|
||||
}
|
||||
|
||||
.subnav {
|
||||
width: 80%;
|
||||
height: 10px;
|
||||
|
|
@ -17,6 +30,8 @@ body{
|
|||
padding: 0 20px;
|
||||
}
|
||||
|
||||
/***** Content *******/
|
||||
|
||||
.content {
|
||||
margin-top: 20px;
|
||||
}
|
||||
|
|
@ -34,16 +49,6 @@ body{
|
|||
margin: 0 auto;
|
||||
}
|
||||
|
||||
.navbar .divider-vertical {
|
||||
height: 40px;
|
||||
margin: 5px 14px;
|
||||
border-right: 2px solid #ffffff;
|
||||
border-left: 2px solid #f2f2f2;
|
||||
}
|
||||
.navbar-inverse .divider-vertical {
|
||||
border-right-color: #222222;
|
||||
border-left-color: #111111;
|
||||
}
|
||||
@media (max-width: 767px) {
|
||||
.navbar-collapse .nav > .divider-vertical {
|
||||
display: none;
|
||||
|
|
|
|||
|
|
@ -9,10 +9,13 @@
|
|||
<title>Koc.se</title>
|
||||
|
||||
<!-- Bootstrap core CSS -->
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
|
||||
<link rel="stylesheet" href="css/bootstrap-theme.min.css">
|
||||
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
|
||||
<link href="css/zallery.css" rel="stylesheet">
|
||||
<link rel="stylesheet" href="css/form-elements.css">
|
||||
<link rel="stylesheet" href="css/register3.css">
|
||||
<link rel="stylesheet" href="css/zallery.css">
|
||||
|
||||
|
||||
<!-- Bootstrap core JavaScript -->
|
||||
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<jsp:include page="header.jsp" />
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-offset-3 col-md-6">
|
||||
<div class="form-box">
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
<jsp:include page="header.jsp" />
|
||||
|
||||
<div class="container">
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-offset-3 col-md-6">
|
||||
<div class="form-box">
|
||||
|
|
|
|||
|
|
@ -56,6 +56,13 @@
|
|||
</library>
|
||||
</orderEntry>
|
||||
<orderEntry type="library" name="Maven: se.koc:zutil:1.0.2-219" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-fileupload:commons-fileupload:1.2.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
|
||||
<orderEntry type="library" name="Maven: dom4j:dom4j:1.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: xml-apis:xml-apis:1.0.b2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.xerial:sqlite-jdbc:3.8.11.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
|
||||
<orderEntry type="library" name="Maven: com.carrotsearch:junit-benchmarks:0.7.2" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.mail:javax.mail-api:1.6.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: javax.activation:activation:1.1" level="project" />
|
||||
<orderEntry type="library" name="Maven: mysql:mysql-connector-java:5.1.36" level="project" />
|
||||
|
|
|
|||
163
db_structure.sql
Normal file
163
db_structure.sql
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
--
|
||||
-- Database: `zallery`
|
||||
--
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Comments`
|
||||
--
|
||||
|
||||
CREATE TABLE `Comments` (
|
||||
`id` int(11) NOT NULL,
|
||||
`image` int(11) DEFAULT NULL,
|
||||
`video` int(11) DEFAULT NULL,
|
||||
`user` int(11) DEFAULT NULL,
|
||||
`date` datetime DEFAULT NULL,
|
||||
`message` text
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Folder`
|
||||
--
|
||||
|
||||
CREATE TABLE `Folder` (
|
||||
`id` int(10) UNSIGNED NOT NULL,
|
||||
`user` int(10) UNSIGNED DEFAULT NULL,
|
||||
`path` text,
|
||||
`parent` int(10) UNSIGNED DEFAULT NULL,
|
||||
`date` datetime NOT NULL,
|
||||
`isPrivate` bit(1) DEFAULT b'0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Image`
|
||||
--
|
||||
|
||||
CREATE TABLE `Image` (
|
||||
`id` int(10) UNSIGNED NOT NULL,
|
||||
`folder` int(10) UNSIGNED NOT NULL,
|
||||
`filename` varchar(45) NOT NULL,
|
||||
`user` int(10) UNSIGNED NOT NULL,
|
||||
`title` varchar(55) DEFAULT NULL,
|
||||
`description` text,
|
||||
`date` datetime DEFAULT NULL,
|
||||
`rating` float DEFAULT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `User`
|
||||
--
|
||||
|
||||
CREATE TABLE `User` (
|
||||
`id` int(11) NOT NULL,
|
||||
`name` varchar(40) NOT NULL,
|
||||
`email` varchar(50) DEFAULT NULL,
|
||||
`emailVerified` tinyint(1) NOT NULL,
|
||||
`password` varchar(32) DEFAULT NULL,
|
||||
`facebookUid` varchar(12) DEFAULT NULL,
|
||||
`sessionId` varchar(32) DEFAULT NULL,
|
||||
`ipHost` varchar(20) DEFAULT NULL,
|
||||
`loginDate` datetime DEFAULT NULL,
|
||||
`sessionHash` varchar(32) DEFAULT NULL,
|
||||
`superUser` tinyint(1) NOT NULL,
|
||||
`enabled` tinyint(1) NOT NULL
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Dumping data for table `User`
|
||||
--
|
||||
|
||||
INSERT INTO `User` (`id`, `name`, `email`, `emailVerified`, `password`, `facebookUid`, `sessionId`, `ipHost`, `loginDate`, `sessionHash`, `superUser`, `enabled`) VALUES
|
||||
(1, 'Admin Admin', 'admin@example.com', 1, '', NULL, '', '', '1970-01-01 01:00:0', '', 1, 1);
|
||||
|
||||
-- --------------------------------------------------------
|
||||
|
||||
--
|
||||
-- Table structure for table `Video`
|
||||
--
|
||||
|
||||
CREATE TABLE `Video` (
|
||||
`id` int(10) UNSIGNED NOT NULL,
|
||||
`folder` int(10) UNSIGNED NOT NULL,
|
||||
`filename` varchar(45) NOT NULL,
|
||||
`user` int(10) UNSIGNED NOT NULL,
|
||||
`title` varchar(55) DEFAULT NULL,
|
||||
`description` text,
|
||||
`date` datetime DEFAULT NULL,
|
||||
`rating` float DEFAULT NULL,
|
||||
`transcoded` tinyint(1) NOT NULL DEFAULT '0',
|
||||
`length` int(10) UNSIGNED NOT NULL DEFAULT '0'
|
||||
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
||||
|
||||
--
|
||||
-- Indexes for table `Comments`
|
||||
--
|
||||
ALTER TABLE `Comments`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `image` (`image`,`video`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Folder`
|
||||
--
|
||||
ALTER TABLE `Folder`
|
||||
ADD PRIMARY KEY (`id`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Image`
|
||||
--
|
||||
ALTER TABLE `Image`
|
||||
ADD PRIMARY KEY (`id`) USING BTREE,
|
||||
ADD KEY `folder` (`folder`);
|
||||
|
||||
--
|
||||
-- Indexes for table `User`
|
||||
--
|
||||
ALTER TABLE `User`
|
||||
ADD PRIMARY KEY (`id`),
|
||||
ADD KEY `email` (`email`),
|
||||
ADD KEY `sessionHash` (`sessionHash`),
|
||||
ADD KEY `facebookUid` (`facebookUid`);
|
||||
|
||||
--
|
||||
-- Indexes for table `Video`
|
||||
--
|
||||
ALTER TABLE `Video`
|
||||
ADD PRIMARY KEY (`id`) USING BTREE,
|
||||
ADD KEY `folder` (`folder`);
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for dumped tables
|
||||
--
|
||||
|
||||
--
|
||||
-- AUTO_INCREMENT for table `Comments`
|
||||
--
|
||||
ALTER TABLE `Comments`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=18;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `Folder`
|
||||
--
|
||||
ALTER TABLE `Folder`
|
||||
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=46;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `Image`
|
||||
--
|
||||
ALTER TABLE `Image`
|
||||
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=1713;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `User`
|
||||
--
|
||||
ALTER TABLE `User`
|
||||
MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=44;
|
||||
--
|
||||
-- AUTO_INCREMENT for table `Video`
|
||||
--
|
||||
ALTER TABLE `Video`
|
||||
MODIFY `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT;
|
||||
1657
db_test_data.sql
Normal file
1657
db_test_data.sql
Normal file
File diff suppressed because it is too large
Load diff
19
docker-compose.yml
Normal file
19
docker-compose.yml
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
version: '3'
|
||||
services:
|
||||
web:
|
||||
image: jeanblanchard/tomcat:7
|
||||
ports:
|
||||
- "8080:8080"
|
||||
db:
|
||||
image: mariadb
|
||||
restart: always
|
||||
environment:
|
||||
MYSQL_ROOT_PASSWORD: "password"
|
||||
MYSQL_DATABASE: "zallery"
|
||||
MYSQL_USER: "zallery"
|
||||
MYSQL_PASSWORD: "password"
|
||||
db_admin:
|
||||
image: adminer
|
||||
restart: always
|
||||
ports:
|
||||
- 8081:8080
|
||||
11
pom.xml
11
pom.xml
|
|
@ -6,7 +6,7 @@
|
|||
|
||||
<groupId>se.koc</groupId>
|
||||
<artifactId>zallery</artifactId>
|
||||
<version>2.0.${build.number}</version>
|
||||
<version>2.0-${build.number}</version>
|
||||
<packaging>war</packaging>
|
||||
|
||||
<name>Zallery</name>
|
||||
|
|
@ -52,6 +52,14 @@
|
|||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<!--<testSourceDirectory>test</testSourceDirectory>-->
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>src</directory>
|
||||
<includes>
|
||||
<include>**/*.properties</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
|
||||
<plugins>
|
||||
<plugin>
|
||||
|
|
@ -77,6 +85,7 @@
|
|||
<configuration>
|
||||
<url>http://localhost:8080/manager/text</url>
|
||||
<server>tomcat</server>
|
||||
<path>/zallery</path>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import javax.naming.InitialContext;
|
|||
import javax.naming.NamingException;
|
||||
import javax.servlet.ServletConfig;
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.annotation.WebServlet;
|
||||
import javax.servlet.http.Cookie;
|
||||
import javax.servlet.http.HttpServlet;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
|
@ -15,6 +16,7 @@ import javax.servlet.http.HttpServletRequest;
|
|||
import zutil.db.DBConnection;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
@WebServlet(value = "/init", loadOnStartup = 1)
|
||||
public class Zallery extends HttpServlet{
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
package zall;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Zallery globally defined constants
|
||||
*/
|
||||
|
|
@ -7,11 +9,12 @@ public interface ZalleryConstant {
|
|||
|
||||
/** Session Constants **/
|
||||
|
||||
String SESSION_KEY_USER = "zal_user";
|
||||
String SESSION_KEY_AUTH_HASH = "zal_session_hash";
|
||||
String SESSION_KEY_USER = "zall_user";
|
||||
String SESSION_KEY_AUTH_HASH = "zall_ueser_session_hash";
|
||||
|
||||
/** Language Key Constants **/
|
||||
|
||||
String LANG_BASENAME = "zallery_lang";
|
||||
String LANG_BASENAME = "zall.lang.zallery_lang";
|
||||
Locale LANG_DEFAULT = Locale.ENGLISH;
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
package zall;
|
||||
|
||||
import zall.util.UserMessage;
|
||||
import zutil.db.DBConnection;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
|
|
@ -9,16 +8,15 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.*;
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Locale;
|
||||
import java.util.PropertyResourceBundle;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import static zall.ZalleryConstant.LANG_BASENAME;
|
||||
import static zall.ZalleryConstant.*;
|
||||
|
||||
public abstract class ZalleryServlet extends HttpServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
protected ResourceBundle lang = PropertyResourceBundle.getBundle(LANG_BASENAME, Locale.getDefault());
|
||||
protected ResourceBundle lang = PropertyResourceBundle.getBundle(LANG_BASENAME, LANG_DEFAULT);
|
||||
|
||||
|
||||
public final void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import zall.manager.AuthenticationManager;
|
|||
import javax.servlet.*;
|
||||
import javax.servlet.annotation.WebFilter;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
|
|
@ -15,6 +14,7 @@ import java.io.IOException;
|
|||
@WebFilter(urlPatterns = "/")
|
||||
public class AuthenticationFilter implements Filter {
|
||||
private static final String LOGIN_URI = "/login";
|
||||
private static final String REGISTER_URI = "/register";
|
||||
|
||||
|
||||
@Override
|
||||
|
|
@ -26,14 +26,13 @@ public class AuthenticationFilter implements Filter {
|
|||
User user = null;
|
||||
|
||||
// continue the request via the filter pipeline if it is login page or it is a isValid User
|
||||
if (requestURI.equals(LOGIN_URI) || AuthenticationManager.isValid(user, (HttpServletRequest) request)) {
|
||||
if (requestURI.equals(LOGIN_URI) ||
|
||||
requestURI.equals(REGISTER_URI) ||
|
||||
AuthenticationManager.isValid(user, (HttpServletRequest) request)) {
|
||||
chain.doFilter(request, response);
|
||||
} else {
|
||||
// do not continue the filter pipeline but respond back to client
|
||||
HttpServletResponse resp = (HttpServletResponse) response;
|
||||
resp.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
resp.setContentType("text/plain");
|
||||
resp.sendRedirect(LOGIN_URI);
|
||||
// do not continue the filter pipeline forward to login page
|
||||
request.getRequestDispatcher(LOGIN_URI).forward(request, response);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import java.sql.SQLException;
|
|||
import java.util.List;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
@WebServlet("/register")
|
||||
@WebServlet("/users")
|
||||
public class UserListServlet extends ZalleryServlet {
|
||||
private static Logger logger = LogUtil.getLogger();
|
||||
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ import zutil.StringUtil;
|
|||
import zutil.db.DBConnection;
|
||||
import zutil.log.LogUtil;
|
||||
|
||||
@WebServlet(value = "/transcoder", loadOnStartup = 1)
|
||||
@WebServlet(value = "/transcoder", loadOnStartup = 100)
|
||||
public class ZalleryTranscoder extends HttpServlet{
|
||||
private static final Logger logger = LogUtil.getLogger();
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue