Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Activities page #53

Merged
merged 3 commits into from

3 participants

@kgrz
Owner

Seperated this commit to a different branch in my local repo. Closed previous PRs.

@zzak
Owner

@kgrz Thanks, sorry I haven't had time to check this out yet, been distracted by :cat:s mostly

@kgrz
Owner
@zzak
Owner

@kgrz I can't seem to figure out how to get this to work when checking it out locally.

I tried going to /p/activity but get an error for missing ./activity/README.md

There's also a puts in the helper that seems misplaced.

@zzak
Owner

@kgrz I'd also like to see this integrated in the site somehow, how should users access this page?

@kgrz
Owner
@kgrz
Owner
@kgrz
Owner

Hmm: http://cl.ly/image/3F060q030413 Perhaps you're on the master branch? My "activity_log" branch is still working and shows the activity log page as a menu item. Is there something else I can do?

@zzak
Owner

i checked out your branch on my machine:

@webhealth
@kgrz
Owner

Couldn't figure out the problem. So, launched a copy here: http://glacial-stream-7891.herokuapp.com/ Note that the "bin" folder in the dropdown is a heroku-specific thing.

I'm planning to add << previous and next >> buttons to the page and show only ~20 commits. Right now, this shows 100.

@zzak
Owner

@kgrz This looks good, I have a few requests:

  • Give this it's own route, using topic route you see the Did we miss something? part in the view. Let's skip that
  • Gravatars, let's show the users avatar along with their commit.
  • Move it out of sidebar nav, I think it deserves a first-class link somewhere on the site.

Your other ideas for pagination would also be good.

Thanks for working on this!

@kgrz
Owner

@zzak Right. Made the changes you specified...and more. Check them here: http://glacial-stream-7891.herokuapp.com/activity

Note: Ignore the old commits that are showing up here. The last three commits are the relevant ones.

@zzak
Owner

Can you rebase and squash?

kgrz added some commits
@kgrz kgrz Activities page 536382a
@kgrz kgrz Activity log
* Refactored code a little bit
* The display of commits is grouped on a per-author mode on a daily
* basis.
* For every day, all the commits under one author are listed under a
* single group in order to avoid repetition of avatars.
* Now has a separate link and it is tucked away under "Contributors"
* part.
* Shows 50 commits by default.
* Shows gravatars of the committers.
* No longer inside the side-nav element
* Spacing changes
8d071f0
@kgrz kgrz added gemfile.lock for heroku push 9cd540c
@kgrz
Owner

@zzak Done

@kgrz
Owner

Earlier, I did not have my fork's activity_log branch synced with master and so, wasn't able to rebase properly. I thought to keep it that way but got rid the idea since this will be merged with master anyway :)

@zzak
Owner

@kgrz Thanks, I'll merge this in in the next day or two.

It looks good, thank you for working on this!

@kgrz
Owner

Or, I can merge it to master directly if you want me to. I opened a PR to get feedback :)

@zzak zzak merged commit 9cd540c into sinatra:master
@zzak
Owner

@kgrz Thanks! Next step might be to extract the helpers to an extension.

What do you think?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 16, 2013
  1. @kgrz

    Activities page

    kgrz authored
  2. @kgrz

    Activity log

    kgrz authored
    * Refactored code a little bit
    * The display of commits is grouped on a per-author mode on a daily
    * basis.
    * For every day, all the commits under one author are listed under a
    * single group in order to avoid repetition of avatars.
    * Now has a separate link and it is tucked away under "Contributors"
    * part.
    * Shows 50 commits by default.
    * Shows gravatars of the committers.
    * No longer inside the side-nav element
    * Spacing changes
  3. @kgrz
This page is out of date. Refresh to see the latest.
Showing with 141 additions and 8 deletions.
  1. +50 −0 Gemfile.lock
  2. +4 −0 activity/README.md
  3. +87 −8 app.rb
