Compare commits
19
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ca4398bad | ||
|
|
dbafb3b277 | ||
|
|
86ef7da2eb | ||
|
|
32a43a850f | ||
|
|
8931e2a07e | ||
|
|
44f49725f8 | ||
|
|
3a89fbdd9a | ||
|
|
8f51e0e4c0 | ||
|
|
30c49eb50d | ||
|
|
8cb9628f0d | ||
|
|
b4aa9a05be | ||
|
|
db0097b8f8 | ||
|
|
bade14daa0 | ||
|
|
743478d593 | ||
|
|
58205cc9ac | ||
|
|
d3005f26af | ||
|
|
c2057a5056 | ||
|
|
bfd4438b97 | ||
|
|
4d2ec950d0 |
@@ -0,0 +1,2 @@
|
|||||||
|
3.1.999: 30c49eb50d6d16fcf82bace3da0e1972b7b220c0
|
||||||
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@discourse/lint-configs/eslint");
|
||||||
@@ -1 +0,0 @@
|
|||||||
{}
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@discourse/lint-configs/prettier");
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
inherit_gem:
|
inherit_gem:
|
||||||
rubocop-discourse: stree-compat.yml
|
rubocop-discourse: stree-compat.yml
|
||||||
|
|
||||||
|
RSpec/NamedSubject:
|
||||||
|
Enabled: false
|
||||||
@@ -1,2 +1,2 @@
|
|||||||
--print-width=100
|
--print-width=100
|
||||||
--plugins=plugin/trailing_comma
|
--plugins=plugin/trailing_comma,plugin/disable_auto_ternary
|
||||||
|
|||||||
+1
-4
@@ -1,4 +1 @@
|
|||||||
module.exports = {
|
module.exports = require("@discourse/lint-configs/template-lint");
|
||||||
plugins: ["ember-template-lint-plugin-discourse"],
|
|
||||||
extends: "discourse:recommended",
|
|
||||||
};
|
|
||||||
|
|||||||
+30
-19
@@ -2,42 +2,53 @@ GEM
|
|||||||
remote: https://rubygems.org/
|
remote: https://rubygems.org/
|
||||||
specs:
|
specs:
|
||||||
ast (2.4.2)
|
ast (2.4.2)
|
||||||
json (2.6.2)
|
json (2.6.3)
|
||||||
parallel (1.22.1)
|
language_server-protocol (3.17.0.3)
|
||||||
parser (3.1.2.1)
|
parallel (1.23.0)
|
||||||
|
parser (3.2.2.4)
|
||||||
ast (~> 2.4.1)
|
ast (~> 2.4.1)
|
||||||
prettier_print (1.2.0)
|
racc
|
||||||
|
prettier_print (1.2.1)
|
||||||
|
racc (1.7.3)
|
||||||
rainbow (3.1.1)
|
rainbow (3.1.1)
|
||||||
regexp_parser (2.6.0)
|
regexp_parser (2.8.2)
|
||||||
rexml (3.2.5)
|
rexml (3.2.6)
|
||||||
rubocop (1.36.0)
|
rubocop (1.57.2)
|
||||||
json (~> 2.3)
|
json (~> 2.3)
|
||||||
|
language_server-protocol (>= 3.17.0)
|
||||||
parallel (~> 1.10)
|
parallel (~> 1.10)
|
||||||
parser (>= 3.1.2.1)
|
parser (>= 3.2.2.4)
|
||||||
rainbow (>= 2.2.2, < 4.0)
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
regexp_parser (>= 1.8, < 3.0)
|
regexp_parser (>= 1.8, < 3.0)
|
||||||
rexml (>= 3.2.5, < 4.0)
|
rexml (>= 3.2.5, < 4.0)
|
||||||
rubocop-ast (>= 1.20.1, < 2.0)
|
rubocop-ast (>= 1.28.1, < 2.0)
|
||||||
ruby-progressbar (~> 1.7)
|
ruby-progressbar (~> 1.7)
|
||||||
unicode-display_width (>= 1.4.0, < 3.0)
|
unicode-display_width (>= 2.4.0, < 3.0)
|
||||||
rubocop-ast (1.21.0)
|
rubocop-ast (1.30.0)
|
||||||
parser (>= 3.1.1.0)
|
parser (>= 3.2.1.0)
|
||||||
rubocop-discourse (3.0)
|
rubocop-capybara (2.19.0)
|
||||||
|
rubocop (~> 1.41)
|
||||||
|
rubocop-discourse (3.4.0)
|
||||||
rubocop (>= 1.1.0)
|
rubocop (>= 1.1.0)
|
||||||
rubocop-rspec (>= 2.0.0)
|
rubocop-rspec (>= 2.0.0)
|
||||||
rubocop-rspec (2.13.2)
|
rubocop-factory_bot (2.24.0)
|
||||||
rubocop (~> 1.33)
|
rubocop (~> 1.33)
|
||||||
ruby-progressbar (1.11.0)
|
rubocop-rspec (2.25.0)
|
||||||
syntax_tree (5.1.0)
|
rubocop (~> 1.40)
|
||||||
|
rubocop-capybara (~> 2.17)
|
||||||
|
rubocop-factory_bot (~> 2.22)
|
||||||
|
ruby-progressbar (1.13.0)
|
||||||
|
syntax_tree (6.2.0)
|
||||||
prettier_print (>= 1.2.0)
|
prettier_print (>= 1.2.0)
|
||||||
unicode-display_width (2.3.0)
|
unicode-display_width (2.5.0)
|
||||||
|
|
||||||
PLATFORMS
|
PLATFORMS
|
||||||
ruby
|
arm64-darwin-21
|
||||||
|
x86_64-linux
|
||||||
|
|
||||||
DEPENDENCIES
|
DEPENDENCIES
|
||||||
rubocop-discourse
|
rubocop-discourse
|
||||||
syntax_tree
|
syntax_tree
|
||||||
|
|
||||||
BUNDLED WITH
|
BUNDLED WITH
|
||||||
2.1.4
|
2.4.21
|
||||||
|
|||||||
@@ -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
|
##### Adsense Advertisement Tag to Discourse's Site Settings
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
##### DoubleClick for Publishers' 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
|
##### Amazon Affiliates' Advertisement Tag to Discourse's Site Settings
|
||||||
Only for Product Link and Banner Ads.
|
Only for Product Link and Banner Ads.
|
||||||
|
|
||||||

