Compare commits
66
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
23b8e3f607 | ||
|
|
7685ebf396 | ||
|
|
4506b0b837 | ||
|
|
0400165798 | ||
|
|
119d331759 | ||
|
|
e28f97a0f4 | ||
|
|
1d3baa5519 | ||
|
|
21de3a2b10 | ||
|
|
c91c456187 | ||
|
|
e42b90507e | ||
|
|
38354f2a2f | ||
|
|
fc109c75c4 | ||
|
|
35cc34ab17 | ||
|
|
95993e7d93 | ||
|
|
10093e0a9f | ||
|
|
02f602236a | ||
|
|
da38a4c053 | ||
|
|
ec53a0d6b8 | ||
|
|
9b72130fdf | ||
|
|
a38fbd0935 | ||
|
|
ea9a0def55 | ||
|
|
81843e8c98 | ||
|
|
114639d2e7 | ||
|
|
5f1e07c556 | ||
|
|
f5c1b6da59 | ||
|
|
6cd52a4966 | ||
|
|
554f03f3da | ||
|
|
c4227de1b5 | ||
|
|
84d9b1a6da | ||
|
|
062efc8a54 | ||
|
|
32f18893ec | ||
|
|
b0c95114ea | ||
|
|
1677f7ae39 | ||
|
|
751916b8e3 | ||
|
|
9581367239 | ||
|
|
6b5412826f | ||
|
|
6f8ff34ffa | ||
|
|
19ac017dd4 | ||
|
|
429c9644de | ||
|
|
de7d8ce497 | ||
|
|
51af568c92 | ||
|
|
1d39cd8c80 | ||
|
|
36f4ebc64b | ||
|
|
789be84744 | ||
|
|
c88bb59d81 | ||
|
|
5ad841de0b | ||
|
|
0948d6b19e | ||
|
|
3828578d5d | ||
|
|
dbafb3b277 | ||
|
|
86ef7da2eb | ||
|
|
32a43a850f | ||
|
|
8931e2a07e | ||
|
|
44f49725f8 | ||
|
|
3a89fbdd9a | ||
|
|
8f51e0e4c0 | ||
|
|
30c49eb50d | ||
|
|
8cb9628f0d | ||
|
|
b4aa9a05be | ||
|
|
db0097b8f8 | ||
|
|
bade14daa0 | ||
|
|
743478d593 | ||
|
|
58205cc9ac | ||
|
|
d3005f26af | ||
|
|
c2057a5056 | ||
|
|
bfd4438b97 | ||
|
|
4d2ec950d0 |
@@ -0,0 +1,4 @@
|
||||
< 3.4.0.beta2-dev: 7685ebf396c93e8accc5a76a81fcec4384a73fa3
|
||||
< 3.4.0.beta1-dev: da38a4c053b68d7076db4441cfe86b473979945d
|
||||
< 3.3.0.beta1-dev: 062efc8a547c19474eaeefae464837d63a5e5fb3
|
||||
3.1.999: 30c49eb50d6d16fcf82bace3da0e1972b7b220c0
|
||||
@@ -1 +0,0 @@
|
||||
{}
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require("@discourse/lint-configs/prettier");
|
||||
@@ -1,2 +1,5 @@
|
||||
inherit_gem:
|
||||
rubocop-discourse: stree-compat.yml
|
||||
|
||||
RSpec/NamedSubject:
|
||||
Enabled: false
|
||||
@@ -1,2 +1,2 @@
|
||||
--print-width=100
|
||||
--plugins=plugin/trailing_comma
|
||||
--plugins=plugin/trailing_comma,plugin/disable_auto_ternary
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
module.exports = require("@discourse/lint-configs/template-lint");
|
||||
@@ -1,4 +0,0 @@
|
||||
module.exports = {
|
||||
plugins: ["ember-template-lint-plugin-discourse"],
|
||||
extends: "discourse:recommended",
|
||||
};
|
||||
+65
-21
@@ -1,36 +1,80 @@
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
activesupport (7.1.3.3)
|
||||
base64
|
||||
bigdecimal
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
connection_pool (>= 2.2.5)
|
||||
drb
|
||||
i18n (>= 1.6, < 2)
|
||||
minitest (>= 5.1)
|
||||
mutex_m
|
||||
tzinfo (~> 2.0)
|
||||
ast (2.4.2)
|
||||
json (2.6.2)
|
||||
parallel (1.22.1)
|
||||
parser (3.1.2.1)
|
||||
base64 (0.2.0)
|
||||
bigdecimal (3.1.8)
|
||||
concurrent-ruby (1.2.3)
|
||||
connection_pool (2.4.1)
|
||||
drb (2.2.1)
|
||||
i18n (1.14.5)
|
||||
concurrent-ruby (~> 1.0)
|
||||
json (2.7.2)
|
||||
language_server-protocol (3.17.0.3)
|
||||
minitest (5.23.1)
|
||||
mutex_m (0.2.0)
|
||||
parallel (1.24.0)
|
||||
parser (3.3.1.0)
|
||||
ast (~> 2.4.1)
|
||||
prettier_print (1.2.0)
|
||||
racc
|
||||
prettier_print (1.2.1)
|
||||
racc (1.8.0)
|
||||
rack (3.0.11)
|
||||
rainbow (3.1.1)
|
||||
regexp_parser (2.6.0)
|
||||
rexml (3.2.5)
|
||||
rubocop (1.36.0)
|
||||
regexp_parser (2.9.2)
|
||||
rexml (3.3.9)
|
||||
rubocop (1.64.0)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (>= 3.17.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.1.2.1)
|
||||
parser (>= 3.3.0.2)
|
||||
rainbow (>= 2.2.2, < 4.0)
|
||||
regexp_parser (>= 1.8, < 3.0)
|
||||
rexml (>= 3.2.5, < 4.0)
|
||||
rubocop-ast (>= 1.20.1, < 2.0)
|
||||
rubocop-ast (>= 1.31.1, < 2.0)
|
||||
ruby-progressbar (~> 1.7)
|
||||
unicode-display_width (>= 1.4.0, < 3.0)
|
||||
rubocop-ast (1.21.0)
|
||||
parser (>= 3.1.1.0)
|
||||
rubocop-discourse (3.0)
|
||||
rubocop (>= 1.1.0)
|
||||
rubocop-rspec (>= 2.0.0)
|
||||
rubocop-rspec (2.13.2)
|
||||
rubocop (~> 1.33)
|
||||
ruby-progressbar (1.11.0)
|
||||
syntax_tree (5.1.0)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.31.3)
|
||||
parser (>= 3.3.1.0)
|
||||
rubocop-capybara (2.20.0)
|
||||
rubocop (~> 1.41)
|
||||
rubocop-discourse (3.8.0)
|
||||
activesupport (>= 6.1)
|
||||
rubocop (>= 1.59.0)
|
||||
rubocop-capybara (>= 2.0.0)
|
||||
rubocop-factory_bot (>= 2.0.0)
|
||||
rubocop-rails (>= 2.25.0)
|
||||
rubocop-rspec (>= 2.25.0)
|
||||
rubocop-factory_bot (2.25.1)
|
||||
rubocop (~> 1.41)
|
||||
rubocop-rails (2.25.0)
|
||||
activesupport (>= 4.2.0)
|
||||
rack (>= 1.1)
|
||||
rubocop (>= 1.33.0, < 2.0)
|
||||
rubocop-ast (>= 1.31.1, < 2.0)
|
||||
rubocop-rspec (2.29.2)
|
||||
rubocop (~> 1.40)
|
||||
rubocop-capybara (~> 2.17)
|
||||
rubocop-factory_bot (~> 2.22)
|
||||
rubocop-rspec_rails (~> 2.28)
|
||||
rubocop-rspec_rails (2.28.3)
|
||||
rubocop (~> 1.40)
|
||||
ruby-progressbar (1.13.0)
|
||||
syntax_tree (6.2.0)
|
||||
prettier_print (>= 1.2.0)
|
||||
unicode-display_width (2.3.0)
|
||||
tzinfo (2.0.6)
|
||||
concurrent-ruby (~> 1.0)
|
||||
unicode-display_width (2.5.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
@@ -40,4 +84,4 @@ DEPENDENCIES
|
||||
syntax_tree
|
||||
|
||||
BUNDLED WITH
|
||||
2.1.4
|
||||
2.5.10
|
||||
|
||||
@@ -96,20 +96,20 @@ the ad slots. The ads will start showing as soon as you add them to slots.
|
||||
|
||||
##### Adsense Advertisement Tag to Discourse's Site Settings
|
||||
|
||||

|
||||

|
||||
|
||||
##### DoubleClick for Publishers' Advertisement Tag to Discourse's Site Settings
|
||||
|
||||

|
||||

|
||||
|
||||
##### Amazon Affiliates' Advertisement Tag to Discourse's Site Settings
|
||||
Only for Product Link and Banner Ads.
|
||||
|
||||

|
||||

|
||||
|
||||
##### Carbon Ads Script Tag to Discourse's Site Settings
|
||||
|
||||

|
||||

|
||||
|
||||
##### AdButler Ads Zone URL to Discourse's Site Settings
|
||||
|
||||
@@ -164,9 +164,7 @@ The following are available locations along with a description and an image show
|
||||
| Topic Above Suggested | Ad will appear in the footer above suggested topics of all Discourse forum topics |
|
||||
| Post Bottom & Nth Post | Ad will appear on the stipulated nth post within a topic. So if you have 5 posts in a topic and you want the ad to display after on the 2nd post, put 2 in ```ad_platform_nth_post_code```. |
|
||||
|
||||
|
||||

|
||||
|
||||

|
||||
|
||||
### Trust Levels
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
import CategorySelector from "select-kit/components/category-selector";
|
||||
|
||||
export default class HouseAdsCategorySelector extends CategorySelector {
|
||||
get value() {
|
||||
return this.selectedCategories.map((c) => c.id);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
import { action, computed } from "@ember/object";
|
||||
import { classNames } from "@ember-decorators/component";
|
||||
import { makeArray } from "discourse-common/lib/helpers";
|
||||
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||
|
||||
@classNames("house-ads-chooser")
|
||||
export default class HouseAdsChooser extends MultiSelectComponent {
|
||||
filterable = true;
|
||||
filterPlaceholder = "admin.adplugin.house_ads.filter_placeholder";
|
||||
tokenSeparator = "|";
|
||||
allowCreate = false;
|
||||
allowAny = false;
|
||||
settingValue = "";
|
||||
valueAttribute = null;
|
||||
nameProperty = null;
|
||||
|
||||
@computed("settingValue")
|
||||
get value() {
|
||||
return this.settingValue
|
||||
.toString()
|
||||
.split(this.tokenSeparator)
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
// TODO: kept for legacy, remove when Discourse is 2.5
|
||||
mutateValues(values) {
|
||||
this.set("settingValue", values.join(this.tokenSeparator));
|
||||
}
|
||||
|
||||
computeValues() {
|
||||
return this.settingValue.split(this.tokenSeparator).filter(Boolean);
|
||||
}
|
||||
|
||||
@computed("choices")
|
||||
get content() {
|
||||
return makeArray(this.choices);
|
||||
}
|
||||
|
||||
@action
|
||||
onChange(value) {
|
||||
const settingValue = makeArray(value).join(this.tokenSeparator);
|
||||
this.onChange?.(settingValue);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
<label for={{this.name}}>{{this.title}}</label>
|
||||
{{house-ads-chooser
|
||||
settingValue=this.adValue
|
||||
choices=this.adNames
|
||||
onChange=(action (mut this.adValue))
|
||||
}}
|
||||
<div class="setting-controls">
|
||||
{{#if this.changed}}
|
||||
<DButton class="ok" @action={{action "save"}} @icon="check" />
|
||||
<DButton class="cancel" @action={{action "cancel"}} @icon="times" />
|
||||
{{/if}}
|
||||
</div>
|
||||
<p class="help">{{this.help}}</p>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { mapBy } from "@ember/object/computed";
|
||||
import { classNames } from "@ember-decorators/component";
|
||||
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
|
||||
|
||||
@classNames("house-ads-setting house-ads-list-setting")
|
||||
export default class HouseAdsListSetting extends HouseAdsSetting {
|
||||
@mapBy("allAds", "name") adNames;
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<label for={{this.name}}>{{this.title}}</label>
|
||||
<TextField @value={{this.adValue}} @classNames="house-ads-text-input" />
|
||||
<div class="setting-controls">
|
||||
{{#if this.changed}}
|
||||
<DButton class="ok" @action={{action "save"}} @icon="check" />
|
||||
<DButton class="cancel" @action={{action "cancel"}} @icon="times" />
|
||||
{{/if}}
|
||||
</div>
|
||||
<p class="help">{{this.help}}</p>
|
||||
@@ -0,0 +1,58 @@
|
||||
import Component from "@ember/component";
|
||||
import { action } from "@ember/object";
|
||||
import { classNames } from "@ember-decorators/component";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { i18n, propertyNotEqual } from "discourse/lib/computed";
|
||||
import I18n from "I18n";
|
||||
|
||||
@classNames("house-ads-setting")
|
||||
export default class HouseAdsSetting extends Component {
|
||||
adValue = "";
|
||||
saving = false;
|
||||
savingStatus = "";
|
||||
|
||||
@i18n("name", "admin.adplugin.house_ads.%@.title") title;
|
||||
@i18n("name", "admin.adplugin.house_ads.%@.description") help;
|
||||
@propertyNotEqual("adValue", "value") changed;
|
||||
|
||||
init() {
|
||||
super.init(...arguments);
|
||||
this.set("adValue", this.get("value"));
|
||||
}
|
||||
|
||||
@action
|
||||
save() {
|
||||
if (!this.get("saving")) {
|
||||
this.setProperties({
|
||||
saving: true,
|
||||
savingStatus: I18n.t("saving"),
|
||||
});
|
||||
|
||||
ajax(`/admin/plugins/pluginad/house_settings/${this.get("name")}.json`, {
|
||||
type: "PUT",
|
||||
data: { value: this.get("adValue") },
|
||||
})
|
||||
.then(() => {
|
||||
const adSettings = this.get("adSettings");
|
||||
adSettings.set(this.get("name"), this.get("adValue"));
|
||||
this.setProperties({
|
||||
value: this.get("adValue"),
|
||||
savingStatus: I18n.t("saved"),
|
||||
});
|
||||
})
|
||||
.catch(popupAjaxError)
|
||||
.finally(() => {
|
||||
this.setProperties({
|
||||
saving: false,
|
||||
savingStatus: "",
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
cancel() {
|
||||
this.set("adValue", this.get("value"));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import DModal from "discourse/components/d-modal";
|
||||
import i18n from "discourse-common/helpers/i18n";
|
||||
|
||||
const Preview = <template>
|
||||
<DModal
|
||||
@closeModal={{@closeModal}}
|
||||
@title={{i18n "admin.adplugin.house_ads.preview"}}
|
||||
>
|
||||
<:body>
|
||||
<div class="house-ad-preview">
|
||||
{{htmlSafe @model.html}}
|
||||
</div>
|
||||
</:body>
|
||||
</DModal>
|
||||
</template>;
|
||||
|
||||
export default Preview;
|
||||
@@ -0,0 +1,8 @@
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import { alias } from "@ember/object/computed";
|
||||
|
||||
export default class AdminPluginsHouseAdsIndexController extends Controller {
|
||||
@controller("adminPlugins.houseAds") adminPluginsHouseAds;
|
||||
@alias("adminPluginsHouseAds.model") houseAds;
|
||||
@alias("adminPluginsHouseAds.houseAdsSettings") adSettings;
|
||||
}
|
||||
@@ -0,0 +1,156 @@
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import EmberObject, { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import { TrackedObject } from "@ember-compat/tracked-built-ins";
|
||||
import { observes } from "@ember-decorators/object";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import Category from "discourse/models/category";
|
||||
import I18n from "I18n";
|
||||
import Preview from "../components/modal/preview";
|
||||
|
||||
export default class adminPluginsHouseAdsShow extends Controller {
|
||||
@service router;
|
||||
@service modal;
|
||||
|
||||
@controller("adminPlugins.houseAds") houseAdsController;
|
||||
|
||||
@tracked selectedCategories = [];
|
||||
@tracked selectedGroups = [];
|
||||
@tracked saving = false;
|
||||
@tracked savingStatus = "";
|
||||
@tracked buffered;
|
||||
|
||||
@observes("model")
|
||||
modelChanged() {
|
||||
this.buffered = new TrackedObject({ ...this.model });
|
||||
this.selectedCategories = this.model.categories || [];
|
||||
this.selectedGroups = this.model.group_ids || [];
|
||||
}
|
||||
|
||||
get disabledSave() {
|
||||
for (const key in this.buffered) {
|
||||
// we don't want to compare the categories array
|
||||
if (key !== "categories" && this.buffered[key] !== this.model[key]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
@action
|
||||
async save() {
|
||||
if (!this.saving) {
|
||||
this.saving = true;
|
||||
this.savingStatus = I18n.t("saving");
|
||||
const data = {};
|
||||
const newRecord = !this.buffered.id;
|
||||
if (!newRecord) {
|
||||
data.id = this.buffered.id;
|
||||
}
|
||||
data.name = this.buffered.name;
|
||||
data.html = this.buffered.html;
|
||||
data.visible_to_logged_in_users =
|
||||
this.buffered.visible_to_logged_in_users;
|
||||
data.visible_to_anons = this.buffered.visible_to_anons;
|
||||
data.category_ids = this.buffered.category_ids;
|
||||
data.group_ids = this.buffered.group_ids;
|
||||
try {
|
||||
const ajaxData = await ajax(
|
||||
newRecord
|
||||
? `/admin/plugins/pluginad/house_creatives`
|
||||
: `/admin/plugins/pluginad/house_creatives/${this.buffered.id}`,
|
||||
{
|
||||
type: newRecord ? "POST" : "PUT",
|
||||
data,
|
||||
}
|
||||
);
|
||||
this.savingStatus = I18n.t("saved");
|
||||
const houseAds = this.houseAdsController.model;
|
||||
if (newRecord) {
|
||||
this.buffered.id = ajaxData.house_ad.id;
|
||||
if (!houseAds.includes(this.buffered)) {
|
||||
houseAds.pushObject(EmberObject.create(this.buffered));
|
||||
}
|
||||
this.router.transitionTo(
|
||||
"adminPlugins.houseAds.show",
|
||||
this.buffered.id
|
||||
);
|
||||
} else {
|
||||
houseAds
|
||||
.find((ad) => ad.id === this.buffered.id)
|
||||
.setProperties(this.buffered);
|
||||
}
|
||||
} catch (error) {
|
||||
popupAjaxError(error);
|
||||
} finally {
|
||||
this.set("model", this.buffered);
|
||||
this.saving = false;
|
||||
this.savingStatus = "";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
setCategoryIds(categoryArray) {
|
||||
this.selectedCategories = categoryArray;
|
||||
this.buffered.category_ids = categoryArray.map((c) => c.id);
|
||||
this.setCategoriesForBuffered();
|
||||
}
|
||||
|
||||
@action
|
||||
setGroupIds(groupIds) {
|
||||
this.selectedGroups = groupIds;
|
||||
this.buffered.group_ids = groupIds.map((id) => id);
|
||||
}
|
||||
|
||||
@action
|
||||
cancel() {
|
||||
this.buffered = new TrackedObject({ ...this.model });
|
||||
this.selectedCategories = this.model.categories || [];
|
||||
this.selectedGroups = this.model.group_ids || [];
|
||||
this.setCategoriesForBuffered();
|
||||
}
|
||||
|
||||
@action
|
||||
async destroy() {
|
||||
if (!this.buffered.id) {
|
||||
this.router.transitionTo("adminPlugins.houseAds.index");
|
||||
return;
|
||||
}
|
||||
try {
|
||||
await ajax(
|
||||
`/admin/plugins/pluginad/house_creatives/${this.buffered.id}`,
|
||||
{
|
||||
type: "DELETE",
|
||||
}
|
||||
);
|
||||
this.houseAdsController.model.removeObject(
|
||||
this.houseAdsController.model.findBy("id", this.buffered.id)
|
||||
);
|
||||
this.router.transitionTo("adminPlugins.houseAds.index");
|
||||
} catch (error) {
|
||||
popupAjaxError(error);
|
||||
}
|
||||
}
|
||||
|
||||
@action
|
||||
openPreview() {
|
||||
this.modal.show(Preview, {
|
||||
model: {
|
||||
html: this.buffered.html,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
setCategoriesForBuffered() {
|
||||
// we need to fetch the categories because the serializer is not being used
|
||||
// to attach the category object to the house ads
|
||||
this.buffered.categories = this.buffered.category_ids
|
||||
? this.buffered.category_ids.map((categoryId) =>
|
||||
Category.findById(categoryId)
|
||||
)
|
||||
: [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
import Controller from "@ember/controller";
|
||||
|
||||
export default class AdminPluginsHouseAdsController extends Controller {
|
||||
loadingAds = true;
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import { action } from "@ember/object";
|
||||
import { service } from "@ember/service";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default class AdminPluginsHouseAdsIndex extends DiscourseRoute {
|
||||
@service router;
|
||||
|
||||
@action
|
||||
moreSettings() {
|
||||
this.router.transitionTo("adminSiteSettingsCategory", "ad_plugin");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
import { TrackedObject } from "@ember-compat/tracked-built-ins";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default class AdminPluginsHouseAdsShow extends DiscourseRoute {
|
||||
model(params) {
|
||||
if (params.ad_id === "new") {
|
||||
return new TrackedObject({
|
||||
name: I18n.t("admin.adplugin.house_ads.new_name"),
|
||||
html: "",
|
||||
visible_to_logged_in_users: true,
|
||||
visible_to_anons: true,
|
||||
});
|
||||
} else {
|
||||
return new TrackedObject(
|
||||
this.modelFor("adminPlugins.houseAds").findBy(
|
||||
"id",
|
||||
parseInt(params.ad_id, 10)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
+6
-6
@@ -1,16 +1,16 @@
|
||||
import EmberObject from "@ember/object";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import EmberObject from "@ember/object";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
settings: null,
|
||||
export default class AdminPluginsHouseAds extends DiscourseRoute {
|
||||
settings = null;
|
||||
|
||||
model() {
|
||||
return ajax("/admin/plugins/pluginad/house_creatives.json").then((data) => {
|
||||
this.set("settings", EmberObject.create(data.settings));
|
||||
return data.house_ads.map((ad) => EmberObject.create(ad));
|
||||
});
|
||||
},
|
||||
}
|
||||
|
||||
setupController(controller, model) {
|
||||
controller.setProperties({
|
||||
@@ -18,5 +18,5 @@ export default DiscourseRoute.extend({
|
||||
houseAdsSettings: this.get("settings"),
|
||||
loadingAds: false,
|
||||
});
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
<section class="house-ads-settings content-body">
|
||||
<div>{{i18n "admin.adplugin.house_ads.description"}}</div>
|
||||
|
||||
{{#if this.houseAds.length}}
|
||||
<form class="form-horizontal">
|
||||
{{house-ads-list-setting
|
||||
name="topic_list_top"
|
||||
value=this.adSettings.topic_list_top
|
||||
allAds=this.houseAds
|
||||
adSettings=this.adSettings
|
||||
}}
|
||||
{{house-ads-list-setting
|
||||
name="topic_above_post_stream"
|
||||
value=this.adSettings.topic_above_post_stream
|
||||
allAds=this.houseAds
|
||||
adSettings=this.adSettings
|
||||
}}
|
||||
{{house-ads-list-setting
|
||||
name="topic_above_suggested"
|
||||
value=this.adSettings.topic_above_suggested
|
||||
allAds=this.houseAds
|
||||
adSettings=this.adSettings
|
||||
}}
|
||||
{{house-ads-list-setting
|
||||
name="post_bottom"
|
||||
value=this.adSettings.post_bottom
|
||||
allAds=this.houseAds
|
||||
adSettings=this.adSettings
|
||||
}}
|
||||
{{house-ads-list-setting
|
||||
name="topic_list_between"
|
||||
value=this.adSettings.topic_list_between
|
||||
allAds=this.houseAds
|
||||
adSettings=this.adSettings
|
||||
}}
|
||||
|
||||
<DButton
|
||||
@label="admin.adplugin.house_ads.more_settings"
|
||||
@icon="cog"
|
||||
@action={{route-action "moreSettings"}}
|
||||
class="btn-default"
|
||||
/>
|
||||
</form>
|
||||
{{else}}
|
||||
<p>
|
||||
{{#link-to route="adminPlugins.houseAds.show" model="new"}}
|
||||
{{i18n "admin.adplugin.house_ads.get_started"}}
|
||||
{{/link-to}}
|
||||
</p>
|
||||
{{/if}}
|
||||
</section>
|
||||
@@ -0,0 +1,78 @@
|
||||
<section class="edit-house-ad content-body">
|
||||
<h1><TextField @value={{this.buffered.name}} class="house-ad-name" /></h1>
|
||||
<div class="controls">
|
||||
<AceEditor
|
||||
@content={{this.buffered.html}}
|
||||
@onChange={{fn (mut this.buffered.html)}}
|
||||
@mode="html"
|
||||
/>
|
||||
</div>
|
||||
<div class="controls">
|
||||
<div class="visibility-settings">
|
||||
<div>
|
||||
<Input
|
||||
@type="checkbox"
|
||||
@checked={{this.buffered.visible_to_logged_in_users}}
|
||||
class="visible-to-logged-in-checkbox"
|
||||
/>
|
||||
<span>{{i18n "admin.adplugin.house_ads.show_to_logged_in_users"}}</span>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<Input
|
||||
class="visible-to-anonymous-checkbox"
|
||||
@type="checkbox"
|
||||
@checked={{this.buffered.visible_to_anons}}
|
||||
/>
|
||||
<span>{{i18n "admin.adplugin.house_ads.show_to_anons"}}</span>
|
||||
</div>
|
||||
|
||||
<HouseAdsCategorySelector
|
||||
@categories={{this.site.categories}}
|
||||
@selectedCategories={{this.selectedCategories}}
|
||||
@onChange={{this.setCategoryIds}}
|
||||
@options={{hash allowAny=true}}
|
||||
class="house-ads-categories"
|
||||
/>
|
||||
<div class="description">
|
||||
{{i18n "admin.adplugin.house_ads.category_chooser_description"}}
|
||||
</div>
|
||||
|
||||
<GroupChooser
|
||||
@content={{this.site.groups}}
|
||||
@onChange={{this.setGroupIds}}
|
||||
@value={{this.selectedGroups}}
|
||||
class="banner-groups"
|
||||
/>
|
||||
<div class="description">
|
||||
{{i18n "admin.adplugin.house_ads.group_chooser_description"}}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<DButton
|
||||
@action={{this.save}}
|
||||
@disabled={{this.disabledSave}}
|
||||
@label="admin.adplugin.house_ads.save"
|
||||
class="btn-primary save-button"
|
||||
/>
|
||||
|
||||
{{#if this.saving}}
|
||||
{{this.savingStatus}}
|
||||
{{else}}
|
||||
{{#unless this.disabledSave}}
|
||||
<DButton @action={{this.cancel}} @label="cancel" />
|
||||
{{/unless}}
|
||||
{{/if}}
|
||||
|
||||
<DButton
|
||||
@action={{this.openPreview}}
|
||||
@label="admin.adplugin.house_ads.preview"
|
||||
/>
|
||||
|
||||
<DButton
|
||||
@action={{this.destroy}}
|
||||
@label="admin.adplugin.house_ads.delete"
|
||||
class="btn-danger delete-button"
|
||||
/>
|
||||
</div>
|
||||
</section>
|
||||
+12
-8
@@ -1,21 +1,25 @@
|
||||
<div class="adplugin-mgmt">
|
||||
<h1>{{i18n "admin.adplugin.house_ads.title"}}</h1>
|
||||
{{#if model.length}}
|
||||
{{#if this.model.length}}
|
||||
<div class="content-list">
|
||||
<div class="house-ads-actions">
|
||||
{{#link-to "adminPlugins.houseAds.show" "new" class="btn btn-primary"}}
|
||||
<LinkTo
|
||||
@route="adminPlugins.houseAds.show"
|
||||
@model="new"
|
||||
class="btn btn-primary"
|
||||
>
|
||||
{{d-icon "plus"}}
|
||||
<span>{{i18n "admin.adplugin.house_ads.new"}}</span>
|
||||
{{/link-to}}
|
||||
{{#link-to "adminPlugins.houseAds.index" class="btn btn-default"}}
|
||||
{{d-icon "cog"}}
|
||||
</LinkTo>
|
||||
<LinkTo @route="adminPlugins.houseAds.index" class="btn btn-default">
|
||||
{{d-icon "gear"}}
|
||||
<span>{{i18n "admin.adplugin.house_ads.settings"}}</span>
|
||||
{{/link-to}}
|
||||
</LinkTo>
|
||||
</div>
|
||||
<ul class="house-ads-list">
|
||||
{{#each model as |ad|}}
|
||||
{{#each this.model as |ad|}}
|
||||
<li class="house-ads-list-item">
|
||||
{{#link-to "adminPlugins.houseAds.show" ad.id}}
|
||||
{{#link-to route="adminPlugins.houseAds.show" model=ad.id}}
|
||||
{{ad.name}}
|
||||
{{/link-to}}
|
||||
</li>
|
||||
@@ -0,0 +1,13 @@
|
||||
# frozen_string_literal: true
|
||||
#
|
||||
class AdstxtController < ::ApplicationController
|
||||
requires_plugin AdPlugin.plugin_name
|
||||
|
||||
skip_before_action :preload_json, :check_xhr, :redirect_to_login_if_required
|
||||
|
||||
def index
|
||||
raise Discourse::NotFound if SiteSetting.ads_txt.blank?
|
||||
|
||||
render plain: SiteSetting.ads_txt
|
||||
end
|
||||
end
|
||||
@@ -5,11 +5,23 @@ module ::AdPlugin
|
||||
requires_plugin AdPlugin.plugin_name
|
||||
|
||||
def index
|
||||
render_json_dump(house_ads: HouseAd.all.map(&:to_hash), settings: HouseAdSetting.all)
|
||||
render_json_dump(
|
||||
house_ads:
|
||||
HouseAd.all.map do |ad|
|
||||
ad.to_hash.merge!(categories: Category.secured(@guardian).where(id: ad.category_ids))
|
||||
end,
|
||||
settings: HouseAdSetting.all,
|
||||
)
|
||||
end
|
||||
|
||||
def show
|
||||
render_json_dump(house_ad: HouseAd.find(params[:id])&.to_hash)
|
||||
house_ad_hash = HouseAd.find(params[:id])&.to_hash
|
||||
if house_ad_hash
|
||||
house_ad_hash.merge!(
|
||||
categories: Category.secured(@guardian).where(id: house_ad_hash[:category_ids]),
|
||||
)
|
||||
end
|
||||
render_json_dump(house_ad: house_ad_hash)
|
||||
end
|
||||
|
||||
def create
|
||||
@@ -38,7 +50,26 @@ module ::AdPlugin
|
||||
private
|
||||
|
||||
def house_ad_params
|
||||
params.permit(:id, :name, :html)
|
||||
@permitted ||=
|
||||
begin
|
||||
permitted =
|
||||
params.permit(
|
||||
:id,
|
||||
:name,
|
||||
:html,
|
||||
:visible_to_anons,
|
||||
:visible_to_logged_in_users,
|
||||
group_ids: [],
|
||||
category_ids: [],
|
||||
)
|
||||
permitted[:visible_to_logged_in_users] = ActiveModel::Type::Boolean.new.cast(
|
||||
permitted[:visible_to_logged_in_users],
|
||||
)
|
||||
permitted[:visible_to_anons] = ActiveModel::Type::Boolean.new.cast(
|
||||
permitted[:visible_to_anons],
|
||||
)
|
||||
permitted
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user