首页 > Java > java教程 > 正文

PlayFramework完整实现一个APP(五)

黄舟
发布: 2016-12-23 16:40:39
原创
1342人浏览过

程序以及基本可用了,需要继续完善页面

 

1.创建页面模板

创建文件 app/views/tags/display.html 

*{ Display a post in one of these modes: 'full', 'home' or 'teaser' }*

<div class="post ${_as == 'teaser' ? 'teaser' : ''}">
   <h2 class="post-title">
       <a href="#">${_post.title}</a>
   </h2>
   <div class="post-metadata">
       <span class="post-author">by ${_post.author.fullname}</span>,
       <span class="post-date">${_post.postedAt.format('dd MMM yy')}</span>
       #{if _as != 'full'}
           <span class="post-comments">
                |  ${_post.comments.size() ?: 'no'}
               comment${_post.comments.size().pluralize()}
               #{if _post.comments}
                   , latest by ${_post.comments[0].author}
               #{/if}
           </span>
       #{/if}
   </div>
   #{if _as != 'teaser'}
       <div class="post-content">
           <div class="about">Detail: </div>
           ${_post.content.nl2br()}
       </div>
   #{/if}
</div>

#{if _as == 'full'}
   <div class="comments">
       <h3>
           ${_post.comments.size() ?: 'no'}
           comment${_post.comments.size().pluralize()}
       </h3>
       
       #{list items:_post.comments, as:'comment'}
           <div class="comment">
               <div class="comment-metadata">
                   <span class="comment-author">by ${comment.author},</span>
                   <span class="comment-date">
                       ${comment.postedAt.format('dd MMM yy')}
                   </span>
               </div>
               <div class="comment-content">
                   <div class="about">Detail: </div>
                   ${comment.content.escape().nl2br()}
               </div>
           </div>
       #{/list}
       
   </div>
#{/if}

  

  

修改index.html

#{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}
   
#{/if}

#{else}
   <div class="empty">
       There is currently nothing to read here.
   </div>
#{/else}

  

  

2.修改Layout  views\main.html

<!DOCTYPE html>

<html>
   <head>
       <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>
       <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="#">${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>

  

3. Application.java 中添加方法,在页面上添加元素

weenCompany闻名企业网站系统5.3.0 繁体中英文 UTF8
weenCompany闻名企业网站系统5.3.0 繁体中英文 UTF8

weenCompany闻名企业网站系统(免费开源)是一个功能强大, 使用简单的中英文企业智能建站系统, 您只需要一些基本的计算机知识就可以利用此系统完成中小型企业网站的建设; 是低成本企业网站架设方案之首选CMS系统, 也适合建设个人网站。weenCompany闻名企业网站系统功能:1. 程序代码简洁严谨, 整个系统程序仅2M左右大小.2. 中英文双语版共用一套网站程序, 双语页面实现自由切换.3

weenCompany闻名企业网站系统5.3.0 繁体中英文 UTF8 0
查看详情 weenCompany闻名企业网站系统5.3.0 繁体中英文 UTF8

@Before
static void addDefaults() {
renderArgs.put("blogTitle", Play.configuration.getPRoperty("blog.title"));
renderArgs.put("blogBaseline", Play.configuration.getProperty("blog.baseline"));
}

添加渲染 blog.title blog.baseline

 

4.修改配置文件 conf\application.conf

# Blog engine configuration
# ~~~~~
blog.title=Yet another blog
blog.baseline=We won't write about anything

  

5.添加页面样式

CSS: http://play-framework.herokuapp.com/zh/files/main.css

添加到 /public/stylesheets/main.css

 

运行效果:

211.png

 以上就是PlayFramework完整实现一个APP(五)的内容,更多相关内容请关注PHP中文网(www.php.cn)!

相关标签:
app
最佳 Windows 性能的顶级免费优化软件
最佳 Windows 性能的顶级免费优化软件

每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号