Skip to content

IF3110-02-Simple Blog Java kelompok 6 #28

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
Binary file removed assets/img/favicon.ico
Binary file not shown.
Binary file removed assets/img/pre.png
Binary file not shown.
142 changes: 142 additions & 0 deletions blogjava (2).sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
-- phpMyAdmin SQL Dump
-- version 4.1.6
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1:3307
-- Generation Time: 30 Nov 2014 pada 07.24
-- Versi Server: 5.6.16
-- PHP Version: 5.5.9

SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
SET time_zone = "+00:00";


/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;

--
-- Database: `blogjava`
--

-- --------------------------------------------------------

--
-- Struktur dari tabel `blogpost`
--

CREATE TABLE IF NOT EXISTS `blogpost` (
`pid` int(5) NOT NULL AUTO_INCREMENT,
`uid` int(11) NOT NULL,
`posttitle` varchar(100) NOT NULL,
`postcontent` text NOT NULL,
`postdate` date NOT NULL,
`published` tinyint(1) NOT NULL DEFAULT '0',
`deleted` tinyint(1) NOT NULL DEFAULT '0',
PRIMARY KEY (`pid`),
KEY `uid` (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=53 ;

--
-- Dumping data untuk tabel `blogpost`
--

INSERT INTO `blogpost` (`pid`, `uid`, `posttitle`, `postcontent`, `postdate`, `published`, `deleted`) VALUES
(7, 1, 'Post Pertamaku', 'ieu post pertama kuring', '2014-11-25', 1, 0),
(8, 1, 'Post Keduaku', 'ieu post Kedua kuring', '2014-11-25', 1, 0),
(9, 1, 'Post ketigaku', 'isi Post ketiga', '2014-11-25', 0, 0),
(10, 2, 'post pertama nisa', 'nisa dian lalala', '2014-11-26', 1, 0),
(45, 1, 'Post ketigaku - Copy', 'isi Post ketiga', '2014-11-25', 0, 0),
(46, 1, 'ini post buat di hapus', 'sesuai judul', '2014-11-28', 1, 0),
(47, 3, 'ini postnya hayyu', 'tanggalnya sudah benar', '2014-11-29', 1, 0),
(48, 2, 'post pertama nisa - edited', 'nisa dian lilili', '2014-11-29', 1, 0),
(49, 3, 'hayyu luthfi', 'di hati yang ter dalam', '2014-11-29', 1, 0),
(50, 3, 'Post Keduaku', 'ieu post Kedua kuring', '2014-11-25', 1, 0),
(51, 3, 'Post Keduaku', 'ieu post Kedua kuring', '2014-11-25', 1, 0),
(52, 3, 'laksjlkajd', ';lkasja/dskjalkdj', '2014-11-28', 0, 0);

-- --------------------------------------------------------

--
-- Struktur dari tabel `komentar`
--

CREATE TABLE IF NOT EXISTS `komentar` (
`cid` int(3) NOT NULL AUTO_INCREMENT,
`pid` int(3) NOT NULL,
`komentator` varchar(32) NOT NULL,
`komen` text NOT NULL,
`email` varchar(30) NOT NULL,
`commentdate` date NOT NULL,
PRIMARY KEY (`cid`),
KEY `fk.pid` (`pid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=36 ;

--
-- Dumping data untuk tabel `komentar`
--

INSERT INTO `komentar` (`cid`, `pid`, `komentator`, `komen`, `email`, `commentdate`) VALUES
(3, 10, 'guest', 'nisa jelek', '[email protected]', '2014-11-28'),
(10, 10, 'ucuplain', 'ucup ganteng loh', '[email protected]', '2014-11-28'),
(11, 10, 'ucup-lain', 'ucup ganteng loh broo', '[email protected]', '2014-11-28'),
(16, 10, 'lala', 'lilili', '[email protected]', '2014-11-28'),
(17, 10, 'lala', 'lilili', '[email protected]', '2014-11-28'),
(23, 10, 'lala', '', '[email protected]', '2014-11-28'),
(27, 10, 'guest', 'lalalalala', 'lala.asda', '2014-11-28'),
(28, 51, 'guest', 'llida.adasd', 'lala.aswd', '2014-11-28'),
(29, 10, 'bukan guest', 'harusnya saklah', '[email protected]', '2014-11-28'),
(30, 10, 'bukan guest', 'harusnya saklah', '[email protected]', '2014-11-28'),
(31, 10, 'guest syalala bum bunmb ubmbm', 'isinya panjang amat mas', '[email protected]', '2014-11-29'),
(32, 10, 'guest syalala bum bunmb ubmbm', 'isinya panjang amat mas', '[email protected]', '2014-11-29'),
(33, 10, 'guest syalala ', 'isinya panjang amat mas', '[email protected]', '2014-11-29'),
(34, 10, 'guest syalala bum bumnmb', 'isinya panjang amat mas', '[email protected]', '2014-11-29'),
(35, 10, 'guest syalala bum bumnmb', 'isinya panjang amat mas', '[email protected]', '2014-11-29');

-- --------------------------------------------------------

--
-- Struktur dari tabel `user`
--

CREATE TABLE IF NOT EXISTS `user` (
`uid` int(3) NOT NULL AUTO_INCREMENT,
`fullname` varchar(32) NOT NULL,
`username` varchar(20) NOT NULL,
`password` varchar(30) NOT NULL,
`role` varchar(10) NOT NULL,
`email` varchar(50) NOT NULL,
PRIMARY KEY (`uid`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

--
-- Dumping data untuk tabel `user`
--

INSERT INTO `user` (`uid`, `fullname`, `username`, `password`, `role`, `email`) VALUES
(1, 'Yusuf Rahmatullah', 'ucup', 'ucup', 'owner', '[email protected]'),
(2, 'Nisa Dian Rachmadi', 'nisa', 'nisa', 'editor', '[email protected]'),
(3, 'Hayyu Luthfi Hanifah', 'hayyu', 'hayyu', 'admin', '[email protected]'),
(4, 'dummy man', 'dummyman', 'dummywoman', 'owner', '[email protected]'),
(5, 'semarak cinta ', 'semarakcinta', 'cinta', 'editor', '[email protected]');

--
-- Ketidakleluasaan untuk tabel pelimpahan (Dumped Tables)
--

--
-- Ketidakleluasaan untuk tabel `blogpost`
--
ALTER TABLE `blogpost`
ADD CONSTRAINT `fk.uid` FOREIGN KEY (`uid`) REFERENCES `user` (`uid`) ON DELETE CASCADE ON UPDATE CASCADE;

--
-- Ketidakleluasaan untuk tabel `komentar`
--
ALTER TABLE `komentar`
ADD CONSTRAINT `fk.pid` FOREIGN KEY (`pid`) REFERENCES `blogpost` (`pid`) ON DELETE CASCADE ON UPDATE CASCADE;

/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
71 changes: 71 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- You may freely edit this file. See commented blocks below for -->
<!-- some examples of how to customize the build. -->
<!-- (If you delete it and reopen the project it will be recreated.) -->
<!-- By default, only the Clean and Build commands use this build script. -->
<!-- Commands such as Run, Debug, and Test only use this build script if -->
<!-- the Compile on Save feature is turned off for the project. -->
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
<!-- in the project's Project Properties dialog box.-->
<project name="simpleblogII" default="default" basedir=".">
<description>Builds, tests, and runs the project simpleblogII.</description>
<import file="nbproject/build-impl.xml"/>
<!--

There exist several targets which are by default empty and which can be
used for execution of your tasks. These targets are usually executed
before and after some main targets. They are:

-pre-init: called before initialization of project properties
-post-init: called after initialization of project properties
-pre-compile: called before javac compilation
-post-compile: called after javac compilation
-pre-compile-single: called before javac compilation of single file
-post-compile-single: called after javac compilation of single file
-pre-compile-test: called before javac compilation of JUnit tests
-post-compile-test: called after javac compilation of JUnit tests
-pre-compile-test-single: called before javac compilation of single JUnit test
-post-compile-test-single: called after javac compilation of single JUunit test
-pre-dist: called before archive building
-post-dist: called after archive building
-post-clean: called after cleaning build products
-pre-run-deploy: called before deploying
-post-run-deploy: called after deploying

Example of pluging an obfuscator after the compilation could look like

<target name="-post-compile">
<obfuscate>
<fileset dir="${build.classes.dir}"/>
</obfuscate>
</target>

For list of available properties check the imported
nbproject/build-impl.xml file.


Other way how to customize the build is by overriding existing main targets.
The target of interest are:

init-macrodef-javac: defines macro for javac compilation
init-macrodef-junit: defines macro for junit execution
init-macrodef-debug: defines macro for class debugging
do-dist: archive building
run: execution of project
javadoc-build: javadoc generation

Example of overriding the target for project execution could look like

<target name="run" depends="<PROJNAME>-impl.jar">
<exec dir="bin" executable="launcher.exe">
<arg file="${dist.jar}"/>
</exec>
</target>

Notice that overridden target depends on jar target and not only on
compile target as regular run target does. Again, for list of available
properties which you can use check the target you are overriding in
nbproject/build-impl.xml file.

-->
</project>
2 changes: 2 additions & 0 deletions build/web/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Manifest-Version: 1.0

2 changes: 2 additions & 0 deletions build/web/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="/simpleblog"/>
Empty file.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/web/WEB-INF/classes/UserBeans/User.class
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added build/web/WEB-INF/lib/javax.faces.jar
Binary file not shown.
Binary file not shown.
11 changes: 11 additions & 0 deletions build/web/WEB-INF/sun-web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE sun-web-app PUBLIC "-//Sun Microsystems, Inc.//DTD GlassFish Application Server 3.0 Servlet 3.0//EN" "http://www.sun.com/software/appserver/dtds/sun-web-app_3_0-0.dtd">
<sun-web-app error-url="">
<class-loader delegate="true"/>
<jsp-config>
<property name="keepgenerated" value="true">
<description>Keep a copy of the generated servlet class' java code.</description>
</property>
</jsp-config>
</sun-web-app>

24 changes: 24 additions & 0 deletions build/web/WEB-INF/web.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?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-mapping>
<servlet-name>Faces Servlet</servlet-name>
<url-pattern>/faces/*</url-pattern>
</servlet-mapping>
<session-config>
<session-timeout>
30
</session-timeout>
</session-config>
<welcome-file-list>
<welcome-file>faces/index.xhtml</welcome-file>
</welcome-file-list>
</web-app>
131 changes: 131 additions & 0 deletions build/web/add_post.xhtml
Original file line number Diff line number Diff line change
@@ -0,0 +1,131 @@
<?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>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:jsf="http://xmlns.jcp.org/jsf">
<f:view>
<h:head>
<title>New Post- Simple blog</title>
<link rel="stylesheet" type="text/css" href="assets/style.css" />
<link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico" />
</h:head>

<h:body class="default">
<div class="wrapper">

<nav class="nav">
<a style="margin: 0px;border:none;float:left" id="logo" href="faces/index.xhtml"><h1>Simple<span>-</span>Blog | </h1></a>
<h1 style="text-transform: lowercase;font-size: 20px;float: left;color: #553400"><h:outputText value="Hello #{beans.user.fullname} " style="float:left "/></h1>
<ul class="nav-primary">
<li>
<h:form>
<ul>

<f:subview id="justAdmin" rendered="#{beans.admin}">
<li style="padding: 5px">
<a href="faces/admin_page.xhtml" style="color: #F40034;z-index:100;">Halaman Admin </a>
</li>
</f:subview>
<f:subview rendered="#{beans.isLogin() and !beans.owner}" id="publish-post">
<li style="padding:5px;">
<a href="faces/publish_post.xhtml" style="color: #F40034;">Publish Post</a>
</li>
</f:subview>
<f:subview rendered="#{beans.isLogin() and !beans.editor}" id="test">
<li style="padding: 5px">
<a href="add_post.xhtml" onclick="#{beans.genAddPostLink()}" style="color: #F40034">+ Tambah Post </a>
</li>
</f:subview>
<li>
<h:outputText value="#{beans.message}" style="color:red" rendered="#{beans.activeMessage()}"/><br></br>
<h:commandLink action="#{beans.Logout()}" style="color:#F40034;z-index:100;" value="Logout" rendered="#{beans.isLogin()}"/>
<h:form rendered="#{!beans.isLogin()}">
<h:outputText value="username: "/>
<h:inputText value="#{beans.user.username}"/>
<h:outputText value="password: "/>
<h:inputSecret value="#{beans.user.password}"/>
<h:outputText value=" "/>
<h:commandButton action="#{beans.login()}" style="background-color: papayawhip;color: darkblue" value="Login" />
</h:form>
</li>
</ul>
</h:form>
</li>
</ul>
</nav>
<article class="art simple post">


<h2 class="art-title" style="margin-bottom:40px">-</h2>

<div class="art-body">
<div class="art-body-inner">
<h2>Tambah Post</h2>
<div id="contact-area">
<h:form rendered="#{beans.isLogin() and !beans.editor}" >
<h:outputLabel>Judul:</h:outputLabel>
<input id="Judul" type="text" jsf:value="#{beans.post.posttitle}" />
<h:outputLabel>Tanggal:</h:outputLabel>
<input id="Tanggal" type="date" jsf:value="#{beans.post.postdate}" />
<h:outputLabel>Konten:</h:outputLabel>
<textarea id="Konten" jsf:value="#{beans.post.postcontent}" />
<h:commandButton value="Submit" style="width:150px;float:right;" action="#{beans.submitPost}" onclick="return validate();" />
</h:form>
</div>


</div>
</div>

</article>

</div>
<footer class="footer">
<div class="back-to-top"><a href="#">Back to top</a></div>
<!-- <div class="footer-nav"><p></p></div> -->
<aside class="offsite-links">
IF3110 Tubes II Kelompok 6
<br></br>Yusuf Rahmatullah
<br></br>Hayyu Lutfi Hanifah
<br></br>Nisa Dian Rachmadi
</aside>
</footer>
</h:body>
</f:view>
<script type="text/javascript">
function validate() {
var title = document.getElementById('Judul').value;
var date = document.getElementById('Tanggal').value;
var content = document.getElementById('Konten').value;
if (title === "" || date === "" || content === "") {
alert("Isikan semua field!");
return false;
} else {
var t = new Date();
dateStream = date.split("-");
if(t.getFullYear() > dateStream[0]){
alert("Tahun yang Anda masukkan salah");
return false;
}else{
if(t.getMonth()+1 > dateStream[1]){
alert("Bulan yang Anda masukkan salah");
return false;
}else{
if(t.getDate() > dateStream[2]){
alert("Tanggal yang Anda masukkan salah");
return false;
}else{
return true;
}
}
}
}
}
</script>
</html>
Loading