# encoding: utf-8 #-- # Copyright (C) 2008 Johan Sørensen # Copyright (C) 2008 Tor Arne Vestbø # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see . #++ #require IO module SiteHelper def recent_event_timestamp(time) distance = Time.now - time human_distance = case distance when 0..3599 "#{distance.ceil / 60} min." else "#{distance.ceil / 60 / 60} h." end end # Inserting wbr tags on colons and slashes for the recent events so that # it word breaks prettier. def word_break_recent_event_actions(text) text.gsub(/]+)>([^<]+)/) { tag_attributes = $~[1] to_break = $~[2] word_broken = to_break.gsub(/\/|\:/) { $~[0] + "" } %{#{word_broken}} } end # Returns the hash of the commit that is in use right now. def current_version_hash r = Grit::Repo.new(RAILS_ROOT) r.head.commit end end