Skip to content

Commit

Permalink
add instructions document
Browse files Browse the repository at this point in the history
  • Loading branch information
aNd1coder committed Jan 15, 2016
1 parent e5d9e8c commit 8be76dc
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 13 deletions.
8 changes: 5 additions & 3 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,17 @@ app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));

app.use(function (req, res, next) {
var url = req.originalUrl, segments = url.split('?')[0].split('/');
var url = req.originalUrl, segments = url.split('?')[0].split('/'), user;

res.locals.controllerName = segments[1];
res.locals.actionName = segments[2] || 'index';

if (url != '/' && url.indexOf("/authorize") == -1 && !req.session.user) {
return res.redirect("/authorize?next=" + encodeURIComponent(url));
} else {
res.locals.user = req.session.user;
user = req.session.user;
user.isSuperAdmin = user && user.roles.indexOf(1) == 0;
res.locals.user = user;
}

next();
Expand Down Expand Up @@ -100,8 +102,8 @@ app.locals.ENVIRONMENT = {
};

app.locals.PROJECT = {
www: '主站',
act: '活动',
www: '主站',
m: 'H5'
};

Expand Down
1 change: 1 addition & 0 deletions config/setting.sample.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
module.exports = {
domain: '***.com',
imgholder: 'http://path/to/imgholder',
doc: 'http://samgui.com/page-factory/',
limit: 10,
api: {
authorize: {
Expand Down
2 changes: 1 addition & 1 deletion views/component/gridview.jade
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ table.table.table-striped.table-hover
else
span.label.label-danger 草稿
td
if(user && user.roles.indexOf(1) == 0 /* super administrator */)
if(user.isSuperAdmin)
a.btn.btn-default.btn-delete(href="/#{controllerName}/delete/#{m._id}") 删除
a.btn.btn-default(href="/#{controllerName}/edit/#{m._id}") 编辑
include ../component/pagination
4 changes: 3 additions & 1 deletion views/component/navbar.jade
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ header.navbar.navbar-static-top
a(href="/hota") 热点图
li.nav-module
a(href="/module/") 模块
if(user && user.roles.indexOf(1) == 0 /* super administrator */)
if(user && user.isSuperAdmin)
li.nav-template
a(href="/template/") 模版
li.nav-page
a(href="/page/") 页面
li.nav-doc
a(href=setting.doc,target="_blank") 帮助
ul.nav.navbar-nav.navbar-right
if(user && user.username)
li
Expand Down
18 changes: 10 additions & 8 deletions views/module/_modal.jade
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@
ul.nav.nav-tabs
li.active
a(href="#content",data-toggle="tab") 内容
li
a(href="#template",data-toggle="tab") 模版
li
a(href="#templateData",data-toggle="tab") 数据
if(user.isSuperAdmin)
li
a(href="#template",data-toggle="tab") 模版
li
a(href="#templateData",data-toggle="tab") 数据
.tab-content.well
#content(class="tab-pane active#{model && model.templateData && model.templateData.rows ? ' form-inline' : ''}")
if(model && model.templateData)
Expand All @@ -34,10 +35,11 @@
.input-group
.input-group-addon= field[1]
input.form-control(type="text",name=field[0],value=field[3] || '',data-rule=field[2])
#template.tab-pane
textarea.form-control(type="text",name="template")= model ? model.template : ''
#templateData.tab-pane
textarea.form-control(type="text",name="templateData")= model ? JSON.stringify(model.templateData) : ''
if(user.isSuperAdmin)
#template.tab-pane
textarea.form-control(type="text",name="template")= model ? model.template : ''
#templateData.tab-pane
textarea.form-control(type="text",name="templateData")= model ? JSON.stringify(model.templateData) : ''
.modal-footer
a.btn.btn-default(href="javascript:;",data-dismiss="modal") 关闭
a.btn.btn-primary.btn-save(href="javascript:;",type="submit") 保存

0 comments on commit 8be76dc

Please sign in to comment.