Author SHA1 Message Date
David Taylor 3ca4398bad DEV: Restructure file locations
- Colocate components / connectors
- Move admin UI files to `admin/assets` so they are only served to admins
2023-11-07 18:14:24 +00:00
David Taylor dbafb3b277 DEV: Update tests to use qunit-dom 2023-11-07 18:14:12 +00:00
David Taylor 86ef7da2eb DEV: Apply eslint --fix 2023-11-07 18:14:12 +00:00
David Taylor 32a43a850f DEV: Update linting config 2023-11-07 18:14:12 +00:00
dependabot[bot] 8931e2a07e Bump @babel/traverse from 7.20.10 to 7.23.2 (#182)
Bumps [@babel/traverse](https://github.com/babel/babel/tree/HEAD/packages/babel-traverse) from 7.20.10 to 7.23.2.
- [Release notes](https://github.com/babel/babel/releases)
- [Changelog](https://github.com/babel/babel/blob/main/CHANGELOG.md)
- [Commits](https://github.com/babel/babel/commits/v7.23.2/packages/babel-traverse)

---
updated-dependencies:
- dependency-name: "@babel/traverse"
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-10-18 18:26:49 +02:00
Discourse Translator Bot 44f49725f8 Update translations (#181) 2023-08-29 15:50:11 +02:00
Discourse Translator Bot 3a89fbdd9a Update translations (#180) 2023-08-23 09:28:54 +02:00
Penar Musaraj 8f51e0e4c0 DEV: Pin plugin for Discourse 3.1 stable (#179) 2023-08-22 13:45:25 -05:00
Discourse Translator Bot 30c49eb50d Update translations (#178) 2023-08-08 15:42:08 +02:00
dependabot[bot] 8cb9628f0d Bump word-wrap from 1.2.3 to 1.2.4 (#177)
Bumps [word-wrap](https://github.com/jonschlinkert/word-wrap) from 1.2.3 to 1.2.4.
- [Release notes](https://github.com/jonschlinkert/word-wrap/releases)
- [Commits](https://github.com/jonschlinkert/word-wrap/compare/1.2.3...1.2.4)

---
updated-dependencies:
- dependency-name: word-wrap
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-19 01:00:58 +02:00
dependabot[bot] b4aa9a05be Bump semver from 6.3.0 to 6.3.1 (#176)
Bumps [semver](https://github.com/npm/node-semver) from 6.3.0 to 6.3.1.
- [Release notes](https://github.com/npm/node-semver/releases)
- [Changelog](https://github.com/npm/node-semver/blob/v6.3.1/CHANGELOG.md)
- [Commits](https://github.com/npm/node-semver/compare/v6.3.0...v6.3.1)

---
updated-dependencies:
- dependency-name: semver
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-07-11 10:37:40 +02:00
Discourse Translator Bot db0097b8f8 Update translations (#175) 2023-07-04 18:13:14 +02:00
Discourse Translator Bot bade14daa0 Update translations (#174) 2023-06-27 16:39:17 +02:00
Isaac Janzen 743478d593 DEV: Use angle bracket syntax (#172) 2023-05-26 09:20:47 -05:00
Kris 58205cc9ac UX: introduce min-height for responsive ads (#170) 2023-04-25 16:19:48 -04:00
Discourse Translator Bot d3005f26af Update translations (#169) 2023-04-11 15:44:40 +02:00
Osama Sayegh c2057a5056 FEATURE: Add per-ad visibility settings for anons and logged-in users (#168)
This commit adds 2 new settings to house ads to control whether an ad is shown to anonymous users and logged in users. Existing ads that were created before this feature will default to true for both settings; i.e., they will remain to be visible to both anonymous and logged-in users, but it will be possible to change the settings. Turning off both settings will effectively disable the ad completely.
2023-04-07 17:56:22 +03:00
Discourse Translator Bot bfd4438b97 Update translations (#167) 2023-02-21 17:11:00 +01:00
Rishabh 4d2ec950d0 Ensure README images are pointing to discourse/gh-owned repositories (#166) 2023-01-25 17:30:08 +05:30
89 changed files with 1786 additions and 1086 deletions
+2
View File
@@ -0,0 +1,2 @@
3.1.999: 30c49eb50d6d16fcf82bace3da0e1972b7b220c0
-3
View File
@@ -1,3 +0,0 @@
{
"extends": "eslint-config-discourse"
}
+1
View File
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/eslint");
-1
View File
@@ -1 +0,0 @@
{}
+1
View File
@@ -0,0 +1 @@
module.exports = require("@discourse/lint-configs/prettier");
+3
View File
@@ -1,2 +1,5 @@
inherit_gem:
rubocop-discourse: stree-compat.yml
RSpec/NamedSubject:
Enabled: false
+1 -1
View File
@@ -1,2 +1,2 @@
--print-width=100
--plugins=plugin/trailing_comma
--plugins=plugin/trailing_comma,plugin/disable_auto_ternary
+1 -4
View File
@@ -1,4 +1 @@
module.exports = {
plugins: ["ember-template-lint-plugin-discourse"],
extends: "discourse:recommended",
};
module.exports = require("@discourse/lint-configs/template-lint");
+30 -19
View File
@@ -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
-2
View File
@@ -109,10 +109,8 @@ Only for Product Link and Banner Ads.
##### Carbon Ads Script Tag to Discourse's Site Settings
![adpluginexample](https://user-images.githubusercontent.com/5862206/214489455-234a3812-3606-47bf-9e49-cdaa3d1e3b9c.png)
##### AdButler Ads Zone URL to Discourse's Site Settings
This plugin only support AdButler "Standard Zones". Text and VAST are not supported.
@@ -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";
@@ -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,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>
@@ -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,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
@@ -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,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,
@@ -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>
+12 -1
View File
@@ -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
View File
@@ -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
+16 -3
View File
@@ -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