Mercurial > hg > Members > nobuyasu > tasks
changeset 7:84e51aafdfed draft
Building the first screen
author | e085711 |
---|---|
date | Thu, 13 Sep 2012 10:37:20 +0900 |
parents | db553ad77045 |
children | cf7b286f4bd8 |
files | .settings/org.eclipse.core.resources.prefs app/controllers/Application.java app/views/Application/index.html app/views/main.html app/views/tags/display.html conf/application.conf public/stylesheets/main.css |
diffstat | 6 files changed, 74 insertions(+), 40 deletions(-) [+] |
line wrap: on
line diff
--- a/.settings/org.eclipse.core.resources.prefs Thu Sep 13 01:57:33 2012 +0900 +++ b/.settings/org.eclipse.core.resources.prefs Thu Sep 13 10:37:20 2012 +0900 @@ -1,3 +1,3 @@ -#Tue Feb 17 18:35:42 CET 2009 -eclipse.preferences.version=1 -encoding/<project>=UTF-8 +eclipse.preferences.version=1 +encoding//app/views/main.html=UTF-8 +encoding/<project>=UTF-8
--- a/app/controllers/Application.java Thu Sep 13 01:57:33 2012 +0900 +++ b/app/controllers/Application.java Thu Sep 13 10:37:20 2012 +0900 @@ -9,6 +9,12 @@ public class Application extends Controller { + @Before + static void addDefaults() { + renderArgs.put("blogTitle",Play.configuration.getProperty("blog.title")); + renderArgs.put("blogBaseline",Play.configuration.getProperty("blog.baseline")); + } + public static void index() { Post frontPost = Post.find("order by postedAt desc").first(); List<Post> olderPosts = Post.find("order by postedAt desc").from(1).fetch(10); @@ -37,6 +43,10 @@ } + public static void show(Long id) { + Post post = Post.findById(id); + render(post); + } } \ No newline at end of file
--- a/app/views/Application/index.html Thu Sep 13 01:57:33 2012 +0900 +++ b/app/views/Application/index.html Thu Sep 13 10:37:20 2012 +0900 @@ -1,29 +1,26 @@ #{extends 'main.html' /} #{set title:'Home' /} - + #{if frontPost} - - #{display post:frontPost, as:'home' /} - - #{if olderPosts.size()} - <div class="older-posts"> - <h3>Older posts <span class="from">from this blog</span></h3> - #{list items:olderPosts, as:'oldPost'} - #{display post:oldPost, as:'teaser'/} - #{/list} - </div> - #{/if} + + #{display post:frontPost, as:'home' /} + + #{if olderPosts.size()} + + <div class="older-posts"> + <h3>Older posts <span class="from">from this blog</span></h3> + + #{list items:olderPosts, as:'oldPost'} + #{display post:oldPost, as:'teaser' /} + #{/list} + </div> + + #{/if} + #{/if} - - + #{else} - <div class="empty"> - There is currently nothing to read here. - </div> -#{/else} - - - - - - + <div class="empty"> + There is currently nothing to read here. + </div> +#{/else} \ No newline at end of file
--- a/app/views/main.html Thu Sep 13 01:57:33 2012 +0900 +++ b/app/views/main.html Thu Sep 13 10:37:20 2012 +0900 @@ -1,16 +1,40 @@ -<!DOCTYPE html> - +<!DOCTYPE html > <html> <head> - <title>#{get 'title' /}</title> - <meta charset="${_response_encoding}"> - <link rel="stylesheet" media="screen" href="@{'/public/stylesheets/main.css'}"> - #{get 'moreStyles' /} - <link rel="shortcut icon" type="image/png" href="@{'/public/images/favicon.png'}"> - <script src="@{'/public/javascripts/jquery-1.6.4.min.js'}" type="text/javascript" charset="${_response_encoding}"></script> - #{get 'moreScripts' /} + <title>#{get 'title' /}</title> + <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> + <link rel="stylesheet" type="text/css" media="screen" + href="@{'/public/stylesheets/main.css'}" /> + <link rel="shortcut icon" type="image/png" + href="@{'/public/images/favicon.png'}" /> </head> <body> - #{doLayout /} + + <div id="header"> + <div id="logo"> + yabe. + </div> + <ul id="tools"> + <li> + <a href="#">Log in to write something</a> + </li> + </ul> + <div id="title"> + <span class="about">About this blog</span> + <h1><a href="@{Application.index()}">${blogTitle}</a></h1> + <h2>${blogBaseline}</h2> + </div> + </div> + + <div id="main"> + #{doLayout /} + </div> + + <p id="footer"> + Yabe is a (not that) powerful blog engine built with the + <a href="http://www.playframework.org">Play framework</a> + as a tutorial application. + </p> + </body> -</html> +</html> \ No newline at end of file
--- a/app/views/tags/display.html Thu Sep 13 01:57:33 2012 +0900 +++ b/app/views/tags/display.html Thu Sep 13 10:37:20 2012 +0900 @@ -3,7 +3,7 @@ <div class="post ${_as == 'teaser' ? 'teaser' :''}"> <h2 class="post-title"> - <a href="#">${_post.title}</a> + <a href="@{Application.show(_post.id)}">${_post.title}</a> </h2> <div class="post-metadata">
--- a/conf/application.conf Thu Sep 13 01:57:33 2012 +0900 +++ b/conf/application.conf Thu Sep 13 10:37:20 2012 +0900 @@ -212,4 +212,7 @@ %test.jpa.ddl=create %test.mail.smtp=mock -module.crud=${play.path}/modules/crud \ No newline at end of file +module.crud=${play.path}/modules/crud + +blog.title=Yet another blog +blog.baseline=We will write about nothing \ No newline at end of file