Permalink
Browse files

Projects listing page.

  • Loading branch information...
1 parent 8b0abf2 commit d756de0d6273307d3b6c24e3cbf5761222d344a7 @cowboy committed Mar 21, 2011
Showing with 59 additions and 11 deletions.
  1. +1 −0 sample_app/app.rb
  2. +30 −1 sample_app/public/js/site.js
  3. +27 −9 sample_app/views/css/site.sass
  4. +1 −1 sample_app/views/index.haml
View
1 sample_app/app.rb
@@ -218,6 +218,7 @@ def tags(pages = @pages)
# All article pages, sorted by other-category.
@articles = pages_by_category('Articles')
+ @pages = []
=begin
@pages = not_dated.select {|page| page.categories.index('Projects')} +
not_dated.reject {|page| page.categories.index('Projects')} +
View
31 sample_app/public/js/site.js
@@ -1,5 +1,5 @@
-// Project listing hovers.
(function($) {
+ // Project listing hovers.
var z = 1;
$(document).delegate('ul.projects > li > a', 'hover', function( e ) {
@@ -15,4 +15,33 @@
// height has to be used!
reveal.css('height', hover ? reveal.css('height', 'auto').height() : 0);
});
+
+ // Project listing Github integration.
+ // TODO: use localStorage.
+ $(function() {
+ $('ul.projects li[data-github]').each(function() {
+ var li = $(this),
+ meta = li.find('.meta'),
+ repo = li.data('github');
+
+ $.getJSON('http://github.com/api/v2/json/repos/show/' + repo + '?callback=?', function( d ) {
+ var r = d && d.repository;
+ if ( !r ) { return; }
+
+ function link( txt, link, num ) {
+ link = link ? '/' + link : '';
+ txt = num == undefined ? txt : num + ' ' + txt + (num == 1 ? '' : 's');
+ return '<a href="http://github.com/' + repo + link + '">' + txt + '</a>';
+ }
+
+ $('<span class="github"/>')
+ .html([
+ link('GitHub'),
+ link('watcher', 'watchers', r.watchers),
+ link('fork', 'network', r.forks),
+ ].join(' '))
+ .appendTo(meta);
+ })
+ });
+ });
})(jQuery);
View
36 sample_app/views/css/site.sass
@@ -58,17 +58,14 @@ code
border: 1px solid #aaa
color: #555
padding: 4px 0.2em 1px
- webkit-border-radius: 4px
-
+ -webkit-border-radius: 4px
// Misc.
.tag-cloud li
display: inline
font-style: none
-
-
// Project listing.
ul.projects
@@ -81,20 +78,34 @@ ul.projects
z-index: 0
left: -4px
right: -4px
- padding-left: 4px
- padding-right: 4px
- padding-top: 2px
+ padding: 2px 4px 4px
border-top-left-radius: 10px
border-top-right-radius: 10px
- &, .meta, .reveal
+ &, *
-webkit-transition: 0.1s ease-out
-webkit-transition-delay: 0.1s
-webkit-transition-property: height, color, background, border, box-shadow
&, .reveal
border: 1px solid rgba(0, 0, 0, 0)
.meta
- color: #ccc
+ color: #aaa
font-size: 70%
+ margin-top: 3px
+ .github
+ position: relative
+ z-index: 1
+ > *
+ margin-left: 0.3em
+ a
+ color: #aaa
+ border: 1px solid #aaa
+ padding: 1px 0.3em
+ -webkit-border-radius: 4px
+ text-decoration: none
+ &:hover
+ color: #aa3300
+ border-color: #aa3300
+ background: #fed
.reveal
background: #fff
font-size: 80%
@@ -115,6 +126,10 @@ ul.projects
z-index: 1
.meta
color: #AA9A89
+ .github a
+ background: none
+ border: 1px solid #AA9A89
+ color: #AA9A89
.reveal
border-color: #000
border-top: none !important
@@ -164,6 +179,7 @@ ul.projects
// Syntax highlighting.
+
@import twilight
.sh
@@ -223,6 +239,7 @@ ul.projects
color: #fff
// No line numbers.
+
.sh-nolines .highlight
background: #181818
padding: 4px
@@ -232,6 +249,7 @@ ul.projects
// WebKit Scrollbar.
// Adapted from http://beautifulpixels.com/goodies/create-custom-webkit-scrollbar/
+
body ::-webkit-scrollbar
height: 12px
::-webkit-scrollbar-button:start, ::-webkit-scrollbar-button:end
View
2 sample_app/views/index.haml
@@ -7,7 +7,7 @@
- pages.each do |p|
- t = p.title.sub(/#{title}[ :]*/i, '')
- t = t[/[A-Z]/] ? t : "#{t[0].upcase}#{t[1..-1]}"
- %li
+ %li{ :'data-github' => p.github }
%a{ href: p.url }= t
- if p.has_fs_mods?
%i

0 comments on commit d756de0

Please sign in to comment.