add subfolder support

This commit is contained in:
Neil Lalonde 2015-12-14 15:01:35 -05:00
parent 46bee3a223
commit 2b553cc815
11 changed files with 60 additions and 28 deletions

View File

@ -8,4 +8,8 @@ module DockerManager::ApplicationHelper
@has_latest_pngcrush ||= Gem::Version.new(pngcrush_version) >= Gem::Version.new('1.7.85')
end
end
def discourse_root_url
Discourse.base_uri
end
end

View File

@ -9,7 +9,22 @@
<meta name="docker-manager/config/environment" content="%7B%22modulePrefix%22%3A%22docker-manager%22%2C%22environment%22%3A%22production%22%2C%22baseURL%22%3A%22/%22%2C%22locationType%22%3A%22hash%22%2C%22EmberENV%22%3A%7B%22FEATURES%22%3A%7B%7D%7D%2C%22contentSecurityPolicy%22%3A%7B%22style-src%22%3A%22%27self%27%20%27unsafe-inline%27%22%2C%22default-src%22%3A%22%27none%27%22%2C%22script-src%22%3A%22%27self%27%22%2C%22font-src%22%3A%22%27self%27%22%2C%22connect-src%22%3A%22%27self%27%22%2C%22img-src%22%3A%22%27self%27%22%2C%22media-src%22%3A%22%27self%27%22%7D%2C%22APP%22%3A%7B%7D%2C%22contentSecurityPolicyHeader%22%3A%22Content-Security-Policy-Report-Only%22%2C%22exportApplicationGlobal%22%3Afalse%7D">
<script>
window.Discourse = { hasLatestPngcrush: <%= has_latest_pngcrush %> };
window.Discourse = {
hasLatestPngcrush: <%= has_latest_pngcrush %>,
rootUrl: '<%= discourse_root_url %>',
getURL: function(url) {
if (!url) return url;
// if it's a non relative URL, return it.
if (url !== '/' && !/^\/[^\/]/.test(url)) return url;
if (url.indexOf(Discourse.rootUrl) !== -1) return url;
if (url[0] !== "/") url = "/" + url;
return Discourse.rootUrl + url;
}
};
</script>
<%= javascript_include_tag "docker-manager-vendor" %>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,6 @@
{{#unless versionCheck.upToDate}}
<tr>
<!-- TODO: this link needs to include relative_url_root to support subfolder installs: -->
<th colspan="5">{{i18n "docker.upgrade"}} <a href="/admin/upgrade" data-auto-route="true">{{i18n "docker.perform_upgrade"}}</a></th>
</tr>
{{/unless}}

View File

@ -18,6 +18,18 @@ export default Ember.Controller.extend({
this.set("banner", banner);
},
logoUrl: function() {
return Discourse.getURL("/assets/images/docker-manager-ea64623b074c8ec2b0303bae846e21e6.png");
}.property(),
returnToSiteUrl: function() {
return Discourse.getURL("/");
}.property(),
backupsUrl: function() {
return Discourse.getURL("/admin/backups");
}.property(),
actions: {
dismiss: function () {
this.set("bannerDismissed", true);

View File

@ -5,7 +5,7 @@ export default {
name: "findCsrfToken",
initialize: function() {
return ajax('/session/csrf').then(function(result) {
return ajax(Discourse.getURL('/session/csrf')).then(function(result) {
var token = result.csrf;
$.ajaxPrefilter(function(options, originalOptions, xhr) {
if (!options.crossDomain) {

View File

@ -9,7 +9,7 @@ var ProcessList = Ember.Object.extend({
refresh: function() {
var self = this;
return ajax("/admin/docker/ps").then(function(result) {
return ajax(Discourse.getURL("/admin/docker/ps")).then(function(result) {
self.set('output', result);
return self;
});

View File

@ -25,7 +25,7 @@ var Repo = Ember.Object.extend({
repoAjax: function(url, args) {
args = args || {};
args.data = this.getProperties('path', 'version', 'branch');
return ajax(url, args);
return ajax(Discourse.getURL(url), args);
},
findLatest: function() {
@ -74,7 +74,7 @@ Repo.reopenClass({
return new Ember.RSVP.Promise(function (resolve) {
if (loaded.length) { return resolve(loaded); }
ajax("/admin/docker/repos").then(function(result) {
ajax(Discourse.getURL("/admin/docker/repos")).then(function(result) {
loaded = result.repos.map(function(r) {
return Repo.create(r);
});

View File

@ -1,5 +1,5 @@
<header class="container">
{{#link-to 'index'}}<img src="/assets/images/docker-manager-ea64623b074c8ec2b0303bae846e21e6.png" class="logo">{{/link-to}}
{{#link-to 'index'}}<img {{bind-attr src="logoUrl"}} class="logo">{{/link-to}}
<h1>{{#link-to 'index'}}Upgrade{{/link-to}}</h1>
</header>
@ -19,8 +19,8 @@
<ul class="nav nav-tabs">
{{#x-tab route="index"}}Versions{{/x-tab}}
{{#x-tab route="processes"}}Processes{{/x-tab}}
<li><a href='/'>Return to site</a></li>
<li><a href='/admin/backups'>Backups</a></li>
<li><a {{bind-attr href="returnToSiteUrl"}}>Return to site</a></li>
<li><a {{bind-attr href="backupsUrl"}}>Backups</a></li>
</ul>
{{outlet}}

View File

@ -12,7 +12,7 @@
"loader.js": "ember-cli/loader.js#3.2.0",
"qunit": "~1.17.1",
"bootbox": "~4.3.0",
"message-bus": "https://raw.githubusercontent.com/SamSaffron/message_bus.git",
"message-bus": "https://github.com/SamSaffron/message_bus.git",
"momentjs": "~2.8.4"
}
}