Compare commits
186
Commits
glam-test
...
restructure
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3ca4398bad | ||
|
|
dbafb3b277 | ||
|
|
86ef7da2eb | ||
|
|
32a43a850f | ||
|
|
8931e2a07e | ||
|
|
44f49725f8 | ||
|
|
3a89fbdd9a | ||
|
|
8f51e0e4c0 | ||
|
|
30c49eb50d | ||
|
|
8cb9628f0d | ||
|
|
b4aa9a05be | ||
|
|
db0097b8f8 | ||
|
|
bade14daa0 | ||
|
|
743478d593 | ||
|
|
58205cc9ac | ||
|
|
d3005f26af | ||
|
|
c2057a5056 | ||
|
|
bfd4438b97 | ||
|
|
4d2ec950d0 | ||
|
|
165ecdefc5 | ||
|
|
c519b4bc92 | ||
|
|
dc48bea931 | ||
|
|
c73ac98748 | ||
|
|
ff6b767796 | ||
|
|
116795aff3 | ||
|
|
fd6ac11ee9 | ||
|
|
203eedb915 | ||
|
|
8ac32a06c3 | ||
|
|
f52ac0775f | ||
|
|
fa2ec23ebc | ||
|
|
f7d9d13de8 | ||
|
|
a647813ce7 | ||
|
|
a570a46ad2 | ||
|
|
3b50a509f2 | ||
|
|
4940d0ea19 | ||
|
|
d9b739f803 | ||
|
|
a4aa6332bb | ||
|
|
469771db1d | ||
|
|
5901a52dbc | ||
|
|
c27f5717e4 | ||
|
|
a514c7aee2 | ||
|
|
3f951116fa | ||
|
|
fb73dda584 | ||
|
|
b9ac5516bf | ||
|
|
e56197505f | ||
|
|
208b56b130 | ||
|
|
898de0c9c8 | ||
|
|
8ca041846a | ||
|
|
7e2a490b67 | ||
|
|
c788b7bf1f | ||
|
|
03ec825e8e | ||
|
|
912e68e587 | ||
|
|
9be37644d8 | ||
|
|
58085298f0 | ||
|
|
62a4eff705 | ||
|
|
0d8e33c661 | ||
|
|
713d2951e7 | ||
|
|
0983b26180 | ||
|
|
8c3f2b691f | ||
|
|
d5cf5776d9 | ||
|
|
55045bba3c | ||
|
|
f2171a51c3 | ||
|
|
a01058f041 | ||
|
|
1d47138cb7 | ||
|
|
d7c127cc48 | ||
|
|
f4247ab7d2 | ||
|
|
190aa503ce | ||
|
|
d74deaad20 | ||
|
|
c25c041f98 | ||
|
|
43189e0f56 | ||
|
|
a43a5d2edc | ||
|
|
1741deecfe | ||
|
|
8a3ca77a60 | ||
|
|
9e30a576da | ||
|
|
fbdff69540 | ||
|
|
c4e88ba82c | ||
|
|
7f90994154 | ||
|
|
a16ed5f0bf | ||
|
|
d3730993a6 | ||
|
|
4ac7779cc9 | ||
|
|
6438000ed4 | ||
|
|
1654937788 | ||
|
|
112fe8f4cb | ||
|
|
4bf6420b91 | ||
|
|
4131f8403a | ||
|
|
2390a9d1d9 | ||
|
|
7b912d9252 | ||
|
|
9adaef17cc | ||
|
|
9ad0133624 | ||
|
|
e692fdf64f | ||
|
|
059b04468a | ||
|
|
fb7f4e5766 | ||
|
|
12f15a0306 | ||
|
|
c66c651c5b | ||
|
|
a626b8e79d | ||
|
|
1f49cf94db | ||
|
|
15b2c1a05e | ||
|
|
22dfb3aa5e | ||
|
|
3a7e642ae3 | ||
|
|
87c1478743 | ||
|
|
30dad0281d | ||
|
|
88e2bab0d6 | ||
|
|
a36c34bedc | ||
|
|
5afca0aaa1 | ||
|
|
8439608f17 | ||
|
|
50788a876e | ||
|
|
501ad7878e | ||
|
|
20ebd91f8f | ||
|
|
b28039e86a | ||
|
|
914735767a | ||
|
|
db4f5f990d | ||
|
|
c27d5f8e85 | ||
|
|
1d073e2a96 | ||
|
|
0a23be6008 | ||
|
|
75fb2bf892 | ||
|
|
1e6e3bb3e9 | ||
|
|
06ea132309 | ||
|
|
24cb463ddb | ||
|
|
dd5fb1f785 | ||
|
|
3fc872520e | ||
|
|
3d0ee3f28a | ||
|
|
05967a8d52 | ||
|
|
cff1459dbc | ||
|
|
5273d52f28 | ||
|
|
4ded0bdba9 | ||
|
|
5b99fd5bbd | ||
|
|
ef316ab4ac | ||
|
|
f11382e224 | ||
|
|
f7582f0df8 | ||
|
|
270799166b | ||
|
|
cd82a905ae | ||
|
|
bec86bd59a | ||
|
|
f2ccce4beb | ||
|
|
af346fc1c2 | ||
|
|
63ae1672ad | ||
|
|
3fdd0f35f3 | ||
|
|
275921ac70 | ||
|
|
116f9dd238 | ||
|
|
cf27a7be64 | ||
|
|
db1bf99277 | ||
|
|
73aa618aef | ||
|
|
155d9f904c | ||
|
|
b59f841944 | ||
|
|
a3e3dbf24b | ||
|
|
0d534ce52a | ||
|
|
8d4df6df91 | ||
|
|
edc549b269 | ||
|
|
02f9145751 | ||
|
|
cc09403757 | ||
|
|
9a02cae641 | ||
|
|
6704238c94 | ||
|
|
51c1b89a62 | ||
|
|
19f0457e8c | ||
|
|
b500ea171f | ||
|
|
0612054da8 | ||
|
|
62888e734f | ||
|
|
2ad24e4a60 | ||
|
|
2ceb99e151 | ||
|
|
4991941d03 | ||
|
|
71c51ebd8b | ||
|
|
dee02ac3ba | ||
|
|
93af4587fa | ||
|
|
09a92f3438 | ||
|
|
3aa9cb8a0c | ||
|
|
e8295c600c | ||
|
|
1929ac405c | ||
|
|
333f6cef81 | ||
|
|
6f786b2f4d | ||
|
|
ad939a851a | ||
|
|
2ba276b0fb | ||
|
|
89200f3b99 | ||
|
|
3054f2539a | ||
|
|
8ab28f4fda | ||
|
|
25090a55a1 | ||
|
|
92609c7af4 | ||
|
|
ca345f273c | ||
|
|
d34b45627e | ||
|
|
31efc7025d | ||
|
|
574500ba08 | ||
|
|
203e14b639 | ||
|
|
8c3fe62e90 | ||
|
|
3a04f95916 | ||
|
|
0432256adb | ||
|
|
35c1af6648 | ||
|
|
04525d0cf1 | ||
|
|
7af8f1d46b |
@@ -0,0 +1,2 @@
|
|||||||
|
3.1.999: 30c49eb50d6d16fcf82bace3da0e1972b7b220c0
|
||||||
|
|
||||||
@@ -1,105 +0,0 @@
|
|||||||
{
|
|
||||||
"env": {
|
|
||||||
"jasmine": true,
|
|
||||||
"node": true,
|
|
||||||
"mocha": true,
|
|
||||||
"browser": true,
|
|
||||||
"builtin": true
|
|
||||||
},
|
|
||||||
"parserOptions": {
|
|
||||||
"ecmaVersion": 7,
|
|
||||||
"sourceType": "module"
|
|
||||||
},
|
|
||||||
"globals":
|
|
||||||
{"Ember":true,
|
|
||||||
"jQuery":true,
|
|
||||||
"$":true,
|
|
||||||
"RSVP":true,
|
|
||||||
"Discourse":true,
|
|
||||||
"Em":true,
|
|
||||||
"PreloadStore":true,
|
|
||||||
"Handlebars":true,
|
|
||||||
"I18n":true,
|
|
||||||
"bootbox":true,
|
|
||||||
"module":true,
|
|
||||||
"moduleFor":true,
|
|
||||||
"moduleForComponent":true,
|
|
||||||
"Pretender":true,
|
|
||||||
"sandbox":true,
|
|
||||||
"controllerFor":true,
|
|
||||||
"test":true,
|
|
||||||
"ok":true,
|
|
||||||
"not":true,
|
|
||||||
"expect":true,
|
|
||||||
"equal":true,
|
|
||||||
"visit":true,
|
|
||||||
"andThen":true,
|
|
||||||
"click":true,
|
|
||||||
"currentPath":true,
|
|
||||||
"currentRouteName":true,
|
|
||||||
"currentURL":true,
|
|
||||||
"fillIn":true,
|
|
||||||
"keyEvent":true,
|
|
||||||
"triggerEvent":true,
|
|
||||||
"count":true,
|
|
||||||
"exists":true,
|
|
||||||
"visible":true,
|
|
||||||
"invisible":true,
|
|
||||||
"asyncRender":true,
|
|
||||||
"selectDropdown":true,
|
|
||||||
"asyncTestDiscourse":true,
|
|
||||||
"fixture":true,
|
|
||||||
"find":true,
|
|
||||||
"sinon":true,
|
|
||||||
"moment":true,
|
|
||||||
"start":true,
|
|
||||||
"_":true,
|
|
||||||
"alert":true,
|
|
||||||
"containsInstance":true,
|
|
||||||
"deepEqual":true,
|
|
||||||
"notEqual":true,
|
|
||||||
"define":true,
|
|
||||||
"require":true,
|
|
||||||
"requirejs":true,
|
|
||||||
"hasModule":true,
|
|
||||||
"Blob":true,
|
|
||||||
"File":true},
|
|
||||||
"rules": {
|
|
||||||
"block-scoped-var": 2,
|
|
||||||
"dot-notation": 0,
|
|
||||||
"eqeqeq": [
|
|
||||||
2,
|
|
||||||
"allow-null"
|
|
||||||
],
|
|
||||||
"guard-for-in": 2,
|
|
||||||
"no-bitwise": 2,
|
|
||||||
"no-caller": 2,
|
|
||||||
"no-cond-assign": 0,
|
|
||||||
"no-debugger": 2,
|
|
||||||
"no-empty": 0,
|
|
||||||
"no-eval": 2,
|
|
||||||
"no-extend-native": 2,
|
|
||||||
"no-extra-parens": 0,
|
|
||||||
"no-irregular-whitespace": 2,
|
|
||||||
"no-iterator": 2,
|
|
||||||
"no-loop-func": 2,
|
|
||||||
"no-multi-str": 2,
|
|
||||||
"no-new": 2,
|
|
||||||
"no-plusplus": 0,
|
|
||||||
"no-proto": 2,
|
|
||||||
"no-script-url": 2,
|
|
||||||
"no-sequences": 2,
|
|
||||||
"no-shadow": 2,
|
|
||||||
"no-undef": 2,
|
|
||||||
"no-unused-vars": 2,
|
|
||||||
"no-with": 2,
|
|
||||||
"semi": 2,
|
|
||||||
"strict": 0,
|
|
||||||
"valid-typeof": 2,
|
|
||||||
"wrap-iife": [
|
|
||||||
2,
|
|
||||||
"inside"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"parser": "babel-eslint"
|
|
||||||
}
|
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@discourse/lint-configs/eslint");
|
||||||
@@ -0,0 +1,11 @@
|
|||||||
|
name: Discourse Plugin
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- main
|
||||||
|
pull_request:
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ci:
|
||||||
|
uses: discourse/.github/.github/workflows/discourse-plugin.yml@v1
|
||||||
+3
-2
@@ -2,7 +2,8 @@
|
|||||||
log/*.log
|
log/*.log
|
||||||
pkg/
|
pkg/
|
||||||
auto_generated
|
auto_generated
|
||||||
Gemfile.lock
|
|
||||||
.DS_Store
|
.DS_Store
|
||||||
*.swp
|
*.swp
|
||||||
.rubocop-https---raw-githubusercontent-com-discourse-discourse-master--rubocop-yml
|
node_modules
|
||||||
|
yarn-error.log
|
||||||
|
.rubocop-https---raw-githubusercontent-com-discourse-*
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@discourse/lint-configs/prettier");
|
||||||
+5
-1
@@ -1 +1,5 @@
|
|||||||
inherit_from: https://raw.githubusercontent.com/discourse/discourse/master/.rubocop.yml
|
inherit_gem:
|
||||||
|
rubocop-discourse: stree-compat.yml
|
||||||
|
|
||||||
|
RSpec/NamedSubject:
|
||||||
|
Enabled: false
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
--print-width=100
|
||||||
|
--plugins=plugin/trailing_comma,plugin/disable_auto_ternary
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
module.exports = require("@discourse/lint-configs/template-lint");
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
[main]
|
|
||||||
host = https://www.transifex.com
|
|
||||||
lang_map = el_GR: el, es_ES: es, fr_FR: fr, hu_HU: hu, ko_KR: ko, pt_PT: pt, sk_SK: sk, vi_VN: vi
|
|
||||||
|
|
||||||
[discourse-org.discourse-adpluginclientenyml]
|
|
||||||
file_filter = config/locales/client.<lang>.yml
|
|
||||||
source_file = config/locales/client.en.yml
|
|
||||||
source_lang = en
|
|
||||||
type = YML
|
|
||||||
|
|
||||||
[discourse-org.discourse-adpluginserverenyml]
|
|
||||||
file_filter = config/locales/server.<lang>.yml
|
|
||||||
source_file = config/locales/server.en.yml
|
|
||||||
source_lang = en
|
|
||||||
type = YML
|
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
source 'https://rubygems.org'
|
source "https://rubygems.org"
|
||||||
|
|
||||||
group :development do
|
group :development do
|
||||||
gem 'translations-manager', git: 'https://github.com/discourse/translations-manager.git'
|
gem "rubocop-discourse"
|
||||||
|
gem "syntax_tree"
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,54 @@
|
|||||||
|
GEM
|
||||||
|
remote: https://rubygems.org/
|
||||||
|
specs:
|
||||||
|
ast (2.4.2)
|
||||||
|
json (2.6.3)
|
||||||
|
language_server-protocol (3.17.0.3)
|
||||||
|
parallel (1.23.0)
|
||||||
|
parser (3.2.2.4)
|
||||||
|
ast (~> 2.4.1)
|
||||||
|
racc
|
||||||
|
prettier_print (1.2.1)
|
||||||
|
racc (1.7.3)
|
||||||
|
rainbow (3.1.1)
|
||||||
|
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.2.2.4)
|
||||||
|
rainbow (>= 2.2.2, < 4.0)
|
||||||
|
regexp_parser (>= 1.8, < 3.0)
|
||||||
|
rexml (>= 3.2.5, < 4.0)
|
||||||
|
rubocop-ast (>= 1.28.1, < 2.0)
|
||||||
|
ruby-progressbar (~> 1.7)
|
||||||
|
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-factory_bot (2.24.0)
|
||||||
|
rubocop (~> 1.33)
|
||||||
|
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.5.0)
|
||||||
|
|
||||||
|
PLATFORMS
|
||||||
|
arm64-darwin-21
|
||||||
|
x86_64-linux
|
||||||
|
|
||||||
|
DEPENDENCIES
|
||||||
|
rubocop-discourse
|
||||||
|
syntax_tree
|
||||||
|
|
||||||
|
BUNDLED WITH
|
||||||
|
2.4.21
|
||||||
@@ -1,10 +1,12 @@
|
|||||||
# Official Discourse Advertising Plugin
|
# Official Discourse Advertising Plugin
|
||||||
|
|
||||||
|
Official Plugin Topic & Documentation: https://meta.discourse.org/t/official-advertising-ad-plugin-for-discourse/33734
|
||||||
|
|
||||||
This is the official Discourse advertising plugin. It allows advertisements to be served by supported advertising platforms for users with a Discourse forum.
|
This is the official Discourse advertising plugin. It allows advertisements to be served by supported advertising platforms for users with a Discourse forum.
|
||||||
|
|
||||||
**Authors**: [Sarah Ni](https://github.com/cyberkoi) & [Vi Nguyen](https://github.com/ladydanger)
|
**Authors**: [Sarah Ni](https://github.com/cyberkoi) & [Vi Nguyen](https://github.com/ladydanger)
|
||||||
|
|
||||||
**Version**: 1.2.0
|
**Version**: 1.2.5
|
||||||
|
|
||||||
**Contributors**: See [credits section](#credits) below
|
**Contributors**: See [credits section](#credits) below
|
||||||
|
|
||||||
@@ -17,8 +19,8 @@ This is the official Discourse advertising plugin. It allows advertisements to
|
|||||||
* [Google Adsense](http://www.google.com.au/adsense/start/why-adsense.html)
|
* [Google Adsense](http://www.google.com.au/adsense/start/why-adsense.html)
|
||||||
* [Google Double Click for Publishers](https://www.google.com/dfp)
|
* [Google Double Click for Publishers](https://www.google.com/dfp)
|
||||||
* [Amazon Affiliates](http://affiliate-program.amazon.com) - Banner and Product Link Ads
|
* [Amazon Affiliates](http://affiliate-program.amazon.com) - Banner and Product Link Ads
|
||||||
* [CodeFund](https://codefund.io) - Ethical Ad Platform for Developers
|
|
||||||
* [Carbon Ads](https://www.carbonads.net/)
|
* [Carbon Ads](https://www.carbonads.net/)
|
||||||
|
* [AdButler](https://www.adbutler.com/)
|
||||||
|
|
||||||
|
|
||||||
## Quick Start in 3 Steps
|
## Quick Start in 3 Steps
|
||||||
@@ -34,7 +36,7 @@ For non-docker or local development installation (those with programming experie
|
|||||||
### Step 1 - Install the Official Discourse Advertising Plugin
|
### Step 1 - Install the Official Discourse Advertising Plugin
|
||||||
|
|
||||||
|
|
||||||
As seen in a [how-to on meta.discourse.org](https://meta.discourse.org/t/advanced-troubleshooting-with-docker/15927#Example:%20Install%20a%20plugin), simply **add the plugin's repository url to your container's app.yml file**:
|
As seen in a [how-to on meta.discourse.org](https://meta.discourse.org/t/install-plugins-in-discourse/19157), simply **add the plugin's repository url to your container's app.yml file**:
|
||||||
|
|
||||||
```yml
|
```yml
|
||||||
hooks:
|
hooks:
|
||||||
@@ -79,8 +81,8 @@ the ad slots. The ads will start showing as soon as you add them to slots.
|
|||||||
<li>House Ads - if you want to create and serve ads from your Discourse instance.</li>
|
<li>House Ads - if you want to create and serve ads from your Discourse instance.</li>
|
||||||
<li>Adsense - if using Adsense as your advertisement platform.</li>
|
<li>Adsense - if using Adsense as your advertisement platform.</li>
|
||||||
<li>DFP - if using the DoubleClick for Publishers advertisement platform.</li>
|
<li>DFP - if using the DoubleClick for Publishers advertisement platform.</li>
|
||||||
<li>CodeFund - if using the CodeFund ethical advertisement platform.</li>
|
|
||||||
<li>Carbon Ads - if using the Carbon Ads advertisement platform.</li>
|
<li>Carbon Ads - if using the Carbon Ads advertisement platform.</li>
|
||||||
|
<li>AdButler - if using the AdButler advertisement platform.</li>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
||||||
@@ -94,24 +96,47 @@ 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.
|
||||||
|
|
||||||

|

|
||||||
|
|
||||||
##### CodeFund Embed Tag to Discourse's Site Settings
|
|
||||||
|
|
||||||

|
|
||||||
|
|
||||||
##### 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
|
||||||
|
|
||||||
|
This plugin only support AdButler "Standard Zones". Text and VAST are not supported.
|
||||||
|
|
||||||
|
If you browse to a zone in the AdButler admin, then you can find the Publisher ID (PPPPPP) and the Zone ID (ZZZZZZ) in the URL of your browser's address bar:
|
||||||
|
|
||||||
|
`https://admin.adbutler.com/?ID=PPPPPP&p=textadzone.view&zoneID=ZZZZZZ`
|
||||||
|
|
||||||
|
Configure the ads in Admin > Settings > AdButler.
|
||||||
|
Enter the publisher id in the "adbutler publisher id" setting, and enter the Zone IDs in the different
|
||||||
|
zone id settings as desired.
|
||||||
|
|
||||||
|
By default, ads are assumed to be size 728 x 90, or 320 x 50 in mobile view.
|
||||||
|
To use different size ads, customize using CSS in your site's theme. Override the following CSS:
|
||||||
|
|
||||||
|
```css
|
||||||
|
.adbutler-ad {
|
||||||
|
width: 728px;
|
||||||
|
height: 90px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.adbutler-mobile-ad {
|
||||||
|
width: 320px;
|
||||||
|
height: 50px;
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
### Step 3 - See Your Ad
|
### Step 3 - See Your Ad
|
||||||
|
|
||||||
@@ -122,9 +147,11 @@ Once you've configured your settings and your advertising platform has ads that
|
|||||||
|
|
||||||
In this section, we go into more detail on:
|
In this section, we go into more detail on:
|
||||||
* Available Locations for Ad Display
|
* Available Locations for Ad Display
|
||||||
* Ad Sizes Supported
|
|
||||||
* Trust Levels
|
* Trust Levels
|
||||||
* Languages Supported
|
* Personal messages
|
||||||
|
* Groups
|
||||||
|
* Categories
|
||||||
|
* Tags
|
||||||
|
|
||||||
### Available Locations for Ad Display
|
### Available Locations for Ad Display
|
||||||
|
|
||||||
@@ -137,26 +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```. |
|
||||||
|
|
||||||
|

|
||||||

|
|
||||||
|
|
||||||
### Advertisement Sizes Supported
|
|
||||||
|
|
||||||
This plugin supports the following ad sizes for the following locations.
|
|
||||||
|
|
||||||
All locations except post bottom | Post bottom location | Mobile
|
|
||||||
--- | --- | ---
|
|
||||||
728 x 90 | 728 x 90 | 320 x 50
|
|
||||||
336 x 280 | 336 x 280 |
|
|
||||||
300 x 250 | 300 x 250 |
|
|
||||||
970 x 90 | 970 x 90 |
|
|
||||||
468 x 60 | 468 x 60 |
|
|
||||||
234 x 60 | 234 x 60 |
|
|
||||||
125 x 125 | |
|
|
||||||
180 x 150 | |
|
|
||||||
200 x 200 | |
|
|
||||||
250 x 250 | |
|
|
||||||
|
|
||||||
|
|
||||||
### Trust Levels
|
### Trust Levels
|
||||||
|
|
||||||
@@ -170,12 +178,21 @@ You can use the ```ad_platform_through_trust_level``` dropdown to disable ads fo
|
|||||||
|
|
||||||
To find more about trust levels in Discourse, refer to [Discourse's posts on trust levels](https://meta.discourse.org/t/what-do-user-trust-levels-do/4924)
|
To find more about trust levels in Discourse, refer to [Discourse's posts on trust levels](https://meta.discourse.org/t/what-do-user-trust-levels-do/4924)
|
||||||
|
|
||||||
### Languages Supported
|
### Personal messages
|
||||||
|
|
||||||
* Chinese (Simplified)
|
By default, ads won't be shown in personal messages. To enable ads in personal messages, use the "no ads for personal messages" setting.
|
||||||
* English
|
|
||||||
* French
|
### Groups
|
||||||
* Spanish
|
|
||||||
|
To give some users an ad-free experience, put the users in groups and add those groups to the "no ads for groups" setting.
|
||||||
|
|
||||||
|
### Categories
|
||||||
|
|
||||||
|
To disable ads in certain categories, add them to the "no ads for categories" setting. Also consider using the "no ads for restricted categories" to disable ads in all categories that have read access restrictions.
|
||||||
|
|
||||||
|
### Tags
|
||||||
|
|
||||||
|
Individual topics can have ads disabled by using tags, and entering those tags in the "no ads for tags" setting. This is useful if some topics violate ad network policies.
|
||||||
|
|
||||||
## Other Installation
|
## Other Installation
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -2,9 +2,9 @@ export default {
|
|||||||
resource: "admin.adminPlugins",
|
resource: "admin.adminPlugins",
|
||||||
path: "/plugins",
|
path: "/plugins",
|
||||||
map() {
|
map() {
|
||||||
this.route("houseAds", { path: "/adplugin/house_ads" }, function() {
|
this.route("houseAds", { path: "/pluginad/house_creatives" }, function () {
|
||||||
this.route("index", { path: "/" });
|
this.route("index", { path: "/" });
|
||||||
this.route("show", { path: "/:ad_id" });
|
this.route("show", { path: "/:ad_id" });
|
||||||
});
|
});
|
||||||
}
|
},
|
||||||
};
|
};
|
||||||
@@ -0,0 +1,42 @@
|
|||||||
|
import Ember from "ember";
|
||||||
|
import MultiSelectComponent from "select-kit/components/multi-select";
|
||||||
|
const { makeArray } = Ember;
|
||||||
|
import { computed } from "@ember/object";
|
||||||
|
|
||||||
|
export default MultiSelectComponent.extend({
|
||||||
|
classNames: ["house-ads-chooser"],
|
||||||
|
filterable: true,
|
||||||
|
filterPlaceholder: "admin.adplugin.house_ads.filter_placeholder",
|
||||||
|
tokenSeparator: "|",
|
||||||
|
allowCreate: false,
|
||||||
|
allowAny: false,
|
||||||
|
settingValue: "",
|
||||||
|
valueAttribute: null,
|
||||||
|
nameProperty: null,
|
||||||
|
|
||||||
|
value: computed("settingValue", function () {
|
||||||
|
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);
|
||||||
|
},
|
||||||
|
|
||||||
|
content: computed("choices", function () {
|
||||||
|
return makeArray(this.choices);
|
||||||
|
}),
|
||||||
|
|
||||||
|
actions: {
|
||||||
|
onChange(value) {
|
||||||
|
const settingValue = makeArray(value).join(this.tokenSeparator);
|
||||||
|
this.attrs.onChange && this.attrs.onChange(settingValue);
|
||||||
|
},
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<label for={{name}}>{{title}}</label>
|
||||||
|
{{house-ads-chooser
|
||||||
|
settingValue=adValue
|
||||||
|
choices=adNames
|
||||||
|
onChange=(action (mut adValue))
|
||||||
|
}}
|
||||||
|
<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>
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
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",
|
||||||
|
adNames: mapBy("allAds", "name"),
|
||||||
|
});
|
||||||
@@ -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>
|
||||||
+11
-10
@@ -1,9 +1,10 @@
|
|||||||
|
import Component from "@ember/component";
|
||||||
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 { i18n, propertyNotEqual } from "discourse/lib/computed";
|
import { i18n, propertyNotEqual } from "discourse/lib/computed";
|
||||||
import computed from "ember-addons/ember-computed-decorators";
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default Ember.Component.extend({
|
export default Component.extend({
|
||||||
classNames: "house-ads-setting",
|
classNames: "house-ads-setting",
|
||||||
adValue: "",
|
adValue: "",
|
||||||
saving: false,
|
saving: false,
|
||||||
@@ -22,29 +23,29 @@ export default Ember.Component.extend({
|
|||||||
if (!this.get("saving")) {
|
if (!this.get("saving")) {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
saving: true,
|
saving: true,
|
||||||
savingStatus: I18n.t("saving")
|
savingStatus: I18n.t("saving"),
|
||||||
});
|
});
|
||||||
|
|
||||||
ajax(
|
ajax(
|
||||||
`/admin/plugins/adplugin/house_ad_settings/${this.get("name")}.json`,
|
`/admin/plugins/pluginad/house_settings/${this.get("name")}.json`,
|
||||||
{
|
{
|
||||||
type: "PUT",
|
type: "PUT",
|
||||||
data: { value: this.get("adValue") }
|
data: { value: this.get("adValue") },
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(data => {
|
.then(() => {
|
||||||
const adSettings = this.get("adSettings");
|
const adSettings = this.get("adSettings");
|
||||||
adSettings.set(this.get("name"), this.get("adValue"));
|
adSettings.set(this.get("name"), this.get("adValue"));
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
value: this.get("adValue"),
|
value: this.get("adValue"),
|
||||||
savingStatus: I18n.t("saved")
|
savingStatus: I18n.t("saved"),
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
.catch(popupAjaxError)
|
.catch(popupAjaxError)
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
saving: false,
|
saving: false,
|
||||||
savingStatus: ""
|
savingStatus: "",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -52,6 +53,6 @@ export default Ember.Component.extend({
|
|||||||
|
|
||||||
cancel() {
|
cancel() {
|
||||||
this.set("adValue", this.get("value"));
|
this.set("adValue", this.get("value"));
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
import Controller, { inject as controller } from "@ember/controller";
|
||||||
|
import { alias } from "@ember/object/computed";
|
||||||
|
|
||||||
|
export default Controller.extend({
|
||||||
|
adminPluginsHouseAds: controller("adminPlugins.houseAds"),
|
||||||
|
houseAds: alias("adminPluginsHouseAds.model"),
|
||||||
|
adSettings: alias("adminPluginsHouseAds.houseAdsSettings"),
|
||||||
|
});
|
||||||
+36
-16
@@ -1,25 +1,41 @@
|
|||||||
|
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 I18n from "I18n";
|
||||||
|
|
||||||
export default Ember.Controller.extend(bufferedProperty("model"), {
|
export default Controller.extend(bufferedProperty("model"), {
|
||||||
adminPluginsHouseAds: Ember.inject.controller("adminPlugins.houseAds"),
|
adminPluginsHouseAds: controller("adminPlugins.houseAds"),
|
||||||
|
|
||||||
saving: false,
|
saving: false,
|
||||||
savingStatus: "",
|
savingStatus: "",
|
||||||
|
|
||||||
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: Ember.computed.or("nameDirty", "htmlDirty"),
|
visibleToAnonsDirty: propertyNotEqual(
|
||||||
disableSave: Ember.computed.not("dirty"),
|
"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: {
|
actions: {
|
||||||
save() {
|
save() {
|
||||||
if (!this.get("saving")) {
|
if (!this.get("saving")) {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
saving: true,
|
saving: true,
|
||||||
savingStatus: I18n.t("saving")
|
savingStatus: I18n.t("saving"),
|
||||||
});
|
});
|
||||||
|
|
||||||
const data = {},
|
const data = {},
|
||||||
@@ -31,22 +47,26 @@ export default Ember.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
|
||||||
? `/admin/plugins/adplugin/house_ads`
|
? `/admin/plugins/pluginad/house_creatives`
|
||||||
: `/admin/plugins/adplugin/house_ads/${buffered.get("id")}`,
|
: `/admin/plugins/pluginad/house_creatives/${buffered.get("id")}`,
|
||||||
{
|
{
|
||||||
type: newRecord ? "POST" : "PUT",
|
type: newRecord ? "POST" : "PUT",
|
||||||
data
|
data,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
.then(data => {
|
.then((ajaxData) => {
|
||||||
this.commitBuffer();
|
this.commitBuffer();
|
||||||
this.set("savingStatus", I18n.t("saved"));
|
this.set("savingStatus", I18n.t("saved"));
|
||||||
if (newRecord) {
|
if (newRecord) {
|
||||||
const model = this.get("model");
|
const model = this.get("model");
|
||||||
model.set("id", data.house_ad.id);
|
model.set("id", ajaxData.house_ad.id);
|
||||||
const houseAds = this.get("adminPluginsHouseAds.model");
|
const houseAds = this.get("adminPluginsHouseAds.model");
|
||||||
if (!houseAds.includes(model)) {
|
if (!houseAds.includes(model)) {
|
||||||
houseAds.pushObject(model);
|
houseAds.pushObject(model);
|
||||||
@@ -61,7 +81,7 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||||||
.finally(() => {
|
.finally(() => {
|
||||||
this.setProperties({
|
this.setProperties({
|
||||||
saving: false,
|
saving: false,
|
||||||
savingStatus: ""
|
savingStatus: "",
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -80,14 +100,14 @@ export default Ember.Controller.extend(bufferedProperty("model"), {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ajax(`/admin/plugins/adplugin/house_ads/${model.get("id")}`, {
|
ajax(`/admin/plugins/pluginad/house_creatives/${model.get("id")}`, {
|
||||||
type: "DELETE"
|
type: "DELETE",
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
houseAds.removeObject(model);
|
houseAds.removeObject(model);
|
||||||
this.transitionToRoute("adminPlugins.houseAds.index");
|
this.transitionToRoute("adminPlugins.houseAds.index");
|
||||||
})
|
})
|
||||||
.catch(() => bootbox.alert(I18n.t("generic_error")));
|
.catch(popupAjaxError);
|
||||||
}
|
},
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
import Controller from "@ember/controller";
|
||||||
|
|
||||||
|
export default Controller.extend({
|
||||||
|
loadingAds: true,
|
||||||
|
});
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
import { action } from "@ember/object";
|
||||||
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
|
export default DiscourseRoute.extend({
|
||||||
|
@action
|
||||||
|
moreSettings() {
|
||||||
|
this.transitionTo("adminSiteSettingsCategory", "ad_plugin");
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import EmberObject from "@ember/object";
|
||||||
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
|
export default DiscourseRoute.extend({
|
||||||
|
model(params) {
|
||||||
|
if (params.ad_id === "new") {
|
||||||
|
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(
|
||||||
|
"id",
|
||||||
|
parseInt(params.ad_id, 10)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
import EmberObject from "@ember/object";
|
||||||
|
import { ajax } from "discourse/lib/ajax";
|
||||||
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
|
export default DiscourseRoute.extend({
|
||||||
|
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({
|
||||||
|
model,
|
||||||
|
houseAdsSettings: this.get("settings"),
|
||||||
|
loadingAds: false,
|
||||||
|
});
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -0,0 +1,51 @@
|
|||||||
|
<DSection @class="house-ads-settings content-body">
|
||||||
|
<div>{{i18n "admin.adplugin.house_ads.description"}}</div>
|
||||||
|
|
||||||
|
{{#if houseAds.length}}
|
||||||
|
<form class="form-horizontal">
|
||||||
|
{{house-ads-list-setting
|
||||||
|
name="topic_list_top"
|
||||||
|
value=adSettings.topic_list_top
|
||||||
|
allAds=houseAds
|
||||||
|
adSettings=adSettings
|
||||||
|
}}
|
||||||
|
{{house-ads-list-setting
|
||||||
|
name="topic_above_post_stream"
|
||||||
|
value=adSettings.topic_above_post_stream
|
||||||
|
allAds=houseAds
|
||||||
|
adSettings=adSettings
|
||||||
|
}}
|
||||||
|
{{house-ads-list-setting
|
||||||
|
name="topic_above_suggested"
|
||||||
|
value=adSettings.topic_above_suggested
|
||||||
|
allAds=houseAds
|
||||||
|
adSettings=adSettings
|
||||||
|
}}
|
||||||
|
{{house-ads-list-setting
|
||||||
|
name="post_bottom"
|
||||||
|
value=adSettings.post_bottom
|
||||||
|
allAds=houseAds
|
||||||
|
adSettings=adSettings
|
||||||
|
}}
|
||||||
|
{{house-ads-list-setting
|
||||||
|
name="topic_list_between"
|
||||||
|
value=adSettings.topic_list_between
|
||||||
|
allAds=houseAds
|
||||||
|
adSettings=adSettings
|
||||||
|
}}
|
||||||
|
|
||||||
|
<DButton
|
||||||
|
@label="admin.adplugin.house_ads.more_settings"
|
||||||
|
@icon="cog"
|
||||||
|
class="btn-default"
|
||||||
|
@action={{route-action "moreSettings"}}
|
||||||
|
/>
|
||||||
|
</form>
|
||||||
|
{{else}}
|
||||||
|
<p>
|
||||||
|
{{#link-to "adminPlugins.houseAds.show" "new"}}
|
||||||
|
{{i18n "admin.adplugin.house_ads.get_started"}}
|
||||||
|
{{/link-to}}
|
||||||
|
</p>
|
||||||
|
{{/if}}
|
||||||
|
</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>
|
||||||
+7
-7
@@ -1,21 +1,21 @@
|
|||||||
<div class="adplugin-mgmt">
|
<div class="adplugin-mgmt">
|
||||||
<h1>{{i18n 'admin.adplugin.house_ads.title'}}</h1>
|
<h1>{{i18n "admin.adplugin.house_ads.title"}}</h1>
|
||||||
{{#if model.length}}
|
{{#if model.length}}
|
||||||
<div class="content-list">
|
<div class="content-list">
|
||||||
<div class="house-ads-actions">
|
<div class="house-ads-actions">
|
||||||
{{#link-to 'adminPlugins.houseAds.show' 'new' class="btn btn-primary"}}
|
{{#link-to "adminPlugins.houseAds.show" "new" class="btn btn-primary"}}
|
||||||
{{d-icon "plus"}}
|
{{d-icon "plus"}}
|
||||||
<span>{{i18n 'admin.adplugin.house_ads.new'}}</span>
|
<span>{{i18n "admin.adplugin.house_ads.new"}}</span>
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
{{#link-to 'adminPlugins.houseAds.index' class="btn btn-default"}}
|
{{#link-to "adminPlugins.houseAds.index" class="btn btn-default"}}
|
||||||
{{d-icon "cog"}}
|
{{d-icon "cog"}}
|
||||||
<span>{{i18n 'admin.adplugin.house_ads.settings'}}</span>
|
<span>{{i18n "admin.adplugin.house_ads.settings"}}</span>
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</div>
|
</div>
|
||||||
<ul class="house-ads-list">
|
<ul class="house-ads-list">
|
||||||
{{#each model as |ad|}}
|
{{#each model as |ad|}}
|
||||||
<li class="house-ads-list-item">
|
<li class="house-ads-list-item">
|
||||||
{{#link-to 'adminPlugins.houseAds.show' ad.id}}
|
{{#link-to "adminPlugins.houseAds.show" ad.id}}
|
||||||
{{ad.name}}
|
{{ad.name}}
|
||||||
{{/link-to}}
|
{{/link-to}}
|
||||||
</li>
|
</li>
|
||||||
@@ -24,4 +24,4 @@
|
|||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{outlet}}
|
{{outlet}}
|
||||||
</div>
|
</div>
|
||||||
@@ -5,10 +5,7 @@ module ::AdPlugin
|
|||||||
requires_plugin AdPlugin.plugin_name
|
requires_plugin AdPlugin.plugin_name
|
||||||
|
|
||||||
def index
|
def index
|
||||||
render_json_dump(
|
render_json_dump(house_ads: HouseAd.all.map(&:to_hash), settings: HouseAdSetting.all)
|
||||||
house_ads: HouseAd.all.map(&:to_hash),
|
|
||||||
settings: HouseAdSetting.all
|
|
||||||
)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def show
|
def show
|
||||||
@@ -17,11 +14,7 @@ module ::AdPlugin
|
|||||||
|
|
||||||
def create
|
def create
|
||||||
ad = HouseAd.create(house_ad_params)
|
ad = HouseAd.create(house_ad_params)
|
||||||
if ad.valid?
|
ad.valid? ? render_json_dump(house_ad: ad.to_hash) : render_json_error(ad)
|
||||||
render_json_dump(house_ad: ad.to_hash)
|
|
||||||
else
|
|
||||||
render_json_error(ad)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def update
|
def update
|
||||||
@@ -31,25 +24,32 @@ module ::AdPlugin
|
|||||||
ad = HouseAd.create(house_ad_params.except(:id))
|
ad = HouseAd.create(house_ad_params.except(:id))
|
||||||
end
|
end
|
||||||
|
|
||||||
if ad.valid?
|
ad.valid? ? render_json_dump(house_ad: ad.to_hash) : render_json_error(ad)
|
||||||
render_json_dump(house_ad: ad.to_hash)
|
|
||||||
else
|
|
||||||
render_json_error(ad)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def destroy
|
def destroy
|
||||||
if ad = HouseAd.find(house_ad_params[:id])
|
if ad = HouseAd.find(house_ad_params[:id])
|
||||||
ad.destroy
|
ad.destroy
|
||||||
else
|
else
|
||||||
render_json_error(I18n.t('not_found'), status: 404)
|
render_json_error(I18n.t("not_found"), status: 404)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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
|
||||||
|
|||||||
+32
-11
@@ -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
|
||||||
|
|
||||||
@@ -37,7 +43,7 @@ module ::AdPlugin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.alloc_id
|
def self.alloc_id
|
||||||
DistributedMutex.synchronize('adplugin-house-ad-id') do
|
DistributedMutex.synchronize("adplugin-house-ad-id") do
|
||||||
max_id = AdPlugin.pstore_get("ad:_id")
|
max_id = AdPlugin.pstore_get("ad:_id")
|
||||||
max_id = 1 unless max_id
|
max_id = 1 unless max_id
|
||||||
AdPlugin.pstore_set("ad:_id", max_id + 1)
|
AdPlugin.pstore_set("ad:_id", max_id + 1)
|
||||||
@@ -46,7 +52,7 @@ module ::AdPlugin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.find(id)
|
def self.find(id)
|
||||||
if r = AdPlugin::pstore_get("ad:#{id}")
|
if r = AdPlugin.pstore_get("ad:#{id}")
|
||||||
from_hash(r)
|
from_hash(r)
|
||||||
else
|
else
|
||||||
nil
|
nil
|
||||||
@@ -54,18 +60,27 @@ module ::AdPlugin
|
|||||||
end
|
end
|
||||||
|
|
||||||
def self.all
|
def self.all
|
||||||
PluginStoreRow.where(plugin_name: AdPlugin.plugin_name)
|
PluginStoreRow
|
||||||
|
.where(plugin_name: AdPlugin.plugin_name)
|
||||||
.where("key LIKE 'ad:%'")
|
.where("key LIKE 'ad:%'")
|
||||||
.where("key != 'ad:_id'")
|
.where("key != 'ad:_id'")
|
||||||
.map do |psr|
|
.map { |psr| from_hash(PluginStore.cast_value(psr.type_name, psr.value)) }
|
||||||
from_hash(PluginStore.cast_value(psr.type_name, psr.value))
|
.sort_by { |ad| ad.id }
|
||||||
end.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
|
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,6 +91,10 @@ 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
|
||||||
|
|
||||||
@@ -83,12 +102,15 @@ module ::AdPlugin
|
|||||||
{
|
{
|
||||||
id: @id,
|
id: @id,
|
||||||
name: @name,
|
name: @name,
|
||||||
html: @html
|
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
|
||||||
|
|
||||||
@@ -97,6 +119,5 @@ module ::AdPlugin
|
|||||||
AdPlugin::HouseAdSetting.publish_settings
|
AdPlugin::HouseAdSetting.publish_settings
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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