ProjectMeshnet/nodeatlas

Create separate config.js.tmpl and make loadmap.js static

Closed this issue · 3 comments

Currently, loadmap.js.tmpl is templated, despite the fact that it only uses the templates to initialize a config variable. This could easily be moved to a much smaller config.js.tmpl for purely the purpose of creating this variable, and loadmap.js.tmpl could be renamed to loadmap.js.

Excerpt from loadmap.js.tmpl

var options = {
    "tileserver": "{{.Map.Tileserver}}",
    "center": new L.LatLng({{.Map.Center.Latitude}},
    {{.Map.Center.Longitude}}),
    "zoom": {{.Map.Zoom}}
}

var cachedMaps = {};
var nodes = [];

var firstLoad = true;
var attribution = '<a href="https://github.com/ProjectMeshnet/nodeatlas">NodeAtlas {{.Version}}</a> — Map data {{.Map.Attribution}}';

var nodelayer = new L.MarkerClusterGroup({
    spiderfyOnMaxZoom: true,
    showCoverageOnHover: false,
    zoomToBoundsOnClick: true,
    maxClusterRadius: {{.Map.ClusterRadius}}
});

I haven't thought about that, but that might be a better idea. It'd be better to have a small pre-compiled file than a large one.

The processing power required is, of course, negligible on today's
computers, particularly seeing as it's only compiled at startup,
rather than per page view. What bothers me most about it is the lack
of default syntax highlighting on .tmpl files. That's really
annoying.

Yeah, I agree.