89 changed files with 1090 additions and 1790 deletions
-2
View File
@@ -1,2 +0,0 @@
3.1.999: 30c49eb50d6d16fcf82bace3da0e1972b7b220c0
+3
View File
@@ -0,0 +1,3 @@
{
"extends": "eslint-config-discourse"
}
-1
View File
@@ -1 +0,0 @@
module.exports = require("@discourse/lint-configs/eslint");
+1
View File
@@ -0,0 +1 @@
{}
-1
View File
@@ -1 +0,0 @@
module.exports = require("@discourse/lint-configs/prettier");
-3
View File
@@ -1,5 +1,2 @@
inherit_gem: inherit_gem:
rubocop-discourse: stree-compat.yml rubocop-discourse: stree-compat.yml
RSpec/NamedSubject:
Enabled: false
+1 -1
View File
@@ -1,2 +1,2 @@
--print-width=100 --print-width=100
--plugins=plugin/trailing_comma,plugin/disable_auto_ternary --plugins=plugin/trailing_comma
+4 -1
View File
@@ -1 +1,4 @@
module.exports = require("@discourse/lint-configs/template-lint"); module.exports = {
plugins: ["ember-template-lint-plugin-discourse"],
extends: "discourse:recommended",
};
+19 -30
View File
@@ -2,53 +2,42 @@ GEM
remote: https://rubygems.org/ remote: https://rubygems.org/
specs: specs:
ast (2.4.2) ast (2.4.2)
json (2.6.3) json (2.6.2)
language_server-protocol (3.17.0.3) parallel (1.22.1)
parallel (1.23.0) parser (3.1.2.1)
parser (3.2.2.4)
ast (~> 2.4.1) ast (~> 2.4.1)
racc prettier_print (1.2.0)
prettier_print (1.2.1)
racc (1.7.3)
rainbow (3.1.1) rainbow (3.1.1)
regexp_parser (2.8.2) regexp_parser (2.6.0)
rexml (3.2.6) rexml (3.2.5)
rubocop (1.57.2) rubocop (1.36.0)
json (~> 2.3) json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10) parallel (~> 1.10)
parser (>= 3.2.2.4) parser (>= 3.1.2.1)
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.28.1, < 2.0) rubocop-ast (>= 1.20.1, < 2.0)
ruby-progressbar (~> 1.7) ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0) unicode-display_width (>= 1.4.0, < 3.0)
rubocop-ast (1.30.0) rubocop-ast (1.21.0)
parser (>= 3.2.1.0) parser (>= 3.1.1.0)
rubocop-capybara (2.19.0) rubocop-discourse (3.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-factory_bot (2.24.0) rubocop-rspec (2.13.2)
rubocop (~> 1.33) rubocop (~> 1.33)
rubocop-rspec (2.25.0) ruby-progressbar (1.11.0)
rubocop (~> 1.40) syntax_tree (5.1.0)
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.5.0) unicode-display_width (2.3.0)
PLATFORMS PLATFORMS
arm64-darwin-21 ruby
x86_64-linux
DEPENDENCIES DEPENDENCIES
rubocop-discourse rubocop-discourse
syntax_tree syntax_tree
BUNDLED WITH BUNDLED WITH
2.4.21 2.1.4
+2
View File
@@ -109,8 +109,10 @@ 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
![adpluginexample](https://user-images.githubusercontent.com/5862206/214489455-234a3812-3606-47bf-9e49-cdaa3d1e3b9c.png) ![adpluginexample](https://user-images.githubusercontent.com/5862206/214489455-234a3812-3606-47bf-9e49-cdaa3d1e3b9c.png)
##### AdButler Ads Zone URL to Discourse's Site Settings ##### AdButler Ads Zone URL to Discourse's Site Settings
This plugin only support AdButler "Standard Zones". Text and VAST are not supported. This plugin only support AdButler "Standard Zones". Text and VAST are not supported.
@@ -1,9 +0,0 @@
<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>
@@ -1,48 +0,0 @@
<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>
+1 -12
View File
@@ -38,18 +38,7 @@ module ::AdPlugin
private private
def house_ad_params def house_ad_params
@permitted ||= params.permit(:id, :name, :html)
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
+2 -28
View File
@@ -4,7 +4,7 @@ module ::AdPlugin
class HouseAd class HouseAd
include ActiveModel::Validations include ActiveModel::Validations
attr_accessor :id, :name, :html, :visible_to_logged_in_users, :visible_to_anons attr_accessor :id, :name, :html
NAME_REGEX = /\A[[:alnum:]\s\.,'!@#$%&\*\-\+\=:]*\z/i NAME_REGEX = /\A[[:alnum:]\s\.,'!@#$%&\*\-\+\=:]*\z/i
@@ -20,8 +20,6 @@ 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)
@@ -29,10 +27,6 @@ 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
@@ -68,19 +62,10 @@ 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
@@ -91,26 +76,15 @@ 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
+3 -16
View File
@@ -21,17 +21,10 @@ module ::AdPlugin
settings settings
end end
def self.settings_and_ads(for_anons: true) def self.settings_and_ads
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(
@@ -63,18 +56,12 @@ 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/anonymous", settings_and_ads(for_anons: true)) MessageBus.publish("/site/house-creatives", settings_and_ads)
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 { alias, or } from "@ember/object/computed";
import { inject as service } from "@ember/service"; import { inject as service } from "@ember/service";
import { alias, or } from "@ember/object/computed";
import discourseComputed from "discourse-common/utils/decorators"; import discourseComputed from "discourse-common/utils/decorators";
import { import {
isNthPost, isNthPost,
@@ -1,7 +1,7 @@
import EmberObject from "@ember/object"; import EmberObject from "@ember/object";
import { isBlank } from "@ember/utils";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component"; import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { isBlank } from "@ember/utils";
import { import {
isNthPost, isNthPost,
isNthTopicListItem, isNthTopicListItem,
@@ -1,9 +1,9 @@
import { scheduleOnce } from "@ember/runloop";
import RSVP from "rsvp";
import loadScript from "discourse/lib/load-script";
import { isTesting } from "discourse-common/config/environment";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component"; import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import loadScript from "discourse/lib/load-script";
import RSVP from "rsvp";
import { scheduleOnce } from "@ember/runloop";
import { isTesting } from "discourse-common/config/environment";
let _loaded = false, let _loaded = false,
_promise = null, _promise = null,
@@ -1,7 +1,7 @@
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed from "discourse-common/utils/decorators";
import { and } from "@ember/object/computed"; import { and } from "@ember/object/computed";
import { htmlSafe } from "@ember/template"; import { htmlSafe } from "@ember/template";
import discourseComputed from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
export default AdComponent.extend({ export default AdComponent.extend({
classNames: ["amazon-product-links"], classNames: ["amazon-product-links"],
@@ -1,6 +1,6 @@
import { htmlSafe } from "@ember/template";
import discourseComputed from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component"; import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed from "discourse-common/utils/decorators";
import { htmlSafe } from "@ember/template";
export default AdComponent.extend({ export default AdComponent.extend({
serve_id: null, serve_id: null,
@@ -1,10 +1,10 @@
import { scheduleOnce } from "@ember/runloop";
import { htmlSafe } from "@ember/template";
import RSVP from "rsvp";
import loadScript from "discourse/lib/load-script";
import { isTesting } from "discourse-common/config/environment";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component"; import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import loadScript from "discourse/lib/load-script";
import RSVP from "rsvp";
import { scheduleOnce } from "@ember/runloop";
import { isTesting } from "discourse-common/config/environment";
import { htmlSafe } from "@ember/template";
let _loaded = false, let _loaded = false,
_promise = null, _promise = null,
@@ -1,10 +1,10 @@
import { alias } from "@ember/object/computed";
import { htmlSafe } from "@ember/template";
import RSVP from "rsvp";
import loadScript from "discourse/lib/load-script";
import { isTesting } from "discourse-common/config/environment";
import discourseComputed, { on } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component"; import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { on } from "discourse-common/utils/decorators";
import loadScript from "discourse/lib/load-script";
import { alias } from "@ember/object/computed";
import RSVP from "rsvp";
import { isTesting } from "discourse-common/config/environment";
import { htmlSafe } from "@ember/template";
let _loaded = false, let _loaded = false,
_promise = null, _promise = null,
@@ -1,6 +1,6 @@
import { isBlank } from "@ember/utils";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component"; import AdComponent from "discourse/plugins/discourse-adplugin/discourse/components/ad-component";
import discourseComputed, { observes } from "discourse-common/utils/decorators";
import { isBlank } from "@ember/utils";
const adIndex = { const adIndex = {
topic_list_top: null, topic_list_top: null,
@@ -1,5 +1,5 @@
import Ember from "ember";
import MultiSelectComponent from "select-kit/components/multi-select"; import MultiSelectComponent from "select-kit/components/multi-select";
import Ember from "ember";
const { makeArray } = Ember; const { makeArray } = Ember;
import { computed } from "@ember/object"; import { computed } from "@ember/object";
@@ -1,5 +1,5 @@
import { mapBy } from "@ember/object/computed";
import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting"; import HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
import { mapBy } from "@ember/object/computed";
export default HouseAdsSetting.extend({ export default HouseAdsSetting.extend({
classNames: "house-ads-setting house-ads-list-setting", classNames: "house-ads-setting house-ads-list-setting",
@@ -1,5 +0,0 @@
{{ad-slot
placement="post-bottom"
[email protected]
[email protected]_number
}}
@@ -1,10 +1,10 @@
import Controller, { inject as controller } from "@ember/controller"; import I18n from "I18n";
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 I18n from "I18n"; import Controller, { inject as controller } from "@ember/controller";
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,20 +14,7 @@ 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"),
visibleToAnonsDirty: propertyNotEqual( dirty: or("nameDirty", "htmlDirty"),
"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: {
@@ -47,10 +34,6 @@ 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

Some files were not shown because too many files have changed in this diff Show More