View
50 Gemfile.lock
@@ -0,0 +1,50 @@
+GEM
+ remote: https://rubygems.org/
+ specs:
+ daemons (1.1.9)
+ eventmachine (1.0.0)
+ glorify (0.5.0)
+ nokogiri
+ rdoc-rouge
+ sinatra
+ json (1.7.7)
+ nokogiri (1.5.9)
+ rack (1.5.2)
+ rack-cache (1.2)
+ rack (>= 0.4)
+ rack-protection (1.3.2)
+ rack
+ rdoc (4.0.0)
+ rdoc-rouge (0.1.0)
+ rdoc (~> 4.0)
+ rouge (~> 0.3.0)
+ rouge (0.3.2)
+ thor
+ sass (3.2.5)
+ sinatra (1.3.4)
+ rack (~> 1.4)
+ rack-protection (~> 1.3)
+ tilt (~> 1.3, >= 1.3.3)
+ slim (1.3.6)
+ temple (~> 0.5.5)
+ tilt (~> 1.3.3)
+ temple (0.5.5)
+ thin (1.5.0)
+ daemons (>= 1.0.9)
+ eventmachine (>= 0.12.6)
+ rack (>= 1.0.0)
+ thor (0.18.0)
+ tilt (1.3.3)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ glorify (~> 0.5.0)
+ json
+ rack-cache
+ rdoc (~> 4.0)
+ sass
+ sinatra
+ slim
+ thin
View
4 activity/README.md
@@ -0,0 +1,4 @@
+# Activity
+
+Showing the last 50 commits. Or, you can View all the commits on
+[GitHub](https://github.com/sinatra/sinatra/commits/master)
View
95 app.rb
@@ -1,3 +1,4 @@
+require 'time'
require 'sinatra'
require 'sass'
require 'json'
@@ -23,7 +24,7 @@
Tilt.prefer Sinatra::Glorify::Template
set :markdown, :layout_engine => :slim
set :views, File.dirname(__FILE__)
-set :ignored_dirs, %w[tmp log config public bin]
+set :ignored_dirs, %w[tmp log config public bin activity]
before do
@menu = Dir.glob("./*/").map do |file|
@@ -32,6 +33,47 @@
end.compact.sort
end
+helpers do
+
+ def commits_url
+ "https://api.github.com/repos/sinatra/sinatra-recipes/commits"
+ end
+
+ def commits
+ JSON.parse(open(commits_url).read)
+ end
+
+ def get_authors
+ commits.map do |x|
+ {
+ :name => x['author']['login'],
+ :avatar => x['author']['avatar_url'],
+ :url => x['author']['html_url']
+ }
+ end.uniq.flatten.group_by {|x| x[:name]}
+ end
+
+ def get_activity
+ commits.map do |x|
+ {
+ :author_name => x['author']['login'],
+ :merge_date => Time.parse(x['commit']['author']['date']).strftime("%d-%B-%Y"),
+ :commit_message => x['commit']['message'],
+ :commit_url => "https://github.com/sinatra/sinatra-recipes/commit/#{x['sha']}"
+ }
+ end.group_by {|x| x[:merge_date] }
+ end
+
+ def get_activity_by_author
+ get_activity.map do |k,v|
+ {
+ :date => k,
+ :activity_by_author => v.group_by {|z| z[:author_name] }
+ }
+ end
+ end
+end
+
get '/' do
begin
open("https://api.github.com/repos/sinatra/sinatra-recipes/contributors") do |api|
@@ -55,13 +97,19 @@
get '/p/:topic/:article' do
pass if params[:topic] == '..'
-
md = File.read("#{params[:topic]}/#{params[:article]}.md")
formatter = RDoc::Markup::ToTableOfContents.new
@toc = RDoc::Markdown.parse(md).accept(formatter)
markdown md
end
+get '/activity' do
+ pass if params[:topic] == '..'
+ @authors = get_authors
+ @activity = get_activity_by_author
+ markdown :'activity/README'
+end
+
get '/style.css' do
sass :style
end
@@ -104,8 +152,7 @@
select#selectNav.chosen data-placeholder="Select a topic"
option
- @menu.each do |me|
- option value="/p/#{me}?#article"
- #{me.capitalize.sub('_', ' ')}
+ option value="/p/#{me}?#article" #{me.capitalize.sub('_', ' ')}
- if @toc and @toc.any?
h2 Chapters
ol
@@ -122,11 +169,32 @@
li
a href="/p/#{params[:topic]}/#{child}?#article"
== child.capitalize.sub('_', ' ')
-
- #contributors
+ - if @activity
+ #activity
+ - @activity.each do |x|
+ h3 #{x[:date]}
+ hr
+ ul.nodec
+ - x[:activity_by_author].each do |author_name, activities|
+ - author = @authors[author_name].first
+ li
+ | <img src="#{author[:avatar]}">
+ | <a href="#{author[:url]}">#{author[:name]}</a>
+ | authored the changes:
+ ul.nodec
+ - activities.each do |activity|
+ li
+ pre
+ = "#{activity[:commit_message]}"
+ small
+ a href="#{activity[:commit_url]}"
+ | View this commit on github
+ #contributors
- if @contributors
h2 Contributors
p
+ |Browse the <a href="/activity">latest activity</a>
+ p
| These recipes are provided by the following outsanding members of the Sinatra
| community:
dl id="contributors"
@@ -134,7 +202,6 @@
dt
a href="http://github.com/#{contributor["login"]}"
img src="http://www.gravatar.com/avatar/#{contributor["gravatar_id"]}?s=50"
-
#footer
- if @readme
h3 Did we miss something?
@@ -159,6 +226,11 @@
line-height: 1.25em
color: #444444
+.nodec li
+ display: block
+ margin-top: 25px
+
+
h1, h2, h3, h4, h5
font-family: Georgia, 'bitstream vera serif', serif
margin: 40px 0 20px 0
@@ -210,6 +282,7 @@
#selectNav
width: 100%
+
#contributors dt
display: inline-block
@@ -236,7 +309,13 @@
color: #CCC
a:hover, a:active
color: #8F8F8F
-
+#activity
+ img
+ height: 50px
+ width: 50px
+ padding-right: 15px
+ ul
+ padding-left: 0px
#sidebar
width: 25%
float: right
Something went wrong with that request. Please try again.