pimatic-angular-material-frontend
Version:
Provides an AngularJS webinterface for Pimatic with material design.
35 lines (30 loc) • 1.17 kB
text/coffeescript
module.exports = (env) ->
express = env.require "express"
fs = require "fs"
# ##The MobileFrontend
class MobileMaterialFrontend extends env.plugins.Plugin
# ###init the frontend:
init: (, , ) ->
# Prepare index.html
fs.readFile __dirname + '/index.tmpl.html', 'utf8', (err,data) =>
if (err)
return env.logger.error err
data = data.replace(/@/g, .customTitle);
data = data.replace(/@/g, .debug);
fs.writeFile __dirname + '/index.html', data, 'utf8', (err) ->
if (err)
return env.logger.error err
env.logger.info "Generated index.html"
# * Static assets
.use .mountPath, express.static(__dirname)
env.logger.info "Mounted material frontend on '" + .mountPath + "'"
.userManager.addAllowPublicAccessCallback( (req) =>
return (
# SocketIO
req.url.match(/^\/socket\.io\/.*$/)? or
# Application
req.url.match(new RegExp('^' + .mountPath + '.*'))?
)
)
plugin = new MobileMaterialFrontend
return plugin