2
0
Fork 0
mirror of https://github.com/discourse/discourse.git synced 2025-09-07 12:02:53 +08:00

FEATURE: Allow customization of robots.txt (#7884)

* FEATURE: Allow customization of robots.txt

This allows admins to customize/override the content of the robots.txt
file at /admin/customize/robots. That page is not linked to anywhere in
the UI -- admins have to manually type the URL to access that page.

* use Ember.computed.not

* Jeff feedback

* Feedback

* Remove unused import
This commit is contained in:
Osama Sayegh 2019-07-15 20:47:44 +03:00 committed by GitHub
parent 90e0f1b378
commit 6515ff19e5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
12 changed files with 282 additions and 7 deletions

View file

@ -0,0 +1,45 @@
import { ajax } from "discourse/lib/ajax";
import { bufferedProperty } from "discourse/mixins/buffered-content";
import { propertyEqual } from "discourse/lib/computed";
export default Ember.Controller.extend(bufferedProperty("model"), {
saved: false,
isSaving: false,
saveDisabled: propertyEqual("model.robots_txt", "buffered.robots_txt"),
resetDisbaled: Ember.computed.not("model.overridden"),
actions: {
save() {
this.setProperties({
isSaving: true,
saved: false
});
ajax("robots.json", {
method: "PUT",
data: { robots_txt: this.buffered.get("robots_txt") }
})
.then(data => {
this.commitBuffer();
this.set("saved", true);
this.set("model.overridden", data.overridden);
})
.finally(() => this.set("isSaving", false));
},
reset() {
this.setProperties({
isSaving: true,
saved: false
});
ajax("robots.json", { method: "DELETE" })
.then(data => {
this.buffered.set("robots_txt", data.robots_txt);
this.commitBuffer();
this.set("saved", true);
this.set("model.overridden", false);
})
.finally(() => this.set("isSaving", false));
}
}
});