amy3478 / matin_email

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

MATIN Newsletter Template

This project is for auto-generating MATIN's newsletters. It is built on Foundation for Emails, a framework for creating responsive HTML devices that work in any email client. It also includes a Python script to fetch RSS feeds.

Installation

To use this project, your computer needs Node.js 0.12 or greater.

Clone this project

To get started, run the following command to clone the project:

git clone https://github.com/amy3478/matin_email.git

Setup

To set up the project, navigate to the project folder in your command line, and install the needed dependencies:

cd matin_email
npm install

4 Templates included

  • 1-column layout, blue-yellow theme alt text
  • 1-column layout, black-gold theme (Recommended)
    alt text
  • 2-column layout, blue-yellow theme alt text
  • 2-column layout, black-gold theme alt text

2 item layouts

  • with the cover image alt text
  • without the cover image alt text

How to create a newsletter

Step 1: Prepare a RSS URL

Get the RSS feed link from MATIN

https://matin.gatech.edu/feedaggregator/feed.rss

For how to prepare the RSS feed on MATIN, please refer to the document.

Or get a RSS feed url from other sites. Below are two examples used for testing the project

https://www.sciencenews.org/feeds/headlines.rss
http://rss.nytimes.com/services/xml/rss/nyt/Science.xml

Step 2: Run the script to fetch the feed

Before run the script, you need to install some Python packages.

pip3 install ImageScraper
pip3 install beautifulsoup4

Run the script

cd src/etc
python3 scraper.py -u <rss-url> -n <num-of-article-to-fetch> -t <path-to-the-template> -k <keyword-to-filter-image>

or

python3 scraper.py --url <rss-url> --num <num-of-article-to-fetch> --tmp <path-to-the-template> --keyword <keyword-to-filter-image>

rss-url:

the URL got from Step 1

num-of-article-to-fetch:

the number of articles to fetch

path-to-the-template:

one of 4 templates below

  • tmp_1_col.html
  • tmp_1_col_gold.html
  • tmp_2_col.html
  • tmp_2_col_gold.html

keyword-to-filter-image:

(OPTIONAL) a keyword used to filter the image grabbed from the article. It has been set to master by default. master is the keyword to get the main image from New York Times RSS.

Website Keyword
New York Times master
Science News main

Example

Use the command below to create a 1-column gold theme newsletter with 5 articles from New York Times Science

python3 scraper.py -u http://rss.nytimes.com/services/xml/rss/nyt/Science.xml -n 5 -t ../pages/tmp_1_col_gold.html -k master

Step 3: Build the newsletter

Because MATIN newsletter project uses Foundation Email framework, we need to build the final version that has inline CSS code. Run the command below.

npm run build

By running the code above, a new tab will be open in your default browser. It always opens index.html by default. In order to see the newsletter you created in Step2, just simply append the name of the template file to the url address. It should look like http://localhost:3xxx/tmp_1_col.html if your newsletter uses tmp_1_col.html as the template.

This will create/update the final html file in dist directory. For instance, if you run the code below

python3 scraper.py -u http://rss.nytimes.com/services/xml/rss/nyt/Science.xml -n 5 -t ../pages/tmp_1_col_gold.html -k master
npm run build

The file dist/tmp_1_col_gold.html should be updated.

Step 4: Create a newsletter on MATIN

  • Login to the Admin panel
  • Choose Newsletter from Components dropdown alt text
  • On Newsletter tab, choose New to create a newsletter alt text
  • Choose No Template and save alt text
  • The created newsletter will be shown on the list. Click it to edit alt text
  • Copy the HTML code from the file generated in the previous step to HTML Content textarea alt text

Step 5: Test

Now you can select the newsletter to preview or send a testing copy to yourself.

Todo

  • Complete the pipeline of fetching secondary content once the content is confirmed

About

License:MIT License


Languages

Language:HTML 72.1%Language:CSS 12.2%Language:JavaScript 9.6%Language:Python 6.1%Language:Shell 0.1%