Last active
April 27, 2017 19:18
-
-
Save anthonymoralez/24a7fe359987ac296a550edfd5edc4a1 to your computer and use it in GitHub Desktop.
Adding RSS and RSS Friendly Gists
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: Don't look too good, nor talk too wise | |
author_name: Anthony Moralez | |
author_uri: http://www.anthonymoralez.com | |
is_hidden: true | |
--- | |
<%= atom_feed %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_raw_gist(user, gist_id, file) | |
url = URI.parse("https://gist.githubusercontent.com/#{user}/#{gist_id}/raw/#{file}") | |
res = Net::HTTP.get_response(url) | |
res.body.force_encoding("UTF-8") | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
script_tag_regex = /(?<script_tag><script\s+src=["']https:\/\/gist\.github\.com\/(?<user>[^\/]+)\/(?<gist_id>[^\.]+)\.js\?file=(?<file>[^"']+)["']\s*>.*<\/script>)/ | |
Nanoc::Filter.define(:gists) do |content, params| | |
content.gsub(script_tag_regex) { |match| | |
raw_gist = get_raw_gist($2, $3, $4) | |
$1 + "\n<noscript><code>" + h(raw_gist) + "</code></noscript>\n" | |
} | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<p>Some stuff that introduces a gist:</p> | |
<script src="https://gist.github.com/anthonymoralez/6f8621ab14061dc9487016939bdcfe99.js?file=nanoc.sh"></script> | |
<noscript><code>$ nanoc</code></noscript> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
title: "Heroku Buildpack for Nanoc" | |
created_at: 2017-04-26 10:04:16 -0700 | |
kind: article | |
published: true | |
excerpt: Short blurb for the beginning of this article. | |
--- | |
Some stuff that introduces a gist: | |
<script src="https://gist.github.com/anthonymoralez/6f8621ab14061dc9487016939bdcfe99.js?file=nanoc.sh"></script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
compile '/feed/*.erb' do | |
filter :erb | |
write item.identifier.without_ext | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment