Skip to content

Commit

Permalink
feat(filter): add black list, white list feature for FreeLists
Browse files Browse the repository at this point in the history
  • Loading branch information
talha131 committed Jul 30, 2019
1 parent 6bc5ff0 commit 2407cc8
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 2 deletions.
38 changes: 37 additions & 1 deletion documentation/content/Mailing List/freelists.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
---
Title: Add FreeLists
Tags: marketing, network, subscriber
layout: post
Date: 2018-07-05 23:20
comments: false
Slug: add-freelists
Category: Mailing List
authors: Talha Mansoor
freelists_filter: off
---

Elegant shows a form to subscribe to your newsletter, above the fold, in the right section of every article.
Expand All @@ -18,3 +18,39 @@ To customize user experience you can also define,
1. `EMAIL_SUBSCRIPTION_LABEL`,
1. `EMAIL_FIELD_PLACEHOLDER` and
1. `SUBSCRIBE_BUTTON_TITLE`

## Show FreeLists Form by default

Just set `FREELISTS_NAME` variable.

## Hide FreeLists Form by default

Unset `FREELISTS_NAME` variable.

This is the default setting.

## Hide FreeLists Form by default. Show on Selected

1. Set `FREELISTS_NAME`
1. Set `FREELISTS_FILTER` to `True`

This will hide FreeLists form on all pages.

Now to show FreeLists form on selected posts, in article metadata set

```yaml
freelists_filter: off
```
## Show FreeLists Form by default. Hide on Selected
1. Set `FREELISTS_NAME`
1. Remove `FREELISTS_FILTER` or set it to `False` which is its default value

This will hide FreeLists form on all pages.

Now to hide FreeLists form on selected posts, in article metadata set

```yaml
freelists_filter: on
```
3 changes: 3 additions & 0 deletions documentation/pelicanconf.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,3 +177,6 @@
"blurb": "FOSS lawyer by trade, hacker by heart.",
},
}

FREELISTS_NAME = "elegant-demo-list"
FREELISTS_FILTER = True
6 changes: 6 additions & 0 deletions templates/_includes/_defaults.html
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,12 @@
{% set FREELISTS_NAME = FREELISTS_NAME %}
{% endif %}

{% if not FREELISTS_FILTER %}
{% set FREELISTS_FILTER = False %}
{% else %}
{% set FREELISTS_FILTER = FREELISTS_FILTER %}
{% endif %}

{# It is displayed along with the SITENAME in the footer of every page #}
{% if not SITESUBTITLE %}
{% set SITESUBTITLE = '' %}
Expand Down
11 changes: 11 additions & 0 deletions templates/_includes/freelists.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
{% macro freelists(article) %}

{% from '_includes/_defaults.html' import FREELISTS_NAME with context %}
{% from '_includes/_defaults.html' import FREELISTS_FILTER with context %}

{%if (not FREELISTS_FILTER or article.freelists_filter == "off") and article.freelists_filter != "on" %}

{% if FREELISTS_NAME %}

{% from '_includes/_defaults.html' import EMAIL_SUBSCRIPTION_LABEL with context %}
{% from '_includes/_defaults.html' import SUBSCRIBE_BUTTON_TITLE with context %}
<div id="mc-embed-signup">
Expand All @@ -11,3 +18,7 @@ <h4>{{ EMAIL_SUBSCRIPTION_LABEL }}</h4>
<!-- END FreeLists WEB FORM -->
</div>
{% endif %}

{% endif %}

{% endmacro %}
3 changes: 2 additions & 1 deletion templates/article.html
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,8 @@ <h4>Tags</h4>
{% endif %}
{% include '_includes/social_links.html' %}
{% include '_includes/mailchimp.html' %}
{% include '_includes/freelists.html' %}
{% from '_includes/freelists.html' import freelists with context %}
{{ freelists(article) }}
</div>
</section>
</div>
Expand Down

0 comments on commit 2407cc8

Please sign in to comment.