From 8129d6032dc20c15ba2890d963ad130b427c1e34 Mon Sep 17 00:00:00 2001 From: Joshua Seigler Date: Mon, 15 May 2017 23:18:54 -0400 Subject: [PATCH] remove RSS plugin --- _config.yml | 5 +- _plugins/rssgenerator.rb | 121 --------------------------------------- 2 files changed, 1 insertion(+), 125 deletions(-) delete mode 100644 _plugins/rssgenerator.rb diff --git a/_config.yml b/_config.yml index 429daf4..24058e2 100644 --- a/_config.yml +++ b/_config.yml @@ -23,10 +23,6 @@ url: https://www.dash.org api: /api/v1 -rss_path: "/rss" -rss_name: "dash_blog_rss.xml" -#rss_post_limit: - (optional) the number of posts in the feed - #languages: ["en", "es", "cn", "pt", "ru", "it"] languages: ["en", "cn", "ru", "pt", "fr"] exclude_from_localizations: ["assets","dist","style-guide"] @@ -50,6 +46,7 @@ sitemap: - "/feed.xml" - "/feed/index.xml" - "/style-guide/index.html" + - "/rss/dash_blog_rss.xml" include_posts: - "/index.html" change_frequency_name: "change_frequency" diff --git a/_plugins/rssgenerator.rb b/_plugins/rssgenerator.rb deleted file mode 100644 index c80a820..0000000 --- a/_plugins/rssgenerator.rb +++ /dev/null @@ -1,121 +0,0 @@ -# Jekyll plugin for generating an rss 2.0 feed for posts -# -# Usage: place this file in the _plugins directory and set the required configuration -# attributes in the _config.yml file -# -# Uses the following attributes in _config.yml: -# name - the name of the site -# url - the url of the site -# description - (optional) a description for the feed (if not specified will be generated from name) -# author - (optional) the author of the site (if not specified will be left blank) -# copyright - (optional) the copyright of the feed (if not specified will be left blank) -# rss_path - (optional) the path to the feed (if not specified "/" will be used) -# rss_name - (optional) the name of the rss file (if not specified "rss.xml" will be used) -# rss_post_limit - (optional) the number of posts in the feed -# -# Author: Assaf Gelber -# Site: http://agelber.com -# Source: http://github.com/agelber/jekyll-rss -# -# Distributed under the MIT license -# Copyright Assaf Gelber 2014 - -module Jekyll - class RssFeed < Page; end - - class RssGenerator < Generator - priority :low - safe true - - # Generates an rss 2.0 feed - # - # site - the site - # - # Returns nothing - def generate(site) - require 'rss' - require 'cgi/util' - - # Create the rss with the help of the RSS module - rss = RSS::Maker.make("2.0") do |maker| - maker.channel.title = site.config['name'] - maker.channel.link = site.config['url'] - maker.channel.description = site.config['description'] || "RSS feed for #{site.config['name']}" - maker.channel.author = site.config["author"] - maker.channel.updated = site.posts.docs.map { |p| p.date }.max - maker.channel.copyright = site.config['copyright'] - - post_limit = site.config['rss_post_limit'].nil? ? site.posts.docs.count : site.config['rss_post_limit'] - 1 - - site.posts.docs.reverse[0..post_limit].each do |doc| - doc.read - maker.items.new_item do |item| - link = "#{site.config['url']}#{doc.url}" - item.guid.content = link - item.title = doc.data['title'] - item.link = link - item.description = "]+?>}, '') + "]]>" - - # the whole doc content, wrapped in CDATA tags - item.content_encoded = "" - - item.updated = doc.date - end - end - end - - # File creation and writing - rss_path = ensure_slashes(site.config['rss_path'] || "/") - rss_name = site.config['rss_name'] || "rss.xml" - full_path = File.join(site.dest, rss_path) - ensure_dir(full_path) - - # We only have HTML in our content_encoded field which is surrounded by CDATA. - # So it should be safe to unescape the HTML. - feed = CGI::unescapeHTML(rss.to_s) - - File.open("#{full_path}#{rss_name}", "w") { |f| f.write(feed) } - - # Add the feed page to the site pages - site.pages << Jekyll::RssFeed.new(site, site.dest, rss_path, rss_name) - end - - private - - # Ensures the given path has leading and trailing slashes - # - # path - the string path - # - # Return the path with leading and trailing slashes - def ensure_slashes(path) - ensure_leading_slash(ensure_trailing_slash(path)) - end - - # Ensures the given path has a leading slash - # - # path - the string path - # - # Returns the path with a leading slash - def ensure_leading_slash(path) - path[0] == "/" ? path : "/#{path}" - end - - # Ensures the given path has a trailing slash - # - # path - the string path - # - # Returns the path with a trailing slash - def ensure_trailing_slash(path) - path[-1] == "/" ? path : "#{path}/" - end - - # Ensures the given directory exists - # - # path - the string path of the directory - # - # Returns nothing - def ensure_dir(path) - FileUtils.mkdir_p(path) - end - end -end