Skip to content

Instantly share code, notes, and snippets.

@mtrovilho
Last active August 29, 2015 13:55
Show Gist options
  • Save mtrovilho/8752202 to your computer and use it in GitHub Desktop.
Save mtrovilho/8752202 to your computer and use it in GitHub Desktop.
Create a list with links for all issues of The-Magazine.org
require 'erb'
HTML_FILENAME = 'the-mag.html'
LATEST_ISSUE = 58
template = %{
<html>
<body>
<% LATEST_ISSUE.downto( 1 ) do |i| %>
<p>
Issue <%= i %>:
<a href="https://the-magazine.com/<%= i %>?epub">epub</a> |
<a href="https://the-magazine.com/<%= i %>?mobi">mobi</a> |
<a href="https://the-magazine.com/<%= i %>?send_epub">send epub</a> |
<a href="https://the-magazine.com/<%= i %>?send_mobi">send mobi</a>
</p>
<% end %>
</body>
</html>
}
erb = ERB.new( template )
html = erb.result
File.open( HTML_FILENAME, 'w' ) do |f|
f.write( html )
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment