init commit
This commit is contained in:
parent
28810484b9
commit
5ba71c10cc
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"about_url": null,
|
||||
"license_url": null,
|
||||
"assets": {
|
||||
},
|
||||
"name": "discourse-gated-category",
|
||||
"component": true
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
.custom-need-access-prompt {
|
||||
background: red;
|
||||
display: block;
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
import Component from "@ember/component";
|
||||
import I18n from "I18n";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { default as getURL } from "discourse-common/lib/get-url";
|
||||
// import cookie from "discourse/lib/cookie";
|
||||
|
||||
export default Component.extend({
|
||||
tagName: "",
|
||||
hidden: true,
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
this.appEvents.on("cta:shown", this, this._triggerPrompt);
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this.appEvents.off("cta:shown", this, this._triggerPrompt);
|
||||
},
|
||||
|
||||
_triggerPrompt() {
|
||||
this.set("hidden", false)
|
||||
},
|
||||
|
||||
@discourseComputed("hidden")
|
||||
shouldShow(hidden) {
|
||||
return !hidden;
|
||||
},
|
||||
|
||||
// @action
|
||||
// dismissBanner() {
|
||||
// this.keyValueStore.setItem("anon-cta-never", "t");
|
||||
// this.session.set("showSignupCta", false);
|
||||
// this.set("hidden", true);
|
||||
// },
|
||||
|
||||
// @action
|
||||
// showBannerLater() {
|
||||
// this.keyValueStore.setItem("anon-cta-hidden", Date.now());
|
||||
// this.set("hidden", true)
|
||||
// },
|
||||
});
|
|
@ -0,0 +1 @@
|
|||
{{need-access-prompt}}
|
|
@ -0,0 +1,48 @@
|
|||
import { withPluginApi } from "discourse/lib/plugin-api";
|
||||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
||||
const enabledCategories = settings.enabled_categories
|
||||
.split("|")
|
||||
.map((id) => parseInt(id, 10))
|
||||
.filter((id) => id);
|
||||
|
||||
const PLUGIN_ID = "discourse-gated-category";
|
||||
|
||||
export default {
|
||||
name: "require-signup-on-select-category",
|
||||
initialize() {
|
||||
withPluginApi("0.8.14", (api) => this.initWithApi(api));
|
||||
},
|
||||
|
||||
initWithApi(api) {
|
||||
const site = api.container.lookup("site:main");
|
||||
|
||||
api.modifyClass("component:topic-list-item", {
|
||||
pluginID: PLUGIN_ID,
|
||||
excerptsRouter: service("router"),
|
||||
|
||||
@discourseComputed(
|
||||
"excerptsRouter.currentRouteName",
|
||||
"excerptsRouter.currentRoute.attributes.category.id"
|
||||
)
|
||||
requireSignUpCategoryId(currentRouteName, categoryId) {
|
||||
if (!currentRouteName.match(/^discovery\./)) return;
|
||||
return categoryId;
|
||||
},
|
||||
|
||||
@discourseComputed("requireSignUpCategoryId")
|
||||
expandPinned(viewingCategory) {
|
||||
const overrideEverywhere =
|
||||
enabledCategories.length === 0;
|
||||
|
||||
const overrideInCategory = enabledCategories.includes(viewingCategory);
|
||||
|
||||
return overrideEverywhere || overrideInCategory
|
||||
? true
|
||||
: this._super();
|
||||
},
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{{!-- {{#if shouldShow}} --}}
|
||||
<div class="custom-need-access-prompt">
|
||||
<h1>{{theme-setting "prompt_heading"}}</h1>
|
||||
{{d-button action=(route-action "showCreateAccount") class="btn-primary sign-up-button" translatedLabel=(theme-setting "prompt_cta_label")}}
|
||||
</div>
|
||||
{{!-- {{/if}} --}}
|
|
@ -0,0 +1,3 @@
|
|||
en:
|
||||
theme_metadata:
|
||||
description: "Categories with logged-in access only"
|
|
@ -0,0 +1,7 @@
|
|||
{
|
||||
"author": "ella",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"eslint-config-discourse": "latest"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,13 @@
|
|||
enabled_categories:
|
||||
type: list
|
||||
list_type: category
|
||||
default: ""
|
||||
description: "Choose which categories that users need to sign up"
|
||||
prompt_heading:
|
||||
type: string
|
||||
default: "Sign up to read the rest of the post"
|
||||
description: ""
|
||||
prompt_cta_label:
|
||||
type: string
|
||||
default: "Sign Up"
|
||||
description: ""
|
Loading…
Reference in New Issue