parent
1de75d070a
commit
23e26e6f65
@ -0,0 +1,11 @@
|
||||
# coding: UTF-8
|
||||
|
||||
class StaticController < ApplicationController
|
||||
layout false
|
||||
|
||||
ssl_allowed :index
|
||||
|
||||
def index
|
||||
render :file => 'public/static/dashboard/index.html'
|
||||
end
|
||||
end
|
@ -0,0 +1,70 @@
|
||||
const Carto = require('../carto-node/index');
|
||||
const PACKAGE = require('../../../../package.json');
|
||||
const version = PACKAGE.version;
|
||||
|
||||
window.StaticConfig = window.StaticConfig || {};
|
||||
window.CartoConfig = window.CartoConfig || {};
|
||||
|
||||
(function (window, document) {
|
||||
var client = new Carto.AuthenticatedClient();
|
||||
|
||||
function getAssetsVersion () {
|
||||
var query = window.location.search.substring(1);
|
||||
var vars = query.split('&');
|
||||
|
||||
for (var i = 0; i < vars.length; i++) {
|
||||
var pair = vars[i].split('=');
|
||||
|
||||
if (pair[0] === 'v') {
|
||||
return pair[1];
|
||||
}
|
||||
}
|
||||
|
||||
return window.StaticConfig.assetVersion || window.CartoConfig.data.user_frontend_version || version;
|
||||
}
|
||||
|
||||
function getAssetsBaseUrl () {
|
||||
var data = window.CartoConfig.data;
|
||||
var userAssetsHost = data.asset_host;
|
||||
|
||||
return (window.StaticConfig.assetsBaseUrl || userAssetsHost && userAssetsHost + '/assets' || data.config.app_assets_base_url) + '/';
|
||||
}
|
||||
|
||||
client.getConfig(function (err, response, data) {
|
||||
window.CartoConfig.data = data;
|
||||
|
||||
if (err) {
|
||||
console.error('Error getting the config:\n', err);
|
||||
} else {
|
||||
if (response.statusCode !== 200) {
|
||||
window.location.href = '/login';
|
||||
}
|
||||
|
||||
var assetsUrl = getAssetsBaseUrl() + getAssetsVersion();
|
||||
|
||||
(function (w, d, a, favicon, stylesheets, scripts, l, h, s, t) {
|
||||
l = d.createElement('link');
|
||||
l.rel = 'shortcut icon';
|
||||
l.href = a + favicon;
|
||||
h = d.getElementsByTagName('head')[0];
|
||||
h.parentNode.insertBefore(l, h);
|
||||
|
||||
stylesheets.forEach(function (src) {
|
||||
l = d.createElement('link');
|
||||
l.rel = 'stylesheet';
|
||||
l.href = a + src;
|
||||
h = d.getElementsByTagName('head')[0];
|
||||
h.parentNode.insertBefore(l, h);
|
||||
});
|
||||
|
||||
scripts.forEach(function (src) {
|
||||
s = d.createElement('script');
|
||||
t = d.getElementsByTagName('script')[0];
|
||||
s.async = false;
|
||||
s.src = a + src;
|
||||
t.parentNode.insertBefore(s, t);
|
||||
});
|
||||
})(window, document, assetsUrl, '/favicons/favicon.ico', window.StaticConfig.stylesheets, window.StaticConfig.scripts);
|
||||
}
|
||||
});
|
||||
})(window, document);
|
@ -0,0 +1,70 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title></title>
|
||||
<style>
|
||||
#initial_startup {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
position: fixed;
|
||||
-moz-user-select: none;
|
||||
-webkit-user-select: none;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
display: -webkit-box;
|
||||
display: -webkit-flex;
|
||||
-webkit-align-items: center;
|
||||
-webkit-justify-content: center;
|
||||
flex-direction: column;
|
||||
-webkit-flex-direction: column;
|
||||
}
|
||||
.spinner {
|
||||
position: relative;
|
||||
margin: 0 auto;
|
||||
border-top: 2px solid #ddd;
|
||||
border-right: 2px solid #ddd;
|
||||
border-bottom: 2px solid #ddd;
|
||||
border-left: 2px solid #0090d7;
|
||||
-webkit-animation: load8 1.1s infinite linear;
|
||||
-khtml-animation: load8 1.1s infinite linear;
|
||||
-moz-animation: load8 1.1s infinite linear;
|
||||
-ms-animation: load8 1.1s infinite linear;
|
||||
-o-animation: load8 1.1s infinite linear;
|
||||
animation: load8 1.1s infinite linear;
|
||||
}
|
||||
.spinner,
|
||||
.spinner:after {
|
||||
width: 36px;
|
||||
height: 36px;
|
||||
border-radius: 50%;
|
||||
}
|
||||
|
||||
@keyframes load8 {
|
||||
100% { transform: rotate(360deg); }
|
||||
}
|
||||
@-webkit-keyframes load8 {
|
||||
100% { -webkit-transform: rotate(360deg); }
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="app"></div>
|
||||
|
||||
<div id="initial_startup">
|
||||
<div class="spinner"></div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
window.StaticConfig = <%= JSON.stringify(htmlWebpackPlugin.options.config) %>
|
||||
</script>
|
||||
|
||||
<% if (!htmlWebpackPlugin.options.inject) { %>
|
||||
<% htmlWebpackPlugin.files.js.forEach(function(jsFile) { %>
|
||||
<script>
|
||||
<%= compilation.assets[jsFile.substr(htmlWebpackPlugin.files.publicPath.length)].source() %>
|
||||
</script>
|
||||
<% }); %>
|
||||
<% } %>
|
||||
</body>
|
||||
</html>
|
@ -0,0 +1,18 @@
|
||||
var files = {
|
||||
dashboard: {
|
||||
stylesheets: [
|
||||
'/stylesheets/cartodb.css',
|
||||
'/stylesheets/common.css',
|
||||
'/stylesheets/dashboard.css'
|
||||
],
|
||||
scripts: [
|
||||
'/javascripts/cdb_static.js',
|
||||
'/javascripts/models_static.js',
|
||||
'/javascripts/dashboard_templates_static.js',
|
||||
'/javascripts/dashboard_deps_static.js',
|
||||
'/javascripts/dashboard_static.js'
|
||||
]
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = files;
|
@ -0,0 +1,44 @@
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
const path = require('path');
|
||||
var webpack_files = require('../lib/build/files/webpack_files');
|
||||
|
||||
const PACKAGE = require('./../package.json');
|
||||
const version = PACKAGE.version;
|
||||
|
||||
module.exports = {
|
||||
entry: './lib/assets/javascripts/cartodb/static.js',
|
||||
output: {
|
||||
filename: `${version}/javascripts/[name].js`,
|
||||
path: path.resolve(__dirname, '../public/assets'),
|
||||
publicPath: '/assets/'
|
||||
},
|
||||
devtool: 'source-map',
|
||||
plugins: Object.keys(webpack_files).map(function (entryName) {
|
||||
return new HtmlWebpackPlugin({
|
||||
inject: false,
|
||||
cache: false,
|
||||
filename: path.resolve(__dirname, '../public/static/' + entryName + '/index.html'),
|
||||
template: path.resolve(__dirname, '../lib/assets/javascripts/cartodb/static/index.jst.ejs'),
|
||||
config: webpack_files[entryName]
|
||||
});
|
||||
}),
|
||||
module: {
|
||||
rules: [
|
||||
{
|
||||
test: /\.js$/,
|
||||
loader: 'babel-loader',
|
||||
include: [
|
||||
path.resolve(__dirname, '../lib/assets/javascripts/carto-node')
|
||||
],
|
||||
options: {
|
||||
presets: ['es2015']
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
node: {
|
||||
fs: 'empty',
|
||||
net: 'empty',
|
||||
tls: 'empty'
|
||||
}
|
||||
};
|
Loading…
Reference in new issue