Skip to content

Commit

Permalink
change design
Browse files Browse the repository at this point in the history
  • Loading branch information
sickboy authored and sickboy committed Feb 15, 2013
1 parent a1155d8 commit ed2f7ae
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 80 deletions.
40 changes: 4 additions & 36 deletions src/jp/dogrun/ileaflet/controller/download/IndexController.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
package jp.dogrun.ileaflet.controller.download;

import java.io.IOException;
import java.io.OutputStream;
import java.math.BigDecimal;
import java.nio.ByteBuffer;
import java.io.InputStream;
import java.nio.channels.Channels;

import jp.dogrun.ileaflet.dao.ContentDao;
import jp.dogrun.ileaflet.model.Content;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;
import org.slim3.util.ThrowableUtil;

import com.google.appengine.api.files.AppEngineFile;
import com.google.appengine.api.files.FileReadChannel;
Expand All @@ -35,39 +32,10 @@ public Navigation run() throws Exception {

FileReadChannel readChannel =
fileService.openReadChannel(readableFile, false);

Integer capacity = (new BigDecimal(content.getCapacity())).intValue();
ByteBuffer buffer = ByteBuffer.allocate(capacity);
readChannel.read(buffer);
InputStream is = Channels.newInputStream(readChannel);

this.download(content.getTitle() + ".epub", buffer.array());
download(content.getTitle() + ".epub", is);

return null;
}

