Skip to content
This repository has been archived by the owner on Aug 20, 2021. It is now read-only.

Commit

Permalink
Remove domain specific configs for simple config.php
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcroox committed Jan 2, 2017
1 parent 3f0e2a4 commit 7f07071
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 38 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ tiles
dist/cache
dist/config/r3.local.php
dist/config/titanmods.xyz.php
dist/config.php
22 changes: 9 additions & 13 deletions dist/assets/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -279,25 +279,24 @@ Events.prototype.projectileLaunch = function(eventData) {
function Map() {

this.terrain;
this.tileSubDomains = false;
this.zooming = false;
this.tileDomain = 'https://r3tiles-a.titanmods.xyz/';
};

Map.prototype.init = function(terrainName, tileSubDomains, cb) {
Map.prototype.init = function(terrainName, cb) {

var self = this;

this.terrain = terrainName.toLowerCase();
this.tileSubDomains = tileSubDomains;

if(typeof mappingConfig[this.terrain] !== "undefined")
this.terrain = mappingConfig[this.terrain];

$.getJSON(webPath + '/maps/' + this.terrain + '/config.json', function(configJson) {
$.getJSON(this.tileDomain + this.terrain + '/config.json', function(configJson) {
self.config = configJson;
self.render(cb);
})
.fail(function() {
.fail(function(e) {
console.log("Error loading terrain config");
cb(true);
});
Expand Down Expand Up @@ -339,14 +338,11 @@ Map.prototype.render = function(cb) {
// We need to set an initial view for the tiles to render
this.setView([this.config.height / 2, this.config.width / 2], this.config.initZoom);

// Inject sub domain support for faster tile loading (if supported)
var tileUrl = (this.tileSubDomains) ? webPath.replace("//", "//{s}.") : webPath;

if(webPath == "http://aar.local")
tileUrl = 'https://titanmods.xyz/r3/ark';
// Inject sub domain support for faster tile loading (for those on non http/2 servers)
var tileUrl = "https://r3tiles-{s}.titanmods.xyz/";

// Add our terrain generated tiles
this.layer = L.tileLayer(tileUrl + '/maps/' + this.terrain + '/tiles/{z}/{x}/{y}.png', {
this.layer = L.tileLayer(tileUrl + this.terrain + '/tiles/{z}/{x}/{y}.png', {
noWrap: true,
maxNativeZoom: this.config.maxZoom,
maxZoom: 10,
Expand Down Expand Up @@ -1029,7 +1025,7 @@ PlayBack.prototype.init = function(replayDetails, sharedPresets, cacheAvailable)
this.zoomedToFirstPlayer = true;

// Setup map with our chosen terrain
map.init(this.replayDetails.map, this.replayDetails.tileSubDomains, function(error) {
map.init(this.replayDetails.map, function(error) {

if (error) {

Expand Down Expand Up @@ -1425,7 +1421,7 @@ Poi.prototype.add = function() {

var self = this;

$.getJSON(webPath + '/maps/' + this.terrain + '/poi.json', function(poiJson) {
$.getJSON(map.tileDomain + this.terrain + '/poi.json', function(poiJson) {

async.forEachOf(poiJson, function(poi, key, callback) {

Expand Down
2 changes: 1 addition & 1 deletion dist/assets/app.min.js

Large diffs are not rendered by default.

Binary file modified dist/assets/images/brand/favicon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dist/config/template.com.php → dist/config.template.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?php
// Rename this file to yourdomain.com.php
// Rename this file to config.php

define('UNIT_NAME', 'Unit Name');

Expand Down
27 changes: 4 additions & 23 deletions dist/inc/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,30 +7,11 @@
$path = substr($dir, 0, strrpos($dir, "/"));
define('APP_PATH', $path);

// Find our host specific config
// If you uploaded this to http://yourunit.com/aar/ you would create "yourunit.com.php" in /config/
$matchingConfigs = array_map(function($id) {
return APP_PATH . '/config/' . $id . '.php';
}, [ gethostname(), $_SERVER['HTTP_HOST'] ]);
// Try loading the config
if(!file_exists(APP_PATH . '/config.php'))
die('Failed to load config.php, have you edited and renamed /config.template.php to /config.php?');

$matchingConfig = false;

foreach($matchingConfigs as $config) {

if(realpath($config)) {
$matchingConfig = $config;
break;
}
}

// Can our host specific config be found?
if($matchingConfig)
require_once($matchingConfig);
else
throw new Exception('Could not load environment config');

if(!defined("DB_HOST"))
throw new Exception('Missing connection details, check your environment config. Use config/aar.local.php as an example');
require_once(APP_PATH . '/config.php');

// Auto load our classes
spl_autoload_register(function ($className) {
Expand Down

0 comments on commit 7f07071

Please sign in to comment.