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:
|
||||
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
|
||||
|
||||
+1
-4
@@ -1,4 +1 @@
|
||||
module.exports = {
|
||||
plugins: ["ember-template-lint-plugin-discourse"],
|
||||
extends: "discourse:recommended",
|
||||
};
|
||||
module.exports = require("@discourse/lint-configs/template-lint");
|
||||
|
||||
+30
-19
@@ -2,42 +2,53 @@ GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
ast (2.4.2)
|
||||
json (2.6.2)
|
||||
parallel (1.22.1)
|
||||
parser (3.1.2.1)
|
||||
json (2.6.3)
|
||||
language_server-protocol (3.17.0.3)
|
||||
parallel (1.23.0)
|
||||
parser (3.2.2.4)
|
||||
ast (~> 2.4.1)
|
||||
prettier_print (1.2.0)
|
||||
racc
|
||||
prettier_print (1.2.1)
|
||||
racc (1.7.3)
|
||||
rainbow (3.1.1)
|
||||
regexp_parser (2.6.0)
|
||||
rexml (3.2.5)
|
||||
rubocop (1.36.0)
|
||||
regexp_parser (2.8.2)
|
||||
rexml (3.2.6)
|
||||
rubocop (1.57.2)
|
||||
json (~> 2.3)
|
||||
language_server-protocol (>= 3.17.0)
|
||||
parallel (~> 1.10)
|
||||
parser (>= 3.1.2.1)
|
||||
parser (>= 3.2.2.4)
|
||||
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.28.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)
|
||||
unicode-display_width (>= 2.4.0, < 3.0)
|
||||
rubocop-ast (1.30.0)
|
||||
parser (>= 3.2.1.0)
|
||||
rubocop-capybara (2.19.0)
|
||||
rubocop (~> 1.41)
|
||||
rubocop-discourse (3.4.0)
|
||||
rubocop (>= 1.1.0)
|
||||
rubocop-rspec (>= 2.0.0)
|
||||
rubocop-rspec (2.13.2)
|
||||
rubocop-factory_bot (2.24.0)
|
||||
rubocop (~> 1.33)
|
||||
ruby-progressbar (1.11.0)
|
||||
syntax_tree (5.1.0)
|
||||
rubocop-rspec (2.25.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)
|
||||
unicode-display_width (2.3.0)
|
||||
unicode-display_width (2.5.0)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
arm64-darwin-21
|
||||
x86_64-linux
|
||||
|
||||
DEPENDENCIES
|
||||
rubocop-discourse
|
||||
syntax_tree
|
||||
|
||||
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
|
||||
|
||||

|
||||