protected void download(String fileName, byte[] data)
throws NullPointerException {
if (fileName == null) {
throw new NullPointerException(
"The fileName parameter must not be null.");
}
if (data == null) {
throw new NullPointerException(
"The data parameter must not be null.");
}
try {
response.setContentType("application/epub+zip");
response.setHeader("Content-disposition", "attachment; "
+ encodeFileName(fileName));
OutputStream out = response.getOutputStream();
try {
out.write(data);
} finally {
out.flush();
out.close();
}
} catch (IOException e) {
ThrowableUtil.wrapAndThrow(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ public EpubValidator(String message) {
public String validate(Map<String, Object> parameters, String name) {

FileItem fileItem = (FileItem)parameters.get(name);
System.out.println(fileItem);
if ( fileItem == null ) return null;

EpubLogic logic = new EpubLogic();
Expand Down
1 change: 1 addition & 0 deletions src/jp/dogrun/ileaflet/dao/ActorDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class ActorDao extends DaoBase<Actor>{

public Actor findById(String identity) {
ActorMeta meta = ActorMeta.get();

return Datastore.query(Actor.class).
filter(
meta.identity.equal(identity)
Expand Down
7 changes: 7 additions & 0 deletions src/jp/dogrun/ileaflet/dao/ContentDao.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ public List<Content> findByIdentity(String identity) {

public Content findById(String id) {
Key key = Datastore.createKey(Content.class, Long.valueOf(id));



ContentMeta meta = ContentMeta.get();




return Datastore.query(Content.class).filter(
meta.key.equal(key)
).asSingle();
Expand Down
2 changes: 1 addition & 1 deletion src/jp/dogrun/ileaflet/meta/ActorMeta.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package jp.dogrun.ileaflet.meta;

//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2013-02-08 18:56:55")
//@javax.annotation.Generated(value = { "slim3-gen", "@VERSION@" }, date = "2013-02-15 18:14:38")
/** */
public final class ActorMeta extends org.slim3.datastore.ModelMeta<jp.dogrun.ileaflet.model.Actor> {

Expand Down
2 changes: 1 addition & 1 deletion war/WEB-INF/appengine-generated/datastore-indexes-auto.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<!-- Indices written at Mon, 11 Feb 2013 18:48:19 JST -->
<!-- Indices written at Fri, 15 Feb 2013 18:17:25 JST -->

<datastore-indexes>

Expand Down
Binary file modified war/WEB-INF/appengine-generated/local_db.bin
Binary file not shown.
67 changes: 36 additions & 31 deletions war/dashboard/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,49 @@
<c:import url="../mainFrame.jsp">
<c:param name="title" value="ダッシュボード"/>
<c:param name="content">

<div class="span2">
<div class="well sidebar-nav">
<ul class="nav nav-list">
<li class="nav-header">Sidebar</li>
<li class="active"><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="nav-header">Sidebar</li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li class="nav-header">Sidebar</li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></li>
</ul>
</div>
</div>

<div class="span12 tabbable tabs-left">

<ul class="nav nav-tabs">
<li class="active">
<a href="#sns" data-toggle="tab">Section 1</a>
</li>
<li>
<a href="#manage" data-toggle="tab">Section 2</a>
</li>
<li>
<a href="#upload" data-toggle="tab">Section 3</a>
</li>
</ul>


<div class="span10">
<div class="tab-content">

<div class="tab-pane active" id="sns">
TOP
</div>
<div class="tab-pane" id="manage">
<table class="table table-bordered">
<c:forEach var="obj" items="${contentList}" varStatus="status">
<tr>
  <td>編集</td>
<td><a href="/view/${obj.key.id}"><c:out value="${obj.title}"/></a></td>
<td><a href="/download/${obj.key.id}">ダウンロード</a></td>
</tr>
</c:forEach>
</table>
</div>

<div class="tab-pane" id="upload">
電子書籍をアップロード:
<form method="POST" action="./upload" enctype="multipart/form-data">
<input type="file" name="epubFile"> <input type="submit" value="アップロード">
</form>
</div>

<br>
<br>
<br>
</div>

<c:forEach var="obj" items="${contentList}" varStatus="status">
  編集|<a href="/view/?id=${obj.key.id}"><c:out value="${obj.title}"/></a>|<a href="/download/?id=${obj.key.id}">ダウンロード</a>
</c:forEach>
</div>
</div>

</c:param>
</c:import>
5 changes: 5 additions & 0 deletions war/js/jquery-1.9.1.min.js

Large diffs are not rendered by default.

9 changes: 8 additions & 1 deletion war/login/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<c:param name="title" value="ログイン"/>
<c:param name="content">

<div class="span12">
<div class="span12">

<form method="POST" action="./logon" class="form-horizontal form-inline">
<div class="control-group">
Expand All @@ -18,13 +18,20 @@
<input type="password" class="input-xlarge" placeholder="Password" name="password">
</div>
</div>

<div class="control-group">
<div class="controls">
<button type="submit" class="btn btn-primary">Sign in</button>
<input type="hidden" name="redirect" value="${redirect}">
</div>
</form>

<a href="./?type=create">アカウントの新規作成</a>

<a href="./?type=forget">パスワードを忘れたら。。。</a>



</div>

</c:param>
Expand Down
21 changes: 12 additions & 9 deletions war/mainFrame.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<title>${param.title}</title>
<link type="text/css" rel="stylesheet" href="/css/global.css" />
<link type="text/css" rel="stylesheet" href="/css/bootstrap.min.css" />
<script src="/js/jquery-1.9.1.min.js"></script>
<script src="/js/bootstrap.min.js"></script>
</head>

Expand Down Expand Up @@ -46,22 +47,24 @@
</div>

<div class="container-fluid">
<div class="row-fluid">

<c:if test="${not empty errors}">

<div class="alert">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Warning!</strong>
<ul>
<c:forEach var="e" items="${f:errors()}">
<li><span class="error">${f:h(e)}</span></li>
</c:forEach>
</ul>
<div class="row-fluid">
<div class="alert">
<button type="button" class="close" data-dismiss="alert">&times;</button>
<strong>Warning!</strong>
<ul>
<c:forEach var="e" items="${f:errors()}">
<li><span class="error">${f:h(e)}</span></li>
</c:forEach>
</ul>
</div>
</div>

</c:if>

<div class="row-fluid">
${param.content}

</div>
Expand Down

0 comments on commit ed2f7ae

Please sign in to comment.