Customize and host feeds.
Switch branches/tags
Nothing to show
Clone or download

README.md

FeedFormatter

Swift Zewo Platform License

Takes a feed from one sources and uses Mustache templates to customize them, making them avaialble via an HTTP server.

Currently only works with feeds (or "playlists") from JW Platform. config.example.yaml is documented and a good place to start.

Environment setup

macOS

Install swiftenv.

⚠️ With homebrew use:

brew install kylef/formulae/swiftenv --HEAD

Install Swift 3.0.2:

swiftenv install 3.0.2

Clone this repo and run swift build. You can generate the Xcode project with:

swift package generate-xcodeproj

Linux

Only tested on Ubuntu 16.04.

Install swiftenv..

apt update
apt install libcurl3 clang
swiftenv install 3.0.2

Setup Nginx as Proxy (optional)

apt update
apt install nginx

Create the following config at [/etc/nginx/sites-available/example.com] or use default. This assumes SSL certificates have been setup using letsencrypt. Don't trust this to be secure or robust, it is merely a starting point.

server {
  listen 80;
  server_name example.com localhost;
  return 301 https://example.com$request_uri;
}


# HTTPS server

server {
  listen 443;
  server_name example.com;

  root /var/www/html;
  index index.html;

  ssl on;
  ssl_certificate /etc/letsencrypt/live/example.com/fullchain.pem;
  ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;

  ssl_session_timeout 5m;

  ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
  ssl_ciphers "HIGH:!aNULL:!MD5 or HIGH:!aNULL:!MD5:!3DES";
  ssl_prefer_server_ciphers on;

  location / {
    root /var/www/html;
    try_files $uri $uri/ @FeedFormatter;

    # Uncomment to enable naxsi on this location
    # include /etc/nginx/naxsi.rules
    # auth_basic "Private Property";
    # auth_basic_user_file /etc/nginx/.htpasswd;

    #expires 30d;
    #add_header Pragma public;
    #add_header Cache-Control "public";
  }

  location @FeedFormatter {
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded_for $proxy_add_x_forwarded_for;
    proxy_pass http://127.0.0.1:8080;
  }
}

Be sure to switch out example.com with your sites domain, /var/www/html with the path to static files to be served directly by nginx, and 8080 with the port you set in the your_config.yaml.

Running

Copy config.example.yaml and example.mrss.xml to get started. Be sure to point to the directory where your templates are, and set defualt template name, as well as configure a feed.

Run with $ ./.build/debug/FeedFormatter --config your_config.yaml