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.
To use this project, your computer needs Node.js 0.12 or greater.
To get started, run the following command to clone the project:
git clone https://github.com/amy3478/matin_email.git
To set up the project, navigate to the project folder in your command line, and install the needed dependencies:
cd matin_email
npm install
- 1-column layout, blue-yellow theme
- 1-column layout, black-gold theme (Recommended)
- 2-column layout, blue-yellow theme
- 2-column layout, black-gold theme
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
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>
the URL got from Step 1
the number of articles to fetch
one of 4 templates below
- tmp_1_col.html
- tmp_1_col_gold.html
- tmp_2_col.html
- tmp_2_col_gold.html
(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 |
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
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.
- Login to the Admin panel
- Choose Newsletter from Components dropdown
- On Newsletter tab, choose New to create a newsletter
- Choose No Template and save
- The created newsletter will be shown on the list. Click it to edit
- Copy the HTML code from the file generated in the previous step to HTML Content textarea
Now you can select the newsletter to preview or send a testing copy to yourself.
- Complete the pipeline of fetching secondary content once the content is confirmed