mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Merge pull request #469 from wojciechka/master
Support for running discourse with a prefix (i.e. as http://servername/discourse)
This commit is contained in:
@@ -7,10 +7,18 @@
|
||||
@module Discourse
|
||||
**/
|
||||
Discourse.AdminUser = Discourse.Model.extend({
|
||||
path: (function() {
|
||||
return Discourse.getURL("/users/") + (this.get('username_lower'));
|
||||
}).property('username'),
|
||||
|
||||
adminPath: (function() {
|
||||
return Discourse.getURL("/admin/users/") + (this.get('username_lower'));
|
||||
}).property('username'),
|
||||
|
||||
|
||||
deleteAllPosts: function() {
|
||||
this.set('can_delete_all_posts', false);
|
||||
$.ajax("/admin/users/" + (this.get('id')) + "/delete_all_posts", {type: 'PUT'});
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/delete_all_posts", {type: 'PUT'});
|
||||
},
|
||||
|
||||
// Revoke the user's admin access
|
||||
@@ -18,14 +26,14 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
this.set('admin', false);
|
||||
this.set('can_grant_admin', true);
|
||||
this.set('can_revoke_admin', false);
|
||||
return $.ajax("/admin/users/" + (this.get('id')) + "/revoke_admin", {type: 'PUT'});
|
||||
return $.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/revoke_admin", {type: 'PUT'});
|
||||
},
|
||||
|
||||
grantAdmin: function() {
|
||||
this.set('admin', true);
|
||||
this.set('can_grant_admin', false);
|
||||
this.set('can_revoke_admin', true);
|
||||
$.ajax("/admin/users/" + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/grant_admin", {type: 'PUT'});
|
||||
},
|
||||
|
||||
// Revoke the user's moderation access
|
||||
@@ -33,18 +41,18 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
this.set('moderator', false);
|
||||
this.set('can_grant_moderation', true);
|
||||
this.set('can_revoke_moderation', false);
|
||||
return $.ajax("/admin/users/" + (this.get('id')) + "/revoke_moderation", {type: 'PUT'});
|
||||
return $.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/revoke_moderation", {type: 'PUT'});
|
||||
},
|
||||
|
||||
grantModeration: function() {
|
||||
this.set('moderator', true);
|
||||
this.set('can_grant_moderation', false);
|
||||
this.set('can_revoke_moderation', true);
|
||||
$.ajax("/admin/users/" + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/grant_moderation", {type: 'PUT'});
|
||||
},
|
||||
|
||||
refreshBrowsers: function() {
|
||||
$.ajax("/admin/users/" + (this.get('id')) + "/refresh_browsers", {type: 'POST'});
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/refresh_browsers", {type: 'POST'});
|
||||
bootbox.alert("Message sent to all clients!");
|
||||
},
|
||||
|
||||
@@ -52,7 +60,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
this.set('can_approve', false);
|
||||
this.set('approved', true);
|
||||
this.set('approved_by', Discourse.get('currentUser'));
|
||||
$.ajax("/admin/users/" + (this.get('id')) + "/approve", {type: 'PUT'});
|
||||
$.ajax(Discourse.getURL("/admin/users/") + (this.get('id')) + "/approve", {type: 'PUT'});
|
||||
},
|
||||
|
||||
username_lower: (function() {
|
||||
@@ -79,7 +87,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
_this = this;
|
||||
if (duration = parseInt(window.prompt(Em.String.i18n('admin.user.ban_duration')), 10)) {
|
||||
if (duration > 0) {
|
||||
return $.ajax("/admin/users/" + this.id + "/ban", {
|
||||
return $.ajax(Discourse.getURL("/admin/users/") + this.id + "/ban", {
|
||||
type: 'PUT',
|
||||
data: {duration: duration},
|
||||
success: function() {
|
||||
@@ -99,7 +107,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
|
||||
unban: function() {
|
||||
var _this = this;
|
||||
return $.ajax("/admin/users/" + this.id + "/unban", {
|
||||
return $.ajax(Discourse.getURL("/admin/users/") + this.id + "/unban", {
|
||||
type: 'PUT',
|
||||
success: function() {
|
||||
window.location.reload();
|
||||
@@ -116,7 +124,7 @@ Discourse.AdminUser = Discourse.Model.extend({
|
||||
|
||||
impersonate: function() {
|
||||
var _this = this;
|
||||
return $.ajax("/admin/impersonate", {
|
||||
return $.ajax(Discourse.getURL("/admin/impersonate"), {
|
||||
type: 'POST',
|
||||
data: {
|
||||
username_or_email: this.get('username')
|
||||
@@ -145,7 +153,7 @@ Discourse.AdminUser.reopenClass({
|
||||
user.set('can_approve', false);
|
||||
return user.set('selected', false);
|
||||
});
|
||||
return $.ajax("/admin/users/approve-bulk", {
|
||||
return $.ajax(Discourse.getURL("/admin/users/approve-bulk"), {
|
||||
type: 'PUT',
|
||||
data: {
|
||||
users: users.map(function(u) {
|
||||
@@ -156,7 +164,7 @@ Discourse.AdminUser.reopenClass({
|
||||
},
|
||||
|
||||
find: function(username) {
|
||||
return $.ajax({url: "/admin/users/" + username}).then(function (result) {
|
||||
return $.ajax({url: Discourse.getURL("/admin/users/") + username}).then(function (result) {
|
||||
return Discourse.AdminUser.create(result);
|
||||
})
|
||||
},
|
||||
@@ -165,7 +173,7 @@ Discourse.AdminUser.reopenClass({
|
||||
var result;
|
||||
result = Em.A();
|
||||
$.ajax({
|
||||
url: "/admin/users/list/" + query + ".json",
|
||||
url: Discourse.getURL("/admin/users/list/") + query + ".json",
|
||||
data: {
|
||||
filter: filter
|
||||
},
|
||||
|
||||
@@ -20,7 +20,7 @@ Discourse.EmailLog.reopenClass({
|
||||
var result;
|
||||
result = Em.A();
|
||||
$.ajax({
|
||||
url: "/admin/email_logs.json",
|
||||
url: Discourse.getURL("/admin/email_logs.json"),
|
||||
data: { filter: filter },
|
||||
success: function(logs) {
|
||||
logs.each(function(log) {
|
||||
|
||||
@@ -47,14 +47,14 @@ Discourse.FlaggedPost = Discourse.Post.extend({
|
||||
|
||||
deletePost: function() {
|
||||
if (this.get('post_number') === "1") {
|
||||
return $.ajax("/t/" + this.topic_id, { type: 'DELETE', cache: false });
|
||||
return $.ajax(Discourse.getURL("/t/") + this.topic_id, { type: 'DELETE', cache: false });
|
||||
} else {
|
||||
return $.ajax("/posts/" + this.id, { type: 'DELETE', cache: false });
|
||||
return $.ajax(Discourse.getURL("/posts/") + this.id, { type: 'DELETE', cache: false });
|
||||
}
|
||||
},
|
||||
|
||||
clearFlags: function() {
|
||||
return $.ajax("/admin/flags/clear/" + this.id, { type: 'POST', cache: false });
|
||||
return $.ajax(Discourse.getURL("/admin/flags/clear/") + this.id, { type: 'POST', cache: false });
|
||||
},
|
||||
|
||||
hiddenClass: (function() {
|
||||
@@ -68,7 +68,7 @@ Discourse.FlaggedPost.reopenClass({
|
||||
var result;
|
||||
result = Em.A();
|
||||
$.ajax({
|
||||
url: "/admin/flags/" + filter + ".json",
|
||||
url: Discourse.getURL("/admin/flags/") + filter + ".json",
|
||||
success: function(data) {
|
||||
var userLookup;
|
||||
userLookup = {};
|
||||
|
||||
@@ -3,7 +3,7 @@ Discourse.Report = Discourse.Model.extend({});
|
||||
Discourse.Report.reopenClass({
|
||||
find: function(type) {
|
||||
var model = Discourse.Report.create({type: type});
|
||||
$.ajax("/admin/reports/" + type, {
|
||||
$.ajax(Discourse.getURL("/admin/reports/") + type, {
|
||||
type: 'GET',
|
||||
success: function(json) {
|
||||
|
||||
@@ -24,4 +24,4 @@ Discourse.Report.reopenClass({
|
||||
});
|
||||
return(model);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
@@ -56,7 +56,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||
override_default_style: this.override_default_style
|
||||
};
|
||||
return $.ajax({
|
||||
url: "/admin/site_customizations" + (this.id ? '/' + this.id : ''),
|
||||
url: Discourse.getURL("/admin/site_customizations") + (this.id ? '/' + this.id : ''),
|
||||
data: {
|
||||
site_customization: data
|
||||
},
|
||||
@@ -68,7 +68,7 @@ Discourse.SiteCustomization = Discourse.Model.extend({
|
||||
if (!this.id) return;
|
||||
|
||||
return $.ajax({
|
||||
url: "/admin/site_customizations/" + this.id,
|
||||
url: Discourse.getURL("/admin/site_customizations/") + this.id,
|
||||
type: 'DELETE'
|
||||
});
|
||||
}
|
||||
@@ -94,7 +94,7 @@ Discourse.SiteCustomization.reopenClass({
|
||||
loading: true
|
||||
});
|
||||
$.ajax({
|
||||
url: "/admin/site_customizations",
|
||||
url: Discourse.getURL("/admin/site_customizations"),
|
||||
dataType: "json",
|
||||
success: function(data) {
|
||||
if (data) {
|
||||
|
||||
@@ -72,7 +72,7 @@ Discourse.SiteSetting = Discourse.Model.extend({
|
||||
save: function() {
|
||||
// Update the setting
|
||||
var setting = this;
|
||||
return $.ajax("/admin/site_settings/" + (this.get('setting')), {
|
||||
return $.ajax(Discourse.getURL("/admin/site_settings/") + (this.get('setting')), {
|
||||
data: { value: this.get('value') },
|
||||
type: 'PUT',
|
||||
success: function() {
|
||||
@@ -91,7 +91,7 @@ Discourse.SiteSetting.reopenClass({
|
||||
**/
|
||||
findAll: function() {
|
||||
var result = Em.A();
|
||||
$.get("/admin/site_settings", function(settings) {
|
||||
$.get(Discourse.getURL("/admin/site_settings"), function(settings) {
|
||||
return settings.each(function(s) {
|
||||
s.originalValue = s.value;
|
||||
return result.pushObject(Discourse.SiteSetting.create(s));
|
||||
|
||||
@@ -26,8 +26,8 @@ Discourse.VersionCheck = Discourse.Model.extend({
|
||||
|
||||
Discourse.VersionCheck.reopenClass({
|
||||
find: function() {
|
||||
return $.ajax({ url: '/admin/version_check', dataType: 'json' }).then(function(json) {
|
||||
return $.ajax({ url: Discourse.getURL('/admin/version_check'), dataType: 'json' }).then(function(json) {
|
||||
return Discourse.VersionCheck.create(json);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user