|

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

|

|
||||||
|
|
||||||
##### AdButler Ads Zone URL 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 |
|
| 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```. |
|
| 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
|
### Trust Levels
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import MultiSelectComponent from "select-kit/components/multi-select";
|
|
||||||
import Ember from "ember";
|
import Ember from "ember";
|
||||||
|
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||||
const { makeArray } = Ember;
|
const { makeArray } = Ember;
|
||||||
import { computed } from "@ember/object";
|
import { computed } from "@ember/object";
|
||||||
|
|
||||||
+2
-2
@@ -6,8 +6,8 @@
|
|||||||
}}
|
}}
|
||||||
<div class="setting-controls">
|
<div class="setting-controls">
|
||||||
{{#if changed}}
|
{{#if changed}}
|
||||||
{{d-button class="ok" action=(action "save") icon="check"}}
|
<DButton class="ok" @action={{action "save"}} @icon="check" />
|
||||||
{{d-button class="cancel" action=(action "cancel") icon="times"}}
|
<DButton class="cancel" @action={{action "cancel"}} @icon="times" />
|
||||||
{{/if}}
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
<p class="help">{{help}}</p>
|
<p class="help">{{help}}</p>
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
|
|
||||||
import { mapBy } from "@ember/object/computed";
|
import { mapBy } from "@ember/object/computed";
|
||||||
|
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
|
||||||
|
|
||||||
export default HouseAdsSetting.extend({
|
export default HouseAdsSetting.extend({
|
||||||
classNames: "house-ads-setting house-ads-list-setting",
|
classNames: "house-ads-setting house-ads-list-setting",
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
<label for={{name}}>{{title}}</label>
|
||||||
|
<TextField @value={{adValue}} @classNames="house-ads-text-input" />
|
||||||
|
<div class="setting-controls">
|
||||||
|
{{#if changed}}
|
||||||
|
<DButton class="ok" @action={{action "save"}} @icon="check" />
|
||||||
|
<DButton class="cancel" @action={{action "cancel"}} @icon="times" />
|
||||||
|
{{/if}}
|
||||||
|
</div>
|
||||||
|
<p class="help">{{help}}</p>
|
||||||
+21
-4
@@ -1,10 +1,10 @@
|
|||||||
import I18n from "I18n";
|
import Controller, { inject as controller } from "@ember/controller";
|
||||||
|
import { not, or } from "@ember/object/computed";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import { popupAjaxError } from "discourse/lib/ajax-error";
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
||||||
import { propertyNotEqual } from "discourse/lib/computed";
|
import { propertyNotEqual } from "discourse/lib/computed";
|
||||||
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
||||||
import Controller, { inject as controller } from "@ember/controller";
|
import I18n from "I18n";
|
||||||
import { not, or } from "@ember/object/computed";
|
|
||||||
|
|
||||||
export default Controller.extend(bufferedProperty("model"), {
|
export default Controller.extend(bufferedProperty("model"), {
|
||||||
adminPluginsHouseAds: controller("adminPlugins.houseAds"),
|
adminPluginsHouseAds: controller("adminPlugins.houseAds"),
|
||||||
@@ -14,7 +14,20 @@ export default Controller.extend(bufferedProperty("model"), {
|
|||||||
|
|
||||||
nameDirty: propertyNotEqual("buffered.name", "model.name"),
|
nameDirty: propertyNotEqual("buffered.name", "model.name"),
|
||||||
htmlDirty: propertyNotEqual("buffered.html", "model.html"),
|
htmlDirty: propertyNotEqual("buffered.html", "model.html"),
|
||||||
dirty: or("nameDirty", "htmlDirty"),
|
visibleToAnonsDirty: propertyNotEqual(
|
||||||
|
"buffered.visible_to_anons",
|
||||||
|
"model.visible_to_anons"
|
||||||
|
),
|
||||||
|
visibleToLoggedInDirty: propertyNotEqual(
|
||||||
|
"buffered.visible_to_logged_in_users",
|
||||||
|
"model.visible_to_logged_in_users"
|
||||||
|
),
|
||||||
|
dirty: or(
|
||||||
|
"nameDirty",
|
||||||
|
"htmlDirty",
|
||||||
|
"visibleToLoggedInDirty",
|
||||||
|
"visibleToAnonsDirty"
|
||||||
|
),
|
||||||
disableSave: not("dirty"),
|
disableSave: not("dirty"),
|
||||||
|
|
||||||
actions: {
|
actions: {
|
||||||
@@ -34,6 +47,10 @@ export default Controller.extend(bufferedProperty("model"), {
|
|||||||
}
|
}
|
||||||
data.name = buffered.get("name");
|
data.name = buffered.get("name");
|
||||||
data.html = buffered.get("html");
|
data.html = buffered.get("html");
|
||||||
|
data.visible_to_logged_in_users = buffered.get(
|
||||||
|
"visible_to_logged_in_users"
|
||||||
|
);
|
||||||
|
data.visible_to_anons = buffered.get("visible_to_anons");
|
||||||
|
|
||||||
ajax(
|
ajax(
|
||||||
newRecord
|
newRecord
|
||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
import DiscourseRoute from "discourse/routes/discourse";
|
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default DiscourseRoute.extend({
|
||||||
@action
|
@action
|
||||||
+3
-1
@@ -1,5 +1,5 @@
|
|||||||
import DiscourseRoute from "discourse/routes/discourse";
|
|
||||||
import EmberObject from "@ember/object";
|
import EmberObject from "@ember/object";
|
||||||
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default DiscourseRoute.extend({
|
||||||
@@ -8,6 +8,8 @@ export default DiscourseRoute.extend({
|
|||||||
return EmberObject.create({
|
return EmberObject.create({
|
||||||
name: I18n.t("admin.adplugin.house_ads.new_name"),
|
name: I18n.t("admin.adplugin.house_ads.new_name"),
|
||||||
html: "",
|
html: "",
|
||||||
|
visible_to_logged_in_users: true,
|
||||||
|
visible_to_anons: true,
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
return this.modelFor("adminPlugins.houseAds").findBy(
|
return this.modelFor("adminPlugins.houseAds").findBy(
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
|
import EmberObject from "@ember/object";
|
||||||
import { ajax } from "discourse/lib/ajax";
|
import { ajax } from "discourse/lib/ajax";
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
import EmberObject from "@ember/object";
|
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default DiscourseRoute.extend({
|
||||||
settings: null,
|
settings: null,
|
||||||
+7
-7
@@ -1,4 +1,4 @@
|
|||||||
{{#d-section class="house-ads-settings content-body"}}
|
<DSection @class="house-ads-settings content-body">
|
||||||
<div>{{i18n "admin.adplugin.house_ads.description"}}</div>
|
<div>{{i18n "admin.adplugin.house_ads.description"}}</div>
|
||||||
|
|
||||||
{{#if houseAds.length}}
|
{{#if houseAds.length}}
|
||||||
@@ -34,12 +34,12 @@
|
|||||||
adSettings=adSettings
|
adSettings=adSettings
|
||||||
}}
|
}}
|
||||||
|
|
||||||
{{d-button
|
<DButton
|
||||||
label="admin.adplugin.house_ads.more_settings"
|
@label="admin.adplugin.house_ads.more_settings"
|
||||||
icon="cog"
|
@icon="cog"
|
||||||
class="btn-default"
|
class="btn-default"
|
||||||
action=(route-action "moreSettings")
|
@action={{route-action "moreSettings"}}
|
||||||
}}
|
/>
|
||||||
</form>
|
</form>
|
||||||
{{else}}
|
{{else}}
|
||||||
<p>
|
<p>
|
||||||
@@ -48,4 +48,4 @@
|
|||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</p>
|
</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{/d-section}}
|
</DSection>
|
||||||
@@ -0,0 +1,48 @@
|
|||||||
|
<DSection @class="edit-house-ad content-body">
|
||||||
|
<h1><TextField @class="house-ad-name" @value={{buffered.name}} /></h1>
|
||||||
|
<div class="controls">
|
||||||
|
<AceEditor @content={{buffered.html}} @mode="html" />
|
||||||
|
</div>
|
||||||
|
<div class="controls">
|
||||||
|
<div class="visibility-settings">
|
||||||
|
<div>
|
||||||
|
<Input
|
||||||
|
class="visible-to-logged-in-checkbox"
|
||||||
|
@type="checkbox"
|
||||||
|
@checked={{this.buffered.visible_to_logged_in_users}}
|
||||||
|
/>
|
||||||
|
<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>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<DButton
|
||||||
|
@action={{action "save"}}
|
||||||
|
@disabled={{disableSave}}
|
||||||
|
class="btn-primary save-button"
|
||||||
|
@label="admin.adplugin.house_ads.save"
|
||||||
|
/>
|
||||||
|
|
||||||
|
{{#if saving}}
|
||||||
|
{{savingStatus}}
|
||||||
|
{{else}}
|
||||||
|
{{#if dirty}}
|
||||||
|
<a href {{action "cancel"}}>{{i18n "cancel"}}</a>
|
||||||
|
{{/if}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
|
<DButton
|
||||||
|
@action={{action "destroy"}}
|
||||||
|
class="btn-danger delete-button"
|
||||||
|
@label="admin.adplugin.house_ads.delete"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
</DSection>
|
||||||
@@ -38,7 +38,18 @@ module ::AdPlugin
|
|||||||
private
|
private
|
||||||
|
|
||||||
def house_ad_params
|
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)
|
||||||
|
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
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
+28
-2
@@ -4,7 +4,7 @@ module ::AdPlugin
|
|||||||
class HouseAd
|
class HouseAd
|
||||||
include ActiveModel::Validations
|
include ActiveModel::Validations
|
||||||
|
|
||||||
attr_accessor :id, :name, :html
|
attr_accessor :id, :name, :html, :visible_to_logged_in_users, :visible_to_anons
|
||||||
|
|
||||||
NAME_REGEX = /\A[[:alnum:]\s\.,'!@#$%&\*\-\+\=:]*\z/i
|
NAME_REGEX = /\A[[:alnum:]\s\.,'!@#$%&\*\-\+\=:]*\z/i
|
||||||
|
|
||||||
@@ -20,6 +20,8 @@ module ::AdPlugin
|
|||||||
def initialize
|
def initialize
|
||||||
@name = "New Ad"
|
@name = "New Ad"
|
||||||
@html = "<div class='house-ad'>New Ad</div>"
|
@html = "<div class='house-ad'>New Ad</div>"
|
||||||
|
@visible_to_logged_in_users = true
|
||||||
|
@visible_to_anons = true
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.from_hash(h)
|
def self.from_hash(h)
|
||||||
@@ -27,6 +29,10 @@ module ::AdPlugin
|
|||||||
ad.name = h[:name]
|
ad.name = h[:name]
|
||||||
ad.html = h[:html]
|
ad.html = h[:html]
|
||||||
ad.id = h[:id].to_i if h[:id]
|
ad.id = h[:id].to_i if h[:id]
|
||||||
|
if h.key?(:visible_to_logged_in_users)
|
||||||
|
ad.visible_to_logged_in_users = h[:visible_to_logged_in_users]
|
||||||
|
end
|
||||||
|
ad.visible_to_anons = h[:visible_to_anons] if h.key?(:visible_to_anons)
|
||||||
ad
|
ad
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -62,10 +68,19 @@ module ::AdPlugin
|
|||||||
.sort_by { |ad| ad.id }
|
.sort_by { |ad| ad.id }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.all_for_anons
|
||||||
|
self.all.select(&:visible_to_anons)
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.all_for_logged_in_users
|
||||||
|
self.all.select(&:visible_to_logged_in_users)
|
||||||
|
end
|
||||||
|
|
||||||
def save
|
def save
|
||||||
if self.valid?
|
if self.valid?
|
||||||
self.id = self.class.alloc_id if self.id.to_i <= 0
|
self.id = self.class.alloc_id if self.id.to_i <= 0
|
||||||
AdPlugin.pstore_set("ad:#{id}", to_hash)
|
AdPlugin.pstore_set("ad:#{id}", to_hash)
|
||||||
|
Site.clear_anon_cache!
|
||||||
self.class.publish_if_ads_enabled
|
self.class.publish_if_ads_enabled
|
||||||
true
|
true
|
||||||
else
|
else
|
||||||
@@ -76,15 +91,26 @@ module ::AdPlugin
|
|||||||
def update(attrs)
|
def update(attrs)
|
||||||
self.name = attrs[:name]
|
self.name = attrs[:name]
|
||||||
self.html = attrs[:html]
|
self.html = attrs[:html]
|
||||||
|
if attrs.key?(:visible_to_logged_in_users)
|
||||||
|
self.visible_to_logged_in_users = attrs[:visible_to_logged_in_users]
|
||||||
|
end
|
||||||
|
self.visible_to_anons = attrs[:visible_to_anons] if attrs.key?(:visible_to_anons)
|
||||||
self.save
|
self.save
|
||||||
end
|
end
|
||||||
|
|
||||||
def to_hash
|
def to_hash
|
||||||
{ id: @id, name: @name, html: @html }
|
{
|
||||||
|
id: @id,
|
||||||
|
name: @name,
|
||||||
|
html: @html,
|
||||||
|
visible_to_logged_in_users: @visible_to_logged_in_users,
|
||||||
|
visible_to_anons: @visible_to_anons,
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
AdPlugin.pstore_delete("ad:#{id}")
|
AdPlugin.pstore_delete("ad:#{id}")
|
||||||
|
Site.clear_anon_cache!
|
||||||
self.class.publish_if_ads_enabled
|
self.class.publish_if_ads_enabled
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -21,10 +21,17 @@ module ::AdPlugin
|
|||||||
settings
|
settings
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.settings_and_ads
|
def self.settings_and_ads(for_anons: true)
|
||||||
settings = AdPlugin::HouseAdSetting.all
|
settings = AdPlugin::HouseAdSetting.all
|
||||||
ad_names = settings.values.map { |v| v.split("|") }.flatten.uniq
|
ad_names = settings.values.map { |v| v.split("|") }.flatten.uniq
|
||||||
ads = AdPlugin::HouseAd.all.select { |ad| ad_names.include?(ad.name) }
|
|
||||||
|
if for_anons
|
||||||
|
ads = AdPlugin::HouseAd.all_for_anons
|
||||||
|
else
|
||||||
|
ads = AdPlugin::HouseAd.all_for_logged_in_users
|
||||||
|
end
|
||||||
|
ads = ads.select { |ad| ad_names.include?(ad.name) }
|
||||||
|
|
||||||
{
|
{
|
||||||
settings:
|
settings:
|
||||||
settings.merge(
|
settings.merge(
|
||||||
@@ -56,12 +63,18 @@ module ::AdPlugin
|
|||||||
else
|
else
|
||||||
AdPlugin.pstore_set("ad-setting:#{setting_name}", new_value)
|
AdPlugin.pstore_set("ad-setting:#{setting_name}", new_value)
|
||||||
end
|
end
|
||||||
|
Site.clear_anon_cache!
|
||||||
|
|
||||||
publish_settings
|
publish_settings
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.publish_settings
|
def self.publish_settings
|
||||||
MessageBus.publish("/site/house-creatives", settings_and_ads)
|
MessageBus.publish("/site/house-creatives/anonymous", settings_and_ads(for_anons: true))
|
||||||
|
MessageBus.publish(
|
||||||
|
"/site/house-creatives/logged-in",
|
||||||
|
settings_and_ads(for_anons: false),
|
||||||
|
group_ids: [Group::AUTO_GROUPS[:trust_level_0]],
|
||||||
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { inject as service } from "@ember/service";
|
|
||||||
import { alias, or } from "@ember/object/computed";
|
import { alias, or } from "@ember/object/computed";
|
||||||
|
import { inject as service } from "@ember/service";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import {
|
import {
|
||||||
isNthPost,
|
isNthPost,
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user