Skip to content

Commit d489326

Browse files
committed
Add an Other Projects section
1 parent ba25bd0 commit d489326

File tree

5 files changed

+92
-48
lines changed

5 files changed

+92
-48
lines changed

bin/compile

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,43 @@
11
#!/usr/bin/env ruby
22
require 'rubygems'
33
require 'bundler/setup'
4+
require 'ostruct'
45
require 'yaml'
56
require 'tilt/erb'
67
require 'tilt/sass'
78

89
require 'uri'
910

11+
module Helpers
12+
def link_to(text, href)
13+
"<a href=\"#{href}\">#{text}</a>"
14+
end
15+
16+
def url_host(url)
17+
URI.parse(url).host.gsub(/^www\./, "")
18+
end
19+
20+
def render_partial(name, locals)
21+
context = OpenStruct.new(locals)
22+
context.extend(Helpers)
23+
Tilt::ERBTemplate.new("templates/_#{name}.html.erb").render(context)
24+
end
25+
end
26+
1027
context = Class.new do
11-
def self.projects
12-
YAML.load_file("projects.yml")["projects"].sort_by{ |symbol, project| symbol }
28+
extend Helpers
29+
30+
def self.popular_projects
31+
projects_by_category("popular")
1332
end
1433

15-
# Helpers
16-
def self.link_to(text, href)
17-
"<a href=\"#{href}\">#{text}</a>"
34+
def self.other_projects
35+
projects_by_category("other")
1836
end
1937

20-
def self.url_host(url)
21-
URI.parse(url).host.gsub(/^www\./, "")
38+
def self.projects_by_category(category)
39+
@projects ||= YAML.load_file("projects.yml")
40+
@projects[category].sort_by{ |symbol, project| symbol }
2241
end
2342
end
2443

projects.yml

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
projects:
1+
popular:
22
nats:
33
name: NATS
44
url: https://nats.io
@@ -421,3 +421,17 @@ projects:
421421
url: http://tim.dysinger.net/posts/2013-09-16-getting-started-with-nanomsg.html
422422
- text: "Nanomsg: ZeroMQ done right"
423423
url: http://hguemar.fedorapeople.org/slides/nanomsg/presentation.html
424+
other:
425+
huey:
426+
name: huey
427+
summary: "a little task queue"
428+
url: https://huey.readthedocs.org/en/latest/
429+
tags:
430+
- python
431+
- redis
432+
- django
433+
links:
434+
- text: "Source on GitHub"
435+
url: https://github.com/coleifer/huey
436+
- text: "Huey, a lightweight task queue for python"
437+
url: http://charlesleifer.com/blog/huey-lightweight-task-queue-python/

templates/_project.html.erb

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<article>
2+
<header class="clearfix">
3+
<h3><a name="<%= symbol %>" href="#<%= symbol %>" class="project_name"><%= project["name"] %></a></h3>
4+
</header>
5+
6+
<p class="project_url"><a href="<%= project["url"] %>"><%= project["url"] %></a></p>
7+
8+
<div class="main_content">
9+
10+
<% if !project["tags"].nil? %>
11+
<ul class="tags">
12+
<% project["tags"].each do |tag| %>
13+
<li class="tag"><%= tag %></li>
14+
<% end %>
15+
</ul>
16+
<% end %>
17+
<p><%= project["summary"] %></p>
18+
<% if !project["description"].nil? %>
19+
<ul class="desc">
20+
<% project["description"].each do |point| %>
21+
<li><%= point %></li>
22+
<% end %>
23+
</ul>
24+
<% end %>
25+
26+
<h4>Resources</h4>
27+
28+
<ul class="links">
29+
<% project["links"].each do |link| %>
30+
<li>
31+
<%= link_to(link["text"], link["url"]) %>
32+
<span class="host"><%= url_host(link["url"]) %></span>
33+
</li>
34+
<% end %>
35+
</ul>
36+
</div>
37+
</article>

templates/css/main.css.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ footer {
118118
padding-bottom: 0;
119119
}
120120

121-
#projects {
121+
.projects {
122122
h2 {
123123
margin-top: 0;
124124
}

templates/index.html.erb

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
66
<title>Queues</title>
77
<meta name="description" content="Job queues, message queues and other queues. Almost all of them.">
8-
<meta name="keywords" content="queue, job queue, work queue, message queue, <%= projects.collect{ |k, v| k }.join(", ") %>">
8+
<meta name="keywords" content="queue, job queue, work queue, message queue, <%= popular_projects.collect{ |k, v| k }.join(", ") %>">
99
<meta name="viewport" content="width=device-width">
1010

1111
<link href='http://fonts.googleapis.com/css?family=Bree+Serif' rel='stylesheet' type='text/css'>
@@ -53,49 +53,23 @@
5353
</div>
5454
</article>
5555

56-
<section id="projects">
56+
<section class="projects">
5757
<header>
58-
<h2>Projects</h2>
58+
<h2>Popular Projects</h2>
5959
</header>
6060

61-
<% projects.each do |symbol, project| %>
62-
<article>
63-
<header class="clearfix">
64-
<h3><a name="<%= symbol %>" href="#<%= symbol %>" class="project_name"><%= project["name"] %></a></h3>
65-
</header>
66-
67-
<p class="project_url"><a href="<%= project["url"] %>"><%= project["url"] %></a></p>
68-
69-
<div class="main_content">
70-
71-
<% if !project["tags"].nil? %>
72-
<ul class="tags">
73-
<% project["tags"].each do |tag| %>
74-
<li class="tag"><%= tag %></li>
75-
<% end %>
76-
</ul>
77-
<% end %>
78-
<p><%= project["summary"] %></p>
79-
<% if !project["description"].nil? %>
80-
<ul class="desc">
81-
<% project["description"].each do |point| %>
82-
<li><%= point %></li>
83-
<% end %>
84-
</ul>
85-
<% end %>
61+
<% popular_projects.each do |symbol, project| %>
62+
<%= render_partial "project", { symbol: symbol, project: project } %>
63+
<% end %>
64+
</section>
8665

87-
<h4>Resources</h4>
66+
<section class="projects">
67+
<header>
68+
<h2>Other Projects</h2>
69+
</header>
8870

89-
<ul class="links">
90-
<% project["links"].each do |link| %>
91-
<li>
92-
<%= link_to(link["text"], link["url"]) %>
93-
<span class="host"><%= url_host(link["url"]) %></span>
94-
</li>
95-
<% end %>
96-
</ul>
97-
</div>
98-
</article>
71+
<% other_projects.each do |symbol, project| %>
72+
<%= render_partial "project", { symbol: symbol, project: project } %>
9973
<% end %>
10074
</section>
10175

0 commit comments

Comments
 (0)