Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TheSimplestBlog #31

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
097cdb5
Create Login.java
vidianindhita Nov 24, 2014
f058c24
Create Login.xhtml
vidianindhita Nov 24, 2014
3e2347b
Create LoginSuccess.jsp
vidianindhita Nov 24, 2014
0dd7348
Delete index.html
mushofan Nov 25, 2014
fbee13f
Create index.jsp
mushofan Nov 25, 2014
d45d9f6
Delete post.html
vidianindhita Dec 1, 2014
f7146ed
Delete new_post.html
vidianindhita Dec 1, 2014
6f21c94
Delete index.jsp
mushofan Dec 1, 2014
05f4933
Delete LoginSuccess.jsp
mushofan Dec 1, 2014
13089c7
Delete Login.java
mushofan Dec 1, 2014
8edc7c4
Delete Login.xhtml
mushofan Dec 1, 2014
3c7a7f3
Delete screen.css
mushofan Dec 1, 2014
cacb82d
Create addcomment.jsp
mushofan Dec 1, 2014
442c526
Create about.jsp
mushofan Dec 1, 2014
6acf53b
Create unpublished.jsp
mushofan Dec 1, 2014
de8369a
Create softdelete.jsp
mushofan Dec 1, 2014
36eda9d
Create restore.jsp
mushofan Dec 1, 2014
499c386
Create register.jsp
mushofan Dec 1, 2014
486af5b
Create publish.jsp
mushofan Dec 1, 2014
debe797
Create post.jsp
mushofan Dec 1, 2014
efad583
Create page2.xhtml
mushofan Dec 1, 2014
961a23f
Create new.jsp
mushofan Dec 1, 2014
3ef6890
Create index.jsp
mushofan Dec 1, 2014
4229a58
Create editpost.jsp
mushofan Dec 1, 2014
f30701e
Create Edit_Akun.xhtml
mushofan Dec 1, 2014
dcd5845
Create delete.jsp
mushofan Dec 1, 2014
c3d4575
Create contact.jsp
mushofan Dec 1, 2014
f43bc27
Create validate.js
mushofan Dec 1, 2014
7cf0a6e
Delete favicon.ico
mushofan Dec 1, 2014
9c2783d
Delete pre.png
mushofan Dec 1, 2014
fea35e7
Create style.css
mushofan Dec 1, 2014
95a5607
Create youtube.png
mushofan Dec 1, 2014
626e88c
Delete youtube.png
mushofan Dec 1, 2014
e182b07
Create context.xml
mushofan Dec 1, 2014
665eeba
Create LoginSuccess.jsp
mushofan Dec 1, 2014
ffdf7d2
Create web.xml
mushofan Dec 1, 2014
41d5b60
Upload Image
mushofan Dec 1, 2014
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions Edit_Akun.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite">
<h:head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="assets/style.css"></link>
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico"></link>
<link href='http://fonts.googleapis.com/css?family=Dawning+of+a+New+Day' rel='stylesheet' type='text/css'></link>
<link href='http://fonts.googleapis.com/css?family=Quicksand:300,400,700' rel='stylesheet' type='text/css'></link>
<title>Simple Blog</title>
</h:head>
<h:body styleClass="default">
<div class="wrapper">
<nav class="nav">
<div id="loginsc">
<h:form rendered="#{Login.isLogin()}">
<h:outputLabel value="Halo #{Login.username}"></h:outputLabel>
<h:commandButton action="#{Login.logout()}" value="logout" style="margin-left: 6px; border: none; border-style: none; outline: none; background-color: #acaba9; font-family: 'Quicksand', sans-serif; height: 16px; font-weight: 700; font-color: #fff; cursor: pointer; color:#ffffff;"></h:commandButton>
</h:form>
</div>

<div id="nav-logo">
<a id="logo" href="index.jsp"><h1>The Simplest Blog</h1></a>
</div>

<div id="menu">
<ul class="nav-primary">
<li><a href="index.jsp">Home</a></li>
<li><a href="about.jsp">About</a></li>
<li><a href="contact.jsp">Contact</a></li>
<f:subview id="manajemen-user" rendered="#{Login.isAdmin()}"><li><a href="page2.xhtml">User-Management</a></li></f:subview>
<f:subview id="draft" rendered="#{Login.isEditor() or Login.isAdmin()}"><li><a href="unpublished.jsp">Draft</a></li></f:subview>
<f:subview id="tambah-post" rendered="#{Login.isOwner() or Login.isAdmin()}"><li><a href="new.jsp">Create Post</a></li></f:subview>
</ul>
</div>
</nav>