|
||||
|
||||
##### 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
|
||||
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||
import Ember from "ember";
|
||||
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||
const { makeArray } = Ember;
|
||||
import { computed } from "@ember/object";
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
}}
|
||||
<div class="setting-controls">
|
||||
{{#if changed}}
|
||||
{{d-button class="ok" action=(action "save") icon="check"}}
|
||||
{{d-button class="cancel" action=(action "cancel") icon="times"}}
|
||||
<DButton class="ok" @action={{action "save"}} @icon="check" />
|
||||
<DButton class="cancel" @action={{action "cancel"}} @icon="times" />
|
||||
{{/if}}
|
||||
</div>
|
||||
<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 HouseAdsSetting from "discourse/plugins/discourse-adplugin/discourse/components/house-ads-setting";
|
||||
|
||||
export default HouseAdsSetting.extend({
|
||||
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 { popupAjaxError } from "discourse/lib/ajax-error";
|
||||
import { propertyNotEqual } from "discourse/lib/computed";
|
||||
import { bufferedProperty } from "discourse/mixins/buffered-content";
|
||||
import Controller, { inject as controller } from "@ember/controller";
|
||||
import { not, or } from "@ember/object/computed";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default Controller.extend(bufferedProperty("model"), {
|
||||
adminPluginsHouseAds: controller("adminPlugins.houseAds"),
|
||||
@@ -14,7 +14,20 @@ export default Controller.extend(bufferedProperty("model"), {
|
||||
|
||||
nameDirty: propertyNotEqual("buffered.name", "model.name"),
|
||||
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"),
|
||||
|
||||
actions: {
|
||||
@@ -34,6 +47,10 @@ export default Controller.extend(bufferedProperty("model"), {
|
||||
}
|
||||
data.name = buffered.get("name");
|
||||
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(
|
||||
newRecord
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import { action } from "@ember/object";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
@action
|
||||
+3
-1
@@ -1,5 +1,5 @@
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import EmberObject from "@ember/object";
|
||||
import DiscourseRoute from "discourse/routes/discourse";
|
||||
import I18n from "I18n";
|
||||
|
||||
export default DiscourseRoute.extend({
|
||||
@@ -8,6 +8,8 @@ export default DiscourseRoute.extend({
|
||||
return EmberObject.create({
|
||||
name: I18n.t("admin.adplugin.house_ads.new_name"),
|
||||
html: "",
|
||||
visible_to_logged_in_users: true,
|
||||
visible_to_anons: true,
|
||||
});
|
||||
} else {
|
||||
return this.modelFor("adminPlugins.houseAds").findBy(
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
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,
|
||||
+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>
|
||||
|
||||
{{#if houseAds.length}}
|
||||
@@ -34,12 +34,12 @@
|
||||
adSettings=adSettings
|
||||
}}
|
||||
|
||||
{{d-button
|
||||
label="admin.adplugin.house_ads.more_settings"
|
||||
icon="cog"
|
||||
<DButton
|
||||
@label="admin.adplugin.house_ads.more_settings"
|
||||
@icon="cog"
|
||||
class="btn-default"
|
||||
action=(route-action "moreSettings")
|
||||
}}
|
||||
@action={{route-action "moreSettings"}}
|
||||
/>
|
||||
</form>
|
||||
{{else}}
|
||||
<p>
|
||||
@@ -48,4 +48,4 @@
|
||||
{{/link-to}}
|
||||
</p>
|
||||
{{/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
|
||||
|
||||
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
|
||||
|
||||
+28
-2
@@ -4,7 +4,7 @@ module ::AdPlugin
|
||||
class HouseAd
|
||||
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
|
||||
|
||||
@@ -20,6 +20,8 @@ module ::AdPlugin
|
||||
def initialize
|
||||
@name = "New Ad"
|
||||
@html = "<div class='house-ad'>New Ad</div>"
|
||||
@visible_to_logged_in_users = true
|
||||
@visible_to_anons = true
|
||||
end
|
||||
|
||||
def self.from_hash(h)
|
||||
@@ -27,6 +29,10 @@ module ::AdPlugin
|
||||
ad.name = h[:name]
|
||||
ad.html = h[:html]
|
||||
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
|
||||
end
|
||||
|
||||
@@ -62,10 +68,19 @@ module ::AdPlugin
|
||||
.sort_by { |ad| ad.id }
|
||||
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
|
||||
if self.valid?
|
||||
self.id = self.class.alloc_id if self.id.to_i <= 0
|
||||
AdPlugin.pstore_set("ad:#{id}", to_hash)
|
||||
Site.clear_anon_cache!
|
||||
self.class.publish_if_ads_enabled
|
||||
true
|
||||
else
|
||||
@@ -76,15 +91,26 @@ module ::AdPlugin
|
||||
def update(attrs)
|
||||
self.name = attrs[:name]
|
||||
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
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
def destroy
|
||||
AdPlugin.pstore_delete("ad:#{id}")
|
||||
Site.clear_anon_cache!
|
||||
self.class.publish_if_ads_enabled
|
||||
end
|
||||
|
||||
|
||||
@@ -21,10 +21,17 @@ module ::AdPlugin
|
||||
settings
|
||||
end
|
||||
|
||||
def self.settings_and_ads
|
||||
def self.settings_and_ads(for_anons: true)
|
||||
settings = AdPlugin::HouseAdSetting.all
|
||||
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.merge(
|
||||
@@ -56,12 +63,18 @@ module ::AdPlugin
|
||||
else
|
||||
AdPlugin.pstore_set("ad-setting:#{setting_name}", new_value)
|
||||
end
|
||||
Site.clear_anon_cache!
|
||||
|
||||
publish_settings
|
||||
end
|
||||
|
||||
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
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import Component from "@ember/component";
|
||||
import { inject as service } from "@ember/service";
|
||||
import { alias, or } from "@ember/object/computed";
|
||||
import { inject as service } from "@ember/service";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import {
|
||||
isNthPost,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user