CSS Ruby HTML
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
bin
data
helpers
source
.gitignore
Gemfile
Gemfile.lock
LICENSE
README.md
config.rb

README.md

Happy Nerds

Happy Nerds is a web site where I collect links to various programming languages/environments, websites and books specifically targeted at kids.

It is built using Middleman and hosted on Netlify.

Architecture

The different category pages are created from a single template via Middleman's proxy method:

# config.rb
...
%w(windows mac linux browser ios raspberry books meta).each do |category|
  proxy(
    "/sites/#{category}/index.html",
    '/sites/template.html',
    locals: { category: category },
    ignore: true
  )
end
...

The template then uses a data file to only include sites in the respective category in each generated page:

...
# source/sites/template.html.erb
<% sites = data.sites.select { |site| site.categories.include?(category) } %>
<% sites.each do |site| %>
    <article>
      <a href="<%= site[:url] %>"><%= site[:name] %></a>
      <p><%= site[:description] %></p>
    </article>
<% end %>

The sitemap generation code makes use of Middleman's internal sitemap:

# source/sitemap.xml.erb
---
layout: false
directory_index: false
---
<% pages = sitemap.resources.find_all { |p| p.source_file.match(/\.html/) } %>
<?xml version="1.0" encoding="UTF-8"?>
<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
<% pages.each do |p| %>
  <url>
    <loc>
      https://www.happynerds.net/<%= p.destination_path.gsub('index.html', '') %>
    </loc>
  </url>
<% end %>
</urlset>

History

The initial version was built with Ruby, Sinatra and MongoDB, hosted on Heroku and mLab.

This was followed by a version using Clojure and Luminus, still backed by MongoDB and hosted on Heroku and mLab.

The next iteration was done with Ruby on Rails and PostgreSQL, and was the last version of the site to run on Heroku.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/citizen428/happynerds. If you want to add another site, add its information to data/sites.json.

License

The code is available as open source under the terms of the MIT License.