<article class="art simple post">

<header class="art-header">
<div class="art-header-inner">
<h2 class="art-title">Account Edit</h2>
</div>
</header>

<div class="art-body">
<div class="art-body-inner">
<div id="contact-area">
<h:form>
<h:inputHidden value="#{akun.idAkun}" binding="#{id}"></h:inputHidden>
<h:outputLabel value="Username :"></h:outputLabel>
<h:inputText value="#{akun.username}"></h:inputText>
<br></br>
<h:outputLabel value="Password :"></h:outputLabel>
<h:inputSecret value="#{akun.password}"></h:inputSecret>
<br></br>
<h:outputLabel value="Role :"></h:outputLabel>
<h:selectOneMenu value="#{akun.role}" styleClass="select">
<f:selectItem itemValue="owner" itemLabel="Owner" />
<f:selectItem itemValue="editor" itemLabel="Editor" />
<f:selectItem itemValue="admin" itemLabel="Admin" />
</h:selectOneMenu>
<br></br>
<h:outputLabel value="Name :"></h:outputLabel>
<h:inputText value="#{akun.name}"></h:inputText>
<br></br>
<h:outputLabel value="Email :"></h:outputLabel>
<h:inputText value="#{akun.email}"></h:inputText>
<br></br>
<h:commandButton action="#{akun.updateAkun(id.value)}" value="Edit" styleClass="submit-button"></h:commandButton>
</h:form>
</div>
</div>
</div>
</article>
</div>
<footer id="footerSlideContainer">
<div id="footerSlideLink">
<div id="footerSlideContent">
<div id="footerSlideText"><a href="">Back to top</a></div>
</div>
</div>
</div>
</footer>
</h:body>
</html>
2 changes: 2 additions & 0 deletions META-INF/context.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="UTF-8"?>
<Context antiJARLocking="true" path="/TheSimplestBlog"/>
26 changes: 26 additions & 0 deletions WEB-INF/LoginSuccess.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<%@ page language="java" contentType="text/html; charset=US-ASCII"
pageEncoding="US-ASCII"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>Login Success Page</title>
</head>
<body>
<%
String userName = null;
Cookie[] cookies = request.getCookies();
if(cookies !=null){
for(Cookie cookie : cookies){
if(cookie.getName().equals("user")) userName = cookie.getValue();
}
}
if(userName == null) response.sendRedirect("login.html");
%>
<h3>Hi <%=userName %>, Login successful.</h3>
<br>
<form action="LogoutServlet" method="post">
<input type="submit" value="Logout" >
</form>
</body>
</html>
32 changes: 32 additions & 0 deletions WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="3.1" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd">
<context-param>
<param-name>javax.faces.PROJECT_STAGE</param-name>
<param-value>Development</param-value>
</context-param>
<servlet>
<servlet-name>Faces Servlet</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>AddCommentServlet</servlet-name>
<servlet-class>AddCommentServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>AddCommentServlet</servlet-name>
<url-pattern>/AddCommentServlet</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.jsp</welcome-file>
</welcome-file-list>
</web-app>
88 changes: 88 additions & 0 deletions about.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
<?xml version="1.0" encoding="UTF-8"?>
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
<!DOCTYPE html>
<f:view>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:composite="http://java.sun.com/jsf/composite">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<link rel="stylesheet" type="text/css" href="assets/style.css"></link>
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico"></link>
<link href='http://fonts.googleapis.com/css?family=Dawning+of+a+New+Day' rel='stylesheet' type='text/css'></link>
<link href='http://fonts.googleapis.com/css?family=Quicksand:300,400,700' rel='stylesheet' type='text/css'></link>
<title>The Simplest Blog | About</title>
</head>
<body styleClass="default">
<div class="wrapper">
<nav class="nav">
<div id="login">
<h:form rendered="#{!Login.isLogin()}">
Username: <h:inputText value="#{Login.username}" style="outline: none; border: none; border-style: none; background-color: #97cdb6; font-family: 'Quicksand', sans-serif; height: 16px;"></h:inputText>
Password: <h:inputSecret value="#{Login.password}" style="outline: none; border: none; border-style: none; background-color: #97cdb6; font-family: 'Quicksand', sans-serif; height: 16px;"></h:inputSecret>
<h:commandButton action="#{Login.Login()}" value="submit" style="margin-left: 6px; border: none; border-style: none; outline: none; background-color: #acaba9; font-family: 'Quicksand', sans-serif; height: 16px; font-weight: 700; font-color: #fff; cursor: pointer; color:#fff;"></h:commandButton>
</h:form>

<h:outputLabel rendered="#{Login.isLoginFailed()}">Invalid username or password</h:outputLabel>
</div>

<div id="loginsc">
<h:form rendered="#{Login.isLogin()}">
<h:outputLabel value="Halo #{Login.username}"></h:outputLabel>
<h:commandButton action="#{Login.logout()}" value="logout" style="margin-left: 6px; border: none; border-style: none; outline: none; background-color: #acaba9; font-family: 'Quicksand', sans-serif; height: 16px; font-weight: 700; font-color: #fff; cursor: pointer; color:#ffffff;"></h:commandButton>
</h:form>
</div>

<div id="nav-logo">
<a id="logo" href="index.jsp"><h1>The Simplest Blog</h1></a>
</div>

<div id="menu">
<ul class="nav-primary">
<li><a href="index.jsp">Home</a></li>
<li><a href="about.jsp">About</a></li>
<li><a href="contact.jsp">Contact</a></li>
<f:subview id="manajemen-user" rendered="#{Login.isAdmin()}"><li><a href="page2.xhtml">User-Management</a></li></f:subview>
<f:subview id="draft" rendered="#{Login.isEditor() or Login.isAdmin()}"><li><a href="unpublished.jsp">Draft</a></li></f:subview>
<f:subview id="tambah-post" rendered="#{Login.isOwner() or Login.isAdmin()}"><li><a href="new.jsp">Create Post</a></li></f:subview>
</ul>
</div>
</nav>

<nav class="art-list">
<div class="postcontainer">
<ul class="art-list-body">
<img src=img/about.png></img>
</ul>
</div>
<div class="postcontainer" id="rightside">
<a id="text-contact">Kindly visit our projects</a><br></br>
<a id="contact-logo" href="#"><img src="img/mail.png"></img></a>
<a id="contact-logo" href="#"><img src="img/fb.png"></img></a><br></br>
<a id="contact-logo" href="#"><img src="img/twitter.png"></img></a>
<a id="contact-logo" href="#"><img src="img/youtube.png"></img></a><br></br>
<a id="contact-logo" href="#"><img src="img/pinterest.png"></img></a>
<a id="contact-logo" href="#"><img src="img/instagram.png"></img></a>
</div>
</nav>
</div>
<footer id="footerSlideContainer">
<div id="footerSlideLink">
<div id="footerSlideContent">
<div id="footerSlideText"><a href="">Back to top</a></div>
</div>
</div>
</div>
</footer>
</body>
</html>
</f:view>

53 changes: 53 additions & 0 deletions addcomment.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<?xml version="1.0" encoding="ISO-8859-1" ?>
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:f="http://java.sun.com/jsf/core" xmlns:h="http://java.sun.com/jsf/html">
<%@ page import="java.sql.Connection, javax.sql.*, java.io.*, javax.naming.*"
%>
<%@ page import="com.mysql.jdbc.Driver, java.sql.PreparedStatement, java.sql.DriverManager, java.util.Random" %><head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>The Simplest Blog | Add Comment</title>
</head>
<body>
<f:view>
<%
String host = "jdbc:mysql://localhost:3305/blog?zeroDateTimeBehavior=convertToNull";
String user = "root";
String pwd = "asdasd123";
Connection con;
PreparedStatement ps;

try {
String nama = request.getParameter("Nama");
String waktu = request.getParameter("waktu");
String id_post = request.getParameter("id_post");
String komentar = request.getParameter("Komentar");
String email = request.getParameter("Email");
Class.forName("com.mysql.jdbc.Driver").newInstance();
int updateQuery = 0;
con = DriverManager.getConnection(host, user, pwd);
if (nama != null && waktu != null && id_post != null && komentar != null && email != null) {
ps = con.prepareStatement("INSERT INTO `comment` (`nama`, `email`, `komentar`, `waktu`, `id_post`) VALUES (?,?,?,?,?)");
ps.setString(1, nama);
ps.setString(2, email);
ps.setString(3, komentar);
ps.setString(4, waktu);
ps.setString(5, id_post);
updateQuery = ps.executeUpdate();
}
out.print("<li class=\"art-list-item\">\n"+
"<div class=\"art-list-item-title-and-time\">\n"+
"<h2 class=\"art-list-title\"><a href=\"post.html\">"+ nama +"</a></h2>\n"+
"<div class=\"art-list-time\">"+ waktu +"</div>\n"+
"</div>\n"+
"<p>" + komentar + "</p>\n"+
"</li>");
} catch (Exception e) {
out.println("Error" + e);
}
%>
</f:view>
</body>
</html>

Loading