Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x | import Crowi from 'server/crowi' import { Express } from 'express' import ssr from './ssr' export default (crowi: Crowi, app: Express, req, res) => { // const debug = Debug('crowi:lib:swigFunctions') const Page = crowi.model('Page') const Config = crowi.model('Config') const User = crowi.model('User') const { locals } = res // token getter locals.csrf = function() { return req.csrfToken } locals.assets = function(file) { // tmp return file } locals.googleLoginEnabled = function() { const config = crowi.getConfig() return Config.googleLoginEnabled(config) } locals.githubLoginEnabled = function() { const config = crowi.getConfig() return Config.githubLoginEnabled(config) } locals.searchConfigured = function() { if (crowi.getSearcher()) { return true } return false } locals.slackConfigured = function() { var config = crowi.getConfig() if (Config.hasSlackToken(config)) { return true } return false } locals.isUploadable = function() { var config = crowi.getConfig() return Config.isUploadable(config) } locals.isExternalShareEnabled = function() { var config = crowi.getConfig() return config.crowi['app:externalShare'] } locals.parentPath = function(path) { if (path == '/') { return path } if (path.match(/.+\/$/)) { return path } return path + '/' } locals.isUserPageList = function(path) { if (path.match(/^\/user\/[^/]+\/$/) || path.match(/^\/user\/$/)) { return true } return false } locals.isUserPage = function(path) { return path.match(/^\/user\/[^/]+$/) } locals.isTopPage = function() { var path = req.path || '' if (path === '/') { return true } return false } locals.isTrashPage = function() { var path = req.path || '' if (path.match(/^\/trash\/.*/)) { return true } return false } locals.isDeletablePage = function() { var Page = crowi.model('Page') var path = req.path || '' return Page.isDeletableName(path) } locals.userPageRoot = function(user) { if (!user || !user.username) { return '' } return '/user/' + user.username } locals.css = { grant: function(pageData) { if (!pageData) { return '' } switch (pageData.grant) { case Page.GRANT_PUBLIC: return 'grant-public' case Page.GRANT_RESTRICTED: return 'grant-restricted' // case Page.GRANT_SPECIFIED: // return 'grant-specified'; // break; case Page.GRANT_OWNER: return 'grant-owner' default: break } return '' }, userStatus: function(user) { // debug('userStatus', user._id, user.usename, user.status); switch (user.status) { case User.STATUS_REGISTERED: return 'badge-info' case User.STATUS_ACTIVE: return 'badge-success' case User.STATUS_SUSPENDED: return 'badge-warning' case User.STATUS_DELETED: return 'badge-danger' case User.STATUS_INVITED: return 'badge-info' default: break } return '' }, } locals.Component = ssr(res) } |