cms3.0——收获(1)
前言:
刚接手cms3.0的工作,似乎对一切都那么的不熟悉,于是在开始新需求之前,先做一个简单的登录系统。
项目目录:
1.使用webstroms建expreess项目,非常方便简单,建好的项目目录就是这样子的:
;
/bin: 用于应用启动
/public: 静态资源目录
/routes:可以认为是controller(控制器)目录
/views: jade/ejs/html模板目录,可以认为是view(视图)目录
app.js 程序main文件
2.在文件夹bin下面找www,右键单击Run 'bin\www',即可看到控制台输出“server Listening on port 3000 +0ms”,然后在浏览器输入“localhost:3000”就可以看见页面上“Hello Express”的字样;
3.在建项目之初,选用的模板是ejs或者jade,在这里为了方便,我们需要把模板改成常用的,挑一种来说,这是修改app.js文件中的代码:
...
var app = express(); // view engine setup
// app.set('views', path.join(__dirname, 'views'));
// app.set('view engine', 'jade'); // 设置模板引擎从jade为html
// view engine setup
app.set('views', path.join(__dirname, 'views'));
var template = require('arttemplate-gg');
template.config('base', '');
template.config('extname', '.html');
app.engine('.html', template.__express);
app.set('view engine', 'html');
...
最后还需要吧views文件夹底下的页面全部修改成.html结束的文件。这样基本的框架才搭建出来了;
4.项目中所需的静态文件,比如jQuery、图片、插件、样式文件统一放在public对应的文件夹底下;
5.在views文件夹底下总共建4个页面:
①err.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body> <h1>{{message}}</h1>
<h2> {{error.status}}</h2>
<pre>{{error.stack}}</pre> </body>
</html>
②home.html
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>欢迎登录@@@@@@@@@@</title>
</head>
<body>
欢迎登录
</body>
</html>
③index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<link href="/public/stylesheets/bootstrap.min.css" rel="stylesheet" media="screen">
<title></title>
</head>
<body>
<p>我是index页面~~~</p>
<script src="/public/javascripts/jquery.min.js"></script>
<script src="/public/javascripts/bootstrap.min.js"></script>
</body>
</html>
④login.html
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>用户登录</title>
<style>
*{ margin:0px; padding:0px; list-style:none;}
body,html{ height:100%;font:12px/1.5 \5FAE\8F6F\96C5\9ED1,tahoma,arial,sans-serif;}
html{ background:url(/images/bg.png) repeat-x;}
body{ background:url(/images/ftbg.png) 0 bottom repeat-x;}
.main{ background:url(/images/mbg.png) no-repeat center bottom;position: absolute;width:100%;height:500px;top:50%;
margin-left:0;margin-top:-290px; z-index:99}
.loginbox{ width:410px; height:375px;background:url(/images/borderbg.png); position: absolute; left:50%; top:50%; margin-left:-200px; margin-top:-200px; border-radius:8px;-moz-border-radius: 8px; -webkit-border-radius:8px; z-index:999;}
.loginbg{ width:310px;padding:40px; margin:0 auto; margin-top:10px; background-color:#fff; border-radius:8px;-moz-border-radius: 8px; -webkit-border-radius:8px;}
.loginbox h3{ font-size:18px; font-weight:normal; color:#333; padding-bottom:15px; text-align:center;}
.loginbox input{ width:260px; height:46px; border:1px solid #dbdbdb; padding:0 5px; font-size:14px; color:#666;border-radius:5px rgba(0,0,0,0.5);-moz-border-radius: 5px; -webkit-border-radius:5px; padding-left:45px; line-height:46px;}
.loginbox ul li{ padding:15px 0; position:relative;}
.loginbox .user{ background:url(/images/lgicon.png) 0 0 no-repeat; display:inline-block; position:absolute; width:19px; height:20px; left:15px; top:27px;}
.loginbox .pwd{ background:url(/images/lgicon.png) 0 bottom no-repeat; display:inline-block; position:absolute; width:19px; height:22px; left:15px; top:27px;}
.loginbox input.lgbtn{ width:312px; background-color:#f86c6b; border:0px; color:#fff; font-size:18px; font-family:\5FAE\8F6F\96C5\9ED1;line-height:46px; text-align:center; cursor:pointer; text-indent:0px; padding:0px;}
.main h2{ margin-top:-40px; font-size:30px; text-align:center; color:#fff; font-weight:normal;}
.footer{ position:fixed; z-index:9; bottom:0px; text-align:center; color:#666; width:100%; padding-bottom:20px; font-size:14px;}
</style>
</head>
<body>
<div class="main">
<h2>小小登录窗口</h2>
<div class="loginbox">
<div class="loginbg">
<h3>测试登录</h3>
<form id="fm" action="/" method="post">
<ul>
<li><span class="user" ></span><input type="text" id="username" name="username" value=""></li>
<li><span class="pwd" ></span><input type="password" id="password" name="password" required="true" value=""><span style="color: red;position: absolute;top: 70px;left: 10px" id="msg">{{msg}}</span></li>
<li><input type="submit" value="登录" class="lgbtn"/></li>
</ul>
</form>
</div>
</div>
</div>
<div class="footer">Come on 测试一下~~~</div>
<script type="text/javascript" src="/plugin/jquery-easyui-1.4.3/jquery.min.js"></script>
<script type="text/javascript" src="/plugin/jquery-easyui-1.4.3/jquery.easyui.min.js"></script>
<script type="text/javascript" src="/plugin/jquery-easyui-1.4.3/locale/easyui-lang-zh_CN.js"></script>
</body>
</html>
6.所对应的js文件——routes底下的index.js
/**
* created 2016-11-01
*
*/ var express = require('express');
var router = express.Router(); /* GET home page. */
router.get('/', function (req, res, next) {
res.render('login', {title: 'Express'});
});
// 自定义方法
router.post('/', function (req, res, next) {
var username = req.body.username;
var password = req.body.password;
var user={
username:'admin',
password:'admin'
};
if(username == user.username && password == user.password){
console.log("验证正确");
res.render('home', {title: 'Express'});
} else {
console.log("验证失败");
res.render('login', {msg: '用户名或密码错误!'});
}
}); module.exports = router;
最终的效果就是:
7.由于js中定义了账号和密码都为admin,因此只有输入值为admin时,才可以跳转到
如左图的页面,否则就是
提示的错误信息~
cms3.0——收获(1)的更多相关文章
- CMS3.0——初次邂逅express
前言: 刚接手cms3.0的工作,似乎对一切都那么的不熟悉,于是在开始新需求之前,先做一个简单的登录系统. 项目目录: 1.使用webstroms建expreess项目,非常方便简单,建好的项目目录就 ...
- 纸壳CMS3.0中的规则引擎,表达式计算
纸壳CMS3.0中的规则引擎,用于计算通用表达试结果.通常业务逻辑总是复杂多变的,使用这个规则引擎可以灵活的修改计算表达式. IRuleManager IRuleManager,是使用规则引擎的主要接 ...
- CMS4.0——后知后觉
前言: 2016年底,自己作为参与者加入CMS3.0的改版中:2017年中,CMS4.0在经过一个月有余的时间,华丽丽的蜕变成现在大家喜闻乐见的:http://news.gangguwang.com/ ...
- 纸壳CMS 3.0升级.Net Core 2.1性能大提升
微软发布了.Net Core 2.1正式版,纸壳CMS也在第一时间做了升级,并做了一系列的优化和调整,性能大幅提升,并解决了一些历史遗留问题,添加了一些新功能. Github https://gith ...
- 74CMS3.0储存型XSS漏洞代码审计
发现一个总结了乌云以前代码审计案例的宝藏网站:https://php.mengsec.com/ 希望自己能成为那个认真复现和学习前辈们思路的那个人,然后准备慢慢开始审计一些新的小型cms了 骑士cms ...
- Discuz 5.x 6.x 7.x 前台SQL注入漏洞
来源:http://wooyun.jozxing.cc/static/bugs/wooyun-2014-071516.html 漏洞出现在/include/editpost.inc.php. if($ ...
- bzoj 1051 强连通分量
反建图,计算强连通分量,将每个分量看成一个点,缩点后的图是一个DAG,如果是一棵树,则根代表的连通分量的大小就是答案,否则答案为0. 收获: 图的东西如果不好解决,可以尝试缩点(有向图将每个强连通分量 ...
- 《京东上千页面搭建基石——CMS前后端分离演进史》阅读笔记
一.背景 CMS即内容管理系统,目的是用于快速进行网站建设或者网页开发. 对于京东网站部门来说,CMS核心目的是用来快速开发和上线各种页面,诸如各种垂直频道页. 二.CMS核心目的 进行数据和模板的统 ...
- Getting started with the basics of programming exercises_1
1.编写一个将输入复制到输出的程序,并将其中连续的多个空格用一个空格代替 使用if 结构: #include<stdio.h> #define NONBLANK 'a'; // repal ...
随机推荐
- Servlet&jsp基础:第三部分
声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...
- NoSql存储日志数据之Spring+Logback+Hbase深度集成
NoSql存储日志数据之Spring+Logback+Hbase深度集成 关键词:nosql, spring logback, logback hbase appender 技术框架:spring-d ...
- JavaWEB 常用开发模式MVC+三层结构
MVC开发模式: M: Model -- JavaBean C: Controler -- Servlet V: View --- JSP 不会在word里面画画,所以就直接截了 老 ...
- iOS - UINavigationController
前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UINavigationController : UIViewController @available(iOS 2 ...
- [转载] 每个 Python 程序员都要知道的日志实践
原文: http://python.jobbole.com/81666/ 在现实生活中,记录日志非常重要.银行转账时会有转账记录:飞机飞行过程中,会有黑盒子(飞行数据记录器)记录飞行过程中的一切.如果 ...
- Codeforces723E One-Way Reform【欧拉回路】
题意:给你n点m边的图,然后让你确定每条边的方向,使得入度=出度的点最多 . 度数为偶数的点均能满足入度 = 出度. 证明:度数为奇数的点有偶数个,奇度点两两配对连无向边,则新图存在欧拉回路,则可使新 ...
- 百度web前端面试2015.10.18
邮件里通知的周日下午两点参加百度校招面试,我13:10分就到了,前台先让我拿了个面试资格单(上面是我的信息),然后在web前端面试入口排队,面试在百度食堂举行的,等了大概1个小时,放我去面试.都是一对 ...
- Linux下搭建SVN服务
SVN有几种方式进行访问,比较常见的是通过自带协议访问(svn://),配置很简单,还有一种就是http协议访问,需要结合apache服务,配置相对繁琐. 安装svn yum -y install s ...
- UNC path
http://www.emailsignature.eu/phpBB2/how-to-get-a-unc-path-name-t341.html In a network, the Universal ...
- Object Pascal 运算符
Object Pascal 的运算符 运算符是程序代码中对各种类型的数据进行计算的符号,通常分为算数运算符.逻辑运算符.比较运算符和按位运算符. 1.算术运算符Object Pascal ...